Fixed sudo issue in connpool tests
This commit is contained in:
parent
16b53660b4
commit
8eb519c079
|
@ -1,6 +1,10 @@
|
||||||
|
sudo: required
|
||||||
|
|
||||||
os: linux
|
os: linux
|
||||||
dist: trusty
|
dist: trusty
|
||||||
|
|
||||||
|
group: edge
|
||||||
|
|
||||||
services:
|
services:
|
||||||
- docker
|
- docker
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,15 @@ This test also requires root privileges to modify odbcinst.ini file on Linux.
|
||||||
<?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']) == 'bamboo')
|
||||||
|
{
|
||||||
|
$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 odbcinst.ini location
|
||||||
|
@ -14,14 +23,14 @@ $lines = explode("\n", shell_exec("odbcinst -j"));
|
||||||
$odbcinst_ini = explode(" ", $lines[1])[1];
|
$odbcinst_ini = explode(" ", $lines[1])[1];
|
||||||
|
|
||||||
//back up the odbcinst.ini file
|
//back up the odbcinst.ini file
|
||||||
shell_exec("sudo cp $odbcinst_ini $odbcinst_ini.bak");
|
shell_exec($sudo."cp $odbcinst_ini $odbcinst_ini.bak");
|
||||||
|
|
||||||
//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($odbcinst_ini);
|
||||||
$current.=$lines_to_add;
|
$current.=$lines_to_add;
|
||||||
shell_exec("cp $odbcinst_ini .");
|
shell_exec("cp $odbcinst_ini .");
|
||||||
file_put_contents("odbcinst.ini", $current);
|
file_put_contents("odbcinst.ini", $current);
|
||||||
shell_exec("sudo cp odbcinst.ini $odbcinst_ini");
|
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"));
|
print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/isPooled.php"));
|
||||||
|
@ -30,16 +39,23 @@ print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/isPooled.php"));
|
||||||
$current = file_get_contents($odbcinst_ini);
|
$current = file_get_contents($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("odbcinst.ini", $current);
|
||||||
shell_exec("sudo cp odbcinst.ini $odbcinst_ini");
|
shell_exec($sudo."cp odbcinst.ini $odbcinst_ini");
|
||||||
|
|
||||||
print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/isPooled.php"));
|
print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/isPooled.php"));
|
||||||
?>
|
?>
|
||||||
--CLEAN--
|
--CLEAN--
|
||||||
<?php
|
<?php
|
||||||
|
$sudo = '';
|
||||||
|
$user = posix_getpwuid(posix_geteuid());
|
||||||
|
if (strtolower($user['name']) == 'bamboo')
|
||||||
|
{
|
||||||
|
$sudo = 'sudo ';
|
||||||
|
}
|
||||||
|
|
||||||
$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];
|
||||||
shell_exec("sudo cp $odbcinst_ini.bak $odbcinst_ini");
|
shell_exec($sudo."cp $odbcinst_ini.bak $odbcinst_ini");
|
||||||
shell_exec("sudo rm $odbcinst_ini.bak");
|
shell_exec($sudo."rm $odbcinst_ini.bak");
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
Pooled
|
Pooled
|
||||||
|
|
|
@ -7,6 +7,15 @@ This test also requires root privileges to modify odbcinst.ini file on Linux.
|
||||||
<?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']) == 'bamboo')
|
||||||
|
{
|
||||||
|
$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 odbcinst.ini location
|
||||||
|
@ -14,14 +23,14 @@ $lines = explode("\n", shell_exec("odbcinst -j"));
|
||||||
$odbcinst_ini = explode(" ", $lines[1])[1];
|
$odbcinst_ini = explode(" ", $lines[1])[1];
|
||||||
|
|
||||||
//back up the odbcinst.ini file
|
//back up the odbcinst.ini file
|
||||||
shell_exec("sudo cp $odbcinst_ini $odbcinst_ini.bak");
|
shell_exec($sudo."cp $odbcinst_ini $odbcinst_ini.bak");
|
||||||
|
|
||||||
//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($odbcinst_ini);
|
||||||
$current.=$lines_to_add;
|
$current.=$lines_to_add;
|
||||||
shell_exec("cp $odbcinst_ini .");
|
shell_exec("cp $odbcinst_ini .");
|
||||||
file_put_contents("odbcinst.ini", $current);
|
file_put_contents("odbcinst.ini", $current);
|
||||||
shell_exec("sudo cp odbcinst.ini $odbcinst_ini");
|
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"));
|
print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/isPooled.php"));
|
||||||
|
@ -30,16 +39,23 @@ print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/isPooled.php"));
|
||||||
$current = file_get_contents($odbcinst_ini);
|
$current = file_get_contents($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("odbcinst.ini", $current);
|
||||||
shell_exec("sudo cp odbcinst.ini $odbcinst_ini");
|
shell_exec($sudo."cp odbcinst.ini $odbcinst_ini");
|
||||||
|
|
||||||
print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/isPooled.php"));
|
print_r(shell_exec(PHP_BINARY." ".dirname(__FILE__)."/isPooled.php"));
|
||||||
?>
|
?>
|
||||||
--CLEAN--
|
--CLEAN--
|
||||||
<?php
|
<?php
|
||||||
|
$sudo = '';
|
||||||
|
$user = posix_getpwuid(posix_geteuid());
|
||||||
|
if (strtolower($user['name']) == 'bamboo')
|
||||||
|
{
|
||||||
|
$sudo = 'sudo ';
|
||||||
|
}
|
||||||
|
|
||||||
$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];
|
||||||
shell_exec("sudo cp $odbcinst_ini.bak $odbcinst_ini");
|
shell_exec($sudo."cp $odbcinst_ini.bak $odbcinst_ini");
|
||||||
shell_exec("sudo rm $odbcinst_ini.bak");
|
shell_exec($sudo."rm $odbcinst_ini.bak");
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
Pooled
|
Pooled
|
||||||
|
|
Loading…
Reference in a new issue