Tests | Address additional flaky tests#4305
Open
edwardneal wants to merge 7 commits into
Open
Conversation
This prevents checks of the default AppContext switch values which would run in parallel to other tests which modify these values via the RAII helper.
* Swap System.Random with the same RNG which SqlClient uses. * Make a fixed number of attempts to reattempt key creation if a key with the generated name already exists.
…ate operation cancellation
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This corrects a number of other flaky tests which I noticed while looking at the XEvents tests; these fixes are small enough to bundle together.
LocalAppContextSwitchesTestThis is a standalone test, in an assembly where tests in the same class run in sequence, and classes run in parallel. That presents a problem if the AppContext switch tests are running in parallel with tests in
ConnectionFailoverTestsorSqlConnectionOptionsTest.LocalAppContextSwitchesTestcan find itself in a position where it's assertingEnableMultiSubnetFailoverByDefaultorIgnoreServerProvidedFailoverPartnerat the same time thatSqlConnectionOptionsTest.TestDefaultMultiSubnetFailoverorConnectionFailoverTests.TransientFault_IgnoreServerProvidedFailoverPartner_ShouldConnectToUserProvidedPartnerare setting these switches totrue.LocalAppContextSwitchesHelperhas its own way to deal with this - a staticSemaphoreSlimwhich only allows one writer at a time. I've chosen to use this in order to maintain consistency when dealing with AppContext switches.BatchTests.ParameterInOutAndReturnThis test manually created a stored procedure with a hardcoded name. There were a few instances where this already existed. I've replaced this with the
StoredProcedureRAII primitive.AKVUnitTests,EnclaveAzureDatabaseTestsSurprisingly, it looks like there have been occasions where a deleted key with the same name already existed. I've switched the RNG to a more robust implementation, and added some limited retry logic.
The simpler solution would probably have been to purge the key and retry, but I'm not sure what permissions this runs with in CI, and if the key has been deleted then there's no point - it'll be purged in due course.
It's also worth noting the differing approach to generating key names. This is because AKV names have different requirements to database objects.
SqlCommandCancelTestThis depended upon always catching a
SqlExceptionwhen an operation was cancelled. Sometimes this can be anInvalidOperationException.Issues
None.
Testing
Modified tests continue to pass.