Skip to content

flaky test: oauth::second_call_within_expiry_hits_the_cache fails intermittently on CI (cache miss on 2nd sequential call) #812

Description

@moonming

Observed on PR #811 CI (run 29995107963, job 89166828069, commit 333ce37 — a change confined to crates/aisix-proxy/src/videos.rs; the aisix-mcp crate is untouched):

thread 'oauth::tests::second_call_within_expiry_hits_the_cache' panicked at crates/aisix-mcp/src/oauth.rs:365:
assertion `left == right` failed: second call must be served from cache

The test mints a token with expires_in: 3600 and asserts the second sequential get_or_fetch is served from cache (endpoint.hits() == 1). A miss between two sequential calls with an hour of validity should be impossible unless the token cache is process-global and subject to interference from sibling tests running in parallel in the same binary (eviction from a bounded cache, or key collision/cleanup between tests). Passes locally and on the same code in earlier runs — timing/parallelism dependent.

Worth checking:

  • whether the oauth token cache is a shared/global structure across tests, and whether it is bounded (parallel sibling tests could evict this entry);
  • whether the fix is test isolation (per-test cache instance) rather than loosening the assertion.

Not weakening the assertion in the PR that observed it — filing per test-discipline (failures get root-caused, not silenced).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions