Fixed skipifs and output

This commit is contained in:
David Puglielli 2018-07-11 16:27:03 -07:00
parent 82be8141a3
commit 0495513c07
12 changed files with 76 additions and 41 deletions

View file

@ -48,7 +48,7 @@ function connect($keywords = '', $options=array(), $errmode = PDO::ERRMODE_EXCEP
// simply use $databaseName from MsSetup.inc to facilitate testing in Azure, // simply use $databaseName from MsSetup.inc to facilitate testing in Azure,
// which does not support switching databases // which does not support switching databases
require("MsSetup.inc"); require("MsSetup.inc");
$dsn = getDSN($server, $databaseName, $driver, $keywords, $disableCE); $dsn = getDSN($server, $databaseName, $DriverName, $keywords, $disableCE);
$conn = new PDO($dsn, $uid, $pwd, $options); $conn = new PDO($dsn, $uid, $pwd, $options);
if ($errmode == PDO::ERRMODE_EXCEPTION || $errmode == PDO::ERRMODE_WARNING || $errmode == PDO::ERRMODE_SILENT) { if ($errmode == PDO::ERRMODE_EXCEPTION || $errmode == PDO::ERRMODE_WARNING || $errmode == PDO::ERRMODE_SILENT) {
$conn->setAttribute(PDO::ATTR_ERRMODE, $errmode); $conn->setAttribute(PDO::ATTR_ERRMODE, $errmode);

View file

@ -2,7 +2,6 @@
Test the Authentication keyword and three options: SqlPassword, ActiveDirectoryIntegrated, and ActiveDirectoryPassword. Test the Authentication keyword and three options: SqlPassword, ActiveDirectoryIntegrated, and ActiveDirectoryPassword.
--SKIPIF-- --SKIPIF--
<?php require('skipif.inc'); <?php require('skipif.inc');
require('skipif_unix.phpt');
require('skipif_version_less_than_2k16.inc'); ?> require('skipif_version_less_than_2k16.inc'); ?>
--FILE-- --FILE--
<?php <?php

View file

@ -7,8 +7,7 @@ killing the connection and then not freeing it. The latter case is the only one
that should fail. Finally, execute two queries in two threads on a recovered that should fail. Finally, execute two queries in two threads on a recovered
non-MARS connection. This should fail too. non-MARS connection. This should fail too.
--SKIPIF-- --SKIPIF--
<?php require('skipif_mid-refactor.inc'); <?php require('skipif_protocol_not_tcp.inc');
require('skipif_protocol_not_tcp.inc');
require('skipif_version_less_than_2k14.inc'); ?> require('skipif_version_less_than_2k14.inc'); ?>
--FILE-- --FILE--
<?php <?php

View file

@ -1,8 +1,7 @@
--TEST-- --TEST--
Test the connection resiliency keywords ConnectRetryCount and ConnectRetryInterval and their ranges of acceptable values Test the connection resiliency keywords ConnectRetryCount and ConnectRetryInterval and their ranges of acceptable values
--SKIPIF-- --SKIPIF--
<?php require('skipif_mid-refactor.inc'); <?php require('skipif_version_less_than_2k14.inc'); ?>
require('skipif_version_less_than_2k14.inc'); ?>
--FILE-- --FILE--
<?php <?php
require_once( "MsSetup.inc" ); require_once( "MsSetup.inc" );

View file

@ -5,8 +5,7 @@ Prepare a statement, break the connection, and execute the statement. Then
test transactions by breaking the connection before beginning a transaction test transactions by breaking the connection before beginning a transaction
and in the middle of the transaction. The latter case should fail. and in the middle of the transaction. The latter case should fail.
--SKIPIF-- --SKIPIF--
<?php require('skipif_mid-refactor.inc'); <?php require('skipif_protocol_not_tcp.inc');
require('skipif_protocol_not_tcp.inc');
require('skipif_version_less_than_2k14.inc'); ?> require('skipif_version_less_than_2k14.inc'); ?>
--FILE-- --FILE--
<?php <?php

View file

@ -4,8 +4,7 @@ Test connection resiliency timeouts
1. Connect with ConnectRetryCount equal to 0. 1. Connect with ConnectRetryCount equal to 0.
2. Reconnect with the default value of ConnectRetryCount(1). 2. Reconnect with the default value of ConnectRetryCount(1).
--SKIPIF-- --SKIPIF--
<?php require('skipif_mid-refactor.inc'); <?php require('skipif_protocol_not_tcp.inc');
require('skipif_protocol_not_tcp.inc');
require('skipif_version_less_than_2k14.inc'); ?> require('skipif_version_less_than_2k14.inc'); ?>
--FILE-- --FILE--
<?php <?php
@ -85,5 +84,5 @@ DropTables( $server, $uid, $pwd, $tableName1, $tableName2 );
?> ?>
--EXPECTREGEX-- --EXPECTREGEX--
Error executing statement 1\. Error executing statement 1\.
SQLSTATE\[08S02\]: \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]TCP Provider: [An existing connection was forcibly closed by the remote host\.|Error code 0x20] SQLSTATE\[08S02\]: \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]TCP Provider: (An existing connection was forcibly closed by the remote host\.|Error code 0x20)
Query successfully executed\. Query successfully executed\.

View file

@ -1,8 +1,14 @@
<?php <?php
// For connection resiliency, must check that
// 1. Either running Windows, or ODBC driver 17.2 or greater on unix
// 2. Either SQL Server version is 2014 or greater, or using Azure
if (!extension_loaded("pdo_sqlsrv")) { if (!extension_loaded("pdo_sqlsrv")) {
die("skip Extension not loaded"); die("skip Extension not loaded");
} }
$is_win = ( strtoupper( substr( php_uname( 's' ),0,3 ) ) === 'WIN' );
require_once( "MsSetup.inc" ); require_once( "MsSetup.inc" );
$conn = new PDO( "sqlsrv:server = $server ;", $uid, $pwd ); $conn = new PDO( "sqlsrv:server = $server ;", $uid, $pwd );
@ -10,6 +16,16 @@ if ($conn === false) {
die( "skip Could not connect during SKIPIF." ); die( "skip Could not connect during SKIPIF." );
} }
$msodbcsql_ver = $conn->getAttribute(PDO::ATTR_CLIENT_VERSION)["DriverVer"];
$msodbcsql_maj = explode(".", $msodbcsql_ver)[0];
$msodbcsql_min = explode(".", $msodbcsql_ver)[1];
if (!$is_win) {
if ($msodbcsql_maj < 17 or $msodbcslq_min < 2) {
die("skip Unsupported ODBC driver version");
}
}
// Get SQL Server Version // Get SQL Server Version
// Exclude this check if running on Azure // Exclude this check if running on Azure
if (!$daasMode) { if (!$daasMode) {

View file

@ -11,16 +11,19 @@ if ($conn === false) {
} }
// Get SQL Server Version // Get SQL Server Version
$stmt = $conn->query( "SELECT @@VERSION" ); // Exclude this check if running on Azure
if ($stmt) { if (!$daasMode) {
$ver_string = $stmt->fetch(PDO::FETCH_NUM)[0]; $stmt = $conn->query( "SELECT @@VERSION" );
} else { if ($stmt) {
die( "skip Could not fetch SQL Server version during SKIPIF."); $ver_string = $stmt->fetch(PDO::FETCH_NUM)[0];
} } else {
die( "skip Could not fetch SQL Server version during SKIPIF.");
}
$version = explode(' ', $ver_string); $version = explode(' ', $ver_string);
if ($version[3] < '2016') { if ($version[3] < '2016') {
die("skip Wrong version of SQL Server, 2016 or later required"); die("skip Wrong version of SQL Server, 2016 or later required");
}
} }
?> ?>

View file

@ -189,8 +189,8 @@ Array
\[SQLSTATE\] => 08S02 \[SQLSTATE\] => 08S02
\[1\] => (10054|-1) \[1\] => (10054|-1)
\[code\] => (10054|-1) \[code\] => (10054|-1)
\[2\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\](TCP Provider: An existing connection was forcibly closed by the remote host\.\n|SMux Provider: Physical connection is not usable \[xFFFFFFFF\])\. \[2\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\](TCP Provider: An existing connection was forcibly closed by the remote host\.\n|SMux Provider: Physical connection is not usable \[xFFFFFFFF\]\. )
\[message\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\](TCP Provider: An existing connection was forcibly closed by the remote host\.\n|SMux Provider: Physical connection is not usable \[xFFFFFFFF\])\. \[message\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\](TCP Provider: An existing connection was forcibly closed by the remote host\.\n|SMux Provider: Physical connection is not usable \[xFFFFFFFF\]\. )
\) \)
\[1\] => Array \[1\] => Array

View file

@ -1,8 +1,14 @@
<?php <?php
// For connection resiliency, must check that
// 1. Either SQL Server version is 2014 or greater, or using Azure;
// 2. Either running Windows, or ODBC driver 17.2 or greater on unix
if (!extension_loaded("sqlsrv")) { if (!extension_loaded("sqlsrv")) {
die("skip Extension not loaded"); die("skip Extension not loaded");
} }
$is_win = ( strtoupper( substr( php_uname( 's' ),0,3 ) ) === 'WIN' );
require_once( "MsSetup.inc" ); require_once( "MsSetup.inc" );
$connectionInfo = array( "UID"=>$userName, "PWD"=>$userPassword ); $connectionInfo = array( "UID"=>$userName, "PWD"=>$userPassword );
@ -12,17 +18,30 @@ if ($conn === false) {
die( "skip Could not connect during SKIPIF." ); die( "skip Could not connect during SKIPIF." );
} }
// Get SQL Server version $msodbcsql_ver = sqlsrv_client_info($conn)["DriverVer"];
$stmt = sqlsrv_query( $conn, "SELECT @@VERSION" ); $msodbcsql_maj = explode(".", $msodbcsql_ver)[0];
if (sqlsrv_fetch($stmt)) { $msodbcsql_min = explode(".", $msodbcsql_ver)[1];
$ver_string = sqlsrv_get_field( $stmt, 0 );
} else { if (!$is_win) {
die("skip Could not fetch SQL Server version."); if ($msodbcsql_maj < 17 or $msodbcslq_min < 2) {
die("skip Unsupported ODBC driver version");
}
} }
$version = explode(' ', $ver_string); // Get SQL Server version
// Exclude this check if running on Azure
if (!$daasMode) {
$stmt = sqlsrv_query( $conn, "SELECT @@VERSION" );
if (sqlsrv_fetch($stmt)) {
$ver_string = sqlsrv_get_field( $stmt, 0 );
} else {
die("skip Could not fetch SQL Server version.");
}
if ($version[3] < '2014') { $version = explode(' ', $ver_string);
die("skip Wrong version of SQL Server, 2014 or later required");
if ($version[3] < '2014') {
die("skip Wrong version of SQL Server, 2014 or later required");
}
} }
?> ?>

View file

@ -13,16 +13,19 @@ if ($conn === false) {
} }
// Get SQL Server version // Get SQL Server version
$stmt = sqlsrv_query( $conn, "SELECT @@VERSION" ); // Exclude this check if running on Azure
if (sqlsrv_fetch($stmt)) { if (!$daasMode) {
$ver_string = sqlsrv_get_field( $stmt, 0 ); $stmt = sqlsrv_query( $conn, "SELECT @@VERSION" );
} else { if (sqlsrv_fetch($stmt)) {
die("skip Could not fetch SQL Server version."); $ver_string = sqlsrv_get_field( $stmt, 0 );
} } else {
die("skip Could not fetch SQL Server version.");
}
$version = explode(' ', $ver_string); $version = explode(' ', $ver_string);
if ($version[3] < '2016') { if ($version[3] < '2016') {
die("skip Wrong version of SQL Server, 2016 or later required"); die("skip Wrong version of SQL Server, 2016 or later required");
}
} }
?> ?>

View file

@ -2,7 +2,6 @@
Test the Authentication keyword and three options: SqlPassword, ActiveDirectoryIntegrated, and ActiveDirectoryPassword. Test the Authentication keyword and three options: SqlPassword, ActiveDirectoryIntegrated, and ActiveDirectoryPassword.
--SKIPIF-- --SKIPIF--
<?php require('skipif.inc'); <?php require('skipif.inc');
require('skipif_unix.inc');
require('skipif_version_less_than_2k16.inc'); ?> require('skipif_version_less_than_2k16.inc'); ?>
--FILE-- --FILE--
<?php <?php