Example #1
0
 /**
  * @covers ::__construct
  * @covers ::bufferJob
  * @covers ::<private>
  * @param array $buffered_jobs
  * @param array $expected_jobs
  * @dataProvider provideBufferJobsScenarios
  */
 public function testJobsCanBeBuffered(array $buffered_jobs, array $expected_jobs)
 {
     $adapter_factory = $this->getProvisioner()->getAdapterFactory();
     $superqueuer = $adapter_factory->getSuperqueuer();
     $scenario = $this->scenario_creator->createScenario($adapter_factory, $buffered_jobs, []);
     $this->asserter->assertJobsToRun($superqueuer, $scenario['uniqid'], $expected_jobs);
 }
Example #2
0
 /**
  * @covers ::beginBatch
  * @covers ::publishBatch
  * @covers ::getJobsToRunGenerator
  */
 public function testQueueingJobsCanBeBatched()
 {
     $provisioner = $this->getProvisioner();
     $scenario = $this->scenario_creator->createScenario($provisioner->getAdapterFactory(), [['name' => 1, 'mutex_id' => 'a'], ['name' => 2, 'mutex_id' => 'a']], []);
     $uniqid = $scenario['uniqid'];
     $current_connection = $provisioner->getAdapterFactory()->getSuperqueuer();
     $other_connection = $provisioner->generateAdapterFactory()->getSuperqueuer();
     $current_connection->beginBatch();
     $jobs_to_run = $this->asserter->assertJobsToRun($current_connection, $uniqid, ['1']);
     $this->asserter->assertJobsToRun($other_connection, $uniqid, ['1']);
     $this->markJobsAsQueued($jobs_to_run);
     $this->asserter->assertJobsToRun($current_connection, $uniqid, []);
     $this->asserter->assertJobsToRun($other_connection, $uniqid, ['1']);
     $current_connection->publishBatch();
     $this->asserter->assertJobsToRun($current_connection, $uniqid, []);
     $this->asserter->assertJobsToRun($other_connection, $uniqid, []);
 }
Example #3
0
 /**
  * @param callable $mark_job_completed
  */
 private function markJobsAsCompleted(callable $mark_job_completed)
 {
     $adapter_factory = $this->getProvisioner()->getAdapterFactory();
     $superqueuer = $adapter_factory->getSuperqueuer();
     $scenario = $this->scenario_creator->createScenario($adapter_factory, [['name' => 1, 'mutex_id' => 'a'], ['name' => 2, 'mutex_id' => 'a']], []);
     $uniqid = $scenario['uniqid'];
     $this->asserter->assertJobsToRun($superqueuer, $uniqid, ['1']);
     $jobs_to_complete = $this->markJobsAsQueued($superqueuer->getJobsToRunGenerator());
     $this->asserter->assertJobsToRun($superqueuer, $uniqid, []);
     foreach ($jobs_to_complete as $job) {
         call_user_func($mark_job_completed, ['buffered_job_id' => $job['buffered_job_id'], 'started_running_at' => date('c')]);
     }
     $this->asserter->assertJobsToRun($superqueuer, $uniqid, ['2']);
 }