Add TNIR conn option and tests
This commit is contained in:
parent
45d87b7a96
commit
208cc4a078
|
@ -57,6 +57,7 @@ const char TraceFile[] = "TraceFile";
|
||||||
const char TraceOn[] = "TraceOn";
|
const char TraceOn[] = "TraceOn";
|
||||||
const char TrustServerCertificate[] = "TrustServerCertificate";
|
const char TrustServerCertificate[] = "TrustServerCertificate";
|
||||||
const char TransactionIsolation[] = "TransactionIsolation";
|
const char TransactionIsolation[] = "TransactionIsolation";
|
||||||
|
const char TransparentNetworkIPResolution[] = "TransparentNetworkIPResolution";
|
||||||
const char WSID[] = "WSID";
|
const char WSID[] = "WSID";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -338,6 +339,15 @@ const connection_option PDO_CONN_OPTS[] = {
|
||||||
CONN_ATTR_BOOL,
|
CONN_ATTR_BOOL,
|
||||||
pdo_bool_conn_str_func::func
|
pdo_bool_conn_str_func::func
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
PDOConnOptionNames::TransparentNetworkIPResolution,
|
||||||
|
sizeof(PDOConnOptionNames::TransparentNetworkIPResolution),
|
||||||
|
SQLSRV_CONN_OPTION_TRANSPARANT_NETWORK_IP_RESOLUTION,
|
||||||
|
ODBCConnOptions::TransparentNetworkIPResolution,
|
||||||
|
sizeof(ODBCConnOptions::TransparentNetworkIPResolution),
|
||||||
|
CONN_ATTR_STRING,
|
||||||
|
conn_str_append_func::func
|
||||||
|
},
|
||||||
{
|
{
|
||||||
PDOConnOptionNames::WSID,
|
PDOConnOptionNames::WSID,
|
||||||
sizeof( PDOConnOptionNames::WSID ),
|
sizeof( PDOConnOptionNames::WSID ),
|
||||||
|
|
|
@ -1100,6 +1100,7 @@ const char TraceFile[] = "TraceFile";
|
||||||
const char TraceOn[] = "TraceOn";
|
const char TraceOn[] = "TraceOn";
|
||||||
const char TrustServerCertificate[] = "TrustServerCertificate";
|
const char TrustServerCertificate[] = "TrustServerCertificate";
|
||||||
const char TransactionIsolation[] = "TransactionIsolation";
|
const char TransactionIsolation[] = "TransactionIsolation";
|
||||||
|
const char TransparentNetworkIPResolution[] = "TransparentNetworkIPResolution";
|
||||||
const char WSID[] = "WSID";
|
const char WSID[] = "WSID";
|
||||||
const char UID[] = "UID";
|
const char UID[] = "UID";
|
||||||
const char PWD[] = "PWD";
|
const char PWD[] = "PWD";
|
||||||
|
@ -1128,6 +1129,7 @@ enum SQLSRV_CONN_OPTIONS {
|
||||||
SQLSRV_CONN_OPTION_APPLICATION_INTENT,
|
SQLSRV_CONN_OPTION_APPLICATION_INTENT,
|
||||||
SQLSRV_CONN_OPTION_MULTI_SUBNET_FAILOVER,
|
SQLSRV_CONN_OPTION_MULTI_SUBNET_FAILOVER,
|
||||||
SQLSRV_CONN_OPTION_AUTHENTICATION,
|
SQLSRV_CONN_OPTION_AUTHENTICATION,
|
||||||
|
SQLSRV_CONN_OPTION_TRANSPARANT_NETWORK_IP_RESOLUTION,
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
SQLSRV_CONN_OPTION_CONN_RETRY_COUNT,
|
SQLSRV_CONN_OPTION_CONN_RETRY_COUNT,
|
||||||
SQLSRV_CONN_OPTION_CONN_RETRY_INTERVAL,
|
SQLSRV_CONN_OPTION_CONN_RETRY_INTERVAL,
|
||||||
|
|
|
@ -205,6 +205,7 @@ const char TraceFile[] = "TraceFile";
|
||||||
const char TraceOn[] = "TraceOn";
|
const char TraceOn[] = "TraceOn";
|
||||||
const char TrustServerCertificate[] = "TrustServerCertificate";
|
const char TrustServerCertificate[] = "TrustServerCertificate";
|
||||||
const char TransactionIsolation[] = "TransactionIsolation";
|
const char TransactionIsolation[] = "TransactionIsolation";
|
||||||
|
const char TransparentNetworkIPResolution[] = "TransparentNetworkIPResolution";
|
||||||
const char UID[] = "UID";
|
const char UID[] = "UID";
|
||||||
const char WSID[] = "WSID";
|
const char WSID[] = "WSID";
|
||||||
|
|
||||||
|
@ -420,6 +421,15 @@ const connection_option SS_CONN_OPTS[] = {
|
||||||
CONN_ATTR_BOOL,
|
CONN_ATTR_BOOL,
|
||||||
bool_conn_str_func::func
|
bool_conn_str_func::func
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
SSConnOptionNames::TransparentNetworkIPResolution,
|
||||||
|
sizeof(SSConnOptionNames::TransparentNetworkIPResolution),
|
||||||
|
SQLSRV_CONN_OPTION_TRANSPARANT_NETWORK_IP_RESOLUTION,
|
||||||
|
ODBCConnOptions::TransparentNetworkIPResolution,
|
||||||
|
sizeof(ODBCConnOptions::TransparentNetworkIPResolution),
|
||||||
|
CONN_ATTR_STRING,
|
||||||
|
conn_str_append_func::func
|
||||||
|
},
|
||||||
{
|
{
|
||||||
SSConnOptionNames::WSID,
|
SSConnOptionNames::WSID,
|
||||||
sizeof( SSConnOptionNames::WSID ),
|
sizeof( SSConnOptionNames::WSID ),
|
||||||
|
|
60
test/pdo_sqlsrv/pdo_TNIR.phpt
Normal file
60
test/pdo_sqlsrv/pdo_TNIR.phpt
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
--TEST--
|
||||||
|
Test the TNIR keyword with enabled and disabled options and the MultiSubnetFailover keyword with true and false options
|
||||||
|
--SKIPIF--
|
||||||
|
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
// The way SYN packets are sent from the host is different depending on the combination of the TNIR and MultiSubnetFailover values
|
||||||
|
// TNIR Enabled, MSF Disabled: One IP is attempted, followed by all IPs in parallel
|
||||||
|
// TNIR Enabled, MSF Enabled: All IPs are attempted in parallel
|
||||||
|
// TNIR Disabled, MSF Disabled: All IPs are attempted one after another
|
||||||
|
// TNIR Disabled, MSF Enabled: All IPs are attempted in parallel
|
||||||
|
// TNIR is enabled by default
|
||||||
|
// MultiSubnetFailover is disabled by default
|
||||||
|
|
||||||
|
require_once("MsSetup.inc");
|
||||||
|
$GLOBALS['uid'] = $uid;
|
||||||
|
$GLOBALS['pwd'] = $pwd;
|
||||||
|
$GLOBALS['server'] = $server;
|
||||||
|
|
||||||
|
function test_tnir( $TNIRValue, $MSFValue ) {
|
||||||
|
$MSFValueStr = ($MSFValue) ? 'true' : 'false';
|
||||||
|
$connectionString = "sqlsrv:Server=$GLOBALS[server]; TransparentNetworkIPResolution=$TNIRValue; MultiSubnetFailover=$MSFValueStr";
|
||||||
|
try {
|
||||||
|
$start = microtime(true);
|
||||||
|
$conn = new PDO($connectionString, $GLOBALS['uid'], $GLOBALS['pwd'], array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
|
||||||
|
echo "Connection successful with TNIR $TNIRValue and MultiSubnetFailover $MSFValueStr.\n";
|
||||||
|
$connect_time = round(microtime(true) - $start, 2);
|
||||||
|
echo "Time to connect is $connect_time sec.\n\n";
|
||||||
|
$conn = NULL;
|
||||||
|
}
|
||||||
|
catch(PDOException $e) {
|
||||||
|
echo "Connection failed with TNIR $TNIRValue and MultiSubnetFailover $MSFValueStr.\n";
|
||||||
|
print_r($e->errorInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
test_tnir("Enabled", false); // case temd (TNIR enabled; MultiSubnetFailover disabled)
|
||||||
|
test_tnir("Enabled", true); // case teme
|
||||||
|
test_tnir("Disabled", false); // case tdmd
|
||||||
|
test_tnir("Disabled", true); // case tdme
|
||||||
|
|
||||||
|
// Interpreting output
|
||||||
|
// If the first resolved IP address can be connected, then the time to connect for all these cases is similar
|
||||||
|
// else if the second resolved IP address can be connected, then temd ~= tdmd > teme ~= tdme
|
||||||
|
// else tdmd > temd > teme ~= tdme
|
||||||
|
// note: the first test takes a bit longer since time is needed for the DNS to resolve the IP addresses of the server host name
|
||||||
|
?>
|
||||||
|
|
||||||
|
--EXPECTREGEX--
|
||||||
|
Connection successful with TNIR Enabled and MultiSubnetFailover false\.
|
||||||
|
Time to connect is [0-9]+\.[0-9]+ sec\.
|
||||||
|
|
||||||
|
Connection successful with TNIR Enabled and MultiSubnetFailover true\.
|
||||||
|
Time to connect is [0-9]+\.[0-9]+ sec\.
|
||||||
|
|
||||||
|
Connection successful with TNIR Disabled and MultiSubnetFailover false\.
|
||||||
|
Time to connect is [0-9]+\.[0-9]+ sec\.
|
||||||
|
|
||||||
|
Connection successful with TNIR Disabled and MultiSubnetFailover true\.
|
||||||
|
Time to connect is [0-9]+\.[0-9]+ sec\.
|
60
test/sqlsrv/sqlsrv_TNIR.phpt
Normal file
60
test/sqlsrv/sqlsrv_TNIR.phpt
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
--TEST--
|
||||||
|
Test the TNIR keyword with enabled and disabled options and the MultiSubnetFailover keyword with true and false options
|
||||||
|
--SKIPIF--
|
||||||
|
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
// The way SYN packets are sent from the host is different depending on the combination of the TNIR and MultiSubnetFailover values
|
||||||
|
// TNIR Enabled, MSF Disabled: One IP is attempted, followed by all IPs in parallel
|
||||||
|
// TNIR Enabled, MSF Enabled: All IPs are attempted in parallel
|
||||||
|
// TNIR Disabled, MSF Disabled: All IPs are attempted one after another
|
||||||
|
// TNIR Disabled, MSF Enabled: All IPs are attempted in parallel
|
||||||
|
// TNIR is enabled by default
|
||||||
|
// MultiSubnetFailover is disabled by default
|
||||||
|
|
||||||
|
require_once("MsSetup.inc");
|
||||||
|
$GLOBALS['uid'] = $uid;
|
||||||
|
$GLOBALS['pwd'] = $pwd;
|
||||||
|
$GLOBALS['server'] = $server;
|
||||||
|
|
||||||
|
function test_tnir( $TNIRValue, $MSFValue ) {
|
||||||
|
$connectionInfo = ["UID" => $GLOBALS['uid'], "PWD" => $GLOBALS['pwd'], "TransparentNetworkIPResolution" => $TNIRValue, "MultiSubnetFailover" => $MSFValue];
|
||||||
|
$MSFValueStr = ($MSFValue) ? 'true' : 'false';
|
||||||
|
$start = microtime(true);
|
||||||
|
$conn = sqlsrv_connect($GLOBALS['server'], $connectionInfo);
|
||||||
|
if ($conn === false) {
|
||||||
|
echo "Connection failed with TNIR $TNIRValue and MultiSubnetFailover $MSFValueStr.\n";
|
||||||
|
print_r(sqlsrv_errors());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo "Connection successful with TNIR $TNIRValue and MultiSubnetFailover $MSFValueStr.\n";
|
||||||
|
$connect_time = round(microtime(true) - $start, 2);
|
||||||
|
echo "Time to connect is $connect_time sec.\n\n";
|
||||||
|
}
|
||||||
|
sqlsrv_close($conn);
|
||||||
|
}
|
||||||
|
|
||||||
|
test_tnir("Enabled", false); // case temd (TNIR enabled; MultiSubnetFailover disabled)
|
||||||
|
test_tnir("Enabled", true); // case teme
|
||||||
|
test_tnir("Disabled", false); // case tdmd
|
||||||
|
test_tnir("Disabled", true); // case tdme
|
||||||
|
|
||||||
|
// Interpreting output
|
||||||
|
// If the first resolved IP address can be connected, then the time to connect for all these cases is similar
|
||||||
|
// else if the second resolved IP address can be connected, then temd ~= tdmd > teme ~= tdme
|
||||||
|
// else tdmd > temd > teme ~= tdme
|
||||||
|
// note: the first test takes a bit longer since time is needed for the DNS to resolve the IP addresses of the server host name
|
||||||
|
?>
|
||||||
|
|
||||||
|
--EXPECTREGEX--
|
||||||
|
Connection successful with TNIR Enabled and MultiSubnetFailover false\.
|
||||||
|
Time to connect is [0-9]+\.[0-9]+ sec\.
|
||||||
|
|
||||||
|
Connection successful with TNIR Enabled and MultiSubnetFailover true\.
|
||||||
|
Time to connect is [0-9]+\.[0-9]+ sec\.
|
||||||
|
|
||||||
|
Connection successful with TNIR Disabled and MultiSubnetFailover false\.
|
||||||
|
Time to connect is [0-9]+\.[0-9]+ sec\.
|
||||||
|
|
||||||
|
Connection successful with TNIR Disabled and MultiSubnetFailover true\.
|
||||||
|
Time to connect is [0-9]+\.[0-9]+ sec\.
|
Loading…
Reference in a new issue