Skip to content

Conversation

benrr101
Copy link
Contributor

Description

Re-enables DataStreamTests.RunAllTestsForSingleServer_TCP previously blocked by #5540

In Release mode, it works just fine without any changes. In Debug mode, though, it has issues with async behavior. The test harness for async test created (but did not start) an async operation, attempted to run the operation in parallel (which should fail as another async operation is in progress), then disposes the test harness and waits on the first async task. This fails because the connection is closed when the test harness is disposed, failing the test. It's unclear to me why the test harness disposes the connection or why it exists at all, but that's not the point. So, to resolve those issues, I followed a pattern used in another part of the test code that asserts the final wait throws. Totally unnecessary imho, but if we have to wait something that'll throw, then we might as well make sure it throws.

Another issue happens deep in the TdsParserStateObject in Debug mode. There is a Debug.Assert in there that validates the previousTimeoutState is Stopped. This check is failing in the test scenarios. However, immediately following the assert, we have an if statement that checks the exact same thing. Theoretically if the assert is correct, we always run the code in the if statement. But, since we have the conditional, we must expect that the asserted condition might not be met. It implies to me that the assert shouldn't exist. So I removed it and the test now passes.

Since this is a lengthy explanation, I figure I should submit this PR by itself.

Issues

#5540 - which I don't think exists in GH.

Testing

Running the test locally, it passes

benrr101 added 2 commits July 16, 2025 16:03
…ocked by #5540

Most of the issues with it were debug-only tests that checked async behavior. Async read task was expected to throw, but was simply being waited, causing the test to fail. Fixed by replacing waits with checks for exception (as was used in a handful of similar tests).

One issue was due to a debug assert failing in the TDS state object. It's really buried in timeout code, so I have no idea what it's expected to do. However, the code immediately after it was flagged by my IDE as always being true due to the debug - why are we conditionally executing code if we expect it to always be a certain value? So, I removed the debug assert.

Also added a handful of todo notes to the test class because it needs breaking up. And it's full of smelly Thread.Wait code.
@benrr101 benrr101 added this to the 7.0-preview1 milestone Jul 21, 2025
@Copilot Copilot AI review requested due to automatic review settings July 21, 2025 17:37
@benrr101 benrr101 added the Area\Tests Issues that are targeted to tests or test projects label Jul 21, 2025
@benrr101 benrr101 requested a review from a team as a code owner July 21, 2025 17:37
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR re-enables the DataStreamTests.RunAllTestsForSingleServer_TCP test that was previously disabled due to issue #5540. The changes address async operation handling issues in Debug mode and resolve test stability problems.

Key changes include:

  • Removing the [ActiveIssue("5540")] attribute to re-enable the disabled test
  • Updating async task waiting patterns to properly handle expected exceptions
  • Removing a problematic Debug.Assert that was causing failures in test scenarios
  • Removing an entire test file that appears to be no longer needed

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
DataStreamTest.cs Re-enables TCP test, updates async exception handling patterns, removes failing test method
AsyncTest.cs Complete file deletion of async performance test
Microsoft.Data.SqlClient.ManualTesting.Tests.csproj Removes reference to deleted AsyncTest.cs file
TdsParserStateObject.cs Removes Debug.Assert that was failing in test scenarios
Comments suppressed due to low confidence (1)

paulmedynski
paulmedynski previously approved these changes Jul 22, 2025
mdaigle
mdaigle previously approved these changes Jul 23, 2025
@paulmedynski
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@paulmedynski paulmedynski dismissed stale reviews from mdaigle and themself via a6a257f August 22, 2025 19:07
Copy link

codecov bot commented Aug 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.51%. Comparing base (8eb9f32) to head (0d41c88).
⚠️ Report is 50 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3494      +/-   ##
==========================================
- Coverage   68.86%   64.51%   -4.36%     
==========================================
  Files         280      276       -4     
  Lines       62417    62582     +165     
==========================================
- Hits        42982    40372    -2610     
- Misses      19435    22210    +2775     
Flag Coverage Δ
addons 90.82% <ø> (-1.76%) ⬇️
netcore 66.79% <ø> (-5.96%) ⬇️
netfx 68.04% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@paulmedynski paulmedynski requested a review from mdaigle August 27, 2025 15:39
@paulmedynski paulmedynski requested a review from mdaigle August 27, 2025 17:46
@paulmedynski paulmedynski merged commit dc8f23b into main Aug 27, 2025
250 checks passed
@paulmedynski paulmedynski deleted the dev/russellben/active-issues-1 branch August 27, 2025 23:31
paulmedynski added a commit that referenced this pull request Sep 3, 2025
- Backported part of #3494 and all of #3591:
  - Added configurable test jobs timeout, defaulting to 90 minutes.
  - Reduced generated database names to 96 chars to try to fix macOS test failures.
paulmedynski added a commit that referenced this pull request Sep 3, 2025
- Backported part of #3494 and all of #3591:
  - Added configurable test jobs timeout, defaulting to 90 minutes.
  - Reduced generated database names to 96 chars to try to fix macOS test failures.Increase test jobs timeout (#3591)
paulmedynski added a commit that referenced this pull request Sep 3, 2025
- Backported part of #3494 and #3591:
  - Added configurable test jobs timeout, defaulting to 90 minutes.
  - Reduced generated database names to 96 chars to try to fix macOS test failures.
paulmedynski added a commit that referenced this pull request Sep 3, 2025
- Backported part of #3494 and #3591:
  - Added configurable test jobs timeout, defaulting to 90 minutes.
  - Reduced generated database names to 96 chars to try to fix macOS test failures.
benrr101 pushed a commit that referenced this pull request Sep 3, 2025
- Backported part of #3494 and all of #3591:
  - Added configurable test jobs timeout, defaulting to 90 minutes.
  - Reduced generated database names to 96 chars to try to fix macOS test failures.
paulmedynski added a commit that referenced this pull request Sep 10, 2025
- Backported part of #3494 and all of #3591:
  - Added configurable test jobs timeout, defaulting to 90 minutes.
  - Reduced generated database names to 96 chars to try to fix macOS test failures.Increase test jobs timeout (#3591)

- Fixed the unique name generators to:
  - Keep max lengths to 30 and 96 characters respectively.
  - Ensure uniqueness at the start of the names.
  - Added link to database identifier syntax.
cheenamalhotra pushed a commit that referenced this pull request Sep 26, 2025
* User Story 38467: Backport mac server name fix

- Backported part of #3494 and all of #3591:
  - Added configurable test jobs timeout, defaulting to 90 minutes.
  - Reduced generated database names to 96 chars to try to fix macOS test failures.Increase test jobs timeout (#3591)

- Fixed the unique name generators to:
  - Keep max lengths to 30 and 96 characters respectively.
  - Ensure uniqueness at the start of the names.
  - Added link to database identifier syntax.

* User Story 38467: Backport mac server name fix

- Added a new test that was erroneously removed in the earlier cherry-pick.
- Added MDS_TEST_CONFIG environment variable to unit test config to override where the confi.json file is read from.
- Updated xUnit to 2.9.3 to avoid transitive System.Net.Http vulnerability warnings.

* Add retry on deadlock for sp_help (#3025)

Add parameter to sp_help

* User Story 38467: Backport mac server name fix

- Fixed cherry-pick of old function name.

* User Story 38467: Backport mac server name fix

- Removed macOS Azure SQL test configuration that uses service principal based auth that our Azure tenant no longer supports.

* User Story 38467: Backport mac server name fix

- Adding console diagnostics to slow enclave tests.

* User Story 38467: Backport mac server name fix

- Adding console diagnostics to slow enclave tests.

* User Story 38467: Backport mac server name fix

- Adding console diagnostics to slow enclave tests.

* Tests | Remove hardcoded credentials from ManualTests (#3204)

* Initial removal of CertificateUtility.CreateCertificate

One test implied that DataTestUtility.AKVUrl would point to an RSA key which aligned with the certificate's private key. Switching this to dynamically generate the key in places.

* Hotfix for Azure Key Vault tests

* Removed hardcoded references to Azure Key Vault key

* Removed hardcoded references to CertificateUtilityWin

These were mostly related to generating CSP keys.

* Code review changes

* Reorder properties and constructors
* Move AEConnectionStringProviderWithCspParameters to its own file
* Tweak to the AKV token acquisition

* Code review

Redundant bracket, alphabetised the ManualTesting csproj

* Update src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/SQLSetupStrategy.cs

Let's try @edwardneal's idea

Co-authored-by: Edward Neal <[email protected]>

* Update src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/SQLSetupStrategy.cs

Co-authored-by: Edward Neal <[email protected]>

* Fixes as per @edwardneal's suggestions

* Fix as per @edwardneal's suggestion

* Fix missing `new`

Co-authored-by: Edward Neal <[email protected]>

* Update src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/SQLSetupStrategyAzureKeyVault.cs

Co-authored-by: Edward Neal <[email protected]>

* Update src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/SQLSetupStrategyAzureKeyVault.cs

Co-authored-by: Edward Neal <[email protected]>

* Address comment that we don't need a CspParameters object as part of the test arguments
* Move test arguments into property (the class was only used in a single location)
* Cleanup test code
* Tweak default provider discovery code to handle edge cases a bit better

* Address comment regarding readonly member variables
Apply long line chomping

* Addressing the last of the comments.

---------

Co-authored-by: Edward Neal <[email protected]>

* - Fixed incorrect unique database object name function that doesn't compile normally.

* Updated TestUtilities project to target the same framework as the test project(s) it is compiling with.

* Removed diagnostic logging now that Enclave tests are passing.

---------

Co-authored-by: Michel Zehnder <[email protected]>
Co-authored-by: Benjamin Russell <[email protected]>
Co-authored-by: Edward Neal <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area\Tests Issues that are targeted to tests or test projects
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants