Skip to content

Commit

Permalink
Tidy up the scheduler test script
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasnetau committed Sep 5, 2021
1 parent 40336ed commit aeaf275
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions tests/scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,6 @@

include __DIR__ . "/../vendor/autoload.php";

function handle_exception($exception) {
$ex_class = get_class($exception);
$message = <<<EOM
Exception : {$ex_class} {$exception->getCode()}
File: {$exception->getFile()}
Line: {$exception->getLine()}
Message: {$exception->getMessage()}
Trace:
{$exception->getTraceAsString()}
EOM;
fwrite(STDERR, "$message\n");
}

set_exception_handler("handle_exception");

$rules = [
MatchAnyRule::class,
MatchOneRule::class,
Expand All @@ -40,19 +24,39 @@ function handle_exception($exception) {
const MEMORY_PRESSURE_HIGH_WATERMARK = 75;
const MEMORY_PRESSURE_LOW_WATERMARK = 50;
//const RUNNING_ACTION_LIMIT_HIGH_WATERMARK = 200000;
};

$scheduler->register_input_process('test_data_stream_1', php_cmd(__DIR__ . "/test_input_1.php"), null, []);
$scheduler->register_input_process('test_data_stream_2', php_cmd(__DIR__ . "/test_input_2.php"), null, []);
public function __construct(array $rules)
{
set_exception_handler([$this, "handle_exception"]);

if (file_exists('/tmp/php_ec-scheduler_test_logs.txt')) {
unlink('/tmp/php_ec-scheduler_test_logs.txt');
}
$scheduler->register_action('log', php_cmd(__DIR__ . "/log.php"), null, false, [
'LOG_FILENAME' => '/tmp/php_ec-scheduler_test_logs.txt',
]);
parent::__construct($rules);
$this->register_input_process('test_data_stream_1', php_cmd(__DIR__ . "/test_input_1.php"));
$this->register_input_process('test_data_stream_2', php_cmd(__DIR__ . "/test_input_2.php"));

$scheduler->setSavefileName("/tmp/php_ec-scheduler_test.state");
$scheduler->setSaveStateInterval(1);
if (file_exists('/tmp/php_ec-scheduler_test_logs.txt')) {
unlink('/tmp/php_ec-scheduler_test_logs.txt');
}
$this->register_action('log', php_cmd(__DIR__ . "/log.php"), null, false, [
'LOG_FILENAME' => '/tmp/php_ec-scheduler_test_logs.txt',
]);

$this->setSavefileName("/tmp/php_ec-scheduler_test.state");
$this->setSaveStateInterval(1);
}

function handle_exception($exception) {
$ex_class = get_class($exception);
$message = <<<EOM
Exception : {$ex_class} {$exception->getCode()}
File: {$exception->getFile()}
Line: {$exception->getLine()}
Message: {$exception->getMessage()}
Trace:
{$exception->getTraceAsString()}
EOM;
fwrite(STDERR, "$message\n");
}
};

$scheduler->run();

0 comments on commit aeaf275

Please sign in to comment.