← Back to issue list

Snap store endpoints test is flaky

View original Github issue

Metadata

Project
craft-store
Number
#243
Type
issue
State
open
Author
lengau
Labels
Created
2024-12-11 23:47:05+00:00
Updated
2025-05-01 16:43:45+00:00
Closed

Current evaluation

No evaluation has been recorded for this issue yet.

Issue body

### Bug Description `tests/unit/test_endpoints.py::test_snap_store` is flaky, as the expiry time can be off by a second due to the way it is generated. ### To Reproduce Put your machine under load, then run: `uv run pytest tests/unit/test_endpoints.py::test_snap_store` until you get it. Or see: https://github.com/canonical/craft-store/actions/runs/12286865000/job/34287817294?pr=241 ### part yaml ```shell n/a ``` ### Relevant log output ```shell ================================== FAILURES =================================== _______________________________ test_snap_store _______________________________ expires = <function expires.<locals>.offset_iso_dt at 0x000002D4A62ED800> def test_snap_store(expires): snap_store = endpoints.SNAP_STORE assert snap_store.tokens == "/api/v2/tokens" assert snap_store.tokens_exchange == "/api/v2/tokens/exchange" assert snap_store.whoami == "/api/v2/tokens/whoami" assert snap_store.upload == "/unscanned-upload/" > assert snap_store.get_token_request( permissions=["permission-foo", "permission-bar"], description="client description", ttl=1000, ) == { "permissions": ["permission-foo", "permission-bar"], "description": "client description", "expires": expires(1000), } E AssertionError: assert {'description...mission-bar']} == {'description...mission-bar']} E E Omitting 2 identical items, use -vv to show E Differing items: E {'expires': '2024-12-12T00:00:23+00:00'} != {'expires': '2024-12-12T00:00:22+00:00'} E E Full diff: E { E 'description': 'client description', E - 'expires': '2024-12-12T00:00:22+00:00', E ? ^ E + 'expires': '2024-12-12T00:00:23+00:00', E ? ^ E 'permissions': [ E 'permission-foo', E 'permission-bar', E ], E } tests\unit\test_endpoints.py:119: AssertionError =========================== short test summary info =========================== FAILED tests/unit/test_endpoints.py::test_snap_store - AssertionError: assert {'description...mission-bar']} == {'description...mission-bar']} Omitting 2 identical items, use -vv to show Differing items: {'expires': '2024-12-12T00:00:23+00:00'} != {'expires': '2024-12-12T00:00:22+00:00'} Full diff: { 'description': 'client description', - 'expires': '2024-12-12T00:00:22+00:00', ? ^ + 'expires': '2024-12-12T00:00:23+00:00', ? ^ 'permissions': [ 'permission-foo', 'permission-bar', ], } ================ 1 failed, 200 passed, 14 deselected in 4.78s ================= ```

Evaluation history

No evaluation history available.