print <<<EXPLAIN
***********************************************************************************************************
  This test makes sure that a fatal error during job execution will result in the job being marked failed.
  This exercises our shutdown error detection.

  This test works if you see output indicating:
    - a job starts running
    - then a fatal error
    - finally "Status change: running => failed"
***********************************************************************************************************


EXPLAIN;
class SampleFatalJob extends SampleLoggingJob
{
    function run(JQManagedJob $mJob)
    {
        // causes a FATAL error
        $foo->bar();
    }
}
// run a job that will FATAL
$q = new JQStore_Array();
$goodJob = $q->enqueue(new SampleFatalJob());
if ($q->count('test') !== 1) {
    throw new Exception("assert failed");
}
SampleJobCounter::reset();
// Start a worker to run the job.
$w = new JQWorker($q, array('queueName' => 'test', 'exitIfNoJobs' => true, 'verbose' => true, 'enableJitter' => false));
$w->start();
예제 #2
0
 function testJobsAutoRetryOnFailure()
 {
     // create a queuestore
     $maxAttempts = 5;
     $q = new JQStore_Array();
     $mJob = $q->enqueue(new SampleFailJob(array('maxAttempts' => $maxAttempts)));
     // Start a worker to run the jobs.
     $w = new JQWorker($q, array('queueName' => 'test', 'exitIfNoJobs' => true, 'silent' => true, 'enableJitter' => false));
     $w->start();
     $this->assertEquals(0, $q->count('test', 'queued'));
     $this->assertEquals(1, $q->count('test', 'failed'));
     $this->assertEquals($maxAttempts, $mJob->getAttemptNumber());
 }