Fix flaky SQL statistics test - #5769
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5769 +/- ##
==========================================
+ Coverage 78.79% 78.90% +0.11%
==========================================
Files 1020 1016 -4
Lines 37783 36940 -843
Branches 5754 5619 -135
==========================================
- Hits 29772 29149 -623
+ Misses 6594 6408 -186
+ Partials 1417 1383 -34 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
The new “new stats” enumeration is deferred and should be materialized immediately after the search to avoid reintroducing test flakiness if the cache changes later in the test.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Fixes a flaky SQL Server integration test by accounting for the process-wide SQL search statistics cache so the test only asserts against statistics newly introduced by the query under test.
Changes:
- Snapshot the SQL search statistics cache before running
gender:missing=trueforPatient. - Scope the negative assertion (no cross-resource-type stat fan-out) to newly-added cache entries while still positively asserting the expected Patient stat exists.
File summaries
| File | Description |
|---|---|
| test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerCreateStatsTests.cs | Updates the flaky :missing=true stats test to compare cache snapshots and ignore pre-existing stats entries. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Description
Fixes an intermittent failure in
GivenMissingTrueSearchForPatientByGender_NotExistsStatsAreCreated.The SQL search statistics cache is process-wide and may already contain valid
individual-genderstatistics for non-Patient resource types created by other test classes. The test now snapshots the cache before executing the Patientgender:missing=truesearch and scopes its negative assertion to newly added statistics. The positive assertion still verifies that the expected Patient statistic exists after the search.Related issues
Addresses AB205695
Testing
Result: 1 passed, 0 failed.
FHIR Team Checklist
Semver Change (docs)
Skip