12 include_once(__DIR__.
'/../../../lib/php/Test/Agent/AgentTestMockHelper.php');
13 include_once(__DIR__.
'/SchedulerTestRunner.php');
31 public function run($uploadId, $userId=2, $groupId=2, $jobId=1, array $args=[])
33 $sysConf = $this->testDb->getFossSysConf();
35 $agentName =
"reuser";
37 $agentDir = dirname(dirname(__DIR__));
40 $installCmd =
'install -D ' . escapeshellarg($agentDir .
'/VERSION') .
' ' . escapeshellarg($sysConf .
'/mods-enabled/' . $agentName .
'/VERSION');
43 $execPath = $agentDir .
'/agent/' . $agentName;
45 $extraArgs = implode(
' ', array_map(
'escapeshellarg', $args));
46 $cmd =
'echo ' . escapeshellarg((
string)$uploadId) .
' | ' . escapeshellarg($execPath) .
' --userID=' . escapeshellarg((
string)$userId) .
' --groupID=' . escapeshellarg((
string)$groupId) .
' --jobId=' . escapeshellarg((
string)$jobId) .
' --scheduler_start -c ' . escapeshellarg($sysConf) . ($extraArgs !==
'' ?
' ' . $extraArgs :
'');
47 $pipeFd = popen($cmd,
'r');
48 $success = $pipeFd !==
false;
53 while (($buffer = fgets($pipeFd, 4096)) !==
false) {
56 $retCode = pclose($pipeFd);
58 print
"failed opening pipe to $cmd";
61 unlink(
"$sysConf/mods-enabled/$agentName/VERSION");
62 rmdir(
"$sysConf/mods-enabled/$agentName");
63 rmdir(
"$sysConf/mods-enabled");
65 return array($success, $output, $retCode);
Handles scheduler interaction.
run($uploadId, $userId=2, $groupId=2, $jobId=1, array $args=[])
Function to run agent from scheduler.
Namespace to hold test cases for Reuser agent.