Skip to content

Commit

Permalink
Skipped the non-applicables tests against Azure Data Warehouse
Browse files Browse the repository at this point in the history
  • Loading branch information
yitam committed Jan 4, 2019
1 parent 5801edd commit 623c527
Show file tree
Hide file tree
Showing 34 changed files with 149 additions and 108 deletions.
27 changes: 27 additions & 0 deletions test/functional/pdo_sqlsrv/MsCommon_mid-refactor.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion test/functional/pdo_sqlsrv/PDO81_MemoryCheck.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ emalloc (which only allocate memory in the memory space allocated for the PHP pr
--ENV--
PHPT_EXEC=true
--SKIPIF--
<?php require('skipif_azure.inc'); ?>
<?php require('skipif_azure_dw.inc'); ?>
--FILE--
<?php
include 'MsCommon.inc';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Tests error returned when binding output parameter with emulate prepare
--SKIPIF--
<?php require_once('skipif_mid-refactor.inc'); ?>
<?php require('skipif_azure_dw.inc'); ?>
--FILE--
<?php
require_once("MsCommon_mid-refactor.inc");
Expand Down
1 change: 1 addition & 0 deletions test/functional/pdo_sqlsrv/pdo_574_next_rowset.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Verifies the functionality of PDOStatement nextRowset
PHPT_EXEC=true
--SKIPIF--
<?php require('skipif_mid-refactor.inc'); ?>
<?php require('skipif_azure_dw.inc'); ?>
--FILE--
<?php

Expand Down
67 changes: 25 additions & 42 deletions test/functional/pdo_sqlsrv/pdo_azure_ad_authentication.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,41 @@ require_once("MsSetup.inc");
//
$connectionInfo = "Database = $databaseName; Authentication = SqlPassword; TrustServerCertificate = true;";

try
{
$conn = new PDO( "sqlsrv:server = $server ; $connectionInfo", $uid, $pwd );
try {
$conn = new PDO("sqlsrv:server = $server ; $connectionInfo", $uid, $pwd);
echo "Connected successfully with Authentication=SqlPassword.\n";
}
catch( PDOException $e )
{
} catch (PDOException $e) {
echo "Could not connect with Authentication=SqlPassword.\n";
print_r( $e->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
// we don't support it.
//
$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";
}

Expand All @@ -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.
1 change: 1 addition & 0 deletions test/functional/pdo_sqlsrv/pdo_prepare_attribute.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Test PDO::prepare() with PDO::ATTR_EMULATE_PREPARES.
PHPT_EXEC=true
--SKIPIF--
<?php require_once('skipif_mid-refactor.inc'); ?>
<?php require('skipif_azure_dw.inc'); ?>
--FILE--
<?php

Expand Down
10 changes: 10 additions & 0 deletions test/functional/pdo_sqlsrv/skipif_azure_dw.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
if (!extension_loaded("pdo_sqlsrv")) {
die("skip Extension not loaded");
}

require_once('MsCommon_mid-refactor.inc');
if (isAzureDW()) {
die("skip test not applicable in Azure Data Warehouse\n");
}
?>
2 changes: 1 addition & 1 deletion test/functional/sqlsrv/0013.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
A test for a simple query
--SKIPIF--
<?php require('skipif.inc'); ?>
<?php require('skipif_azure_dw.inc'); ?>
--FILE--
<?php
sqlsrv_configure('WarningsReturnAsErrors', 0);
Expand Down
2 changes: 1 addition & 1 deletion test/functional/sqlsrv/0022.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
zombied streams after sqlsrv_stmt_cancel.
--SKIPIF--
<?php require('skipif.inc'); ?>
<?php require('skipif_azure_dw.inc'); ?>
--FILE--
<?php
sqlsrv_configure( 'WarningsReturnAsErrors', 0 );
Expand Down
2 changes: 1 addition & 1 deletion test/functional/sqlsrv/53_0021.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Test for integer, float, and datetime types vs various sql server types.
--SKIPIF--
<?php require('skipif.inc'); ?>
<?php require('skipif_azure_dw.inc'); ?>
--FILE--
<?php

Expand Down
22 changes: 22 additions & 0 deletions test/functional/sqlsrv/MsCommon.inc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,28 @@ 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
$conn = connect();
$tsql = "SELECT SERVERPROPERTY ('edition'), SERVERPROPERTY ('EngineEdition')";
$stmt = sqlsrv_query($conn, $tsql);

if (sqlsrv_fetch($stmt)) {
$edition = sqlsrv_get_field($stmt, 0);
$engEd = sqlsrv_get_field($stmt, 1, SQLSRV_PHPTYPE_INT);

if ($edition == "SQL Azure" && $engEd == 6) {
return true;
} else {
return false;
}
} else {
die("Could not fetch edition info.");
}
}

function startTest($testName)
{
if (traceMode()) {
Expand Down
4 changes: 2 additions & 2 deletions test/functional/sqlsrv/TC81_MemoryCheck.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ emalloc (which only allocate memory in the memory space allocated for the PHP pr
--ENV--
PHPT_EXEC=true
--SKIPIF--
<?php require('skipif_azure.inc');
require('skipif_versions_old.inc'); ?>
<?php require('skipif_versions_old.inc'); ?>
<?php require('skipif_azure.inc'); ?>
--FILE--
<?php
require_once('MsCommon.inc');
Expand Down
2 changes: 1 addition & 1 deletion test/functional/sqlsrv/bugfix_dataCorruption.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
data corruption fix.
--SKIPIF--
<?php require('skipif.inc'); ?>
<?php require('skipif_azure_dw.inc'); ?>
--FILE--
<?php
sqlsrv_configure( 'WarningsReturnAsErrors', 0 );
Expand Down
2 changes: 1 addition & 1 deletion test/functional/sqlsrv/fix_test_168256-2.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Fix for 168256.
--SKIPIF--
<?php require('skipif.inc'); ?>
<?php require('skipif_azure_dw.inc'); ?>
--FILE--
<?php
sqlsrv_configure('WarningsReturnAsErrors', 0);
Expand Down
2 changes: 1 addition & 1 deletion test/functional/sqlsrv/fix_test_168256.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Fix for 168256.
--SKIPIF--
<?php require('skipif.inc'); ?>
<?php require('skipif_azure_dw.inc'); ?>
--FILE--
<?php
sqlsrv_configure('WarningsReturnAsErrors', 0);
Expand Down
1 change: 1 addition & 0 deletions test/functional/sqlsrv/fix_test_182741.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
fix for 182741.
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
<?php require('skipif_azure_dw.inc'); ?>
--FILE--
<?php
sqlsrv_configure('WarningsReturnAsErrors', 0);
Expand Down
12 changes: 12 additions & 0 deletions test/functional/sqlsrv/skipif_azure_dw.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

if (!extension_loaded("sqlsrv")) {
die("skip extension not loaded");
}

require_once('MsCommon.inc');
if (isAzureDW()) {
die("skip test not applicable in Azure Data Warehouse\n");
}

?>
1 change: 1 addition & 0 deletions test/functional/sqlsrv/sqlsrv_574_next_result.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Verifies the functionality of sqlsrv_next_result
PHPT_EXEC=true
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
<?php require('skipif_azure_dw.inc'); ?>
--FILE--
<?php

Expand Down
Loading

0 comments on commit 623c527

Please sign in to comment.