public function testOnStopConditionCheckHandler_SIGINT() { $this->listener->onPCNTLSignal(SIGTERM); $this->listener->onStopConditionCheck($this->event); $this->assertContains('interrupt by an external signal', $this->listener->onReportQueueState($this->event)); $this->assertTrue($this->event->shouldExitWorkerLoop()); }
public function testRequestStopWhileThresholdExceeded() { $this->listener->setMaxMemory(1024); $this->listener->onStopConditionCheck($this->event); $this->assertContains('memory threshold of 1kB exceeded (usage: ', $this->listener->onReportQueueState($this->event)); $this->assertTrue($this->event->shouldExitWorkerLoop()); }
public function testOnStopConditionCheckHandler() { $this->listener->setMaxRuns(3); $this->listener->onStopConditionCheck($this->event); $this->assertContains('1 jobs processed', $this->listener->onReportQueueState($this->event)); $this->assertFalse($this->event->shouldExitWorkerLoop()); $this->listener->onStopConditionCheck($this->event); $this->assertContains('2 jobs processed', $this->listener->onReportQueueState($this->event)); $this->assertFalse($this->event->shouldExitWorkerLoop()); $this->listener->onStopConditionCheck($this->event); $this->assertContains('maximum of 3 jobs processed', $this->listener->onReportQueueState($this->event)); $this->assertTrue($this->event->shouldExitWorkerLoop()); }
public function testStopConditionCheckIdlingThrottling() { // builds a file list if (!is_dir('tests/build')) { mkdir('tests/build', 0755, true); } file_put_contents('tests/build/filewatch.txt', 'hi'); $this->listener->setPattern('/^\.\/(tests\/build).*\.(txt)$/'); $this->listener->setIdleThrottleTime(1); $this->event->setName(WorkerEvent::EVENT_PROCESS_IDLE); // records last time based when idle event $this->listener->onStopConditionCheck($this->event); // file has changed file_put_contents('tests/build/filewatch.txt', 'hello'); $this->listener->onStopConditionCheck($this->event); $this->assertFalse($this->event->shouldExitWorkerLoop()); sleep(1); $this->listener->onStopConditionCheck($this->event); $this->assertTrue($this->event->shouldExitWorkerLoop()); }
public function testOnLogJobProcessDone_DoesNotHaltPropagation() { $this->listener->onLogJobProcessDone($this->event); $this->assertFalse($this->event->shouldExitWorkerLoop()); }
public function testOnJobPopHandler() { $this->listener->onJobPop($this->event); $this->assertFalse($this->event->shouldExitWorkerLoop()); }