Skip to content

Commit 1d44a2e

Browse files
Tests | Manual Test "Set" Trait (#4071)
Co-authored-by: Paul Medynski <31868385+paulmedynski@users.noreply.github.com>
1 parent 5ac26c9 commit 1d44a2e

177 files changed

Lines changed: 495 additions & 575 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build.proj

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,13 +353,13 @@
353353
TestSet
354354
Applies to: TestSqlClientManual
355355
Description: Used to select a set of tests to run from the SqlClient manual tests project. If not
356-
specified, all tests will be executed.
356+
specified, all manual tests will be executed. In the manual test target, this
357+
value is converted into a Set trait filter and combined with any TestFilters.
357358
Default value: [blank]
358359
Allowed values: ([1][2][3][AE])
359360
Examples: "1", "12", "AE", "12AE"
360361
-->
361362
<TestSet Condition="'$(TestSet)' == ''" />
362-
<TestSetArgument Condition="'$(TestSet)' != ''">-p:TestSet="$(TestSet)"</TestSetArgument>
363363
</PropertyGroup>
364364

365365
<!-- ================================================================= -->
@@ -664,14 +664,27 @@
664664
<LogFilePrefix Condition="'$(TestFramework)' != ''">$(LogFilePrefix)-$(TestFramework)</LogFilePrefix>
665665
<LogFilePrefix Condition="'$(TestSet)' != ''">$(LogFilePrefix)-$(TestSet)</LogFilePrefix>
666666

667+
<!-- Join test sets together, if any were selected -->
668+
<NormalizedTestSet>$(TestSet.ToUpper())</NormalizedTestSet>
669+
<TestSetFilter Condition="$(NormalizedTestSet.Contains('1'))">Set=1</TestSetFilter>
670+
<TestSetFilter Condition="$(NormalizedTestSet.Contains('2'))">$(TestSetFilter)|Set=2</TestSetFilter>
671+
<TestSetFilter Condition="$(NormalizedTestSet.Contains('3'))">$(TestSetFilter)|Set=3</TestSetFilter>
672+
<TestSetFilter Condition="$(NormalizedTestSet.Contains('AE'))">$(TestSetFilter)|Set=AE</TestSetFilter>
673+
<TestSetFilter>$(TestSetFilter.Trim('|'))</TestSetFilter>
674+
675+
<!-- Combine existing filters with test set filters -->
676+
<ManualTestFilters Condition="'$(TestSetFilter)' != '' and '$(TestFilters)' != ''">$(TestFilters)&amp;($(TestSetFilter))</ManualTestFilters>
677+
<ManualTestFilters Condition="'$(TestSetFilter)' == ''">$(TestFilters)</ManualTestFilters>
678+
<ManualTestFilters Condition="'$(TestFilters)' == ''">$(TestSetFilter)</ManualTestFilters>
679+
<ManualTestFiltersArgument Condition="'$(ManualTestFilters)' != ''">--filter "$(ManualTestFilters)"</ManualTestFiltersArgument>
680+
667681
<DotnetCommand>
668682
"$(DotnetPath)dotnet" test "$(SqlClientManualTestProjectPath)"
669683
-p:Configuration=$(Configuration)
670684
$(TestBlameArgument)
671685
$(TestCodeCoverageArgument)
672-
$(TestFiltersArgument)
686+
$(ManualTestFiltersArgument)
673687
$(TestFrameworkArgument)
674-
$(TestSetArgument)
675688
--results-directory "$(TestResultsFolderPath)"
676689
--logger:"trx;LogFilePrefix=$(LogFilePrefix)"
677690

src/Microsoft.Data.SqlClient.slnx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,11 @@
205205
<Project Path="Microsoft.Data.SqlClient/tests/StressTests/SqlClient.Stress.Runner/SqlClient.Stress.Runner.csproj" />
206206
<Project Path="Microsoft.Data.SqlClient/tests/StressTests/SqlClient.Stress.Tests/SqlClient.Stress.Tests.csproj" />
207207
</Folder>
208-
<Folder Name="/test/TestClr/">
209-
<Project Path="Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UDTs/Address/Address.csproj" />
210-
<Project Path="Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UDTs/Circle/Circle.csproj" />
211-
<Project Path="Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UDTs/Shapes/Shapes.csproj" />
212-
<Project Path="Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UDTs/Utf8String/Utf8String.csproj" />
208+
<Folder Name="/test/TestUdts/">
209+
<Project Path="Microsoft.Data.SqlClient/tests/TestUdts/Address/Address.csproj" />
210+
<Project Path="Microsoft.Data.SqlClient/tests/TestUdts/Circle/Circle.csproj" />
211+
<Project Path="Microsoft.Data.SqlClient/tests/TestUdts/Shapes/Shapes.csproj" />
212+
<Project Path="Microsoft.Data.SqlClient/tests/TestUdts/Utf8String/Utf8String.csproj" />
213213
</Folder>
214214
<Project Path="../tools/PackageCompatibility/src/PackageCompatibility.csproj" />
215215
<Project Path="../tools/PackageCompatibility/test/PackageCompatibility.Test.csproj" />

src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.FunctionalTests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
<PackageReference Include="xunit.runner.visualstudio" ExcludeAssets="compile" />
7878

7979
<ProjectReference Include="$(RepoRoot)src/Microsoft.Data.SqlClient/tests/Common/Microsoft.Data.SqlClient.TestCommon.csproj" />
80-
<ProjectReference Include="$(RepoRoot)src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UDTs/Address/Address.csproj" />
80+
<ProjectReference Include="$(RepoRoot)src/Microsoft.Data.SqlClient/tests/TestUdts/Address/Address.csproj" />
8181
<ProjectReference Include="$(RepoRoot)src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/Microsoft.Data.SqlClient.TestUtilities.csproj" />
8282
<ProjectReference Include="$(RepoRoot)src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS/TDS.csproj" />
8383
<ProjectReference Include="$(RepoRoot)src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.EndPoint/TDS.EndPoint.csproj" />
@@ -101,7 +101,7 @@
101101
<PackageReference Include="xunit.runner.visualstudio" ExcludeAssets="compile" />
102102

103103
<ProjectReference Include="$(RepoRoot)src/Microsoft.Data.SqlClient/tests/Common/Microsoft.Data.SqlClient.TestCommon.csproj" />
104-
<ProjectReference Include="$(RepoRoot)src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UDTs/Address/Address.csproj" />
104+
<ProjectReference Include="$(RepoRoot)src/Microsoft.Data.SqlClient/tests/TestUdts/Address/Address.csproj" />
105105
<ProjectReference Include="$(RepoRoot)src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/Microsoft.Data.SqlClient.TestUtilities.csproj" />
106106
<ProjectReference Include="$(RepoRoot)src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS/TDS.csproj" />
107107
<ProjectReference Include="$(RepoRoot)src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.EndPoint/TDS.EndPoint.csproj" />

src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/AKVTests.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
namespace Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted
1414
{
15+
[Trait("Set", "AE")]
1516
public class AKVTest : IClassFixture<SQLSetupStrategyAzureKeyVault>
1617
{
1718
private readonly SQLSetupStrategyAzureKeyVault _fixture;
@@ -59,12 +60,12 @@ public void TestEncryptDecryptWithAKV()
5960
}
6061

6162
/*
62-
This unit test is going to assess an issue where a failed decryption leaves a connection in a bad state
63+
This unit test is going to assess an issue where a failed decryption leaves a connection in a bad state
6364
when it is returned to the connection pool. If a subsequent connection is retried it will result in an "Internal connection fatal error",
64-
which causes that connection to be doomed, preventing it from being returned to the pool.
65+
which causes that connection to be doomed, preventing it from being returned to the pool.
6566
Consequently, retrying a third connection will encounter the same decryption error, leading to a repetitive failure cycle.
6667
67-
The purpose of this unit test is to simulate a decryption error and verify that the connection remains usable when returned to the pool.
68+
The purpose of this unit test is to simulate a decryption error and verify that the connection remains usable when returned to the pool.
6869
It aims to confirm that three consecutive connections will consistently fail with the "Failed to decrypt column" error.
6970
*/
7071
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringSetupForAE), nameof(DataTestUtility.IsAKVSetupAvailable))]
@@ -100,10 +101,10 @@ public void ForcedColumnDecryptErrorTestShouldFail()
100101
// does not leave the connection in a bad state.
101102
// In each try, when a "Failed to decrypt error" is thrown, the connection's TDS Parser state object buffer is drained of any
102103
// pending data so it does not interfere with future operations. In addition, the TDS parser state object's reader.DataReady flag
103-
// is set to false so that the calling function that catches the exception will not continue to use the reader. Otherwise, it will
104+
// is set to false so that the calling function that catches the exception will not continue to use the reader. Otherwise, it will
104105
// timeout waiting to read data that doesn't exist. Also, the TDS Parser state object HasPendingData flag is also set to false
105106
// to indicate that the buffer has been cleared and to avoid it getting cleared again in SqlDataReader.TryCloseInternal function.
106-
// Finally, after successfully handling the decryption error, the connection is then returned back to the connection pool without
107+
// Finally, after successfully handling the decryption error, the connection is then returned back to the connection pool without
107108
// an error. A proof that the connection's state object is clean is in the second connection being able to throw the same error.
108109
// The third connection is for making sure we test 3 times as the minimum number of connections to reproduce the issue previously.
109110
for (int i = 0; i < 3; i++)
@@ -182,7 +183,7 @@ public void TestLocalCekCacheIsScopedToProvider()
182183
sqlDataReader2.Close();
183184

184185
// global cek cache and local cek cache are populated above
185-
// when using a new per-command provider, it will only use its local cek cache
186+
// when using a new per-command provider, it will only use its local cek cache
186187
// the following query should fail due to an empty cek cache and invalid credentials
187188
customProvider[SqlColumnEncryptionAzureKeyVaultProvider.ProviderName] =
188189
new SqlColumnEncryptionAzureKeyVaultProvider(new ClientSecretCredential("tenant", "client", "secret"));

src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/AKVUnitTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
namespace Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted
1414
{
15+
[Trait("Set", "AE")]
1516
public class AKVUnitTests : IClassFixture<AzureKeyVaultKeyFixture>
1617
{
1718
const string EncryptionAlgorithm = "RSA_OAEP";

src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/ApiShould.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

@@ -24,6 +24,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted
2424
/// <summary>
2525
/// Always Encrypted public API Manual tests.
2626
/// </summary>
27+
[Trait("Set", "AE")]
2728
// @TODO: These tests are known to not run reliably in DEBUG mode.
2829
[ConditionalClass(typeof(DataTestUtility), nameof(DataTestUtility.IsNotDebugBuild))]
2930
public sealed class ApiShould : IClassFixture<SQLSetupStrategyCertStoreProvider>, IDisposable

src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/BulkCopyAE.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted
1212
/// <summary>
1313
/// Always Encrypted public API Manual tests.
1414
/// </summary>
15+
[Trait("Set", "AE")]
1516
public sealed class BulkCopyAE : IClassFixture<SQLSetupStrategyCertStoreProvider>, IDisposable
1617
{
1718
private SQLSetupStrategy fixture;

src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/BulkCopyAEErrorMessage.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted
1111
/// <summary>
1212
/// Always Encrypted public API Manual tests.
1313
/// </summary>
14+
[Trait("Set", "AE")]
1415
public class BulkCopyAEErrorMessage : IClassFixture<SQLSetupStrategyCertStoreProvider>
1516
{
1617
private SQLSetupStrategy _fixture;

src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/ColumnDecryptErrorTests.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted
1212
{
13+
[Trait("Set", "AE")]
1314
public sealed class ColumnDecryptErrorTests : IClassFixture<SQLSetupStrategyAzureKeyVault>, IDisposable
1415
{
1516
private SQLSetupStrategyAzureKeyVault fixture;
@@ -28,13 +29,13 @@ public ColumnDecryptErrorTests(SQLSetupStrategyAzureKeyVault context)
2829
* properly reset before being returned to the pool. If this doesn't happen, then random bytes
2930
* may be left in the connection's state. These can interfere with the next operation that utilizes
3031
* the connection.
31-
*
32+
*
3233
* We test that state is properly reset by triggering the same error condition twice. Routing column key discovery
33-
* away from AKV toward a dummy key store achieves this. Each connection pulls from a pool of max
34-
* size one to ensure we are using the same internal connection/socket both times. We expect to
34+
* away from AKV toward a dummy key store achieves this. Each connection pulls from a pool of max
35+
* size one to ensure we are using the same internal connection/socket both times. We expect to
3536
* receive the "Failed to decrypt column" exception twice. If the state were not cleaned properly,
3637
* the second error would be different because the TDS stream would be unintelligible.
37-
*
38+
*
3839
* Finally, we assert that restoring the connection to AKV allows a successful query.
3940
*/
4041
[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.IsTargetReadyForAeWithKeyStore), nameof(DataTestUtility.IsAKVSetupAvailable))]
@@ -75,7 +76,7 @@ public void TestCleanConnectionAfterDecryptFail(string connString, string select
7576

7677
using SqlCommand sqlCommand = new SqlCommand(string.Format(selectQuery, tableName),
7778
sqlConnection, null, SqlCommandColumnEncryptionSetting.Enabled);
78-
79+
7980
using SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
8081

8182
Assert.True(sqlDataReader.HasRows, "FAILED: Select statement did not return any rows.");

src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/ConversionTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.using System;
44

@@ -18,6 +18,7 @@
1818

1919
namespace Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted
2020
{
21+
[Trait("Set", "AE")]
2122
public sealed class ConversionTests : IDisposable, IClassFixture<ColumnMasterKeyCertificateFixture>
2223
{
2324

@@ -621,7 +622,7 @@ private void AdjustSizePrecisionAndScale(ref ColumnMetaData largeColumnMeta, ref
621622

622623
if (TypeHasSize(largeColumnMeta.ColumnType))
623624
{
624-
// 20% of the time use (max) as the length.
625+
// 20% of the time use (max) as the length.
625626
largeColumnMeta.UseMax = (largeColumnMeta.ColumnType is SqlDbType.VarChar ||
626627
largeColumnMeta.ColumnType is SqlDbType.NVarChar ||
627628
largeColumnMeta.ColumnType is SqlDbType.VarBinary) &&
@@ -683,7 +684,7 @@ largeColumnMeta.ColumnType is SqlDbType.NVarChar ||
683684
{
684685
smallColumnMeta.Precision = 0;
685686

686-
// For Time / DateTime2 / DateTimeOffset types, actual scale is set to 7 when parameter.scale is zero.
687+
// For Time / DateTime2 / DateTimeOffset types, actual scale is set to 7 when parameter.scale is zero.
687688
// Active Issue in SQLParameter.cs when user wants to specify zero as the actual scale.
688689
smallColumnMeta.Scale = random.Next(minScale, largeColumnMeta.Scale);
689690
}

0 commit comments

Comments
 (0)