Skip to content

Fix flaky SQL statistics test - #5769

Merged
apurvabhaleMS merged 3 commits into
mainfrom
personal/abhale/fix-flaky-stat-tests
Sep 2, 2026
Merged

apurvabhaleMS merged 3 commits into
mainfrom
personal/abhale/fix-flaky-stat-tests

Conversation

@apurvabhaleMS

@apurvabhaleMS apurvabhaleMS commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes an intermittent failure in GivenMissingTrueSearchForPatientByGender_NotExistsStatsAreCreated.

The SQL search statistics cache is process-wide and may already contain valid individual-gender statistics for non-Patient resource types created by other test classes. The test now snapshots the cache before executing the Patient gender:missing=true search 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

  • Update the title of the PR to be succinct and less than 65 characters
  • Add a milestone to the PR for the sprint that it is merged (i.e. add S47)
  • Tag the PR with the type of update: Bug, Build, Dependencies, Enhancement, New-Feature or Documentation
  • Tag the PR with Open source, Azure API for FHIR (CosmosDB or common code) or Azure Healthcare APIs (SQL or common code) to specify where this change is intended to be released.
  • Tag the PR with Schema Version backward compatible or Schema Version backward incompatible or Schema Version unchanged if this adds or updates Sql script which is/is not backward compatible with the code.
  • When changing or adding behavior, if your code modifies the system design or changes design assumptions, please create and include an ADR.
  • CI is green before merge Build Status
  • Review squash-merge requirements

Semver Change (docs)

Skip

@apurvabhaleMS
apurvabhaleMS requested a review from a team as a code owner August 28, 2026 14:34
@codecov-commenter

Codecov Comments Bot (codecov-commenter) commented Aug 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.90%. Comparing base (53e30b0) to head (57c3bdc).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            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     

see 70 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@apurvabhaleMS apurvabhaleMS added Enhancement-Test Enhancement on tests. Azure Healthcare APIs Label denotes that the issue or PR is relevant to the FHIR service in the Azure Healthcare APIs Schema Version unchanged No-ADR ADR not needed PaaS-breaking-change Add this label if your changes will require additional changes in PaaS repos to be complete No-PaaS-breaking-change labels Aug 28, 2026
@apurvabhaleMS apurvabhaleMS added this to the FY27\Q1\2wk\2wk05 milestone Aug 28, 2026
@apurvabhaleMS
apurvabhaleMS enabled auto-merge (squash) August 31, 2026 22:08
@apurvabhaleMS
apurvabhaleMS requested a lite review from Copilot September 1, 2026 22:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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=true for Patient.
  • 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>
@apurvabhaleMS
apurvabhaleMS merged commit 8a49535 into main Sep 2, 2026
48 checks passed
@apurvabhaleMS
apurvabhaleMS deleted the personal/abhale/fix-flaky-stat-tests branch September 2, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Azure Healthcare APIs Label denotes that the issue or PR is relevant to the FHIR service in the Azure Healthcare APIs Enhancement-Test Enhancement on tests. No-ADR ADR not needed No-PaaS-breaking-change PaaS-breaking-change Add this label if your changes will require additional changes in PaaS repos to be complete Schema Version unchanged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants