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,
// which does not support switching databases
require("MsSetup.inc");
$dsn = getDSN($server, $databaseName, $driver, $keywords, $disableCE);
$dsn = getDSN($server, $databaseName, $DriverName, $keywords, $disableCE);
$conn = new PDO($dsn, $uid, $pwd, $options);
if ($errmode == PDO::ERRMODE_EXCEPTION || $errmode == PDO::ERRMODE_WARNING || $errmode == PDO::ERRMODE_SILENT) {
$conn->setAttribute(PDO::ATTR_ERRMODE, $errmode);

View file

@ -2,7 +2,6 @@
Test the Authentication keyword and three options: SqlPassword, ActiveDirectoryIntegrated, and ActiveDirectoryPassword.
--SKIPIF--
<?php require('skipif.inc');
require('skipif_unix.phpt');
require('skipif_version_less_than_2k16.inc'); ?>
--FILE--
<?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
non-MARS connection. This should fail too.
--SKIPIF--
<?php require('skipif_mid-refactor.inc');
require('skipif_protocol_not_tcp.inc');
<?php require('skipif_protocol_not_tcp.inc');
require('skipif_version_less_than_2k14.inc'); ?>
--FILE--
<?php

View file

@ -1,8 +1,7 @@
--TEST--
Test the connection resiliency keywords ConnectRetryCount and ConnectRetryInterval and their ranges of acceptable values
--SKIPIF--
<?php require('skipif_mid-refactor.inc');
require('skipif_version_less_than_2k14.inc'); ?>
<?php require('skipif_version_less_than_2k14.inc'); ?>
--FILE--
<?php
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
and in the middle of the transaction. The latter case should fail.
--SKIPIF--
<?php require('skipif_mid-refactor.inc');
require('skipif_protocol_not_tcp.inc');
<?php require('skipif_protocol_not_tcp.inc');
require('skipif_version_less_than_2k14.inc'); ?>
--FILE--
<?php

View file

@ -4,8 +4,7 @@ Test connection resiliency timeouts
1. Connect with ConnectRetryCount equal to 0.
2. Reconnect with the default value of ConnectRetryCount(1).
--SKIPIF--
<?php require('skipif_mid-refactor.inc');
require('skipif_protocol_not_tcp.inc');
<?php require('skipif_protocol_not_tcp.inc');
require('skipif_version_less_than_2k14.inc'); ?>
--FILE--
<?php
@ -85,5 +84,5 @@ DropTables( $server, $uid, $pwd, $tableName1, $tableName2 );
?>
--EXPECTREGEX--
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\.

View file

@ -1,8 +1,14 @@
<?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")) {
die("skip Extension not loaded");
}
$is_win = ( strtoupper( substr( php_uname( 's' ),0,3 ) ) === 'WIN' );
require_once( "MsSetup.inc" );
$conn = new PDO( "sqlsrv:server = $server ;", $uid, $pwd );
@ -10,6 +16,16 @@ if ($conn === false) {
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
// Exclude this check if running on Azure
if (!$daasMode) {

View file

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

View file

@ -189,8 +189,8 @@ Array
\[SQLSTATE\] => 08S02
\[1\] => (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\])\.
\[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\])\.
\[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\]\. )
\)
\[1\] => Array

View file

@ -1,8 +1,14 @@
<?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")) {
die("skip Extension not loaded");
}
$is_win = ( strtoupper( substr( php_uname( 's' ),0,3 ) ) === 'WIN' );
require_once( "MsSetup.inc" );
$connectionInfo = array( "UID"=>$userName, "PWD"=>$userPassword );
@ -12,17 +18,30 @@ if ($conn === false) {
die( "skip Could not connect during SKIPIF." );
}
// Get SQL Server version
$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.");
$msodbcsql_ver = sqlsrv_client_info($conn)["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");
}
}
$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') {
die("skip Wrong version of SQL Server, 2014 or later required");
$version = explode(' ', $ver_string);
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
$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.");
}
// 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.");
}
$version = explode(' ', $ver_string);
$version = explode(' ', $ver_string);
if ($version[3] < '2016') {
die("skip Wrong version of SQL Server, 2016 or later required");
if ($version[3] < '2016') {
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.
--SKIPIF--
<?php require('skipif.inc');
require('skipif_unix.inc');
require('skipif_version_less_than_2k16.inc'); ?>
--FILE--
<?php