Skip to content

ngtests: test loading of cached metadata #1681

Closed

Description

@sechkova

Description of issue or feature request:
Taken from @jku's comment that summarizes it very well, tests are needed which:

  • check that expected metadata is read from cache the expected number of times
  • check if cached metadata is used to verify new metadata downloaded from remote
    • trickier but I suppose we can rely on negative tests here: tests that are expected to fail on that verification

Activity

  1. added
    backlog
    on Nov 24, 2021
  2. added this to the Sprint 13 milestone on Nov 24, 2021
  3. ivanayov commented on Nov 24, 2021

    @ivanayov
    Collaborator

    Can I take this, please?

  4. jku commented on Nov 24, 2021

    @jku
    Member

    I think teodoras current approach of mocking open (in #1593) is pretty good: just implementing this in the relevant tests is probably fine (so no test utilities needed).

    The question is, which tests should test metadata file opens:

    Maybe this single test is enough? @sechkova opinions?

  5. sechkova commented on Nov 24, 2021

    @sechkova
    ContributorAuthor

    What I imagined while writing the issue is potentially having a class that tests all weird cases of loading cached metadata. This would mean at least:

    Step 1: make a successful update of valid metadata which stores it in cache (by calling preferably Updater.get_targetinfo or in some special case Updater.refresh)
    Step 2: Create a new updater and perform a second update while the metadata is already stored in cache (metadata dir)
    Step 3:

    • test that a valid timestamp is loaded from cache (and is used to verify the new timestamp)
    • test that if a valid snapshot is loaded from cache a new snapshot is not downloaded
    • test that if a valid targets is loaded from cache a new targets is not downloaded

    Step 4:

    • test that an expired timestamp when loaded from cache is not stored as final but is used to verify the new timestamp
    • test that an expired snapshot when loaded from cache is not stored as final but is used to verify the new downloaded snapshot
    • test that an expired targets when loaded from cache is not stored as final but is used to verify the new downloaded targets
    • expired targets is invalid and should be neither loaded, stored nor used.

    Step 5:

    • test that an invalid (incorrectly signed) timestamp when loaded from cache IS NOT used to verify the new timestamp
    • test that an invalid (incorrectly signed) snapshot when loaded from cache IS NOT used to verify the new timestamp
    • test that an invalid (incorrectly signed) targets when loaded from cache IS NOT used to verify the new targets

    Step 3 can be based on the test in #1593 but I think a separate test case will be more clear. I haven't thought out well steps 4 and 5 but I'm open for suggestions. Maybe start with 3 and re-scope the issue accordingly?

  6. sechkova commented on Nov 24, 2021

    @sechkova
    ContributorAuthor

    Forgot to mention that root as a special case should be already covered in test_updater_top_level_update.py but probably this claim should be confirmed.

  7. jku commented on Nov 24, 2021

    @jku
    Member

    oh yeah, validating that local metadata is actually used when downloaded metadata is verified (the second case in the issue description) is tricky. I think doing just the first case in the issue description (validate that correct files are read from disk the correct number of times) is a good first step -- so that would be roughly steps 1-3 in your comment. I would argue it's mostly just augmenting the test function you wrote, but a new one is fine too

  8. added 3 commits that reference this issue on Dec 2, 2021
    6d00db6
    bd17789
    707e5ee
  9. MVrachev commented on Dec 6, 2021

    @MVrachev
    Collaborator

    What I imagined while writing the issue is potentially having a class that tests all weird cases of loading cached metadata. This would mean at least:

    Step 1: make a successful update of valid metadata which stores it in cache (by calling preferably Updater.get_targetinfo or in some special case Updater.refresh)

    @sechkova why it's preferable to call Updater.get_targetinfo instead of directly calling refresh?
    Maybe I am missing some context here.

  10. sechkova commented on Dec 7, 2021

    @sechkova
    ContributorAuthor

    @sechkova why it's preferable to call Updater.get_targetinfo instead of directly calling refresh?
    Maybe I am missing some context here.

    Seems like I've had in mind refreshing both top-levels and delegated roles metadata when writing this. Updater.get_targetinfo calls refresh internally.

  11. removed this from the Sprint 13 milestone on Dec 8, 2021
  12. 7 remaining items

  13. added 6 commits that reference this issue on Dec 10, 2021
    21b145d
    57c65c1
    46c5731
    a7e9c67
    ab47dda
    e1b42f4
  14. added 3 commits that reference this issue on Jan 4, 2022
    3cac744
    c96b488
    d27c0fd
  15. added a commit that references this issue on Jan 7, 2022
    e61f0e9
  16. added a commit that references this issue on Feb 3, 2022
    65c4f92
  17. added a commit that references this issue on Feb 18, 2022
    0961ce0
  18. added a commit that references this issue on Mar 18, 2022
    15c8d80
  19. added a commit that references this issue on May 10, 2022
    7de325d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

backlogtesting

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions