Page MenuHomeSoftware Heritage

Add a test to compare the result of revision_add() with known results
ClosedPublic

Authored by douardda on Mar 25 2021, 3:03 PM.

Details

Summary

Use a 'synthetic' file to describe the expected behavior of the
insertion of revisions in the provenance index.

Add tests for both the (noroot, lower) and (noroot, upper) cases.

Diff Detail

Repository
rDPROV Provenance database
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Build is green

Patch application report for D5337 (id=19136)

Rebasing onto eb524713c3...

Current branch diff-target is up to date.
Changes applied before test
commit 45b2e263901ea0173370e3eef4a59c0fe6d9669c
Author: David Douard <david.douard@sdfa3.org>
Date:   Thu Mar 25 15:01:35 2021 +0100

    Add a test for the (noroot, upper) case

commit 86e0456dee59dc0058cbdf1bb0c9294843480023
Author: David Douard <david.douard@sdfa3.org>
Date:   Wed Mar 24 09:49:11 2021 +0100

    Add a test to compare the result of revision_add() with known results
    
    Use a 'synthetic' file to describe the expected behavior of the
    insertion of revisions in the provenance index.

See https://jenkins.softwareheritage.org/job/DPROV/job/tests-on-diff/8/ for more details.

refactor a bit the test

get rid of useless local variables and rename helper function count() as db_count()

Build is green

Patch application report for D5337 (id=19137)

Rebasing onto eb524713c3...

Current branch diff-target is up to date.
Changes applied before test
commit 5ae58a332623c0ef73ded3d531f702e576c26887
Author: David Douard <david.douard@sdfa3.org>
Date:   Thu Mar 25 15:01:35 2021 +0100

    Add a test for the (noroot, upper) case

commit 79b6b8d4b05a520db65e7aae691c88edc18c09d9
Author: David Douard <david.douard@sdfa3.org>
Date:   Wed Mar 24 09:49:11 2021 +0100

    Add a test to compare the result of revision_add() with known results
    
    Use a 'synthetic' file to describe the expected behavior of the
    insertion of revisions in the provenance index.

See https://jenkins.softwareheritage.org/job/DPROV/job/tests-on-diff/9/ for more details.

vlorentz added inline comments.
swh/provenance/tests/conftest.py
94–96

why do you override the one from swh/core/pytest_plugin.py?

246

Might as well use Any instad of this big Union.

What about a TypedDict?

swh/provenance/tests/conftest.py
94–96

because I forgot it was there :-)

246

probably a good idea, yes

apply vlorentz comments

  • convert datadir() and synthetic_result() as non-fixture simple functions (the fixture apect was indeed unecessary for now),
  • use TypedDict-based objects in synthetic_result()

Build is green

Patch application report for D5337 (id=19178)

Rebasing onto eb524713c3...

Current branch diff-target is up to date.
Changes applied before test
commit 97d709d2bd3a128323b068b40745c5f15b7de702
Author: David Douard <david.douard@sdfa3.org>
Date:   Thu Mar 25 15:01:35 2021 +0100

    Add a test for the (noroot, upper) case

commit b728a6ad6e2cb8a161a316dcf3f50283d256ba0a
Author: David Douard <david.douard@sdfa3.org>
Date:   Wed Mar 24 09:49:11 2021 +0100

    Add a test to compare the result of revision_add() with known results
    
    Use a 'synthetic' file to describe the expected behavior of the
    insertion of revisions in the provenance index.

See https://jenkins.softwareheritage.org/job/DPROV/job/tests-on-diff/10/ for more details.

Build has FAILED

Patch application report for D5337 (id=19202)

Rebasing onto 41bc4cef33...

Current branch diff-target is up to date.
Changes applied before test
commit bd34d8a165f73bb54cf32f38304b191bf8fe0806
Author: David Douard <david.douard@sdfa3.org>
Date:   Thu Mar 25 15:01:35 2021 +0100

    Add a test for the (noroot, upper) case

commit 5403dd19ba2d13da3bfa27e3c87c9d1ca95f3cb6
Author: David Douard <david.douard@sdfa3.org>
Date:   Wed Mar 24 09:49:11 2021 +0100

    Add a test to compare the result of revision_add() with known results
    
    Use a 'synthetic' file to describe the expected behavior of the
    insertion of revisions in the provenance index.

Link to build: https://jenkins.softwareheritage.org/job/DPROV/job/tests-on-diff/11/
See console output for more information: https://jenkins.softwareheritage.org/job/DPROV/job/tests-on-diff/11/console

Build has FAILED

Patch application report for D5337 (id=19208)

Rebasing onto 877a8a02b5...

Current branch diff-target is up to date.
Changes applied before test
commit 571c64f21b80a9521f25c5b4ed4b8b1480fa513c
Author: David Douard <david.douard@sdfa3.org>
Date:   Thu Mar 25 15:01:35 2021 +0100

    Add a test for the (noroot, upper) case

commit 43944fc66d506dbf50d8c9cbfd3226fefaf7ba6a
Author: David Douard <david.douard@sdfa3.org>
Date:   Wed Mar 24 09:49:11 2021 +0100

    Add a test to compare the result of revision_add() with known results
    
    Use a 'synthetic' file to describe the expected behavior of the
    insertion of revisions in the provenance index.

Link to build: https://jenkins.softwareheritage.org/job/DPROV/job/tests-on-diff/12/
See console output for more information: https://jenkins.softwareheritage.org/job/DPROV/job/tests-on-diff/12/console

Build is green

Patch application report for D5337 (id=19214)

Rebasing onto 4a5a99ea7d...

Current branch diff-target is up to date.
Changes applied before test
commit 88c3910d2da58cc4167fb72b7ec530eec51cad8b
Author: David Douard <david.douard@sdfa3.org>
Date:   Thu Mar 25 15:01:35 2021 +0100

    Add a test for the (noroot, upper) case

commit 5d3f925e42530de891d94041046b2aec66d182c3
Author: David Douard <david.douard@sdfa3.org>
Date:   Wed Mar 24 09:49:11 2021 +0100

    Add a test to compare the result of revision_add() with known results
    
    Use a 'synthetic' file to describe the expected behavior of the
    insertion of revisions in the provenance index.

See https://jenkins.softwareheritage.org/job/DPROV/job/tests-on-diff/13/ for more details.

ardumont added a subscriber: ardumont.

lgtm, couple of suggestion or question inline.

swh/provenance/tests/conftest.py
217

Revision---Content
Revision-Directory
Directory-Content
? I guess.

225

Shouln't those be in their respective class instead?

And referred to it here with sphinx like link here?

298

i don't know at which point the part generating the file to parse is safe...

So maybe the following could help avoid missing any inconsistencies?

else:
    logger.warning("unknown relation: %s", row)
This revision is now accepted and ready to land.Mar 30 2021, 10:33 AM
swh/provenance/tests/conftest.py
217

yes, but it uses the notations from @grouss' "synthetic" files

225

TypedDict classes could be documented, yes (but meh)

298

Honestly I don't know either. I believe these files have been written by hand, so...

swh/provenance/tests/conftest.py
217

sorry, i meant to know if that was the meaning behind it, not to propose another writing.

And the more I read, the more it meant sense.

Build is green

Patch application report for D5337 (id=19833)

Rebasing onto 62617e5006...

Current branch diff-target is up to date.
Changes applied before test
commit 8853314af9817988a58450937c9d25097e66e741
Author: David Douard <david.douard@sdfa3.org>
Date:   Thu Mar 25 15:01:35 2021 +0100

    Add a test for the (noroot, upper) case

commit adbc99dd357dc452081df1965805756987b7e09b
Author: David Douard <david.douard@sdfa3.org>
Date:   Wed Mar 24 09:49:11 2021 +0100

    Add a test to compare the result of revision_add() with known results
    
    Use a 'synthetic' file to describe the expected behavior of the
    insertion of revisions in the provenance index.

See https://jenkins.softwareheritage.org/job/DPROV/job/tests-on-diff/17/ for more details.