FOSSology  4.4.0
Open Source License Compliance by Open Source Software
SchedulerTestRunnerCli.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2014 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
9 
11 
12 include_once(__DIR__.'/../../../lib/php/Test/Agent/AgentTestMockHelper.php');
13 include_once(__DIR__.'/SchedulerTestRunner.php');
14 
21 {
23  private $testDb;
24 
25  public function __construct(TestPgDb $testDb)
26  {
27  $this->testDb = $testDb;
28  }
29 
39  public function run($uploadId, $userId=2, $groupId=2, $jobId=1, $args="")
40  {
41  $sysConf = $this->testDb->getFossSysConf();
42 
43  $agentName = "deciderjob";
44 
45  $agentDir = dirname(__DIR__, 2);
46  $execDir = "$agentDir/agent";
47  system("install -D $agentDir/VERSION $sysConf/mods-enabled/$agentName/VERSION");
48 
49  $pipeFd = popen($cmd = "echo $uploadId | $execDir/$agentName --userID=$userId --groupID=$groupId --jobId=$jobId --scheduler_start -c $sysConf $args", "r");
50  $success = $pipeFd !== false;
51 
52  $output = "";
53  $retCode = -1;
54  if ($success) {
55  while (($buffer = fgets($pipeFd, 4096)) !== false) {
56  $output .= $buffer;
57  }
58  $retCode = pclose($pipeFd);
59  } else {
60  print "failed opening pipe to $cmd";
61  }
62 
63  unlink("$sysConf/mods-enabled/$agentName/VERSION");
64  rmdir("$sysConf/mods-enabled/$agentName");
65  rmdir("$sysConf/mods-enabled");
66 
67  return array($success, $output, $retCode);
68  }
69 }
run($uploadId, $userId=2, $groupId=2, $jobId=1, $args="")
Mock as agent was called from CLI.
Interface for scheduler. Called by test case.
Namespace for decider job test cases.