Uh oh!
There was an error while loading. Please reload this page.
Test expired metadata from cache - #1707
Conversation
I'm leaving this with the non-matching description on purpose, as the expected behaviour in |
Pull Request Test Coverage Report for Build 1865335270Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
MVrachev
commented
Dec 7, 2021
I have some ideas about this pr and will have a conversation with Ivana soon. |
This may have been clarified already but I'l say it here: We do load expired metadata with one big caveat: the expired metadata can only be used to validate a newer version of the same type of metadata. In practice:
|
8bd6065 to
c86ad65Comparejku
commented
Dec 13, 2021
the core issue here is that verifying that local files are opened does not mean they are actually used to verify new downloaded metadata (this is made clear even in the test itself: it opens Just to be clear: I think this is a useful test that probably does not exist yet... but test_updater_top_level_update.py has some clearly related tests like Also (and this is a small detail in comparison), I've been trying to advocate not meddling with the client metadata cache manually: in this case I think it would be better to not do that and instead mock current time (pretend that time now > expiry). Search for mock_time in tests for examples of this. |
7b15487 to
e12a4a6CompareUh oh!
There was an error while loading. Please reload this page.
sechkova
commented
Dec 14, 2021
I admit I find it hard to follow the intentions here, I am sorry if I've put a misleading issue description. |
ivanayov
commented
Dec 14, 2021
@sechkova the idea was to simulate an expired metadata in cache without manually modifying the cache files. I might have misunderstood this mock - the intention is to simulate change in system time, so that what's stored in cache is considered expired, without need of directly touching the local metadata. |
It is pretty similar, except that I think we don't actually persist downloaded non-root metadata if it's expired, even though we probably could (rado pointed this out to me -- I had not noticed). This difference isn't that important for actual working repos but for testing it means we need to mock system time (or utcnow() as you point out) to "make the local metadata expired". |
sechkova
commented
Dec 14, 2021
Thanks, now I think I got all pieces together. So I agree, |
ef136d4 to
ae0ee2eComparejku
commented
Jan 11, 2022
I'm marking this a draft since the issue pointed out by Teodora (mocking the wrong thing) is still there: I might have other comments but I've been postponing review until the basics are there. I'm available for a chat if anything is unclear. |
ae0ee2e to
7e56b0cCompareivanayov
commented
Feb 3, 2022
@jku I changed to mocking |
jku
left a comment
There was a problem hiding this comment.
marking request changes so it's visible on PR list: we talked about this over zoom, and found an issue with the timeline of expiries and the mocked refresh: ivana promised to fix
ba6ef64 to
ed0d0b8Compareivanayov
commented
Feb 18, 2022
I've pushed an update. |
There was a problem hiding this comment.
Nice, all test code seems correct and clear.
- Left some minor tweak suggestions in code
- These tests should have a docstring to explain what they are testing: they are some of the trickiest tests we have. Something like "Local timestamp must be used in rollback checks even if it is expired" -- maybe the same text that's already before the actual assertRaises
Additionally maybe the dosctring should also include a timeline, example of one test:
* day 0: first updater refresh
* day 0 (a bit later): repository publishes timestamp v2
* day 7: timestamp v1 expiry
* day 18: second updater refresh: assert that rollback check uses expired v1 here
* day 21: timestamp v2 expiry
not sure about that last thing though: it's a lot of lines... but may be helpful to understand what's going on? I'll leave decision to you
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This tests that an expired timestamp/snapshot/targets when loaded from cache is not stored as final but is used to verify the new timestamp Fixestheupdateframework#1681 Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>
This change verifies that when local metadata has expired, it is still used to verify new metadata that's pulled from remote Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>
This change fixes the expired metadata tests to mock `datetime` as previously they mocked `time` incorrectly, which did not affect update methods, as they use `datetime.datetime.utcnow()` to calculate now Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>
ed0d0b8 to
0f6c961CompareThis change improves the logic of expired metadata tests, so that it is explicitly visible what the expiry time and the versions are and when update/refresh is called in that period Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>
0f6c961 to
8d4d9afCompareivanayov
commented
Mar 18, 2022
Thank you @jku , I added docstrings to all the test methods for clarification. |
jku
left a comment
There was a problem hiding this comment.
my comment about reusing the datetime.datetime.utcnow() result is marked resolved but all functions still call utcnow() twice...
That is a trivial complaint so let's go with this version, I think it's a good set of very tricky tests. Thanks.
ivanayov
commented
Mar 21, 2022
@jku ah, I resolved by inertia with the microseconds updates... will note to address in following changes. Thanks |
This tests that an expired timestamp/snapshot/targets when loaded
from cache is not stored as final but is used to verify the new
timestamp
Addresses #1681