From e201c7fc064fc5a91383af50704a0d97d003da3f Mon Sep 17 00:00:00 2001 From: Johnny Pham Date: Wed, 25 Aug 2021 16:04:06 -0700 Subject: [PATCH 01/10] use makecert path from config.json if provided --- .../TestFixtures/Setup/CertificateUtilityWin.cs | 3 ++- .../tests/ManualTests/DataCommon/DataTestUtility.cs | 2 ++ .../tools/Microsoft.Data.SqlClient.TestUtilities/Config.cs | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/Setup/CertificateUtilityWin.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/Setup/CertificateUtilityWin.cs index 91a0b6e7fb..66d3c3588d 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/Setup/CertificateUtilityWin.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/Setup/CertificateUtilityWin.cs @@ -31,7 +31,8 @@ internal static void CreateCertificate(string certificateName, string certificat Assert.False(string.IsNullOrWhiteSpace(certificateName), "FAILED: certificateName should not be null or empty."); Assert.False(string.IsNullOrWhiteSpace(certificateLocation), "FAILED: certificateLocation should not be null or empty."); - ProcessStartInfo processStartInfo = new ProcessStartInfo(@"makecert"); + string makecertPath = string.IsNullOrEmpty(DataTestUtility.MakecertPath) ? "makecert" : DataTestUtility.MakecertPath; + ProcessStartInfo processStartInfo = new ProcessStartInfo(makecertPath); processStartInfo.Arguments = string.Format(@"-n ""CN={0}"" -pe -sr {1} -r -eku 1.3.6.1.5.5.8.2.2,1.3.6.1.4.1.311.10.3.11 -ss my -sky exchange -sp ""{2}"" -sy {3} -len 2048 -a sha256", certificateName, certificateLocation, diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs index 8ea16c9a83..20ce3c22a4 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs @@ -48,6 +48,7 @@ public static class DataTestUtility public static readonly bool UseManagedSNIOnWindows = false; public static readonly bool IsAzureSynapse = false; public static Uri AKVBaseUri = null; + public static readonly string MakecertPath= null; public static readonly string DNSCachingConnString = null; public static readonly string DNSCachingServerCR = null; // this is for the control ring @@ -97,6 +98,7 @@ static DataTestUtility() IsDNSCachingSupportedTR = c.IsDNSCachingSupportedTR; EnclaveAzureDatabaseConnString = c.EnclaveAzureDatabaseConnString; UserManagedIdentityClientId = c.UserManagedIdentityClientId; + MakecertPath = c.MakecertPath; System.Net.ServicePointManager.SecurityProtocol |= System.Net.SecurityProtocolType.Tls12; diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/Config.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/Config.cs index c5a3da8c3e..b56551ef1f 100644 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/Config.cs +++ b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/Config.cs @@ -37,6 +37,7 @@ public class Config public bool IsDNSCachingSupportedTR = false; // this is for the tenant ring public string EnclaveAzureDatabaseConnString = null; public string UserManagedIdentityClientId = null; + public string MakecertPath = null; public static Config Load(string configPath = @"config.json") { From 930228624fbadd270f31280fc0f932184595c5d6 Mon Sep 17 00:00:00 2001 From: Johnny Pham Date: Thu, 26 Aug 2021 16:11:13 -0700 Subject: [PATCH 02/10] use better random names in adapter test --- .../SQL/AdapterTest/AdapterTest.cs | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AdapterTest/AdapterTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AdapterTest/AdapterTest.cs index ae52a6efab..f9c8889d7f 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AdapterTest/AdapterTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AdapterTest/AdapterTest.cs @@ -54,10 +54,10 @@ public class AdapterTest public AdapterTest() { // create random name for temp tables - _randomGuid = Guid.NewGuid().ToString(); - _tempTable = Environment.MachineName + "_" + _randomGuid; + _tempTable = DataTestUtility.GetUniqueName("AdapterTest"); _tempTable = _tempTable.Replace('-', '_'); + _randomGuid = Guid.NewGuid().ToString(); _tempKey = "employee_id_key_" + Environment.TickCount.ToString() + _randomGuid; _tempKey = _tempKey.Replace('-', '_'); @@ -768,25 +768,27 @@ public void BulkUpdateTest() [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] public void UpdateRefreshTest() { + string identTableName = DataTestUtility.GetUniqueName("ID_"); string createIdentTable = - "CREATE TABLE ID_" + _tempTable + "(id int IDENTITY," + + $"CREATE TABLE {identTableName} (id int IDENTITY," + "LastName nvarchar(50) NULL," + "Firstname nvarchar(50) NULL)"; + string spName = DataTestUtility.GetUniqueName("sp_insert",withBracket:false); string spCreateInsert = - "CREATE PROCEDURE sp_insert" + _tempTable + + $"CREATE PROCEDURE {spName}" + "(@FirstName nvarchar(50), @LastName nvarchar(50), @id int OUTPUT) " + "AS INSERT INTO " + _tempTable + " (FirstName, LastName) " + "VALUES (@FirstName, @LastName); " + "SELECT @id=@@IDENTITY"; - string spDropInsert = "DROP PROCEDURE sp_insert" + _tempTable; + string spDropInsert = $"DROP PROCEDURE {spName}"; bool dropSP = false; using (SqlDataAdapter adapter = new SqlDataAdapter()) using (SqlConnection conn = new SqlConnection(DataTestUtility.TCPConnectionString)) using (SqlCommand cmd = new SqlCommand(null, conn)) - using (SqlCommand temp = new SqlCommand("SELECT id, LastName, FirstName into " + _tempTable + " from ID_" + _tempTable, conn)) + using (SqlCommand temp = new SqlCommand("SELECT id, LastName, FirstName into " + _tempTable + $" from {identTableName}", conn)) using (SqlCommand tableClean = new SqlCommand("", conn)) { ExecuteNonQueryCommand(createIdentTable); @@ -794,7 +796,7 @@ public void UpdateRefreshTest() { adapter.InsertCommand = new SqlCommand() { - CommandText = "sp_insert" + _tempTable, + CommandText = spName, CommandType = CommandType.StoredProcedure }; adapter.InsertCommand.Parameters.Add(new SqlParameter("@FirstName", SqlDbType.NVarChar, 50, "FirstName")); @@ -853,7 +855,7 @@ public void UpdateRefreshTest() { ExecuteNonQueryCommand(spDropInsert); ExecuteNonQueryCommand("DROP TABLE " + _tempTable); - ExecuteNonQueryCommand("DROP TABLE ID_" + _tempTable); + ExecuteNonQueryCommand("DROP TABLE " + identTableName); } } } @@ -1078,15 +1080,16 @@ public void AutoGenUpdateTest() [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] public void AutoGenErrorTest() { + string identTableName = DataTestUtility.GetUniqueName("ID_"); string createIdentTable = - "CREATE TABLE ID_" + _tempTable + "(id int IDENTITY," + + $"CREATE TABLE {identTableName} (id int IDENTITY," + "LastName nvarchar(50) NULL," + "Firstname nvarchar(50) NULL)"; try { using (SqlConnection conn = new SqlConnection(DataTestUtility.TCPConnectionString)) - using (SqlCommand cmd = new SqlCommand("SELECT * into " + _tempTable + " from ID_" + _tempTable, conn)) + using (SqlCommand cmd = new SqlCommand($"SELECT * into {_tempTable} from {identTableName}", conn)) using (SqlDataAdapter adapter = new SqlDataAdapter()) { ExecuteNonQueryCommand(createIdentTable); @@ -1114,7 +1117,7 @@ public void AutoGenErrorTest() finally { ExecuteNonQueryCommand("DROP TABLE " + _tempTable); - ExecuteNonQueryCommand("DROP TABLE ID_" + _tempTable); + ExecuteNonQueryCommand("DROP TABLE " + identTableName); } } From 57ccf3043619525ffd56ee15ef056926bddcdaba Mon Sep 17 00:00:00 2001 From: Johnny Pham Date: Fri, 10 Sep 2021 10:36:24 -0700 Subject: [PATCH 03/10] Update Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.csproj --- ...t.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.csproj b/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.csproj index 1a20433f34..72b48df81b 100644 --- a/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.csproj +++ b/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.csproj @@ -20,6 +20,7 @@ + From ec2e797fa9c81053757b2b1f406f54a2ebb64bb2 Mon Sep 17 00:00:00 2001 From: Johnny Pham Date: Fri, 10 Sep 2021 13:40:24 -0700 Subject: [PATCH 04/10] akv nuspec --- ...a.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.csproj | 1 - ...a.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.nuspec | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.csproj b/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.csproj index 72b48df81b..1a20433f34 100644 --- a/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.csproj +++ b/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.csproj @@ -20,7 +20,6 @@ - diff --git a/tools/specs/add-ons/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.nuspec b/tools/specs/add-ons/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.nuspec index e52a11072f..159bc717cc 100644 --- a/tools/specs/add-ons/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.nuspec +++ b/tools/specs/add-ons/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.nuspec @@ -25,21 +25,21 @@ Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyStoreProvider.SqlColumnEncrypti sqlclient microsoft.data.sqlclient azurekeyvaultprovider akvprovider alwaysencrypted - + - + - + From 9153d3cf83898c1376dc2de778b7580edfb61c68 Mon Sep 17 00:00:00 2001 From: Johnny Pham Date: Fri, 10 Sep 2021 13:50:43 -0700 Subject: [PATCH 05/10] Update Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.nuspec --- ...a.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.nuspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/specs/add-ons/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.nuspec b/tools/specs/add-ons/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.nuspec index 159bc717cc..e52a11072f 100644 --- a/tools/specs/add-ons/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.nuspec +++ b/tools/specs/add-ons/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.nuspec @@ -25,21 +25,21 @@ Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyStoreProvider.SqlColumnEncrypti sqlclient microsoft.data.sqlclient azurekeyvaultprovider akvprovider alwaysencrypted - + - + - + From 05d8dabcc5e0981bbf2bafe27a8bbc168da99bc6 Mon Sep 17 00:00:00 2001 From: Johnny Pham Date: Tue, 21 Sep 2021 14:30:08 -0700 Subject: [PATCH 06/10] Update DataTestUtility.cs --- .../tests/ManualTests/DataCommon/DataTestUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs index ef1f2d2f7b..e6ff0a3bf6 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs @@ -48,7 +48,7 @@ public static class DataTestUtility public static readonly bool UseManagedSNIOnWindows = false; public static readonly bool IsAzureSynapse = false; public static Uri AKVBaseUri = null; - public static readonly string MakecertPath= null; + public static readonly string MakecertPath = null; public static string FileStreamDirectory = null; public static readonly string DNSCachingConnString = null; From 0e1d699eb5d7d70e84b2e282feb522ee22d96e25 Mon Sep 17 00:00:00 2001 From: Johnny Pham Date: Tue, 21 Sep 2021 16:50:50 -0700 Subject: [PATCH 07/10] add makecert property to update config.default.json and buildguide.md --- BUILDGUIDE.md | 1 + .../Microsoft.Data.SqlClient.TestUtilities/config.default.json | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/BUILDGUIDE.md b/BUILDGUIDE.md index cdd98d85a5..a4a0c77588 100644 --- a/BUILDGUIDE.md +++ b/BUILDGUIDE.md @@ -123,6 +123,7 @@ Manual Tests require the below setup to run: |FileStreamDirectory | (Optional) If File Stream is enabled on SQL Server, pass local directory path to be used for setting up File Stream enabled database. | `D:\\escaped\\absolute\\path\\to\\directory\\` | |UseManagedSNIOnWindows | (Optional) Enables testing with Managed SNI on Windows| `true` OR `false`| |IsAzureSynpase | (Optional) When set to 'true', test suite runs compatible tests for Azure Synapse/Parallel Data Warehouse. | `true` OR `false`| + |MakecertPath | The location of makercert.exe. This is not required if the path is present in the PATH environment variable. | Location of makecert.exe on machine | ### Commands to run Manual Tests: diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/config.default.json b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/config.default.json index 69bacdc3f9..043b73c4c9 100644 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/config.default.json +++ b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/config.default.json @@ -26,5 +26,6 @@ "IsDNSCachingSupportedTR": false, "IsAzureSynapse": false, "EnclaveAzureDatabaseConnString": "", - "UserManagedIdentityClientId": "" + "UserManagedIdentityClientId": "", + "MakecertPath": "" } From 569dd5a3dc7b7cc3f18ca0e92a8241bf8275fbe2 Mon Sep 17 00:00:00 2001 From: Johnny Pham Date: Wed, 22 Sep 2021 10:39:10 -0700 Subject: [PATCH 08/10] typo --- BUILDGUIDE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILDGUIDE.md b/BUILDGUIDE.md index a4a0c77588..4b39d83dc8 100644 --- a/BUILDGUIDE.md +++ b/BUILDGUIDE.md @@ -123,7 +123,7 @@ Manual Tests require the below setup to run: |FileStreamDirectory | (Optional) If File Stream is enabled on SQL Server, pass local directory path to be used for setting up File Stream enabled database. | `D:\\escaped\\absolute\\path\\to\\directory\\` | |UseManagedSNIOnWindows | (Optional) Enables testing with Managed SNI on Windows| `true` OR `false`| |IsAzureSynpase | (Optional) When set to 'true', test suite runs compatible tests for Azure Synapse/Parallel Data Warehouse. | `true` OR `false`| - |MakecertPath | The location of makercert.exe. This is not required if the path is present in the PATH environment variable. | Location of makecert.exe on machine | + |MakecertPath | The location of makecert.exe. This is not required if the path is present in the PATH environment variable. | Location of makecert.exe on machine | ### Commands to run Manual Tests: From 4fae7b37af503d169327bfe55c75f669576c785a Mon Sep 17 00:00:00 2001 From: Johnny Pham Date: Mon, 27 Sep 2021 12:20:36 -0700 Subject: [PATCH 09/10] use DataTestUtility methods to drop database objects --- .../SQL/AdapterTest/AdapterTest.cs | 120 +++++++++--------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AdapterTest/AdapterTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AdapterTest/AdapterTest.cs index f9c8889d7f..104a657133 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AdapterTest/AdapterTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AdapterTest/AdapterTest.cs @@ -179,15 +179,15 @@ public void PrepUnprepTest() public void SqlVariantTest() { string tableName = DataTestUtility.GenerateObjectName(); - try + // good test for null values and unicode strings + using (SqlConnection conn = new SqlConnection(DataTestUtility.TCPConnectionString)) + using (SqlCommand cmd = new SqlCommand(null, conn)) + using (SqlDataAdapter sqlAdapter = new SqlDataAdapter()) { - ExecuteNonQueryCommand("CREATE TABLE " + tableName + " (c0_bigint bigint, c1_variant sql_variant)"); - - // good test for null values and unicode strings - using (SqlConnection conn = new SqlConnection(DataTestUtility.TCPConnectionString)) - using (SqlCommand cmd = new SqlCommand(null, conn)) - using (SqlDataAdapter sqlAdapter = new SqlDataAdapter()) + try { + ExecuteNonQueryCommand("CREATE TABLE " + tableName + " (c0_bigint bigint, c1_variant sql_variant)"); + cmd.Connection.Open(); // the ORDER BY clause tests that we correctly ignore the ORDER token @@ -263,10 +263,10 @@ public void SqlVariantTest() } } } - } - finally - { - ExecuteNonQueryCommand("DROP TABLE " + tableName); + finally + { + DataTestUtility.DropTable(conn, tableName); + } } } @@ -659,7 +659,7 @@ public void UpdateTest() } finally { - ExecuteNonQueryCommand("DROP TABLE " + _tempTable); + DataTestUtility.DropTable(conn, _tempTable); } } } @@ -757,7 +757,7 @@ public void BulkUpdateTest() } finally { - ExecuteNonQueryCommand("DROP TABLE " + _tempTable); + DataTestUtility.DropTable(conn, _tempTable); } } } @@ -774,7 +774,7 @@ public void UpdateRefreshTest() "LastName nvarchar(50) NULL," + "Firstname nvarchar(50) NULL)"; - string spName = DataTestUtility.GetUniqueName("sp_insert",withBracket:false); + string spName = DataTestUtility.GetUniqueName("sp_insert", withBracket: false); string spCreateInsert = $"CREATE PROCEDURE {spName}" + "(@FirstName nvarchar(50), @LastName nvarchar(50), @id int OUTPUT) " + @@ -853,9 +853,9 @@ public void UpdateRefreshTest() { if (dropSP) { - ExecuteNonQueryCommand(spDropInsert); - ExecuteNonQueryCommand("DROP TABLE " + _tempTable); - ExecuteNonQueryCommand("DROP TABLE " + identTableName); + DataTestUtility.DropStoredProcedure(conn, spName); + DataTestUtility.DropTable(conn, _tempTable); + DataTestUtility.DropTable(conn, identTableName); } } } @@ -875,18 +875,18 @@ public void UpdateNullTest() "VALUES (@val_cvarbin, @val_cimage)"; bool dropSP = false; - try - { - ExecuteNonQueryCommand(createTable); - ExecuteNonQueryCommand(createSP); - dropSP = true; - using (SqlConnection conn = new SqlConnection(DataTestUtility.TCPConnectionString)) - using (SqlCommand cmdInsert = new SqlCommand(procName, conn)) - using (SqlCommand cmdSelect = new SqlCommand("select * from " + tableName, conn)) - using (SqlCommand tableClean = new SqlCommand("delete " + tableName, conn)) - using (SqlDataAdapter adapter = new SqlDataAdapter()) + using (SqlConnection conn = new SqlConnection(DataTestUtility.TCPConnectionString)) + using (SqlCommand cmdInsert = new SqlCommand(procName, conn)) + using (SqlCommand cmdSelect = new SqlCommand("select * from " + tableName, conn)) + using (SqlCommand tableClean = new SqlCommand("delete " + tableName, conn)) + using (SqlDataAdapter adapter = new SqlDataAdapter()) + { + try { + ExecuteNonQueryCommand(createTable); + ExecuteNonQueryCommand(createSP); + dropSP = true; conn.Open(); cmdInsert.CommandType = CommandType.StoredProcedure; @@ -907,13 +907,13 @@ public void UpdateNullTest() DataTestUtility.AssertEqualsWithDescription(DBNull.Value, ds.Tables[0].Rows[0][0], "Unexpected value."); DataTestUtility.AssertEqualsWithDescription(DBNull.Value, ds.Tables[0].Rows[0][1], "Unexpected value."); } - } - finally - { - if (dropSP) + finally { - ExecuteNonQueryCommand("DROP PROCEDURE " + procName); - ExecuteNonQueryCommand("DROP TABLE " + tableName); + if (dropSP) + { + DataTestUtility.DropStoredProcedure(conn, procName); + DataTestUtility.DropTable(conn, tableName); + } } } } @@ -932,18 +932,18 @@ public void UpdateOffsetTest() "VALUES (@val_cvarbin, @val_cimage)"; bool dropSP = false; - try - { - ExecuteNonQueryCommand(createTable); - ExecuteNonQueryCommand(createSP); - dropSP = true; - using (SqlConnection conn = new SqlConnection(DataTestUtility.TCPConnectionString)) - using (SqlCommand cmdInsert = new SqlCommand(procName, conn)) - using (SqlCommand cmdSelect = new SqlCommand("select * from " + tableName, conn)) - using (SqlCommand tableClean = new SqlCommand("delete " + tableName, conn)) - using (SqlDataAdapter adapter = new SqlDataAdapter()) + using (SqlConnection conn = new SqlConnection(DataTestUtility.TCPConnectionString)) + using (SqlCommand cmdInsert = new SqlCommand(procName, conn)) + using (SqlCommand cmdSelect = new SqlCommand("select * from " + tableName, conn)) + using (SqlCommand tableClean = new SqlCommand("delete " + tableName, conn)) + using (SqlDataAdapter adapter = new SqlDataAdapter()) + { + try { + ExecuteNonQueryCommand(createTable); + ExecuteNonQueryCommand(createSP); + dropSP = true; conn.Open(); cmdInsert.CommandType = CommandType.StoredProcedure; @@ -980,13 +980,13 @@ public void UpdateOffsetTest() val = (byte[])(ds.Tables[0].Rows[0][1]); Assert.True(ByteArraysEqual(expectedBytes2, val), "FAILED: Test 2: Unequal byte arrays."); } - } - finally - { - if (dropSP) + finally { - ExecuteNonQueryCommand("DROP PROCEDURE " + procName); - ExecuteNonQueryCommand("DROP TABLE " + tableName); + if (dropSP) + { + DataTestUtility.DropStoredProcedure(conn, procName); + DataTestUtility.DropTable(conn, tableName); + } } } } @@ -1071,7 +1071,7 @@ public void AutoGenUpdateTest() } finally { - ExecuteNonQueryCommand("DROP TABLE " + _tempTable); + DataTestUtility.DropTable(conn, _tempTable); } } } @@ -1086,11 +1086,11 @@ public void AutoGenErrorTest() "LastName nvarchar(50) NULL," + "Firstname nvarchar(50) NULL)"; - try + using (SqlConnection conn = new SqlConnection(DataTestUtility.TCPConnectionString)) + using (SqlCommand cmd = new SqlCommand($"SELECT * into {_tempTable} from {identTableName}", conn)) + using (SqlDataAdapter adapter = new SqlDataAdapter()) { - using (SqlConnection conn = new SqlConnection(DataTestUtility.TCPConnectionString)) - using (SqlCommand cmd = new SqlCommand($"SELECT * into {_tempTable} from {identTableName}", conn)) - using (SqlDataAdapter adapter = new SqlDataAdapter()) + try { ExecuteNonQueryCommand(createIdentTable); @@ -1113,11 +1113,11 @@ public void AutoGenErrorTest() SqlCommandBuilder builder = new SqlCommandBuilder(adapter); adapter.Update(ds, _tempTable); } - } - finally - { - ExecuteNonQueryCommand("DROP TABLE " + _tempTable); - ExecuteNonQueryCommand("DROP TABLE " + identTableName); + finally + { + DataTestUtility.DropTable(conn, _tempTable); + DataTestUtility.DropTable(conn, identTableName); + } } } @@ -1209,7 +1209,7 @@ public void AutoGenBulkUpdateTest() } finally { - ExecuteNonQueryCommand("DROP TABLE " + _tempTable); + DataTestUtility.DropTable(conn, _tempTable); } } } From fc6fd86e07598b675ce6b2d75c18b1fb6cc55a77 Mon Sep 17 00:00:00 2001 From: Johnny Pham Date: Mon, 27 Sep 2021 13:42:17 -0700 Subject: [PATCH 10/10] Update BUILDGUIDE.md --- BUILDGUIDE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILDGUIDE.md b/BUILDGUIDE.md index 4b39d83dc8..9d17a6f5f5 100644 --- a/BUILDGUIDE.md +++ b/BUILDGUIDE.md @@ -123,7 +123,7 @@ Manual Tests require the below setup to run: |FileStreamDirectory | (Optional) If File Stream is enabled on SQL Server, pass local directory path to be used for setting up File Stream enabled database. | `D:\\escaped\\absolute\\path\\to\\directory\\` | |UseManagedSNIOnWindows | (Optional) Enables testing with Managed SNI on Windows| `true` OR `false`| |IsAzureSynpase | (Optional) When set to 'true', test suite runs compatible tests for Azure Synapse/Parallel Data Warehouse. | `true` OR `false`| - |MakecertPath | The location of makecert.exe. This is not required if the path is present in the PATH environment variable. | Location of makecert.exe on machine | + |MakecertPath | The full path to makecert.exe. This is not required if the path is present in the PATH environment variable. | `D:\\escaped\\absolute\\path\\to\\makecert.exe` | ### Commands to run Manual Tests: