private function compare($job) { global $CONF; $before = new DateTime(date("Y-m-d")); $start = new DateTime(date("Y-m-d")); $start->sub(new DateInterval("P30D")); KettleRunner::execute('/../tests/execute_dim.ktr', array('TransformationName' => $CONF->EtlBasePath . $job, 'LastUpdatedAt' => $start->format('Y/m/d') . " 00:00:00")); $sourceDB = new MySQLRunner($CONF->MonitoringDbHostName, $CONF->MonitoringDbPort, $CONF->MonitoringDbUser, $CONF->MonitoringDbPassword); $sourceRows = $sourceDB->run("SELECT count(*) amount FROM monmon.monitor_entry where updated_at>='" . $start->format('Y-m-d') . "' and updated_at<='" . $before->format('Y-m-d') . "'"); $targetDB = new MySQLRunner($CONF->DbHostName, $CONF->DbPort, $CONF->DbUser, $CONF->DbPassword); $targetRows = $targetDB->run("SELECT count(*) amount FROM kalturadw.dwh_fact_errors e, kalturadw.dwh_dim_error_object_types t where error_time>='" . $start->format('Y-m-d') . "' and error_time<='" . $before->format('Y-m-d') . "' and e.error_object_type_id = t.error_object_type_id and t.error_object_type_name = 'Transcoding'"); #$this->assertGreaterThan(0, $targetRows[0]['amount']); $this->assertEquals($sourceRows[0]['amount'], $targetRows[0]['amount']); }
private function compare($job, $source, $target) { global $CONF; $before = new DateTime(date("Y-m-d")); $start = new DateTime(date("Y-m-d")); $start->sub(new DateInterval("P30D")); $end = new DateTime(date("Y-m-d")); $end->add(new DateInterval("P1D")); KettleRunner::execute('/../tests/execute_dim.ktr', array('TransformationName' => $CONF->EtlBasePath . $job, 'LastUpdatedAt' => $start->format('Y/m/d') . " 00:00:00", 'OperationalReplicationSyncedAt' => $end->format('Y/m/d') . " 00:00:00")); $sourceDB = new MySQLRunner($CONF->OpDbHostName, $CONF->OpDbPort, $CONF->OpDbUser, $CONF->OpDbPassword); $sourceRows = $sourceDB->run("SELECT count(*) amount FROM kaltura." . $source . " where updated_at>='" . $start->format('Y-m-d') . "' and created_at<='" . $before->format('Y-m-d') . "'"); $targetDB = new MySQLRunner($CONF->DbHostName, $CONF->DbPort, $CONF->DbUser, $CONF->DbPassword); $targetRows = $targetDB->run("SELECT count(*) amount FROM kalturadw." . $target . " where updated_at>='" . $start->format('Y-m-d') . "' and created_at<='" . $before->format('Y-m-d') . "'"); #$this->assertGreaterThan(0, $targetRows[0]['amount']); $this->assertEquals($sourceRows[0]['amount'], $targetRows[0]['amount']); }
private function compare($dateId, $includedBW, $usedBW, $overageBW, $includedST, $usedST, $overageST, $includedBWST, $usedBWST, $overageBWST, $includedEntry, $usedEntry, $overageEntry, $includedPlay, $usedPlay, $overagePlay) { $monthId = intval($dateId / 100); $rows = MySQLRunner::execute("CALL kalturadw.calc_partner_overage(?)", array(0 => $monthId)); $this->assertGreaterThan(0, count($rows)); for ($i = 0; $i < count($rows); $i++) { if ($rows[$i]["publisher_id"] == $this->partnerId) { $this->assertEquals($includedBW, $rows[$i]["included_bandwidth_kb"]); $this->assertEquals($usedBW, $rows[$i]["actual_bandwidth_kb"]); $this->assertEquals($overageBW, $rows[$i]["charge_overage_bandwidth_kb"]); $this->assertEquals($includedST, $rows[$i]["included_storage_mb"]); $this->assertEquals($usedST, $rows[$i]["actual_storage_mb"]); $this->assertEquals($overageST, $rows[$i]["charge_overage_storage_mb"]); $this->assertEquals($includedBWST, $rows[$i]["included_total_usage_mb"]); $this->assertEquals($usedBWST, $rows[$i]["actual_total_usage_mb"]); $this->assertEquals($overageBWST, $rows[$i]["charge_overage_total_usage_mb"]); $this->assertEquals($includedEntry, $rows[$i]["included_entries"]); $this->assertEquals($usedEntry, $rows[$i]["actual_entries"]); $this->assertEquals($overageEntry, $rows[$i]["charge_overage_entries"]); $this->assertEquals($includedPlay, $rows[$i]["included_plays"]); $this->assertEquals($usedPlay, $rows[$i]["actual_plays"]); $this->assertEquals($overagePlay, $rows[$i]["charge_overage_plays"]); return; } } #not found partner, fail test $this->fail(); }
private static function deleteLiveEntries() { $lines = file('source/delete_live_entries.sql'); foreach ($lines as $line) { MySQLRunner::execute($line); } }
public static function execute($sql, $params = array(), $returnResults = true) { global $CONF; $db = new MySQLRunner($CONF->DbHostName, $CONF->DbPort, $CONF->DbUser, $CONF->DbPassword); return $db->run($sql, $params, $returnResults); }
public static function register() { KettleRunner::execute('/common/register_etl_server.ktr'); MySQLRunner::execute("CALL kalturadw.populate_time_dim('2011-01-01 00:00:00','2011-08-01 00:00:00')"); }
public static function dropTablePartitions($tableSchema, $tableName, $initialPartition = 'p_0') { $sql = "SELECT partition_name FROM information_schema.PARTITIONS WHERE table_schema = '{$tableSchema}' and table_name = '{$tableName}' AND partition_name <> '{$initialPartition}'"; $rows = MySQLRunner::execute($sql); foreach ($rows as $row) { $sql = "ALTER TABLE {$tableSchema}.{$tableName} DROP PARTITION " . $row["partition_name"]; MySQLRunner::execute($sql); } }
private function countRows($table_name, $date) { $rows = MySQLRunner::execute("SELECT * FROM kalturadw." . $table_name . " WHERE date_id = " . $date->format("Ymd")); return count($rows); }