$status = TRUE;
    break;
}
if (!$status) {
    Tap::plan('skip_all', 'unable to connect to test job url: ' . $url);
}
Tap::plan(5);
$tube = '__test__';
Job::config()->addConnection(new Pheanstalk('127.0.0.1', '11300'));
Job::config()->setQueuePrefix('test');
$runner = new Runner();
$ct = $runner->flush($queue);
print "\nJOBS flushed from the queue before starting: {$ct}\n";
for ($i = 0; $i < 100; $i++) {
    $start = microtime(TRUE);
    $job = new Job($url);
    $job->queue = $queue;
    $id = $job->store();
    $elapsed = number_format(microtime(TRUE) - $start, 3);
    print "\nSTORE " . $id . ' ' . $elapsed . 's';
}
$start = microtime(TRUE);
$runner->watch($queue);
$runner->setTimelimit(20);
$runner->setMax(10);
$runner->attachDebugger($debugger = function ($v) {
    if ($v instanceof Exception) {
        $v = $v->__toString();
    }
    if (!is_scalar($v)) {
        strval($v);
 protected function buildTubePattern($v)
 {
     $prefix = Job::config()->queuePrefix();
     return '#^' . preg_quote($prefix, '#') . '(' . str_replace('\\*', '([^\\n]+)?', preg_quote($v, '#')) . ')' . '_([\\d]{8})$#';
 }
    print json_encode(array('127.0.0.1:11300'));
    exit;
}
if (!isset($_GET['signed'])) {
    die("\n<h1>ok</h1>\n");
}
use Gaia\Job;
$nonce = new Gaia\Nonce('test001');
$server = new Gaia\Container($_SERVER);
$hash = $server->HTTP_X_JOB_NONCE;
$id = $server->HTTP_X_JOB_ID;
$uri = $server->REQUEST_URI;
$valid = $nonce->check($hash, $uri);
$status = $valid ? 'complete' : 'failed';
if ($id) {
    header('X-JOB-ID: ' . $id);
}
if ($id && $valid) {
    Job::config()->addConnection(new Pheanstalk('127.0.0.1', '11300'));
    $job = Job::find($id);
    if (!$job->complete()) {
        $status = 'failed-to-mark-complete';
        $valid = FALSE;
    }
}
header('X-JOB-STATUS: ' . $status);
if (!$valid) {
    header($server->SERVER_PROTOCOL . ' 403 Forbidden');
}
echo "\n<h1>{$status}</h1>\n";
// EOF