From 907e8c8e5cc89f77ea6097f96bad251b08f8b11d Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Wed, 31 Jan 2018 08:27:06 -0800 Subject: [PATCH 1/2] Modified tests and setup to run AE tests in Azure --- test/functional/pdo_sqlsrv/MsCommon.inc | 14 +++++++++++--- .../pdo_sqlsrv/MsCommon_mid-refactor.inc | 12 ++++++++++-- test/functional/setup/ae_keys.sql | 3 --- test/functional/setup/setup_dbs.py | 7 ++++--- test/functional/sqlsrv/MsHelper.inc | 6 ++++++ 5 files changed, 31 insertions(+), 11 deletions(-) diff --git a/test/functional/pdo_sqlsrv/MsCommon.inc b/test/functional/pdo_sqlsrv/MsCommon.inc index 89f6c8ee..cddfdab9 100644 --- a/test/functional/pdo_sqlsrv/MsCommon.inc +++ b/test/functional/pdo_sqlsrv/MsCommon.inc @@ -16,10 +16,18 @@ function IsAEQualified($conn) { $msodbcsql_ver = $conn->getAttribute(PDO::ATTR_CLIENT_VERSION)["DriverVer"]; - $server_ver = $conn->getAttribute(PDO::ATTR_SERVER_VERSION); $msodbcsql_maj = explode(".", $msodbcsql_ver)[0]; - $msodbcsql_min = explode(".", $msodbcsql_ver)[1]; - if ($msodbcsql_maj < 17 || explode('.', $server_ver)[0] < 13) + if ($msodbcsql_maj < 17) { + return false; + } + require 'MsSetup.inc'; + if ($daasMode) { + // running against Azure + return true; + } + // if not Azure, check the server version + $server_ver = $conn->getAttribute(PDO::ATTR_SERVER_VERSION); + if (explode('.', $server_ver)[0] < 13) return false; return true; } diff --git a/test/functional/pdo_sqlsrv/MsCommon_mid-refactor.inc b/test/functional/pdo_sqlsrv/MsCommon_mid-refactor.inc index 7384f2a5..3a16bd27 100644 --- a/test/functional/pdo_sqlsrv/MsCommon_mid-refactor.inc +++ b/test/functional/pdo_sqlsrv/MsCommon_mid-refactor.inc @@ -20,11 +20,19 @@ const KSP_TEST_TABLE = 'CustomKSPTestTable'; function isAEQualified($conn) { $msodbcsql_ver = $conn->getAttribute(PDO::ATTR_CLIENT_VERSION)["DriverVer"]; - $server_ver = $conn->getAttribute(PDO::ATTR_SERVER_VERSION); $msodbcsql_maj = explode(".", $msodbcsql_ver)[0]; - if ($msodbcsql_maj < 17 || explode('.', $server_ver)[0] < 13) { + if ($msodbcsql_maj < 17) { return false; } + require 'MsSetup.inc'; + if ($daasMode) { + // running against Azure + return true; + } + // if not Azure, check the server version + $server_ver = $conn->getAttribute(PDO::ATTR_SERVER_VERSION); + if (explode('.', $server_ver)[0] < 13) + return false; return true; } diff --git a/test/functional/setup/ae_keys.sql b/test/functional/setup/ae_keys.sql index aa4b9d78..35c87720 100644 --- a/test/functional/setup/ae_keys.sql +++ b/test/functional/setup/ae_keys.sql @@ -1,6 +1,3 @@ -USE $(dbname) -GO - /* DROP Column Encryption Key first, Column Master Key cannot be dropped until no encryption depends on it */ IF EXISTS (SELECT * FROM sys.column_encryption_keys WHERE [name] LIKE '%AEColumnKey%') diff --git a/test/functional/setup/setup_dbs.py b/test/functional/setup/setup_dbs.py index 3c8fb404..c73b0e9e 100644 --- a/test/functional/setup/setup_dbs.py +++ b/test/functional/setup/setup_dbs.py @@ -45,13 +45,14 @@ def executeBulkCopy(conn_options, dbname, tblname, datafile): inst_command = redirect_string.format(dbname, tblname, datafile) + conn_options executeCommmand(inst_command) -def setupAE( conn_options, dbname, azure ): - if (platform.system() == 'Windows' and azure.lower() == 'no'): +def setupAE(conn_options, dbname): + if (platform.system() == 'Windows'): # import self signed certificate inst_command = "certutil -user -p '' -importPFX My PHPcert.pfx NoRoot" executeCommmand(inst_command) # create Column Master Key and Column Encryption Key - executeSQLscript('ae_keys.sql', conn_options, dbname) + script_command = 'sqlcmd ' + conn_options + ' -i ae_keys.sql -d ' + dbname + executeCommmand(script_command) if __name__ == '__main__': parser = argparse.ArgumentParser() diff --git a/test/functional/sqlsrv/MsHelper.inc b/test/functional/sqlsrv/MsHelper.inc index f7cecd4d..7d69bbff 100644 --- a/test/functional/sqlsrv/MsHelper.inc +++ b/test/functional/sqlsrv/MsHelper.inc @@ -353,6 +353,12 @@ function isQualified($conn) if (explode(".", $msodbcsql_ver)[0] < 17) { return false; } + global $daasMode; + if ($daasMode) { + // running against Azure + return true; + } + // if not Azure, check the server version $server_ver = sqlsrv_server_info($conn)['SQLServerVersion']; if (explode('.', $server_ver)[0] < 13) { return false; From ac47841be94a81d626a17e17c6b66a1a12e1f383 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Wed, 31 Jan 2018 08:42:45 -0800 Subject: [PATCH 2/2] Removed one argument --- test/functional/setup/setup_dbs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/setup/setup_dbs.py b/test/functional/setup/setup_dbs.py index c73b0e9e..32b821ef 100644 --- a/test/functional/setup/setup_dbs.py +++ b/test/functional/setup/setup_dbs.py @@ -85,7 +85,7 @@ if __name__ == '__main__': # populate these tables populateTables(conn_options, args.DBNAME) # setup AE (certificate, column master key and column encryption key) - setupAE(conn_options, args.DBNAME, args.AZURE) + setupAE(conn_options, args.DBNAME) os.chdir(current_working_dir)