public function testCopyPartner()
 {
     $iniFile = realpath(__DIR__ . "/../../../configurations/batch");
     $schedulerConfig = new KSchedulerConfig($iniFile);
     $taskConfigs = $schedulerConfig->getTaskConfigList();
     $config = null;
     foreach ($taskConfigs as $taskConfig) {
         if ($taskConfig->name == self::JOB_NAME) {
             $config = $taskConfig;
         }
     }
     $this->assertNotNull($config);
     $jobs = $this->prepareJobs();
     $config->setTaskIndex(1);
     $instance = new $config->type($config);
     $instance->setUnitTest(true);
     echo "Starting to run...\n";
     $jobs = $instance->run($jobs);
     echo "Done running...\n";
     $instance->done();
     foreach ($jobs as $job) {
         echo "Asserting job status is FINISHED...\n";
         $this->assertEquals(KalturaBatchJobStatus::FINISHED, $job->status);
     }
 }
 public function doTest($filePath, KalturaThumbParamsOutput $thumbParamsOutput, $expectedStatus, $testName)
 {
     $outputFileName = "{$testName}.jpg";
     $finalPath = "{$this->outputFolder}/{$outputFileName}";
     if (file_exists($finalPath)) {
         unlink($finalPath);
     }
     $iniFile = "batch_config.ini";
     $schedulerConfig = new KSchedulerConfig($iniFile);
     $taskConfigs = $schedulerConfig->getTaskConfigList();
     $config = null;
     foreach ($taskConfigs as $taskConfig) {
         if ($taskConfig->name == self::JOB_NAME) {
             $config = $taskConfig;
         }
     }
     $this->assertNotNull($config);
     $jobs = $this->prepareJobs($filePath, $thumbParamsOutput);
     $config->setTaskIndex(1);
     $instance = new $config->type($config);
     $instance->setUnitTest(true);
     $jobs = $instance->run($jobs);
     $instance->done();
     foreach ($jobs as $job) {
         $this->assertEquals($expectedStatus, $job->status, "test [{$testName}] expected status [{$expectedStatus}] actual status [{$job->status}] with message [{$job->message}]");
         if ($job->status != KalturaBatchJobStatus::FINISHED) {
             continue;
         }
         $outPath = $job->data->thumbPath;
         $this->assertFileExists($outPath);
         rename($outPath, $finalPath);
     }
 }
 /**
  * @param string $jobName
  */
 public function run($jobName)
 {
     $this->debug(__LINE__, "run({$jobName})");
     $taskConfigs = $this->schedulerConfig->getTaskConfigList();
     $this->debug(__LINE__, "taskConfigs: " . count($taskConfigs));
     foreach ($taskConfigs as $taskConfig) {
         if ($taskConfig->name == $jobName) {
             if ($this->initOnly) {
                 $taskConfig->setInitOnly(true);
             }
             $this->exeJob($taskConfig);
         }
     }
     $this->debug(__LINE__, "-- Done --");
     die;
 }
 protected function onEvent(KBatchEvent $event, KSchedularTaskConfig $taskConfig)
 {
     $event->batch_client_version = "1.0";
     $event->batch_event_time = time();
     $event->batch_name = $taskConfig->name;
     $event->section_id = $taskConfig->id;
     $event->batch_type = $taskConfig->type;
     $event->location_id = $this->schedulerConfig->getId();
     $event->host_name = $this->schedulerConfig->getName();
     KDwhClient::send($event);
 }
Beispiel #5
0
 public function doTest($objectType, KalturaFilter $filter, $expectedStatus)
 {
     $iniFile = "batch_config.ini";
     $schedulerConfig = new KSchedulerConfig($iniFile);
     $taskConfigs = $schedulerConfig->getTaskConfigList();
     $config = null;
     foreach ($taskConfigs as $taskConfig) {
         if ($taskConfig->name == self::JOB_NAME) {
             $config = $taskConfig;
         }
     }
     $this->assertNotNull($config);
     $jobs = $this->prepareJobs($objectType, $filter);
     $config->setTaskIndex(1);
     $instance = new $config->type($config);
     $instance->setUnitTest(true);
     $jobs = $instance->run($jobs);
     $instance->done();
     foreach ($jobs as $job) {
         $this->assertEquals($expectedStatus, $job->status);
     }
 }
 public function doTest($partnerId, $srcCategoryId, $destCategoryId, $moveFromChildren, $copyOnly, $expectedStatus)
 {
     $iniFile = "batch_config.ini";
     $schedulerConfig = new KSchedulerConfig($iniFile);
     $taskConfigs = $schedulerConfig->getTaskConfigList();
     $config = null;
     foreach ($taskConfigs as $taskConfig) {
         if ($taskConfig->name == self::JOB_NAME) {
             $config = $taskConfig;
         }
     }
     $this->assertNotNull($config);
     $jobs = $this->prepareJobs($partnerId, $srcCategoryId, $destCategoryId, $moveFromChildren, $copyOnly);
     $config->setTaskIndex(1);
     $instance = new $config->type($config);
     $instance->setUnitTest(true);
     $jobs = $instance->run($jobs);
     $instance->done();
     foreach ($jobs as $job) {
         $this->assertEquals($expectedStatus, $job->status);
     }
 }
 public function run($jobs = null)
 {
     KalturaLog::info("Schedule helper batch is running");
     try {
         $systemReady = self::$kClient->system->ping();
         if (!$systemReady) {
             KalturaLog::err("System is not yet ready - ping failed");
             return;
         }
     } catch (KalturaClientException $e) {
         KalturaLog::err("System is not yet ready - ping failed");
         return;
     }
     $scheduler = new KalturaScheduler();
     $scheduler->configuredId = $this->getSchedulerId();
     $scheduler->name = $this->getSchedulerName();
     $scheduler->host = KSchedulerConfig::getHostname();
     // get command results from the scheduler
     $commandResults = KScheduleHelperManager::loadResultsCommandsFile();
     KalturaLog::info(count($commandResults) . " command results returned from the scheduler");
     if (count($commandResults)) {
         $this->sendCommandResults($commandResults);
     }
     // get config from the schduler
     $configItems = KScheduleHelperManager::loadConfigItems();
     if (count($configItems)) {
         KalturaLog::info(count($configItems) . " config records sent from the scheduler");
         $this->sendConfigItems($scheduler, $configItems);
     }
     $filters = KScheduleHelperManager::loadFilters();
     KalturaLog::info(count($filters) . " filter records found for the scheduler");
     // get status from the schduler
     $statuses = KScheduleHelperManager::loadStatuses();
     KalturaLog::info(count($statuses) . " status records sent from the scheduler");
     // send status to the server
     $statusResponse = self::$kClient->batchcontrol->reportStatus($scheduler, (array) $statuses, (array) $filters);
     KalturaLog::info(count($statusResponse->queuesStatus) . " queue status records returned from the server");
     KalturaLog::info(count($statusResponse->controlPanelCommands) . " control commands returned from the server");
     KalturaLog::info(count($statusResponse->schedulerConfigs) . " config items returned from the server");
     // send commands to the scheduler
     $commands = array_merge($statusResponse->queuesStatus, $statusResponse->schedulerConfigs, $statusResponse->controlPanelCommands);
     KalturaLog::info(count($commands) . " commands sent to scheduler");
     $this->saveSchedulerCommands($commands);
 }
 public static function getHostname()
 {
     if (self::$hostname) {
         return self::$hostname;
     }
     if (isset($_SERVER['HOSTNAME'])) {
         self::$hostname = $_SERVER['HOSTNAME'];
     }
     if (is_null(self::$hostname)) {
         self::$hostname = gethostname();
     }
     if (is_null(self::$hostname)) {
         self::$hostname = $_SERVER['SERVER_NAME'];
     }
     if (is_null(self::$hostname)) {
         die('Host name is not defined, please define environment variable named HOSTNAME');
     }
     return self::$hostname;
 }
Beispiel #9
0
<?php

$newDir = $argv[1];
$oldDir = $argv[2];
require_once __DIR__ . "/bootstrap.php";
$hosts = array('ny-batch1', 'ny-batch2', 'ny-batch3', 'ny-batch4', 'ny-batch5', 'ny-batch6', 'ny-cencoder2', 'ny-cencoder3', 'ny-encoder10', 'ny-encoder11', 'ny-encoder12', 'ny-encoder13', 'ny-encoder14', 'ny-encoder15', 'ny-encoder16', 'ny-encoder17', 'ny-encoder18', 'ny-encoder19', 'ny-encoder2', 'ny-encoder20', 'ny-encoder21', 'ny-encoder22', 'ny-encoder3', 'ny-encoder4', 'ny-encoder5', 'ny-encoder6', 'ny-encoder7', 'ny-encoder8', 'ny-encoder9', 'ny-fms1', 'ny-vmwin', 'ny-vmwin1', 'NY-VMWIN10', 'NY-VMWIN11', 'NY-VMWIN12', 'NY-VMWIN13', 'NY-VMWIN14', 'NY-VMWIN15', 'ny-vmwin2', 'ny-vmwin3', 'NY-VMWIN4', 'NY-VMWIN5', 'NY-VMWIN6', 'NY-VMWIN7', 'NY-VMWIN8', 'NY-VMWIN9', 'ny-vmwin-small', 'ny-win1', 'ny-win3', 'ny-win4', 'ny-xserve1', 'pa-batch1', 'pa-batch2', 'pa-batch3', 'pa-batch4', 'pa-batch5', 'pa-batch6', 'pa-cencoder2', 'pa-cencoder3', 'pa-encoder10', 'pa-encoder11', 'pa-encoder12', 'pa-encoder13', 'pa-encoder14', 'pa-encoder15', 'pa-encoder16', 'pa-encoder17', 'pa-encoder18', 'pa-encoder19', 'pa-encoder2', 'pa-encoder20', 'pa-encoder21', 'pa-encoder22', 'pa-encoder23', 'pa-encoder24', 'pa-encoder3', 'pa-encoder4', 'pa-encoder5', 'pa-encoder6', 'pa-encoder7', 'pa-encoder8', 'pa-encoder9', 'pa-fms1', 'pa-reports', 'pa-vmwin', 'pa-vmwin1', 'pa-vmwin10', 'pa-vmwin11', 'pa-vmwin12', 'pa-vmwin13', 'pa-vmwin14', 'pa-vmwin15', 'pa-vmwin2', 'pa-vmwin3', 'pa-vmwin4', 'pa-vmwin5', 'pa-vmwin6', 'pa-vmwin7', 'pa-vmwin8', 'pa-vmwin9', 'pa-vmwin-small', 'PA-WIN1', 'pa-win3', 'pa-win4', 'pa-xserve1', 'vmwin-small');
foreach ($hosts as $host) {
    KSchedulerConfig::setHostname($host);
    $newConfig = new KSchedulerConfig($newDir);
    $oldConfig = new KSchedulerConfig($oldDir);
    $array1 = $newConfig->toArray();
    $array2 = $oldConfig->toArray();
    $diff1 = array_diff($array1, $array2);
    $diff2 = array_diff($array2, $array1);
    if (count($diff1)) {
        KalturaLog::info("Host {$host} [" . print_r($diff1, true) . "]");
    }
    if (count($diff2)) {
        KalturaLog::info("Host {$host} [" . print_r($diff2, true) . "]");
    }
    if (!count($diff1) && !count($diff2)) {
        KalturaLog::info("Host {$host} OK");
    }
}