Skip to content
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

Snap store endpoints test is flaky #243

Open
lengau opened this issue Dec 11, 2024 · 1 comment
Open

Snap store endpoints test is flaky #243

lengau opened this issue Dec 11, 2024 · 1 comment
Labels
Bug Something isn't working triaged

Comments

@lengau
Copy link
Collaborator

lengau commented Dec 11, 2024

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

n/a

Relevant log output

================================== 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 =================
@lengau lengau added Bug Something isn't working triaged labels Dec 11, 2024
Copy link

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-3800.

This message was autogenerated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working triaged
Projects
None yet
Development

No branches or pull requests

1 participant