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

that looks quite awesomly promising.

will that replace the current shell scripts?

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
1–6

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)

10

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

18–24

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.

docker/tests/test_deposit.py
1–6

yeah this diff is not really finished yet...

10

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

18–24

I was sure this would come! 😈

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'.
This revision is now accepted and ready to land.Jan 8 2020, 4:04 PM

forgot the renaming of host->deposit_host