You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Flaky test: TestPrometheusMetrics_IncrementedCorrectly (pkg/util/queryeviction) — race between async eviction and evictionsTotal assertion #7604
AI Tool Usage Notice
If you used an AI tool to help draft this issue,
please make sure you have reviewed and validated all content before submitting.
You are responsible for the accuracy and quality of everything in this report.
Low-quality or unreviewed AI-generated submissions may be closed without further investigation.
See our Generative AI Contribution Policy for details.
Describe the bug
TestPrometheusMetrics_IncrementedCorrectly (pkg/util/queryeviction) intermittently fails with the evictionsTotal counter reading one less than expected:
The test starts an asynchronous evictor (startEvictor, which runs a background loop on CheckInterval), drives 3 evictions via waitEvicted, then asserts the metric:
evictionsTotal is incremented by the background eviction goroutine. waitEvicted signals that an eviction occurred, but the assertion can observe 2 when the metric increment for the third eviction has not been published yet — i.e., the test synchronizes on the eviction signal but not on the metric write.
(This package was introduced by #7488, "Add Query Resource Based Eviction".)
To Reproduce
Steps to reproduce the behavior:
Start Cortex (recent master)
Run the test repeatedly:
go test -count=200 -run TestPrometheusMetrics_IncrementedCorrectly ./pkg/util/queryeviction/
Expected behavior
The test passes deterministically; the assertion observes all 3 eviction metric increments (the test should synchronize on the metric being published, not only on the eviction signal).
Environment:
Infrastructure: GitHub Actions CI, ubuntu-24.04 (amd64), test job
Filed from CI failure-log analysis with AI assistance; the run link and evictor_test.go:210 were reviewed and verified against master before submitting.
Activity