Skip to content

cache: TestObservedUpstreamsStore_ShrinkRemovesTheEntry / _RestoreSkipsDeadEntries fail locally (6/6 on main), pass in CI — timing-bound Eventually on the debounced flush #955

Closed

Description

@bpalermo

Symptom

On main at 2038fac, unchanged, on the workstation (2026-09-26 ~17:30Z):

bazel test --runs_per_test=6 --test_filter='TestObservedUpstreamsStore_ShrinkRemovesTheEntry' //agent/internal/xds/cache:cache_test
    observedstore_test.go:202:   ×5   (require.Eventually: len(storedServices) == 1 after ObserveDependency)
    observedstore_test.go:207:   ×1   ("the expired entry is gone from the file")
        Error: Condition never satisfied

Six of six runs red; a full-package run also reports observedstore_test.go:150 and :227 (_RestoreSkipsDeadEntries, _UnionsWithResumeHeldClusters, "both sources are persisted, in key order"). The same package passed in the test job of #953 forty minutes earlier and the whole tree passed locally this morning (112/112 before #947), so this is environment-sensitive, not deterministic.

Where it waits

observedstore_test.go: eventuallyWait = 2s, eventuallyTick = 5ms; the cache's defaultObservedFlushDebounce = 1s (markObservedDirtyLocked → time.AfterFunc(debounce, flushObservedUpstreams)). ShrinkRemovesTheEntry sets observedTTL = 30ms, sleeps 40 ms, prunes, then waits ≤2 s for the file to shrink. A 1 s debounce inside a 2 s window leaves ~1 s of slack for the write + fsnotify-free re-read; under load (a concurrent Bazel build, two kind clusters earlier today) that slack is gone, and Eventually ticks at 5 ms so it is not the tick.

Why it matters

The cache package is the one every control-plane PR runs. A test that goes red 6/6 on a loaded workstation makes the local pre-merge signal unusable for that package, and the temptation is to skip or filter it — which is how a real regression in the observed-upstreams store (#701's warm start) would get through.

Fix direction

Inject the debounce for tests (newStoreTestCache already sets observedTTL; set observedFlushDebounce to ~10 ms the same way, or expose a synchronous flushObservedUpstreamsNow() for tests to call instead of waiting), and widen eventuallyWait relative to the debounce (≥ 3×). Not touched in the PR that found it (#947-era QUIC work, PR 7) because a test-only change under a feature PR hides the finding.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions