Modifying UNIX connection pooling tests to not require root permissions (#471)
* Editing unix connection pooling tests to not requiere root permissions * Fix type in sqlsrv_ConnPool_Unix.phpt * Fix type in PDO_ConnPool_Unix.phpt
This commit is contained in:
parent
e959679aa6
commit
f25f844719
|
@ -1,63 +1,47 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
PDO Connection Pooling Test on Unix
|
PDO_SQLSRV Connection Pooling Test on Unix
|
||||||
--DESCRIPTION--
|
--DESCRIPTION--
|
||||||
This test assumes odbcinst.ini has not been modified.
|
This test assumes the default odbcinst.ini has not been modified.
|
||||||
This test also requires root privileges to modify odbcinst.ini file on Linux.
|
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') die("Skipped: Test for Linux and Mac"); ?>
|
<?php if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') die("Skipped: Test for Linux and Mac"); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
// On Bamboo we must use sudo to fiddle with odbcinst.ini
|
|
||||||
// On travis-ci we can't use sudo
|
|
||||||
$sudo = '';
|
|
||||||
$user = posix_getpwuid(posix_geteuid());
|
|
||||||
if (strtolower($user['name']) != 'root')
|
|
||||||
{
|
|
||||||
$sudo = 'sudo ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$lines_to_add="CPTimeout=5\n[ODBC]\nPooling=Yes\n";
|
$lines_to_add="CPTimeout=5\n[ODBC]\nPooling=Yes\n";
|
||||||
|
|
||||||
//get odbcinst.ini location
|
//get default odbcinst.ini location
|
||||||
$lines = explode("\n", shell_exec("odbcinst -j"));
|
$lines = explode("\n", shell_exec("odbcinst -j"));
|
||||||
$odbcinst_ini = explode(" ", $lines[1])[1];
|
$odbcinst_ini = explode(" ", $lines[1])[1];
|
||||||
|
$custom_odbcinst_ini = dirname(__FILE__)."/odbcinst.ini";
|
||||||
|
|
||||||
//back up the odbcinst.ini file
|
//copy the default odbcinst.ini into the current folder
|
||||||
shell_exec($sudo."cp $odbcinst_ini $odbcinst_ini.bak");
|
copy( $odbcinst_ini, $custom_odbcinst_ini);
|
||||||
|
|
||||||
//enable pooling by modifying the odbcinst.ini file
|
//enable pooling by modifying the odbcinst.ini file
|
||||||
$current = file_get_contents($odbcinst_ini);
|
$current = file_get_contents($custom_odbcinst_ini);
|
||||||
$current.=$lines_to_add;
|
$current.=$lines_to_add;
|
||||||
shell_exec("cp $odbcinst_ini .");
|
file_put_contents($custom_odbcinst_ini, $current);
|
||||||
file_put_contents("odbcinst.ini", $current);
|
|
||||||
shell_exec($sudo."cp odbcinst.ini $odbcinst_ini");
|
|
||||||
|
|
||||||
//Creating a new php process, because for changes in odbcinst.ini file to affect pooling, drivers must be reloaded.
|
//Creating a new php process, because for changes in odbcinst.ini file to affect pooling, drivers must be reloaded.
|
||||||
print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/isPooled.php"));
|
//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"));
|
||||||
|
|
||||||
|
|
||||||
//disable pooling by modifying the odbcinst.ini file
|
//disable pooling by modifying the odbcinst.ini file
|
||||||
$current = file_get_contents($odbcinst_ini);
|
$current = file_get_contents($custom_odbcinst_ini);
|
||||||
$current = str_replace($lines_to_add,'',$current);
|
$current = str_replace($lines_to_add,'',$current);
|
||||||
file_put_contents("odbcinst.ini", $current);
|
file_put_contents($custom_odbcinst_ini, $current);
|
||||||
shell_exec($sudo."cp odbcinst.ini $odbcinst_ini");
|
|
||||||
|
|
||||||
print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/isPooled.php"));
|
print_r(shell_exec("export ODBCSYSINI=".dirname(__FILE__)."&&".PHP_BINARY." ".dirname(__FILE__)."/isPooled.php"));
|
||||||
?>
|
?>
|
||||||
--CLEAN--
|
--CLEAN--
|
||||||
<?php
|
<?php
|
||||||
$sudo = '';
|
$custom_odbcinst_ini = dirname(__FILE__)."/odbcinst.ini";
|
||||||
$user = posix_getpwuid(posix_geteuid());
|
unlink($custom_odbcinst_ini);
|
||||||
if (strtolower($user['name']) == 'bamboo')
|
//back to default odbcinst.ini
|
||||||
{
|
shell_exec("unset ODBCSYSINI");
|
||||||
$sudo = 'sudo ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$lines = explode("\n", shell_exec("odbcinst -j"));
|
|
||||||
$odbcinst_ini = explode(" ", $lines[1])[1];
|
|
||||||
shell_exec($sudo."cp $odbcinst_ini.bak $odbcinst_ini");
|
|
||||||
shell_exec($sudo."rm $odbcinst_ini.bak");
|
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
Pooled
|
Pooled
|
||||||
Not Pooled
|
Not Pooled
|
||||||
|
|
||||||
|
|
|
@ -1,63 +1,47 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
SQLSRV Connection Pooling Test on Unix
|
SQLSRV Connection Pooling Test on Unix
|
||||||
--DESCRIPTION--
|
--DESCRIPTION--
|
||||||
This test assumes odbcinst.ini has not been modified.
|
This test assumes the default odbcinst.ini has not been modified.
|
||||||
This test also requires root privileges to modify odbcinst.ini file on Linux.
|
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') die("Skipped: Test for Linux and Mac"); ?>
|
<?php if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') die("Skipped: Test for Linux and Mac"); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
// On Bamboo we must use sudo to fiddle with odbcinst.ini
|
|
||||||
// On travis-ci we can't use sudo
|
|
||||||
$sudo = '';
|
|
||||||
$user = posix_getpwuid(posix_geteuid());
|
|
||||||
if (strtolower($user['name']) != 'root')
|
|
||||||
{
|
|
||||||
$sudo = 'sudo ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$lines_to_add="CPTimeout=5\n[ODBC]\nPooling=Yes\n";
|
$lines_to_add="CPTimeout=5\n[ODBC]\nPooling=Yes\n";
|
||||||
|
|
||||||
//get odbcinst.ini location
|
//get default odbcinst.ini location
|
||||||
$lines = explode("\n", shell_exec("odbcinst -j"));
|
$lines = explode("\n", shell_exec("odbcinst -j"));
|
||||||
$odbcinst_ini = explode(" ", $lines[1])[1];
|
$odbcinst_ini = explode(" ", $lines[1])[1];
|
||||||
|
$custom_odbcinst_ini = dirname(__FILE__)."/odbcinst.ini";
|
||||||
|
|
||||||
//back up the odbcinst.ini file
|
//copy the default odbcinst.ini into the current folder
|
||||||
shell_exec($sudo."cp $odbcinst_ini $odbcinst_ini.bak");
|
copy( $odbcinst_ini, $custom_odbcinst_ini);
|
||||||
|
|
||||||
//enable pooling by modifying the odbcinst.ini file
|
//enable pooling by modifying the odbcinst.ini file
|
||||||
$current = file_get_contents($odbcinst_ini);
|
$current = file_get_contents($custom_odbcinst_ini);
|
||||||
$current.=$lines_to_add;
|
$current.=$lines_to_add;
|
||||||
shell_exec("cp $odbcinst_ini .");
|
file_put_contents($custom_odbcinst_ini, $current);
|
||||||
file_put_contents("odbcinst.ini", $current);
|
|
||||||
shell_exec($sudo."cp odbcinst.ini $odbcinst_ini");
|
|
||||||
|
|
||||||
//Creating a new php process, because for changes in odbcinst.ini file to affect pooling, drivers must be reloaded.
|
//Creating a new php process, because for changes in odbcinst.ini file to affect pooling, drivers must be reloaded.
|
||||||
print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/isPooled.php"));
|
//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"));
|
||||||
|
|
||||||
|
|
||||||
//disable pooling by modifying the odbcinst.ini file
|
//disable pooling by modifying the odbcinst.ini file
|
||||||
$current = file_get_contents($odbcinst_ini);
|
$current = file_get_contents($custom_odbcinst_ini);
|
||||||
$current = str_replace($lines_to_add,'',$current);
|
$current = str_replace($lines_to_add,'',$current);
|
||||||
file_put_contents("odbcinst.ini", $current);
|
file_put_contents($custom_odbcinst_ini, $current);
|
||||||
shell_exec($sudo."cp odbcinst.ini $odbcinst_ini");
|
|
||||||
|
|
||||||
print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/isPooled.php"));
|
print_r(shell_exec("export ODBCSYSINI=".dirname(__FILE__)."&&".PHP_BINARY." ".dirname(__FILE__)."/isPooled.php"));
|
||||||
?>
|
?>
|
||||||
--CLEAN--
|
--CLEAN--
|
||||||
<?php
|
<?php
|
||||||
$sudo = '';
|
$custom_odbcinst_ini = dirname(__FILE__)."/odbcinst.ini";
|
||||||
$user = posix_getpwuid(posix_geteuid());
|
unlink($custom_odbcinst_ini);
|
||||||
if (strtolower($user['name']) == 'bamboo')
|
//back to default odbcinst.ini
|
||||||
{
|
shell_exec("unset ODBCSYSINI");
|
||||||
$sudo = 'sudo ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$lines = explode("\n", shell_exec("odbcinst -j"));
|
|
||||||
$odbcinst_ini = explode(" ", $lines[1])[1];
|
|
||||||
shell_exec($sudo."cp $odbcinst_ini.bak $odbcinst_ini");
|
|
||||||
shell_exec($sudo."rm $odbcinst_ini.bak");
|
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
Pooled
|
Pooled
|
||||||
Not Pooled
|
Not Pooled
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue