Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve flaky integration tests #3836

Merged
merged 11 commits into from
May 7, 2024

Conversation

brendankowitz
Copy link
Member

@brendankowitz brendankowitz commented May 1, 2024

Description

This pull request primarily focuses on improving the test suite for integration tests. The changes include modifications to the Azure DevOps pipeline YAML file to separate integration tests into different jobs, changes to the test suite to improve database setup and teardown, and enhancements to the test suite to better handle cancellation and disposal of resources.

Changes to the CI/CD pipeline:

  • build/jobs/run-tests.yml: The integration test job was split into two separate jobs, CosmosIntegrationTests and SqlIntegrationTests, to allow for more granular control over the execution of different types of integration tests. This change also involves the addition of new tasks to each job to execute the respective tests. [1] [2]

Improvements to test suite:

Enhancements to cancellation and disposal:

  • src/Microsoft.Health.Fhir.SqlServer/Features/Watchdogs/FhirTimer.cs: Improved the handling of cancellation in the RunInternalAsync method to immediately return if cancellation is requested.
  • test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/ChangeFeed/SqlServerFhirResourceChangeCaptureDisabledTests.cs and test/Microsoft.Health.Fhir.Shared.Tests.Integration/Features/ChangeFeed/SqlServerFhirResourceChangeCaptureFixture.cs: Modified the disposal of resources in test classes to check if the resource is null before attempting to dispose of it. This change makes the test suite more robust in the face of unexpected errors during setup. [1] [2]

Related issues

Addresses AB#120046

Testing

Describe how this change was tested.

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.
  • CI is green before merge Build Status
  • Review squash-merge requirements

Semver Change (docs)

Patch|Skip|Feature|Breaking (reason)

@brendankowitz brendankowitz force-pushed the personal/bkowitz/find-flaky-integration-tests branch 2 times, most recently from aa94c59 to ccc4014 Compare May 1, 2024 23:21
@brendankowitz brendankowitz force-pushed the personal/bkowitz/find-flaky-integration-tests branch from 29d8a66 to d223900 Compare May 2, 2024 17:28
@brendankowitz brendankowitz added this to the S140 milestone May 2, 2024
@brendankowitz brendankowitz added Build Open source This change is only relevant to the OSS code or release. labels May 2, 2024
@brendankowitz brendankowitz force-pushed the personal/bkowitz/find-flaky-integration-tests branch 2 times, most recently from 93a145f to d1acae9 Compare May 2, 2024 21:29
@brendankowitz brendankowitz force-pushed the personal/bkowitz/find-flaky-integration-tests branch from d1acae9 to b05053d Compare May 3, 2024 18:41
@brendankowitz brendankowitz force-pushed the personal/bkowitz/find-flaky-integration-tests branch from 9c6191a to b4c4873 Compare May 3, 2024 20:55
@brendankowitz brendankowitz force-pushed the personal/bkowitz/find-flaky-integration-tests branch from cc5a59f to d50bd7d Compare May 3, 2024 23:17
@brendankowitz brendankowitz marked this pull request as ready for review May 6, 2024 16:30
@brendankowitz brendankowitz requested a review from a team as a code owner May 6, 2024 16:30
@brendankowitz brendankowitz changed the title Possibly flaky tests Improve flaky integration tests May 6, 2024
@brendankowitz brendankowitz force-pushed the personal/bkowitz/find-flaky-integration-tests branch 3 times, most recently from 8192399 to 208f71d Compare May 7, 2024 14:56
@@ -206,18 +217,32 @@ public async Task DeleteDatabase(string databaseName, CancellationToken cancella
return;
}

SqlConnection.ClearAllPools();

await _dbSetupRetryPolicy.ExecuteAsync(async () =>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we not want to retry the cleanup?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was mainly trying to find where all the time is spent for integration tests. I think we wait the max amount of time on retries to delete the database at the end of every fixture.
Strangely enough, when watching the resource group the databases all seemed to eventually drop, perhaps there's something async going on under the covers on the sql side.

On top of this, we delete the resource group at the end of the test which should cover anything that failed, and CI has a task to remove orphaned test databases.

@brendankowitz brendankowitz force-pushed the personal/bkowitz/find-flaky-integration-tests branch from 208f71d to 7e8a563 Compare May 7, 2024 16:31
feordin
feordin previously approved these changes May 7, 2024
@brendankowitz brendankowitz merged commit 4a1b5ee into main May 7, 2024
47 checks passed
@brendankowitz brendankowitz deleted the personal/bkowitz/find-flaky-integration-tests branch May 7, 2024 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build Open source This change is only relevant to the OSS code or release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants