/** * (non-PHPdoc) * @see Zend_Config::get() */ public function get($name, $default = null) { $value = parent::get($name, $default); $isGlobal = KalturaGlobalData::isGlobalData($value); if ($isGlobal) { $value = KalturaGlobalData::getData($value); } else { if ($value instanceof Zend_Config) { //We transform it to be a test configuration object so we can take global data from it $value = KalturaTestConfig::fromZendConfig($value); } } return $value; }
/** * * Compares the $actualValue with the $expectedValue on the given field / property, no Exception is thrown * @param string $fieldName * @param object $actualValue * @param object $expectedResult * @throws no exception can be thrown (for mass compares) */ public function compareOnField($fieldName, $actualValue, $expectedValue, $assertToPerform, $message = null) { try { $this->currentFailure = new KalturaFailure($fieldName, $actualValue, $expectedValue, $assertToPerform, $message); if (!is_null($expectedValue)) { $isGlobalData = KalturaGlobalData::isGlobalData($expectedValue); if ($isGlobalData) { $expectedValue = KalturaGlobalData::getData($expectedValue); } } $this->{$assertToPerform}($expectedValue, $actualValue, $this->currentFailure); } catch (PHPUnit_Framework_AssertionFailedError $e) { $this->hasFailures = true; $resultObject = $this->getTestResultObject(); if ($resultObject) { $resultObject->addFailure($this, $e, PHP_Timer::stop()); } else { $name = $this->getName(true); //print("In add failure Result is NULL for test [$name]\n"); } } catch (Exception $e) { $this->getTestResultObject()->addError($this, $e, PHP_Timer::stop()); } }
/** * * Checks if the given name is in the global data * @param string $name */ public static function isGlobalData($name) { if (KalturaGlobalData::$dataFile == null) { $isInit = KalturaGlobalData::initDataFile(); if (!$isInit) { return null; } } $value = null; if (is_string($name) || is_integer($name)) { $value = KalturaGlobalData::getData($name); KalturaLog::debug("Name [" . print_r($name, true) . "] Value [" . print_r($value, true) . "]"); } if (is_null($value)) { return false; } return true; }
/** * * Add the data for DWH */ private static function addDWHdata(KalturaClient $client) { $partnerId = $client->getConfig()->partnerId; KalturaGlobalData::setData("@DWH_START_TIME@", time()); try { $ch = curl_init(); for ($i = 0; $i < 1000; $i++) { $eventType = KalturaStatsEventType::PLAY; $entryId = KalturaGlobalData::getData("@DEFAULT_ENTRY_ID@"); $event->clientVer = "test client"; $clientVer = "testClient"; $event->sessionId = "test session"; $sessionId = "testSession"; $referer = "http://kaltura.com/" . $i % 10; $uiconfId = KalturaGlobalData::getData("@UI_CONF_ID@"); $currentTimeStamp = time(); // $statsString = "GET //api_v3/index.php?service=stats&action=collect&kalsig=5e1adae915042f96eacf7c6d972b2f54&event%3AeventTimestamp=$currentTimeStamp&event%3AuiconfId=$uiconfId&event%3AsessionId=53BDB894%2D35D8%2D6369%2DE4BF%2DF227861A76FD&event%3AobjectType=KalturaStatsEvent&event%3AisFirstInSession=false&event%3AclientVer=3%2E0%3Av3%2E5%2E16%2Ea&event%3Aseek=false&event%3ApartnerId=$partnerId&ignoreNull=1&event%3Aduration=11&clientTag=kdp%3Av3%2E5%2E16%2Ea%2Ccache%5Fst%3A1314028568&event%3AcurrentPoint=33&event%3AeventType=$eventType&event%3Areferrer=$referer&event%3AentryId=$entryId HTTP/1.1"; // self::$serviceUrl; // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, self::$serviceUrl . "/api_v3/index.php?service=stats&action=collect&kalsig=5e1adae915042f96eacf7c6d972b2f54&event%3AeventTimestamp={$currentTimeStamp}&event%3AuiconfId={$uiconfId}&event%3AsessionId=53BDB894%2D35D8%2D6369%2DE4BF%2DF227861A76FD&event%3AobjectType=KalturaStatsEvent&event%3AisFirstInSession=false&event%3AclientVer=3%2E0%3Av3%2E5%2E16%2Ea&event%3Aseek=false&event%3ApartnerId={$partnerId}&ignoreNull=1&event%3Aduration=11&clientTag=kdp%3Av3%2E5%2E16%2Ea%2Ccache%5Fst%3A1314028568&event%3AcurrentPoint=33&event%3AeventType={$eventType}&event%3Areferrer={$referer}&event%3AentryId={$entryId}"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // grab URL and pass it to the browser $res = curl_exec($ch); } // close cURL resource, and free up system resources curl_close($ch); } catch (Exception $e) { KalturaLog::err("Exception was raised during http request: " . $e->getMessage() . "\n"); } KalturaGlobalData::setData("@PLAYS@", $i); //Log rotating only if the service url is localhost if (self::$serviceUrl == "localhost") { $logRotateConfString = "/opt/kaltura/log/kaltura_apache_access.log {\nrotate 5\ndaily\nmissingok\ncompress\nnodateext\nnotifempty\nsharedscripts\npostrotate\n\t/usr/sbin/apachectl -k restart\nendscript\nlastaction\n\tmv /opt/kaltura/log/kaltura_apache_access.log.1.gz /opt/kaltura/log/kaltura_apache_access.log-{$partnerId}.gz\nendscript\n}"; $logRotatePath = "/tmp/log_rotate.conf"; file_put_contents($logRotatePath, $logRotateConfString); //Now log rotate on local machine exec("dos2unix {$logRotatePath}"); exec("logrotate -f {$logRotatePath}"); // //run hourly exec("/opt/kaltura/dwh/etlsource/execute/etl_hourly.sh"); // // //run daily exec("/opt/kaltura/dwh/etlsource/execute/etl_daily.sh"); } KalturaGlobalData::setData("@DWH_END_TIME@", time()); }
/** * * Gets the admin kuser Id */ private function getAdminKuserId() { $partnerId = KalturaGlobalData::getData("@TEST_PARTNER_ID@"); $puserId = KalturaGlobalData::getData("TEST_PARTNER_USER_ID"); KuserPeer::getKuserByPartnerAndUid($partnerId, $puserId); }