Page MenuHomeSoftware Heritage

tests/test_storage: Fix tests execution with psycopg2 < 2.8
ClosedPublic

Authored by anlambert on Sep 4 2019, 2:37 PM.

Details

Summary

This is another attempt to fix a psycopg2 related issue (see D1943).

psycopg2 introduced new exception types in its 2.8 version giving more details
about the encountered errors. These exceptions live in the newly added module psycopg2.errors.

Unfortunately, current Debian package python3-psycopg2 version is 2.7.7 on buster
and 2.6.2 on stretch. So this means Debian packaging and tests execution when not
using a virtualenv on Debian stable are currently broken for swh-storage.

Fortunately, the newly added exceptions in version 2.8 are derived from previously available ones for backward compatibility.

So use psycopg2 exceptions common to all module versions to ensure tests can be executed everywhere.

Diff Detail

Repository
rDSTO Storage manager
Branch
fix-psycopg2-exceptions-in-tests
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 7655
Build 10982: tox-on-jenkinsJenkins
Build 10981: arc lint + arc unit

Event Timeline

Update: Fix deprecation warning (assertRaisesRegexp -> assertRaisesRegex)

Update: also check Postgres error code to restore previous testing behavior

This revision is now accepted and ready to land.Sep 4 2019, 3:27 PM

See console output for more information: https://jenkins.softwareheritage.org/job/DSTO/job/tox/632/console

gotcha, it's not your code adaptations which raises the error.

swh-model got tagged (and debian built). That contains one constraint less on the origin's type (it can be null now). See D1953.

So that's why there is no longer an exception raised on the scenario which does not integrate the origin's type.

It made me raise an eyebrow as well ;)

Update: Remove failing assertion after swh-model update (not really the scope of that diff
so adding a new commit)

This revision was automatically updated to reflect the committed changes.