public function _test_tryingToKillScript()
 {
     if ('Windows' == substr(php_uname(), 0, 7)) {
         $this->setExpectedExceptionRegExp('Zend\\ServiceManager\\Exception\\ServiceNotCreatedException');
     }
     $worker = $this->container->get($this->workerServiceName);
     $pId = $worker->call(['delay' => 10]);
     $this->assertTrue($worker->isProcessWorking($pId));
     //        $itemData = [
     //            'pid' => $pId,
     //            'startedAt' => UTCTime::getUTCTimestamp(),
     //            'scriptName' => 'Worker: tryingToKillScript',
     //            'timeout' => 30
     //        ];
     //        $this->dataStore->create($itemData);
     // Trying to kill script
     posix_kill($pId, 9);
     // Give script the time for dying
     sleep(1);
     // Checks it
     $this->assertFalse($worker->isProcessWorking($pId));
     sleep(6);
     // Five records in the log: plus records after previous test
     // and in this test script won't write the entry: it was killed
     $this->assertEquals(5, $this->dataStore->count());
 }
 public function test_callCallable()
 {
     $promise = $this->decorator->asyncCall(['rpc_callback' => ['\\zaboy\\test\\scheduler\\Examples\\Callback\\SimpleClass', 'staticMethodWhichLogsOneRow'], 'tick_id' => time(), 'step' => 1]);
     $this->assertEquals($promise->getState(), $promise::PENDING);
     sleep(2);
     $this->assertEquals($promise->getState(), $promise::FULFILLED);
     $this->assertEquals(1, $this->log->count());
 }
 public function test_checkProcess()
 {
     // Let finish to processes
     sleep(2);
     /** @var \zaboy\scheduler\Broker\ScriptBroker $broker */
     $broker = $this->container->get('script_broker');
     $broker->checkProcess();
     $this->assertEquals(1, $this->pidsDataStore->count());
     sleep(30);
     $broker->checkProcess();
     $this->assertEquals(0, $this->pidsDataStore->count());
 }
 /**
  * This test may not work in virtual environment like windows web-server (denwer, openserver etc) or vbox virtual machines
  */
 public function test_clearLog()
 {
     // Add limits for log files
     $totalTime = 3;
     $this->setTicker(['total_time' => $totalTime, 'step' => 0.1, 'tick__max_log_rows' => 30, 'hop__max_log_rows' => 1, 'critical_overtime' => 100]);
     $this->ticker->start();
     sleep($totalTime);
     $this->assertEquals(30, $this->tickLog->count());
     $this->assertEquals(1, $this->hopLog->count());
 }
Example #5
0
 /**
  * {@inheritdoc}
  *
  * {@inheritdoc}
  */
 public function count()
 {
     return parent::count();
 }