Skip to content

Conversation

@paulmedynski
Copy link
Contributor

Description

This PR moves all existing MDS tests that use the ActiveDirectoryAuthenticationProvider (ADAP) into the Azure project. The tests are moved as-is with non-functional changes to get them to build/run.

A few MDS tests were unnecessarily using ADAP when they should have been using a test provider, so I updated them to do so.

A full suite of tests for the Azure package will be created in future PRs.

Testing

Existing CI for the Azure and MDS packages should confirm everything.

@paulmedynski paulmedynski added this to the 7.0.0-preview3 milestone Oct 24, 2025
Copy link
Contributor Author

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

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

Commentary for reviewers.

#pragma warning disable 0618 // Type or member is obsolete
[InlineData(SqlAuthenticationMethod.ActiveDirectoryPassword)]
#pragma warning restore 0618 // Type or member is obsolete
[InlineData(SqlAuthenticationMethod.ActiveDirectoryInteractive)]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interactive was missing from the original test, so I added it here.

namespace Microsoft.Data.SqlClient.ManualTesting.Tests
{
public class AADConnectionsTest
public class AADConnectionTest
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test class name didn't match the filename.

// Clear token cache for code coverage.
ActiveDirectoryAuthenticationProvider.ClearUserTokenCache();
using (SqlConnection connection = new SqlConnection(DataTestUtility.AADPasswordConnectionString))
#pragma warning disable 0618 // Type or member is obsolete
Copy link
Contributor Author

@paulmedynski paulmedynski Oct 24, 2025

Choose a reason for hiding this comment

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

These tests were unnecessarily using our auth provider, so I updated them to use the test provider defined above, which fetches real tokens via MSAL itself.

- Moved existing tests that use ActiveDirectoryAuthenticationProvider into Azure tests.
- Updated some MDS tests that unnecessarily used ActiveDirectoryAuthenticationProvider.
- Fixed project-based builds so we can restore MDS netcore and netfx projects at the same time.
- Added a Managed Identity provider that is installed by default for the Manual Tests suite.
- Moved some tests from ManualTests to Azure that require the provider.
- Avoiding calling SetProvider with a null value, since it isn't possible to unset a provider once set.
- Added caching to the managed identity provider for the ManualTest project.
- Added environment variable debug logging to Abstractions and Azure pipeline jobs.
- Moved username/password Entra auth provider into its own file for sharing across tests.
- Added ADO service connection for test tasks that require access to Azure resources.
- Added workload identity federation tests.
- Disabling xUnit shadow copy to prevent strong name varification failures.
@paulmedynski paulmedynski force-pushed the dev/paul/azure-split/move-tests branch from 1903ecc to b17155b Compare October 28, 2025 16:27
@codecov
Copy link

codecov bot commented Oct 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.77%. Comparing base (48e5eb7) to head (617c922).

Additional details and impacted files
@@                           Coverage Diff                           @@
##           dev/paul/azure-split/authentication    #3717      +/-   ##
=======================================================================
- Coverage                                76.77%   76.77%   -0.01%     
=======================================================================
  Files                                      269      269              
  Lines                                    45029    45029              
=======================================================================
- Hits                                     34573    34571       -2     
- Misses                                   10456    10458       +2     
Flag Coverage Δ
addons 90.82% <ø> (ø)
netcore 76.64% <ø> (-0.03%) ⬇️
netfx 76.14% <ø> (-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.

Copy link
Contributor Author

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

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

Commentary for reviewers.

public class AADConnectionsTest
public class AADConnectionTest
{
class CustomSqlAuthenticationProvider : SqlAuthenticationProvider
Copy link
Contributor Author

@paulmedynski paulmedynski Oct 29, 2025

Choose a reason for hiding this comment

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

Moved this to UsernamePasswordProvider.cs so it could be shared.

--verbosity ${{ parameters.verbosity }}
--verbosity ${{ parameters.dotnetVerbosity }}
-p:ReferenceType=${{ parameters.referenceType }}
-p:ForceMdsAssemblyNameSuffix=true
Copy link
Contributor Author

@paulmedynski paulmedynski Oct 29, 2025

Choose a reason for hiding this comment

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

This is explained in my comments on Directory.Build.props.

# to stress test.
- name: pipelineArtifactName
displayName: Pipeline Artifact Name
# The verbosity level for the dotnet CLI commands.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorted parameters alphabetically and added some debug/verbosity.

Apply an MDS assembly name suffix, if necessary. See the top-level
Directory.Build.props for more information.
-->
<DefineConstants Condition="'$(ApplyMdsAssemblyNameSuffix)' == 'true'">$(DefineConstants);APPLY_MDS_ASSEMBLY_NAME_SUFFIX</DefineConstants>
Copy link
Contributor Author

@paulmedynski paulmedynski Oct 29, 2025

Choose a reason for hiding this comment

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

Abstractions performs reflection against the MDS assembly, so it needs to know how to form the assembly name. Explained in Directory.Build.props.

Append an assembly name suffix, if necessary. See the top-level
Directory.Build.props for more information.
-->
<AssemblyName>Microsoft.Data.SqlClient</AssemblyName>
Copy link
Contributor Author

@paulmedynski paulmedynski Oct 29, 2025

Choose a reason for hiding this comment

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

The 2 ref projects didn't previously specify <AssemblyName>. Not sure why, or if this new addition will cause problems. Thoughts?

<ProjectReference
Condition="'$(TargetGroup)'=='netfx'"
Include="$(NetFxSource)src\Microsoft.Data.SqlClient.csproj" />
<ProjectReference Include="../../../Microsoft.Data.SqlClient.Extensions/Azure/src/Azure.csproj" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This ensures that none of the Functional (or Manual) tests are depending on our auth provider by accident.

//
// TODO: Figure out which ones and install on-demand rather than
// globally.
SqlAuthenticationProvider.SetProvider(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This entire test suite is now serviced either by this provider, or by the UsernamePasswordProvider on-demand.

No other auth methods have a provider installed.

}
finally
{
if (original is not null)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason there is no unset-provider mechanism, so we're polluting the global scope in the event that no provider was registered before this test.

You will see this pattern elsewhere as well. SetProvider() throws an NRE if you pass null.

<group targetFramework="net462">
<reference file="Microsoft.Data.SqlClient.dll" />
<reference file="Microsoft.Data.SqlClient.xml" />
<reference file="Microsoft.Data.SqlClient$AssemblyNameSuffixNetFx$.dll" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Our project-reference based builds probably shouldn't be attempting to generate NuGet packages, but since they do, I made it work. The generated packages aren't used for anything (see CI-SqlClient pipeline), so there is no harm here.

As mentioned in the Directory.Build.props commentary, this is all temporary code anyway and should disappear before 7.0.0 GA.

project to determine whether or not to apply the MDS assembly name suffix.
-->
<ApplyMdsAssemblyNameSuffix>false</ApplyMdsAssemblyNameSuffix>
<ApplyMdsAssemblyNameSuffix
Copy link
Contributor Author

@paulmedynski paulmedynski Oct 29, 2025

Choose a reason for hiding this comment

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

This is a temporary measure to get the Abstractions and Azure projects (and their tests) to build without having to employ the confusing tricks found in the FunctionalTests, ManualTests, and AKV projects, where we only support building for one type of framework at a time (ick!). This will all disappear when we finally complete the .NET and .NET Framework codebase merge, and we have a single MDS project.

Copy link
Contributor

Choose a reason for hiding this comment

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

Single assembly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed that part since it was confusing. We will produce the same number of MDS assembly files (DLLs), but will no longer be prevented from building them all at once via project references due to multiple projects specifying the same assembly name.

…ig helper.

- Injecting config into pipeline runs via the config.json approach.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants