Page MenuHomeSoftware Heritage

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

Authored by anlambert on Wed, Sep 4, 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
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

anlambert created this revision.Wed, Sep 4, 2:37 PM
anlambert updated this revision to Diff 6576.Wed, Sep 4, 2:43 PM

Update: Fix deprecation warning (assertRaisesRegexp -> assertRaisesRegex)

anlambert updated this revision to Diff 6580.Wed, Sep 4, 3:13 PM

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

ardumont accepted this revision.Wed, Sep 4, 3:27 PM

Sounds good.

This revision is now accepted and ready to land.Wed, Sep 4, 3:27 PM
ardumont added a comment.EditedWed, Sep 4, 3:40 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 ;)

anlambert updated this revision to Diff 6587.Wed, Sep 4, 3:46 PM

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

ardumont accepted this revision.Wed, Sep 4, 3:47 PM
This revision was automatically updated to reflect the committed changes.