public function testGetFreeCpu() { $cpus = $this->getDemoCpus(); $this->assertEquals('CPU_REMOTE', $this->cpuService->getFreeCpu()); $job = new Job(); $job->setCpu('CPU_REMOTE'); $job->setStatus(Job::STATUS_EXECUTING); $this->dm->persist($job); $this->dm->flush(); $this->assertEquals('CPU_LOCAL', $this->cpuService->getFreeCpu()); $job2 = new Job(); $job2->setCpu('CPU_LOCAL'); $job2->setStatus(Job::STATUS_EXECUTING); $this->dm->persist($job2); $this->dm->flush(); $this->assertEquals('CPU_CLOUD', $this->cpuService->getFreeCpu()); $job3 = new Job(); $job3->setCpu('CPU_CLOUD'); $job3->setStatus(Job::STATUS_EXECUTING); $this->dm->persist($job3); $this->dm->flush(); $this->assertEquals('CPU_REMOTE', $this->cpuService->getFreeCpu()); $job4 = new Job(); $job4->setCpu('CPU_REMOTE'); $job4->setStatus(Job::STATUS_EXECUTING); $this->dm->persist($job4); $this->dm->flush(); $this->assertNull($this->cpuService->getFreeCpu()); }
private function createJobWithStatus($status = Job::STATUS_WAITING, $multimediaObject) { $job = new Job(); $job->setMmId($multimediaObject->getId()); $job->setStatus($status); $this->dm->persist($job); $this->dm->flush(); }
/** * Change status of a given job */ private function changeStatus(Job $job, $actualStatus, $newStatus) { if ($actualStatus === $job->getStatus()) { $job->setStatus($newStatus); $this->dm->persist($job); $this->dm->flush(); } }
public function testRemoveTrackFromMultimediaObject() { $this->createBroadcasts(); $series = $this->factoryService->createSeries(); $multimediaObject = $this->factoryService->createMultimediaObject($series); $this->assertEquals(0, count($multimediaObject->getTracks())); $this->assertEquals(0, count($this->repoJobs->findAll())); $job = new Job(); $job->setMmId($multimediaObject->getId()); $job->setStatus(Job::STATUS_FINISHED); $job->setProfile('master'); $track = new Track(); $track->addTag('profile:master'); $multimediaObject->addTrack($track); $this->dm->persist($job); $this->dm->persist($multimediaObject); $this->dm->flush(); $this->assertEquals(1, count($multimediaObject->getTracks())); $this->assertEquals(1, count($this->repoJobs->findAll())); $multimediaObject = $this->repoMmobj->find($multimediaObject->getId()); $track = $multimediaObject->getTracks()[0]; $this->trackService->removeTrackFromMultimediaObject($multimediaObject, $track->getId()); $this->assertEquals(0, count($multimediaObject->getTracks())); $this->assertEquals(0, count($this->repoJobs->findAll())); }
private function createNewJob($status = null, $multimediaObject) { $job = new Job(); if (null !== $status) { $job->setStatus($status); } $job->setMmId($multimediaObject->getId()); $job->setTimeini(new \DateTime('now')); $job->setTimestart(new \DateTime('now')); $job->setDuration(60); $job->setNewDuration(65); $job->setProfile('master_copy'); $job->setCpu('cpu_local'); $job->setOutput('OK'); $job->setEmail('*****@*****.**'); $job->setPathIni('pathini/to/track.mp4'); $job->setPathEnd('pathend/to/track.mp4'); $this->dm->persist($job); $this->dm->flush(); return $job; }
private function newJob($mm_id, $name) { $job = new Job(); $language_id = 'es'; $profile = 1; $cpu = 'local'; $url = 'video/' . $mm_id . '/' . $name . '.avi'; $status = Job::STATUS_WAITING; $priority = 1; $timeini = new \DateTime('now'); $timestart = new \DateTime('now'); $timeend = new \DateTime('now'); $pid = 3; $path_ini = 'path/ini'; $path_end = 'path/end'; $ext_ini = 'ext/ini'; $ext_end = 'ext/end'; $duration = 40; $size = '12000'; $email = '*****@*****.**'; $locale = 'en'; $job->setLocale('en'); $job->setMmId($mm_id); $job->setLanguageId($language_id); $job->setProfile($profile); $job->setCpu($cpu); $job->setUrl($url); $job->setStatus($status); $job->setPriority($priority); $job->setName($name); $job->setTimeini($timeini); $job->setTimestart($timestart); $job->setTimeend($timeend); $job->setPid($pid); $job->setPathIni($path_ini); $job->setPathEnd($path_end); $job->setExtIni($ext_ini); $job->setExtEnd($ext_end); $job->setDuration($duration); $job->setSize($size); $job->setEmail($email); $this->dm->persist($job); $this->dm->flush(); return $job; }
public function testGetterAndSetter() { $job = new Job(); $mm_id = '54ad3f5e6e4cd68a278b4573'; $language_id = 'es'; $profile = 1; $cpu = 'local'; $url = 'video/' . $mm_id . '/video1.avi'; $status = Job::STATUS_WAITING; $priority = 1; $name = 'video1'; $description = 'description1'; $timeini = new \DateTime('now'); $timestart = new \DateTime('now'); $timeend = new \DateTime('now'); $pid = 3; $path_ini = 'path/ini'; $path_end = 'path/end'; $ext_ini = 'ext/ini'; $ext_end = 'ext/end'; $duration = 40; $size = '12000'; $email = '*****@*****.**'; $initVars = array('ocurls' => array('presenter/master' => 'http://presentatermaster.com', 'presentation/master' => 'http://presentationmaster')); $locale = 'en'; $job->setLocale('en'); $job->setMmId($mm_id); $job->setLanguageId($language_id); $job->setProfile($profile); $job->setCpu($cpu); $job->setUrl($url); $job->setStatus($status); $job->setPriority($priority); $job->setName($name); $job->setDescription($description); $job->setTimeini($timeini); $job->setTimestart($timestart); $job->setTimeend($timeend); $job->setPid($pid); $job->setPathIni($path_ini); $job->setPathEnd($path_end); $job->setExtIni($ext_ini); $job->setExtEnd($ext_end); $job->setDuration($duration); $job->setSize($size); $job->setEmail($email); $job->setInitVars($initVars); $this->assertEquals($mm_id, $job->getMmId()); $this->assertEquals($language_id, $job->getLanguageId()); $this->assertEquals($profile, $job->getProfile()); $this->assertEquals($cpu, $job->getCpu()); $this->assertEquals($url, $job->getUrl()); $this->assertEquals($status, $job->getStatus()); $this->assertEquals($priority, $job->getPriority()); $this->assertEquals($name, $job->getName()); $this->assertEquals($description, $job->getDescription()); $this->assertEquals($timeini, $job->getTimeini()); $this->assertEquals($timestart, $job->getTimestart()); $this->assertEquals($timeend, $job->getTimeend()); $this->assertEquals($pid, $job->getPid()); $this->assertEquals($path_ini, $job->getPathIni()); $this->assertEquals($path_end, $job->getPathEnd()); $this->assertEquals($ext_ini, $job->getExtIni()); $this->assertEquals($ext_end, $job->getExtEnd()); $this->assertEquals($duration, $job->getDuration()); $this->assertEquals($size, $job->getSize()); $this->assertEquals($email, $job->getEmail()); $this->assertEquals($initVars, $job->getInitVars()); $this->assertEquals($locale, $job->getLocale()); $descriptionI18n = array('en' => 'description', 'es' => 'descripción'); $nameI18n = array('en' => 'name', 'es' => 'nombre'); $job->setI18nDescription($descriptionI18n); $job->setI18nName($nameI18n); $this->assertEquals($descriptionI18n, $job->getI18nDescription()); $this->assertEquals($nameI18n, $job->getI18nName()); $this->assertEquals("Waiting", $job->getStatusText()); }
private function createNewJob($status = null, $priority = null) { $job = new Job(); if (null !== $status) { $job->setStatus($status); } if (null !== $priority) { $job->setPriority($priority); } $job->setTimeini(new \DateTime('now')); $this->dm->persist($job); $this->dm->flush(); return $job; }