forked from department-of-veterans-affairs/va.gov-cms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scale.php
70 lines (53 loc) · 1.57 KB
/
scale.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
use Symfony\Component\Process\Exception\ExceptionInterface as ProcessException;
require_once __DIR__ . '/docroot/autoload.php';
$start_time = time() + 10;
$number_of_forks = 5;
$test_cmd = $cmd = '/app/bin/phpunit --debug --exclude-group disabled --verbose --colors=always tests/phpunit/ScalabilityCreateNodeTest.php';
$pids = [];
for ($i = 0; $i < $number_of_forks; $i++) {
switch ($pid = pcntl_fork()) {
case -1:
// @fail
die('Fork failed');
break;
case 0:
// @child: Include() misbehaving code here
run_test($start_time, $cmd, $i);
echo 'exit child ' . $i;
exit();
default:
$pids[] = $pid;
break;
}
}
foreach ($pids as $pid) {
echo 'Waiting on ' . $pid . PHP_EOL;
pcntl_waitpid($pid, $status);
echo $pid . ' complete' . PHP_EOL;
}
function run_test(int $start_time, string $cmd, int $id) {
echo $id . ': Waiting on start time' . PHP_EOL;
while (time() < $start_time) {
}
echo $id . ': Staring test' . PHP_EOL;;
try {
$process = new Symfony\Component\Process\Process($cmd);
$process->run();
} catch (ProcessException $e) {
}
if (!$process->isSuccessful()) {
echo $id . ' ERROR ######################' . PHP_EOL;
echo sprintf(
'Unable to execute the following command %s {output: %s}',
$process->getCommandLine(),
$process->getErrorOutput()
);
echo $process->getOutput();
}
if ($process->isSuccessful()) {
echo $id . ' SUCCESS ######################' . PHP_EOL;
echo $process->getErrorOutput();
echo $process->getOutput();
}
}