From 623c527ce3ab8265a15fcc730da441cdb79d290a Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Fri, 4 Jan 2019 15:42:30 -0800 Subject: [PATCH] Skipped the non-applicables tests against Azure Data Warehouse --- .../pdo_sqlsrv/MsCommon_mid-refactor.inc | 27 +++++++ .../pdo_sqlsrv/PDO81_MemoryCheck.phpt | 2 +- ...ment_bindParam_output_emulate_prepare.phpt | 1 + .../pdo_sqlsrv/pdo_574_next_rowset.phpt | 1 + .../pdo_azure_ad_authentication.phpt | 67 +++++++---------- .../pdo_sqlsrv/pdo_prepare_attribute.phpt | 1 + .../functional/pdo_sqlsrv/skipif_azure_dw.inc | 10 +++ test/functional/sqlsrv/0013.phpt | 2 +- test/functional/sqlsrv/0022.phpt | 2 +- test/functional/sqlsrv/53_0021.phpt | 2 +- test/functional/sqlsrv/MsCommon.inc | 22 ++++++ test/functional/sqlsrv/TC81_MemoryCheck.phpt | 4 +- .../sqlsrv/bugfix_dataCorruption.phpt | 2 +- test/functional/sqlsrv/fix_test_168256-2.phpt | 2 +- test/functional/sqlsrv/fix_test_168256.phpt | 2 +- test/functional/sqlsrv/fix_test_182741.phpt | 1 + test/functional/sqlsrv/skipif_azure_dw.inc | 12 +++ .../sqlsrv/sqlsrv_574_next_result.phpt | 1 + .../sqlsrv_azure_ad_authentication.phpt | 69 +++++++----------- .../functional/sqlsrv/sqlsrv_data_to_str.phpt | 2 +- test/functional/sqlsrv/sqlsrv_get_field.phpt | 2 +- test/functional/sqlsrv/sqlsrv_metadata.phpt | 2 +- test/functional/sqlsrv/sqlsrv_readStream.phpt | 2 +- .../sqlsrv/srv_223_sqlsrv_fetch_absolute.phpt | 3 +- .../sqlsrv/test_closeConnection.phpt | 2 +- test/functional/sqlsrv/test_fetch.phpt | 2 +- test/functional/sqlsrv/test_fetch2.phpt | 2 +- test/functional/sqlsrv/test_insert_null.phpt | 2 +- .../sqlsrv/test_insert_nullStr.phpt | Bin 2663 -> 2672 bytes test/functional/sqlsrv/test_largeData.phpt | 2 +- test/functional/sqlsrv/test_newError_msg.phpt | 2 +- .../sqlsrv/test_sqlsrv_phptype_stream.phpt | Bin 10374 -> 10383 bytes test/functional/sqlsrv/test_stream.phpt | 2 +- .../sqlsrv/test_warning_errors2.phpt | 2 +- 34 files changed, 149 insertions(+), 108 deletions(-) create mode 100644 test/functional/pdo_sqlsrv/skipif_azure_dw.inc create mode 100644 test/functional/sqlsrv/skipif_azure_dw.inc diff --git a/test/functional/pdo_sqlsrv/MsCommon_mid-refactor.inc b/test/functional/pdo_sqlsrv/MsCommon_mid-refactor.inc index cf2ff605c..d327d8599 100644 --- a/test/functional/pdo_sqlsrv/MsCommon_mid-refactor.inc +++ b/test/functional/pdo_sqlsrv/MsCommon_mid-refactor.inc @@ -624,6 +624,33 @@ function IsDaasMode() return ($daasMode ? true : false); } +function isAzureDW() +{ + // Check if running Azure Data Warehouse + // For details, https://docs.microsoft.com/sql/t-sql/functions/serverproperty-transact-sql + try { + $conn = connect(); + + // Check if running Azure Data Warehouse + // For details, https://docs.microsoft.com/sql/t-sql/functions/serverproperty-transact-sql + $tsql = "SELECT SERVERPROPERTY ('edition'), SERVERPROPERTY ('EngineEdition')"; + $stmt = $conn->query($tsql); + + $result = $stmt->fetch(PDO::FETCH_NUM); + $edition = $result[0]; + $engEd = intval($result[1]); + + if ($edition == "SQL Azure" && $engEd == 6) { + return true; + } else { + return false; + } + } catch (Exception $e) { + echo $e->getMessage(); + die("skip Failed to connect or could not fetch edition info."); + } +} + function FatalError($errorMsg) { if (!IsPdoMode()) { diff --git a/test/functional/pdo_sqlsrv/PDO81_MemoryCheck.phpt b/test/functional/pdo_sqlsrv/PDO81_MemoryCheck.phpt index 9fc7cd955..5513290b6 100644 --- a/test/functional/pdo_sqlsrv/PDO81_MemoryCheck.phpt +++ b/test/functional/pdo_sqlsrv/PDO81_MemoryCheck.phpt @@ -6,7 +6,7 @@ emalloc (which only allocate memory in the memory space allocated for the PHP pr --ENV-- PHPT_EXEC=true --SKIPIF-- - + --FILE-- + --FILE-- + --FILE-- getMessage() ); + print_r($e->getMessage()); echo "\n"; } -$stmt = $conn->query( "SELECT count(*) FROM cd_info" ); -if ( $stmt === false ) -{ +// For details, https://docs.microsoft.com/sql/t-sql/functions/serverproperty-transact-sql +$conn->setAttribute(PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE, true); +$stmt = $conn->query("SELECT SERVERPROPERTY('EngineEdition')"); +if ($stmt === false) { echo "Query failed.\n"; -} -else -{ - $result = $stmt->fetch(); - var_dump( $result ); +} else { + $result = $stmt->fetch(PDO::FETCH_NUM); + $edition = $result[0]; + var_dump($edition); } -$conn = null; +unset($conn); /////////////////////////////////////////////////////////////////////////////////////////// // Test Azure AD with integrated authentication. This should fail because @@ -43,16 +40,13 @@ $conn = null; // $connectionInfo = "Authentication = ActiveDirectoryIntegrated; TrustServerCertificate = true;"; -try -{ - $conn = new PDO( "sqlsrv:server = $server ; $connectionInfo" ); +try { + $conn = new PDO("sqlsrv:server = $server ; $connectionInfo"); echo "Connected successfully with Authentication=ActiveDirectoryIntegrated.\n"; - $conn = null; -} -catch( PDOException $e ) -{ + unset($conn); +} catch (PDOException $e) { echo "Could not connect with Authentication=ActiveDirectoryIntegrated.\n"; - print_r( $e->getMessage() ); + print_r($e->getMessage()); echo "\n"; } @@ -65,35 +59,24 @@ $azureDatabase = $adDatabase; $azureUsername = $adUser; $azurePassword = $adPassword; -if ($azureServer != 'TARGET_AD_SERVER') -{ +if ($azureServer != 'TARGET_AD_SERVER') { $connectionInfo = "Authentication = ActiveDirectoryPassword; TrustServerCertificate = false"; - try - { - $conn = new PDO( "sqlsrv:server = $azureServer ; $connectionInfo", $azureUsername, $azurePassword ); + try { + $conn = new PDO("sqlsrv:server = $azureServer ; $connectionInfo", $azureUsername, $azurePassword); echo "Connected successfully with Authentication=ActiveDirectoryPassword.\n"; - } - catch( PDOException $e ) - { + } catch (PDOException $e) { echo "Could not connect with ActiveDirectoryPassword.\n"; - print_r( $e->getMessage() ); + print_r($e->getMessage()); echo "\n"; } -} -else -{ +} else { echo "Not testing with Authentication=ActiveDirectoryPassword.\n"; } ?> --EXPECTF-- Connected successfully with Authentication=SqlPassword. -array(2) { - [""]=> - string(1) "7" - [0]=> - string(1) "7" -} +string(1) "%d" Could not connect with Authentication=ActiveDirectoryIntegrated. SQLSTATE[IMSSP]: Invalid option for the Authentication keyword. Only SqlPassword or ActiveDirectoryPassword is supported. %s with Authentication=ActiveDirectoryPassword. diff --git a/test/functional/pdo_sqlsrv/pdo_prepare_attribute.phpt b/test/functional/pdo_sqlsrv/pdo_prepare_attribute.phpt index d0da03e1d..01774f081 100644 --- a/test/functional/pdo_sqlsrv/pdo_prepare_attribute.phpt +++ b/test/functional/pdo_sqlsrv/pdo_prepare_attribute.phpt @@ -4,6 +4,7 @@ Test PDO::prepare() with PDO::ATTR_EMULATE_PREPARES. PHPT_EXEC=true --SKIPIF-- + --FILE-- \ No newline at end of file diff --git a/test/functional/sqlsrv/0013.phpt b/test/functional/sqlsrv/0013.phpt index cb2236dfd..6ccb46426 100644 --- a/test/functional/sqlsrv/0013.phpt +++ b/test/functional/sqlsrv/0013.phpt @@ -1,7 +1,7 @@ --TEST-- A test for a simple query --SKIPIF-- - + --FILE-- + --FILE-- + --FILE-- + + --FILE-- + --FILE-- + --FILE-- + --FILE-- + --FILE-- \ No newline at end of file diff --git a/test/functional/sqlsrv/sqlsrv_574_next_result.phpt b/test/functional/sqlsrv/sqlsrv_574_next_result.phpt index c21f71787..82cb4b4e9 100644 --- a/test/functional/sqlsrv/sqlsrv_574_next_result.phpt +++ b/test/functional/sqlsrv/sqlsrv_574_next_result.phpt @@ -6,6 +6,7 @@ Verifies the functionality of sqlsrv_next_result PHPT_EXEC=true --SKIPIF-- + --FILE-- $databaseName, "UID"=>$uid, "PWD"=>$pwd, "Authentication"=>'SqlPassword', "TrustServerCertificate"=>true); -$conn = sqlsrv_connect( $server, $connectionInfo ); +$conn = sqlsrv_connect($server, $connectionInfo); -if( $conn === false ) -{ +if ($conn === false) { echo "Could not connect with Authentication=SqlPassword.\n"; - var_dump( sqlsrv_errors() ); -} -else -{ + var_dump(sqlsrv_errors()); +} else { echo "Connected successfully with Authentication=SqlPassword.\n"; } -$stmt = sqlsrv_query( $conn, "SELECT count(*) FROM cd_info" ); -if ( $stmt === false ) -{ +// For details, https://docs.microsoft.com/sql/t-sql/functions/serverproperty-transact-sql +$stmt = sqlsrv_query($conn, "SELECT SERVERPROPERTY('EngineEdition')"); +if (sqlsrv_fetch($stmt)) { + $edition = sqlsrv_get_field($stmt, 0); + var_dump($edition); +} else { echo "Query failed.\n"; } -else -{ - $result = sqlsrv_fetch_array( $stmt ); - var_dump( $result ); -} -sqlsrv_free_stmt( $stmt ); -sqlsrv_close( $conn ); +sqlsrv_free_stmt($stmt); +sqlsrv_close($conn); /////////////////////////////////////////////////////////////////////////////////////////// // Test Azure AD with integrated authentication. This should fail because @@ -45,17 +40,14 @@ sqlsrv_close( $conn ); // $connectionInfo = array( "Authentication"=>"ActiveDirectoryIntegrated", "TrustServerCertificate"=>true ); -$conn = sqlsrv_connect( $server, $connectionInfo ); -if( $conn === false ) -{ +$conn = sqlsrv_connect($server, $connectionInfo); +if ($conn === false) { echo "Could not connect with Authentication=ActiveDirectoryIntegrated.\n"; $errors = sqlsrv_errors(); print_r($errors[0]); -} -else -{ +} else { echo "Connected successfully with Authentication=ActiveDirectoryIntegrated.\n"; - sqlsrv_close( $conn ); + sqlsrv_close($conn); } /////////////////////////////////////////////////////////////////////////////////////////// @@ -67,36 +59,25 @@ $azureDatabase = $adDatabase; $azureUsername = $adUser; $azurePassword = $adPassword; -if ($azureServer != 'TARGET_AD_SERVER') -{ - $connectionInfo = array( "UID"=>$azureUsername, "PWD"=>$azurePassword, +if ($azureServer != 'TARGET_AD_SERVER') { + $connectionInfo = array( "UID"=>$azureUsername, "PWD"=>$azurePassword, "Authentication"=>'ActiveDirectoryPassword', "TrustServerCertificate"=>false ); - $conn = sqlsrv_connect( $azureServer, $connectionInfo ); - if( $conn === false ) - { + $conn = sqlsrv_connect($azureServer, $connectionInfo); + if ($conn === false) { echo "Could not connect with ActiveDirectoryPassword.\n"; - print_r( sqlsrv_errors() ); - } - else - { + print_r(sqlsrv_errors()); + } else { echo "Connected successfully with Authentication=ActiveDirectoryPassword.\n"; - sqlsrv_close( $conn ); + sqlsrv_close($conn); } -} -else -{ +} else { echo "Not testing with Authentication=ActiveDirectoryPassword.\n"; } ?> --EXPECTF-- Connected successfully with Authentication=SqlPassword. -array(2) { - [0]=> - int(7) - [""]=> - int(7) -} +string(1) "%d" Could not connect with Authentication=ActiveDirectoryIntegrated. Array ( diff --git a/test/functional/sqlsrv/sqlsrv_data_to_str.phpt b/test/functional/sqlsrv/sqlsrv_data_to_str.phpt index 5f456108f..08f42b26b 100644 --- a/test/functional/sqlsrv/sqlsrv_data_to_str.phpt +++ b/test/functional/sqlsrv/sqlsrv_data_to_str.phpt @@ -1,7 +1,7 @@ --TEST-- large types to strings of 1MB size. --SKIPIF-- - + --FILE-- + --FILE-- + --FILE-- + --FILE-- SQLSRV_CURSOR_CLIENT_BUFFERED)); if ($stmt === false) { printErrors(); diff --git a/test/functional/sqlsrv/test_closeConnection.phpt b/test/functional/sqlsrv/test_closeConnection.phpt index 24c96e0d1..f796bf801 100644 --- a/test/functional/sqlsrv/test_closeConnection.phpt +++ b/test/functional/sqlsrv/test_closeConnection.phpt @@ -1,7 +1,7 @@ --TEST-- using an already closed connection. --SKIPIF-- - + --FILE-- + --FILE-- + --FILE-- + --FILE-- >c%`KE&v->1Rwwa diff --git a/test/functional/sqlsrv/test_largeData.phpt b/test/functional/sqlsrv/test_largeData.phpt index e282df2a7..4fa2d830a 100644 --- a/test/functional/sqlsrv/test_largeData.phpt +++ b/test/functional/sqlsrv/test_largeData.phpt @@ -1,7 +1,7 @@ --TEST-- send a large amount (10MB) using encryption. --SKIPIF-- - + --FILE-- + --FILE-- <^sa%^9CqRa%r9pHjZj+gbwvQ^5zj delta 10 RcmeAVYzv&=y)ndE0{|Em1N#5~ diff --git a/test/functional/sqlsrv/test_stream.phpt b/test/functional/sqlsrv/test_stream.phpt index 3836341de..dee4e72e9 100644 --- a/test/functional/sqlsrv/test_stream.phpt +++ b/test/functional/sqlsrv/test_stream.phpt @@ -14,7 +14,7 @@ Test for stream zombifying. fatalError("Failed to connect."); } - $stmt = sqlsrv_query($conn, "SELECT * FROM [test_streamable_types]"); + $stmt = sqlsrv_query($conn, "SELECT * FROM sys.objects"); $metadata = sqlsrv_field_metadata($stmt); $count = count($metadata); sqlsrv_fetch($stmt); diff --git a/test/functional/sqlsrv/test_warning_errors2.phpt b/test/functional/sqlsrv/test_warning_errors2.phpt index 4145565ac..15353ac6c 100644 --- a/test/functional/sqlsrv/test_warning_errors2.phpt +++ b/test/functional/sqlsrv/test_warning_errors2.phpt @@ -15,7 +15,7 @@ if( $conn === false ) { die( print_r( sqlsrv_errors(), true )); } -$stmt = sqlsrv_prepare( $conn, "SELECT * FROM [cd_info]"); +$stmt = sqlsrv_prepare( $conn, "SELECT * FROM sys.objects"); $result = sqlsrv_field_metadata( $stmt ); if( $result === false ) {