Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
Add setUpTest and tearDownTest to run a bash script at the right time.
Browse files Browse the repository at this point in the history
The bash script is run with environment variable OSS_PERF_PHASE set to
either "setUpTest" or "tearDownTest"; the variable OSS_PERF_TARGET is
set to the target at hand.
  • Loading branch information
rrh committed Apr 23, 2015
1 parent 1578f33 commit a4348c2
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
13 changes: 13 additions & 0 deletions base/PerfOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ final class PerfOptions {
public ?string $php5;
public ?string $hhvm;

//
// setUpTest and tearDownTest are called before and after each
// individual invocation of the $php5 or $hhvm
//
public ?string $setUpTest;
public ?string $tearDownTest;

public array $hhvmExtraArguments;
public array $phpExtraArguments;

Expand Down Expand Up @@ -124,6 +131,9 @@ public function __construct(Vector<string> $argv) {
'dump-pcre-cache',
'profBC',

'setUpTest:',
'tearDownTest:',

'i-am-not-benchmarking',

'hhvm-extra-arguments:',
Expand Down Expand Up @@ -177,6 +187,9 @@ public function __construct(Vector<string> $argv) {
$this->php5 = hphp_array_idx($o, 'php5', null);
$this->hhvm = hphp_array_idx($o, 'hhvm', null);

$this->setUpTest = hphp_array_idx($o, 'setUpTest', null);
$this->tearDownTest = hphp_array_idx($o, 'tearDownTest', null);

$this->siege = hphp_array_idx($o, 'siege', 'siege');
$this->nginx = hphp_array_idx($o, 'nginx', 'nginx');

Expand Down
24 changes: 24 additions & 0 deletions base/PerfRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ private static function RunWithOptionsAndEngine(

$target->install();

if ($options->setUpTest != null) {
$command = "OSS_PERF_PHASE=" . "setUp"
. " " . "OSS_PERF_TARGET=" . (string) $target
. " " . $options->setUpTest
;
self::PrintProgress('Starting setUpTest ' . $command);
shell_exec($command);
self::PrintProgress('Finished setUpTest ' . $command);
} else {
self::PrintProgress('There is no setUpTest');
}

self::PrintProgress('Starting Nginx');
$nginx = new NginxDaemon($options, $target);
$nginx->start();
Expand Down Expand Up @@ -149,6 +161,18 @@ private static function RunWithOptionsAndEngine(
}
$php_engine->stop();

if ($options->tearDownTest != null) {
$command = "OSS_PERF_PHASE=" . "tearDown"
. " " . "OSS_PERF_TARGET=" . (string) $target
. " " . $options->tearDownTest
;
self::PrintProgress('Starting tearDownTest ' . $command);
shell_exec($command);
self::PrintProgress('Finished tearDownTest ' . $command);
} else {
self::PrintProgress('There is no tearDownTest');
}

return $combined_stats;
}

Expand Down
10 changes: 10 additions & 0 deletions batch-run.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ enum BatchRuntimeType: string {
'type' => BatchRuntimeType,
'bin' => string,
'args' => Vector<string>,
'setUpTest' => string,
'tearDownTest' => string,
);

type BatchTarget = shape(
Expand All @@ -31,6 +33,10 @@ function batch_get_runtime(string $name, array $data): BatchRuntime {
'name' => $name,
'type' => $data['type'],
'bin' => $data['bin'],
'setUpTest' => array_key_exists('setUpTest', $data)
? $data['setUpTest'] : null,
'tearDownTest' => array_key_exists('tearDownTest', $data)
? $data['tearDownTest'] : null,
'args' => array_key_exists('args', $data)
? new Vector($data['args'])
: Vector { },
Expand Down Expand Up @@ -135,6 +141,10 @@ function batch_get_single_run(
$options->php5 = $runtime['bin'];
break;
}

$options->setUpTest = $runtime['setUpTest'];
$options->tearDownTest = $runtime['tearDownTest'];

$options->validate();

return $options;
Expand Down

0 comments on commit a4348c2

Please sign in to comment.