Skip to content

Commit 361189c

Browse files
committed
User Story 38467: Backport mac server name fix
- Adding console diagnostics to slow enclave tests.
1 parent 2001824 commit 361189c

File tree

1 file changed

+40
-12
lines changed

1 file changed

+40
-12
lines changed

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

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Runtime.CompilerServices;
34
using System.Security.Cryptography.X509Certificates;
5+
using System.Text;
46
using Xunit;
57

68
namespace Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted
@@ -11,13 +13,39 @@ public class TestTrustedMasterKeyPaths : IClassFixture<SQLSetupStrategyCertStore
1113
private readonly string tableName;
1214
private readonly string columnMasterKeyPath;
1315

16+
private static void Log(
17+
string message,
18+
[CallerMemberName] string who = "")
19+
{
20+
StringBuilder builder = new();
21+
builder.Append(DateTime.UtcNow.ToString("HH:mm:ss.fff"));
22+
builder.Append(' ');
23+
builder.Append(nameof(TestTrustedMasterKeyPaths));
24+
builder.Append('.');
25+
builder.Append(who);
26+
builder.Append("(): ");
27+
builder.Append(message);
28+
Console.WriteLine(builder.ToString());
29+
}
30+
31+
private static void LogStart(
32+
[CallerMemberName] string who = "")
33+
{
34+
Log("Start", who);
35+
}
36+
private static void LogEnd(
37+
[CallerMemberName] string who = "")
38+
{
39+
Log("End", who);
40+
}
41+
1442
public TestTrustedMasterKeyPaths(SQLSetupStrategyCertStoreProvider fixture)
1543
{
16-
Console.WriteLine("Start: TestTrustedMasterKeyPaths()");
44+
LogStart();
1745
columnMasterKeyPath = string.Format(@"{0}/{1}/{2}", StoreLocation.CurrentUser.ToString(), @"my", CertificateUtility.CreateCertificate().Thumbprint);
1846
this.fixture = fixture;
1947
tableName = fixture.TrustedMasterKeyPathsTestTable.Name;
20-
Console.WriteLine("End: TestTrustedMasterKeyPaths()");
48+
LogEnd();
2149
}
2250

2351
/// <summary>
@@ -26,7 +54,7 @@ public TestTrustedMasterKeyPaths(SQLSetupStrategyCertStoreProvider fixture)
2654
/// <param name="sqlDataReader"></param>
2755
private void ValidateResultSet(SqlDataReader sqlDataReader)
2856
{
29-
Console.WriteLine("Start: ValidateResultSet()");
57+
LogStart();
3058
// Validate the result set
3159
int rowsFound = 0;
3260
while (sqlDataReader.Read())
@@ -45,15 +73,15 @@ private void ValidateResultSet(SqlDataReader sqlDataReader)
4573
rowsFound++;
4674
}
4775
Assert.True(rowsFound == 1, "Incorrect number of rows returned in first execution.");
48-
Console.WriteLine("End: ValidateResultSet()");
76+
LogEnd();
4977
}
5078

5179
[PlatformSpecific(TestPlatforms.Windows)]
5280
[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringSetupForAE))]
5381
[ClassData(typeof(AEConnectionStringProvider))]
5482
public void TestTrustedColumnEncryptionMasterKeyPathsWithNullDictionary(string connection)
5583
{
56-
Console.WriteLine($"Start: TestTrustedColumnEncryptionMasterKeyPathsWithNullDictionary(); connection string: {connection}");
84+
LogStart();
5785
SqlConnectionStringBuilder connBuilder = new SqlConnectionStringBuilder(connection);
5886
connBuilder.ConnectTimeout = 10000;
5987
string connStringNow = connBuilder.ToString();
@@ -86,15 +114,15 @@ FROM [{tableName}]
86114
}
87115
// Clear out trusted key paths
88116
SqlConnection.ColumnEncryptionTrustedMasterKeyPaths.Clear();
89-
Console.WriteLine("End: TestTrustedColumnEncryptionMasterKeyPathsWithNullDictionary()");
117+
LogEnd();
90118
}
91119

92120
[PlatformSpecific(TestPlatforms.Windows)]
93121
[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringSetupForAE))]
94122
[ClassData(typeof(AEConnectionStringProvider))]
95123
public void TestTrustedColumnEncryptionMasterKeyPathsWithOneServer(string connection)
96124
{
97-
Console.WriteLine($"Start: TestTrustedColumnEncryptionMasterKeyPathsWithOneServer(); connection string: {connection}");
125+
LogStart();
98126
SqlConnectionStringBuilder connBuilder = new SqlConnectionStringBuilder(connection);
99127
connBuilder.ConnectTimeout = 10000;
100128
string connStringNow = connBuilder.ToString();
@@ -134,15 +162,15 @@ FROM [{tableName}]
134162
}
135163
// Clear out trusted key paths
136164
SqlConnection.ColumnEncryptionTrustedMasterKeyPaths.Clear();
137-
Console.WriteLine("End: TestTrustedColumnEncryptionMasterKeyPathsWithOneServer()");
165+
LogEnd();
138166
}
139167

140168
[PlatformSpecific(TestPlatforms.Windows)]
141169
[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringSetupForAE))]
142170
[ClassData(typeof(AEConnectionStringProvider))]
143171
public void TestTrustedColumnEncryptionMasterKeyPathsWithMultipleServers(string connection)
144172
{
145-
Console.WriteLine($"Start: TestTrustedColumnEncryptionMasterKeyPathsWithMultipleServers(); connection string: {connection}");
173+
LogStart();
146174
SqlConnectionStringBuilder connBuilder = new SqlConnectionStringBuilder(connection);
147175
connBuilder.ConnectTimeout = 10000;
148176
string connStringNow = connBuilder.ToString();
@@ -199,15 +227,15 @@ FROM [{tableName}]
199227
}
200228
// Clear out trusted key paths
201229
SqlConnection.ColumnEncryptionTrustedMasterKeyPaths.Clear();
202-
Console.WriteLine("End: TestTrustedColumnEncryptionMasterKeyPathsWithMultipleServers()");
230+
LogEnd();
203231
}
204232

205233
[PlatformSpecific(TestPlatforms.Windows)]
206234
[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringSetupForAE))]
207235
[ClassData(typeof(AEConnectionStringProvider))]
208236
public void TestTrustedColumnEncryptionMasterKeyPathsWithInvalidInputs(string connection)
209237
{
210-
Console.WriteLine($"Start: TestTrustedColumnEncryptionMasterKeyPathsWithInvalidInputs(); connection string: {connection}");
238+
LogStart();
211239
SqlConnectionStringBuilder connBuilder = new SqlConnectionStringBuilder(connection);
212240
connBuilder.ConnectTimeout = 10000;
213241
string connStringNow = connBuilder.ToString();
@@ -314,7 +342,7 @@ FROM [{tableName}]
314342

315343
// Clear out trusted key paths
316344
SqlConnection.ColumnEncryptionTrustedMasterKeyPaths.Clear();
317-
Console.WriteLine("End: TestTrustedColumnEncryptionMasterKeyPathsWithInvalidInputs()");
345+
LogEnd();
318346
}
319347
}
320348
}

0 commit comments

Comments
 (0)