CC-2166: Packaging Improvements. Moved the Zend app into airtime_mvc. It is now installed to /var/www/airtime. Storage is now set to /srv/airtime/stor. Utils are now installed to /usr/lib/airtime/utils/. Added install/airtime-dircheck.php as a simple test to see if everything is install/uninstalled correctly.

This commit is contained in:
Paul Baranowski 2011-04-14 18:55:04 -04:00
parent 514777e8d2
commit b11cbd8159
4546 changed files with 138 additions and 51 deletions

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,24 @@
<?php
$path = dirname(__FILE__).'/../../../library/pear';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
$WHITE_SCREEN_OF_DEATH = false;
require_once(dirname(__FILE__).'/../../configs/conf.php');
require_once('DB.php');
require_once('PHPUnit.php');
require_once 'StoredFileTests.php';
require_once 'SchedulerTests.php';
//require_once 'SchedulerExportTests.php';
require_once 'PlaylistTests.php';
//$suite = new PHPUnit_TestSuite("PlayListTests");
//$suite = new PHPUnit_TestSuite("SchedulerTests");
$suite = new PHPUnit_TestSuite("StoredFileTest");
$suite->addTestSuite("PlaylistTests");
$suite->addTestSuite("SchedulerTests");
//$suite->addTestSuite("SchedulerExportTests");
$result = PHPUnit::run($suite);
echo $result->toString();

View file

@ -0,0 +1,41 @@
<?php
require_once(dirname(__FILE__)."/../Schedule.php");
class SchedulerExportTests extends PHPUnit_TestCase {
function setup() {
global $CC_CONFIG, $CC_DBC;
// Clear the files table
$sql = "DELETE FROM ".$CC_CONFIG["filesTable"];
$CC_DBC->query($sql);
// Add a file
$values = array("filepath" => dirname(__FILE__)."/test10001.mp3");
$this->storedFile = StoredFile::Insert($values, false);
// Add a file
$values = array("filepath" => dirname(__FILE__)."/test10002.mp3");
$this->storedFile2 = StoredFile::Insert($values, false);
// Clear the schedule table
$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"];
$CC_DBC->query($sql);
// Create a playlist
$playlist = new Playlist();
$playlist->create("Scheduler Unit Test");
$result = $playlist->addAudioClip($this->storedFile->getId());
$result = $playlist->addAudioClip($this->storedFile2->getId());
$result = $playlist->addAudioClip($this->storedFile2->getId());
// Schedule it
$i = new ScheduleGroup();
$this->groupIdCreated = $i->add('2010-11-11 01:30:23', null, $playlist->getId());
}
public function testExport() {
echo Schedule::ExportRangeAsJson("2010-01-01 00:00:00", "2011-01-01 00:00:00");
}
}

View file

@ -0,0 +1,129 @@
<?php
require_once(dirname(__FILE__)."/../Schedule.php");
class SchedulerTests extends PHPUnit_TestCase {
private $groupIdCreated;
private $storedFile;
private $storedFile2;
function setup() {
global $CC_CONFIG, $CC_DBC;
// Clear the files table
//$sql = "DELETE FROM ".$CC_CONFIG["filesTable"];
//$CC_DBC->query($sql);
// Add a file
$values = array("filepath" => dirname(__FILE__)."/test10001.mp3");
$this->storedFile = StoredFile::Insert($values, false);
// Add a file
$values = array("filepath" => dirname(__FILE__)."/test10002.mp3");
$this->storedFile2 = StoredFile::Insert($values, false);
// Clear the schedule table
//$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"];
//$CC_DBC->query($sql);
}
function testDateToId() {
$dateStr = "2006-04-02 10:20:08.123456";
$id = ScheduleGroup::dateToId($dateStr);
$expected = "20060402102008123";
if ($id != $expected) {
$this->fail("Did not convert date to ID correctly #1: $id != $expected");
}
$dateStr = "2006-04-02 10:20:08";
$id = ScheduleGroup::dateToId($dateStr);
$expected = "20060402102008000";
if ($id != $expected) {
$this->fail("Did not convert date to ID correctly #2: $id != $expected");
}
}
function testAddAndRemoveAudioFile() {
$i = new ScheduleGroup();
$this->groupIdCreated = $i->add('2010-10-10 01:30:23', $this->storedFile->getId());
if (PEAR::isError($this->groupIdCreated)) {
$this->fail("Failed to create scheduled item: ". $this->groupIdCreated->getMessage());
}
$i = new ScheduleGroup($this->groupIdCreated);
$result = $i->remove();
if ($result != 1) {
$this->fail("Did not remove item.");
}
}
function testAddAndRemovePlaylist() {
// Create a playlist
$playlist = new Playlist();
$playlist->create("Scheduler Unit Test ".uniqid());
$result = $playlist->addAudioClip($this->storedFile->getId());
$result = $playlist->addAudioClip($this->storedFile2->getId());
$result = $playlist->addAudioClip($this->storedFile2->getId());
$i = new ScheduleGroup();
$this->groupIdCreated = $i->add('2010-11-11 01:30:23', null, $playlist->getId());
if (PEAR::isError($this->groupIdCreated)) {
$this->fail("Failed to create scheduled item: ". $this->groupIdCreated->getMessage());
}
$group = new ScheduleGroup($this->groupIdCreated);
if ($group->count() != 3) {
$this->fail("Wrong number of items added.");
}
$items = $group->getItems();
if (!is_array($items) || ($items[1]["starts"] != "2010-11-11 01:30:34.231")) {
$this->fail("Wrong start time for 2nd item.");
}
$result = $group->remove();
if ($result != 1) {
$this->fail("Did not remove item.");
}
Playlist::Delete($playlist->getId());
}
function testIsScheduleEmptyInRange() {
$i = new ScheduleGroup();
$this->groupIdCreated = $i->add('2011-10-10 01:30:23', $this->storedFile->getId());
if (PEAR::isError($this->groupIdCreated)) {
$this->fail($this->groupIdCreated->getMessage());
return;
}
if (Schedule::isScheduleEmptyInRange('2011-10-10 01:30:23', '00:00:12.555')) {
$this->fail("Reporting empty schedule when it isnt.");
return;
}
// echo "groupid: ".$this->groupIdCreated."\n";
$success = $i->remove();
if ($success === false) {
$this->fail("Failed to delete schedule group.");
return;
}
if (!Schedule::isScheduleEmptyInRange('2011-10-10 01:30:23', '00:00:12.555')) {
$this->fail("Reporting booked schedule when it isnt.");
return;
}
}
/*
function testGetItems() {
$i1 = new ScheduleGroup();
$groupId1 = $i1->add('2008-01-01 12:00:00.000', $this->storedFile->getId());
$i2 = new ScheduleGroup();
$i2->addAfter($groupId1, $this->storedFile->getId());
$items = Schedule::GetItems("2008-01-01", "2008-01-02");
if (count($items) != 2) {
$this->fail("Wrong number of items returned.");
return;
}
$i1->remove();
$i2->remove();
}
*/
}

View file

@ -0,0 +1,86 @@
<?php
require_once(dirname(__FILE__).'/../StoredFile.php');
$dsn = $CC_CONFIG['dsn'];
$CC_DBC = DB::connect($dsn, TRUE);
if (PEAR::isError($CC_DBC)) {
echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n";
exit(1);
}
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
class StoredFileTest extends PHPUnit_TestCase {
function __construct($name) {
parent::__construct($name);
}
function setup() {
}
function testGetAudioMetadata() {
$filePath = dirname(__FILE__)."/ex1.mp3";
$metadata = Metadata::LoadFromFile($filePath);
if (PEAR::isError($metadata)) {
$this->fail($metadata->getMessage());
return;
}
if (($metadata["dc:description"] != "Tmu sem tam videla ...")
|| ($metadata["audio"]["dataformat"] != "mp3")
|| ($metadata["dc:type"] != "Speech")) {
$str = " [dc:description] = " . $metadata["dc:description"] ."\n"
. " [audio][dataformat] = " . $metadata["audio"]["dataformat"]."\n"
. " [dc:type] = ".$metadata["dc:type"]."\n";
$this->fail("Metadata has unexpected values:\n".$str);
}
//var_dump($metadata);
//$this->assertTrue(FALSE);
}
function testDeleteAndPutFile() {
$STORAGE_SERVER_PATH = dirname(__FILE__)."/../../";
$filePath = dirname(__FILE__)."/ex1.mp3";
// Delete any old data from previous tests
$md5 = md5_file($filePath);
$duplicate = StoredFile::RecallByMd5($md5);
if ($duplicate) {
$duplicate->delete();
}
// Test inserting a file by linking
$values = array("filepath" => $filePath,
"dc:description" => "Unit test ".time());
$storedFile = StoredFile::Insert($values, false);
if (PEAR::isError($storedFile)) {
$this->fail("Failed to create StoredFile: ".$storedFile->getMessage());
return;
}
//var_dump($storedFile);
$id = $storedFile->getId();
if (!is_numeric($id)) {
$this->fail("StoredFile not created correctly. id = ".$id);
return;
}
// Test loading metadata
$f = new StoredFile();
$f->__setGunid($storedFile->getGunid());
$f->loadMetadata();
if (!is_array($md = $f->getMetadata())) {
$this->fail("Unable to load metadata.");
return;
}
//var_dump($md);
// Check if the length field has been set.
$f2 = StoredFile::RecallByGunid($storedFile->getGunid());
$m2 = $f2->getMetadata();
if (!isset($m2["length"]) || $m2["length"] == "00:00:00.000000") {
$this->fail("Length not reporting correctly in metadata.");
return;
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,3 @@
<?php
header ("location: ../");
exit;

View file

@ -0,0 +1,25 @@
<?php
require_once(__DIR__.'/../../3rd_party/php/propel/runtime/lib/Propel.php');
// Initialize Propel with the runtime configuration
//Example how to use PDO:
//Propel::init(__DIR__."/../propel-db/build/conf/airtime-conf.php");
//Add the generated 'classes' directory to the include path
set_include_path(__DIR__."/../propel-db/build/classes" . PATH_SEPARATOR . get_include_path());
$con = Propel::getConnection("campcaster");
$sql = "SELECT COUNT(*) FROM cc_schedule WHERE (starts >= '2010-01-01 00:00:00.000') "
." AND (ends <= (TIMESTAMP '2011-01-01 00:00:00.000' + INTERVAL '01:00:00.123456'))";
$rows1 = $con->query($sql);
var_dump($rows1->fetchAll());
$sql2 = "SELECT COUNT(*) FROM cc_playlistcontents";
$rows2 = $con->query($sql2);
var_dump($rows2->fetchAll());
$sql3 = "SELECT TIMESTAMP '2011-01-01 00:00:00.000' + INTERVAL '01:00:00.123456'";
$result3 = $con->query($sql3);
var_dump($result3->fetchAll());

View file

@ -0,0 +1,26 @@
<?xml version="1.0"?>
<playlist id="0e22c20310212a51">
<playlistElement id="0000000000000103" relativeOffset="00:00:00.000000" >
<audioClip id="0000000000010003"
playlength="00:00:11.500000"
title = "three"
uri="file:var/test10003.mp3"
/>
</playlistElement>
<playlistElement id="0000000000000104" relativeOffset="00:00:11.500000">
<playlist id="0000000000000001"
playlength="01:30:00.000000"
title="My First Playlist">
</playlist>
</playlistElement>
<metadata
xmlns="http://mdlf.org/campcaster/elements/1.0/"
xmlns:ls="http://mdlf.org/campcaster/elements/1.0/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcterms="http://purl.org/dc/terms/"
>
<dc:title>embedded playlist</dc:title>
<dcterms:extent>01:30:11.500000</dcterms:extent>
</metadata>
</playlist>

View file

@ -0,0 +1,104 @@
<?php
set_include_path(__DIR__.'/..' . PATH_SEPARATOR . get_include_path());
set_include_path(__DIR__.'/../../../library' . PATH_SEPARATOR . get_include_path());
require_once __DIR__.'/../Shows.php';
require_once __DIR__.'/../StoredFile.php';
require_once __DIR__.'/../Playlist.php';
require_once __DIR__.'/../Schedule.php';
require_once __DIR__.'/../Preference.php';
require_once __DIR__.'/../RabbitMq.php';
require_once __DIR__.'/../../configs/conf.php';
require_once __DIR__.'/../../../install/include/AirtimeIni.php';
require_once __DIR__.'/../../../install/include/AirtimeInstall.php';
require_once __DIR__.'/../../../library/propel/runtime/lib/Propel.php';
Propel::init(__DIR__.'/../../configs/airtime-conf.php');
AirtimeInstall::DbConnect(true);
$sql = "DELETE FROM cc_show";
$CC_DBC->query($sql);
$sql = "DELETE FROM cc_show_days";
$CC_DBC->query($sql);
$sql = "DELETE FROM cc_show_instances";
$CC_DBC->query($sql);
/*
// Create a playlist
$playlist = new Playlist();
$playlist->create("Calendar Load test playlist ".uniqid());
// Add a file
$values = array("filepath" => __DIR__."/test10001.mp3");
$storedFile = StoredFile::Insert($values, false);
$result = $playlist->addAudioClip($storedFile->getId());
// Add a file
$values = array("filepath" => __DIR__."/test10002.mp3");
$storedFile2 = StoredFile::Insert($values, false);
$result = $playlist->addAudioClip($storedFile2->getId());
$result = $playlist->addAudioClip($storedFile2->getId());
echo "Created playlist ".$playlist->getName()." with ID ".$playlist->getId()."\n";
*/
// Create the shows
function createTestShow($showNumber, $showTime, $duration = "1:00")
{
$data = array();
$strTime = $showTime->format("Y-m-d H:i");
echo "Adding show: $strTime\n";
$data['add_show_name'] = 'automated show '.$showNumber;
$data['add_show_start_date'] = $showTime->format("Y-m-d");
$data['add_show_start_time'] = $showTime->format("H:i");
$data['add_show_duration'] = $duration;
$data['add_show_no_end'] = 0;
$data['add_show_repeats'] = 0;
$data['add_show_description'] = 'automated show';
$data['add_show_url'] = 'http://www.OfirGal.com';
$data['add_show_color'] = "";
$data['add_show_genre'] = "Ofir";
$data['add_show_background_color'] = "";
$data['add_show_record'] = 0;
$data['add_show_hosts'] ="";
$showId = Show::create($data);
//echo "show created, ID: $showId\n";
// populating the show with a playlist
$instances = Show::getShows($showTime->format("Y-m-d H:i:s"), $showTime->format("Y-m-d H:i:s"));
$instance = array_pop($instances);
$show = new ShowInstance($instance["instance_id"]);
//echo "Adding playlist to show instance ".$show->getShowInstanceId()."\n";
$show->scheduleShow(array(1));
//echo "done\n";
//$show->scheduleShow(array($playlist->getId()));
}
$showTime = new DateTime();
$resolution = "hour";
$showNumber = 1;
$numberOfDays = 180;
$numberOfHours = 0;
$endDate = new DateTime();
$endDate->add(new DateInterval("P".$numberOfDays."DT".$numberOfHours."H"));
echo "End date: ".$endDate->format("Y-m-d H:i")."\n";
while ($showTime < $endDate) {
echo $showTime->format("Y-m-d H:i")." < " .$endDate->format("Y-m-d H:i")."\n";
if ($resolution == "minute") {
createTestShow($showNumber, $showTime, "0:01");
$showTime->add(new DateInterval("PT1M"));
} elseif ($resolution == "hour") {
createTestShow($showNumber, $showTime);
$showTime->add(new DateInterval("PT1H"));
}
$showNumber = $showNumber + 1;
}
RabbitMq::PushScheduleFinal();

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<audioClip>
<metadata
xmlns="http://mdlf.org/campcaster/elements/1.0/"
xmlns:ls="http://mdlf.org/campcaster/elements/1.0/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
>
<dc:title>Webstream test 1</dc:title>
<dcterms:extent>01:30:00.000000</dcterms:extent>
<ls:url>http://localhost/y</ls:url>
</metadata>
</audioClip>