Skip to content

RepositorySimulator: add trackers/counters for downloaded files #1682

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sechkova opened this issue Nov 17, 2021 · 2 comments · Fixed by #1705
Closed

RepositorySimulator: add trackers/counters for downloaded files #1682

sechkova opened this issue Nov 17, 2021 · 2 comments · Fixed by #1705
Assignees
Labels
backlog Issues to address with priority for current development goals testing
Milestone

Comments

@sechkova
Copy link
Contributor

Description of issue or feature request:
There is a need in some test cases to check whether Updater requested the correct files from the repository.
For a concrete use case see #1666.

One option used in #1666 is to use unittest.mock and "wrap" RepositorySimulator._fetch_* methods which does the job but does make the tests less readable.
Therefore as an alternative, proposed by @jku #1666 (review), checking that the expected files are downloaded from remote can be done by adding some download counters into RepositorySimulator which would be cleaner and more maintainable

@sechkova sechkova added the backlog Issues to address with priority for current development goals label Nov 24, 2021
@sechkova sechkova added this to the Sprint 13 milestone Nov 24, 2021
@kairoaraujo
Copy link
Contributor

I will work on it.

@jku
Copy link
Member

jku commented Nov 24, 2021

basically my idea was that

  • repositorysimulator keeps lists of requests (I guess one for metadata, one for targets makes sense). It adds an item to list every time a request is made
  • tests can at any time check that the list is what they expect
  • tests can also clear the list when they want
  • the format of the lists should be whatever makes most sense for the test code (urls? metadata role names? 🤷)

kairoaraujo pushed a commit to kairoaraujo/python-tuf that referenced this issue Dec 1, 2021
This change is to implement a feature to track the fetch calls to
the metadata and targets. This feature was mentioned in PR theupdateframework#1666 that
generated issue theupdateframework#1682.
It is the ``RepositorySimulator.fetch_tracker``. It also changes the
``test_updater_consistent_snapshot`` to use the fetch_tracker
instead of mocking it.

It implements a ``dataclass`` that stores the calls to fetch metadata
(``_fetch_metadata``) and targets (``_fetch_targets``).
This dataclass has a method to clean (``clear``) the current metadata
and targets tracker.

The fetch calls for metadata are stored as a list of tuples that
contains metadata role name and version, and fetch calls for targets
are stored as a list of target paths.

Signed-off-by: Kairo de Araujo <[email protected]>
kairoaraujo pushed a commit to kairoaraujo/python-tuf that referenced this issue Dec 2, 2021
This commit implements a feature in Repository Simulator to
track the fetch calls to the metadata and targets. This feature was
mentioned in PR theupdateframework#1666 that generated issue theupdateframework#1682.
This commit adds ``RepositorySimulator.fetch_tracker``. It also changes
the ``tests/test_updater_consistent_snapshot.py`` to use the
``fetch_tracker`` instead of using mock.

It implements a ``dataclass`` that stores the calls to fetch metadata
(``_fetch_metadata``) in ``fetch_tracker.metadata`` and targets
(``_fetch_targets``) in ``fetch_tracker.targets``.

The fetch calls for metadata, and targets are stored as lists.

Signed-off-by: Kairo de Araujo <[email protected]>
kairoaraujo pushed a commit to kairoaraujo/python-tuf that referenced this issue Dec 3, 2021
This commit implements a feature in Repository Simulator to
track the fetch calls to the metadata and targets. This feature was
mentioned in PR theupdateframework#1666 that generated issue theupdateframework#1682.
This commit adds RepositorySimulator.fetch_tracker. It also changes
the tests/test_updater_consistent_snapshot.py to use the
fetch_tracker instead of using mock.

It implements a dataclass that stores the calls to fetch metadata
(_fetch_metadata) in fetch_tracker.metadata and targets
(_fetch_targets) in fetch_tracker.targets.

The fetch calls for metadata, and targets are stored as lists.

Signed-off-by: Kairo de Araujo <[email protected]>
kairoaraujo pushed a commit to kairoaraujo/python-tuf that referenced this issue Dec 3, 2021
This commit implements a feature in Repository Simulator to
track the fetch calls to the metadata and targets. This feature was
mentioned in PR theupdateframework#1666 that generated issue theupdateframework#1682.
This commit adds RepositorySimulator.fetch_tracker. It also changes
the tests/test_updater_consistent_snapshot.py to use the
fetch_tracker instead of using mock.

It implements a dataclass that stores the calls to fetch metadata
(_fetch_metadata) in fetch_tracker.metadata and targets
(_fetch_targets) in fetch_tracker.targets.

The fetch calls for metadata, and targets are stored as lists.

Signed-off-by: Kairo de Araujo <[email protected]>
kairoaraujo pushed a commit to kairoaraujo/python-tuf that referenced this issue Dec 7, 2021
This commit implements a feature in Repository Simulator to
track the fetch calls to the metadata and targets. This feature was
mentioned in PR theupdateframework#1666 that generated issue theupdateframework#1682.
This commit adds RepositorySimulator.fetch_tracker. It also changes
the tests/test_updater_consistent_snapshot.py to use the
fetch_tracker instead of using mock.

It implements a dataclass that stores the calls to fetch metadata
(_fetch_metadata) in fetch_tracker.metadata and targets
(_fetch_targets) in fetch_tracker.targets.

The fetch calls for metadata, and targets are stored as lists.

Signed-off-by: Kairo de Araujo <[email protected]>
kairoaraujo pushed a commit to kairoaraujo/python-tuf that referenced this issue Dec 8, 2021
This commit implements a feature in Repository Simulator to
track the fetch calls to the metadata and targets. This feature was
mentioned in PR theupdateframework#1666 that generated issue theupdateframework#1682.
This commit adds RepositorySimulator.fetch_tracker. It also changes
the tests/test_updater_consistent_snapshot.py to use the
fetch_tracker instead of using mock.

It implements a dataclass that stores the calls to fetch metadata
(_fetch_metadata) in fetch_tracker.metadata and targets
(_fetch_targets) in fetch_tracker.targets.

The fetch calls for metadata, and targets are stored as lists.

Signed-off-by: Kairo de Araujo <[email protected]>
@sechkova sechkova modified the milestones: Sprint 13, Sprint 14 Dec 8, 2021
@jku jku closed this as completed in #1705 Dec 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Issues to address with priority for current development goals testing
Projects
None yet
3 participants