Page MenuHomeSoftware Heritage

Add testinfra based e2e tests for the deposit
ClosedPublic

Authored by douardda on Dec 20 2019, 2:32 PM.

Details

Summary

These tests create deposit and wait for them to be in the 'done' status.
Warning, this requires testinfra to be available (as well as docker-compose).

https://testinfra.readthedocs.io

Depends on D2489

Diff Detail

Repository
rDENV Development environment
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

douardda created this revision.Dec 20 2019, 2:32 PM

that looks quite awesomly promising.

will that replace the current shell scripts?

vlorentz added a subscriber: vlorentz.EditedDec 20 2019, 2:49 PM

You could remove most of the code in your tests by using the code behind the Icinga plugin in D2484. It already handles generating an archive, checking the status periodically, etc. eg. test_create_deposit_simple could be rewritten as:

from swh.icinga_plugins.deposit import DepositCheck

def test_create_deposit_simple(host, sample_metadata, sample_archive):
    config = {
        'metadata': sample_metadata,
        'archive': sample_archive,
        'username': 'test',
        'password': 'test',
        'server': 'http://nginx:5080/deposit/1',
        'collection': 'test',
        'critical': 60,  # in seconds
    }
    deposit_check = DepositCheck(config)
    assert deposit_check.main() == 0
docker/tests/test_deposit.py
2–7

Missing copyright header, and you should split imports into two groups (stdlib vs third-party) (see item 2 of the imports section of PEP 8)

11

I don't find this name explicit enough. What about docker_deposit?

19–25

Let's not make our CI depend on github. You can generate such files yourself easily, see https://forge.softwareheritage.org/D2484#change-xFeVCZUT0m7V or make the repo tarball its own files when running

that looks quite awesomly promising.
will that replace the current shell scripts?

if it makes consensus, sure.

douardda added inline comments.Dec 20 2019, 2:56 PM
docker/tests/test_deposit.py
2–7

yeah this diff is not really finished yet...

11

I just used the example from testinfra's doc ;-)

19–25

I was sure this would come! 😈

douardda updated this revision to Diff 8909.Wed, Jan 8, 4:00 PM

Update/fixes according vlorentz' comments

aka:

  • add copyright & fix import order in test_deposit.py,
  • do not depend on external service (aka github) for crafting a deposit archive to upload,
  • rename the 'host' fixture as 'deposit_host'.
vlorentz accepted this revision.Wed, Jan 8, 4:04 PM
This revision is now accepted and ready to land.Wed, Jan 8, 4:04 PM
douardda updated this revision to Diff 8912.Wed, Jan 8, 4:51 PM

forgot the renaming of host->deposit_host

This revision was automatically updated to reflect the committed changes.