2017-03-31 03:45:27 +03:00
|
|
|
--TEST--
|
|
|
|
SQLSRV Connection Pooling Test on Unix
|
2017-04-01 03:41:38 +03:00
|
|
|
--DESCRIPTION--
|
2017-07-12 20:57:43 +03:00
|
|
|
This test assumes the default odbcinst.ini has not been modified.
|
2017-03-31 03:45:27 +03:00
|
|
|
--SKIPIF--
|
2017-06-03 02:00:57 +03:00
|
|
|
<?php if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') die("Skipped: Test for Linux and Mac"); ?>
|
2017-03-31 03:45:27 +03:00
|
|
|
--FILE--
|
|
|
|
<?php
|
2018-07-21 03:24:48 +03:00
|
|
|
function findODBCDriver($content, $lines_to_add)
|
|
|
|
{
|
|
|
|
require_once('MsSetup.inc');
|
|
|
|
$command = "odbcinst -q -d -n '$driver'";
|
|
|
|
$info = shell_exec($command);
|
|
|
|
|
|
|
|
return str_replace($info, $info.$lines_to_add, $content);
|
|
|
|
}
|
|
|
|
|
2017-03-31 03:45:27 +03:00
|
|
|
$lines_to_add="CPTimeout=5\n[ODBC]\nPooling=Yes\n";
|
|
|
|
|
2017-07-12 20:57:43 +03:00
|
|
|
//get default odbcinst.ini location
|
2017-03-31 03:45:27 +03:00
|
|
|
$lines = explode("\n", shell_exec("odbcinst -j"));
|
|
|
|
$odbcinst_ini = explode(" ", $lines[1])[1];
|
2017-07-12 20:57:43 +03:00
|
|
|
$custom_odbcinst_ini = dirname(__FILE__)."/odbcinst.ini";
|
2017-03-31 03:45:27 +03:00
|
|
|
|
2017-07-12 20:57:43 +03:00
|
|
|
//copy the default odbcinst.ini into the current folder
|
|
|
|
copy( $odbcinst_ini, $custom_odbcinst_ini);
|
2017-05-31 01:24:56 +03:00
|
|
|
|
2017-03-31 03:45:27 +03:00
|
|
|
//enable pooling by modifying the odbcinst.ini file
|
2017-07-12 20:57:43 +03:00
|
|
|
$current = file_get_contents($custom_odbcinst_ini);
|
2018-07-21 03:24:48 +03:00
|
|
|
$new_content = findODBCDriver($current, $lines_to_add);
|
|
|
|
file_put_contents($custom_odbcinst_ini, $new_content);
|
2017-03-31 03:45:27 +03:00
|
|
|
|
|
|
|
//Creating a new php process, because for changes in odbcinst.ini file to affect pooling, drivers must be reloaded.
|
2017-07-12 20:57:43 +03:00
|
|
|
//Also setting the odbcini path to the current folder for the same process.
|
|
|
|
//This will let us modify odbcinst.ini without root permissions
|
|
|
|
print_r(shell_exec("export ODBCSYSINI=".dirname(__FILE__)."&&".PHP_BINARY." ".dirname(__FILE__)."/isPooled.php"));
|
|
|
|
|
2017-03-31 03:45:27 +03:00
|
|
|
|
|
|
|
//disable pooling by modifying the odbcinst.ini file
|
2017-07-12 20:57:43 +03:00
|
|
|
$current = file_get_contents($custom_odbcinst_ini);
|
2017-04-03 20:52:43 +03:00
|
|
|
$current = str_replace($lines_to_add,'',$current);
|
2017-07-12 20:57:43 +03:00
|
|
|
file_put_contents($custom_odbcinst_ini, $current);
|
2017-03-31 03:45:27 +03:00
|
|
|
|
2017-07-12 20:57:43 +03:00
|
|
|
print_r(shell_exec("export ODBCSYSINI=".dirname(__FILE__)."&&".PHP_BINARY." ".dirname(__FILE__)."/isPooled.php"));
|
2017-03-31 03:45:27 +03:00
|
|
|
?>
|
2017-05-31 01:24:56 +03:00
|
|
|
--CLEAN--
|
|
|
|
<?php
|
2017-07-12 20:57:43 +03:00
|
|
|
$custom_odbcinst_ini = dirname(__FILE__)."/odbcinst.ini";
|
|
|
|
unlink($custom_odbcinst_ini);
|
|
|
|
//back to default odbcinst.ini
|
|
|
|
shell_exec("unset ODBCSYSINI");
|
2017-06-22 00:59:53 +03:00
|
|
|
|
2017-05-31 01:24:56 +03:00
|
|
|
?>
|
2017-03-31 03:45:27 +03:00
|
|
|
--EXPECT--
|
|
|
|
Pooled
|
|
|
|
Not Pooled
|