From 7b2b1560d8962e8c7b9c090660e8e47d0eb5b95a Mon Sep 17 00:00:00 2001 From: martin Date: Wed, 5 Oct 2011 19:01:36 -0400 Subject: [PATCH 1/3] CC-2870: Create testing infrastructure for testing upgrades -initial commit --- dev_tools/fabric/airtime.vhost | 11 ++++ dev_tools/fabric/fab_setup.py | 91 ++++++++++++++++++++++++++++++++++ utils/airtime-check-system.php | 13 ++++- 3 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 dev_tools/fabric/airtime.vhost create mode 100644 dev_tools/fabric/fab_setup.py diff --git a/dev_tools/fabric/airtime.vhost b/dev_tools/fabric/airtime.vhost new file mode 100644 index 000000000..b06183c5d --- /dev/null +++ b/dev_tools/fabric/airtime.vhost @@ -0,0 +1,11 @@ + + ServerAdmin foo@bar.org + DocumentRoot /var/www/airtime/public + + + DirectoryIndex index.php + AllowOverride all + Order allow,deny + Allow from all + + diff --git a/dev_tools/fabric/fab_setup.py b/dev_tools/fabric/fab_setup.py new file mode 100644 index 000000000..a0ca484ea --- /dev/null +++ b/dev_tools/fabric/fab_setup.py @@ -0,0 +1,91 @@ +import os +import time +from fabric.api import * +from fabric.contrib.files import comment, sed, append + + +# Download tar file +# + +# Globals + +env.user = 'martin' +env.hosts = ['192.168.5.36'] + +""" +Main dispatcher function to be called from the command-line. Allows us to specify source and target version of Airtime, +to test upgrade scripts, along with whether we should load a fresh version of the OS (from a VM snapshot), the OS version +and architecture. +""" +def dispatcher(source_version="182", target_version="194", fresh_os=True, os_version='10.04', os_arch='amd64'): + if (fresh_os): + create_fresh_os(os_version, os_arch) + globals()["airtime_%s"%source_version]() + globals()["airtime_%s"%target_version]() + + +def test(): + x = sudo('airtime-check-system') + print x.failed + print x.succeeded + print x.return_code + +def create_fresh_os(os_version, os_arch): + ret = local('VBoxManage snapshot ubuntu_64_server restore Fresh', capture=True) + if (ret.failed): + print ret + print "Restoring snapshot failed, are you sure it's not already running?" + + ret = local('VBoxManage startvm ubuntu_64_server', capture=True) + if (ret.failed): + print ret + print "Starting Virtual Machine failed, are you sure it's not already running?" + + time.sleep(15) + +def airtime_182(): + sudo('apt-get update') + sudo('apt-get install -y tar gzip unzip apache2 php5-pgsql libapache2-mod-php5 ' + \ + 'php-pear php5-gd postgresql odbc-postgresql python python-configobj poc-streamer ' + \ + 'lame daemontools daemontools-run python-mutagen libsoundtouch-ocaml sudo ' + \ + 'libtaglib-ocaml libao-ocaml libmad-ocaml libesd0 icecast2 oggvideotools ' + \ + 'libportaudio2 libsamplerate0 libcamomile-ocaml-dev ecasound php5-curl mpg123 ' + \ + 'python-setuptools python-pip rabbitmq-server libvorbis-ocaml-dev libmp3lame-dev flac') + + sudo('pip install kombu') + sudo('pip install poster') + + sudo('mkdir -p /tmp/pear/cache') + sudo('pear channel-discover pear.phing.info || true') + sudo('pear install phing/phing-2.4.2') + + sudo('ln -sf /etc/apache2/mods-available/php5.* /etc/apache2/mods-enabled') + sudo('ln -sf /etc/apache2/mods-available/rewrite.* /etc/apache2/mods-enabled') + + sed('/etc/php5/apache2/php.ini', ";upload_tmp_dir =", "upload_tmp_dir = /tmp", use_sudo=True) + sed('/etc/php5/apache2/php.ini', ";date.timezone =", 'date.timezone = "America/Toronto"', use_sudo=True) + + put('airtime.vhost', '/etc/apache2/sites-available/airtime', use_sudo=True) + sudo('a2dissite default') + sudo('ln -sf /etc/apache2/sites-available/airtime /etc/apache2/sites-enabled/airtime') + sudo('a2enmod rewrite') + sudo('service apache2 restart') + + sed('/etc/default/icecast2', 'ENABLE=false', 'ENABLE=true', use_sudo=True) + sudo('service icecast2 start') + + run('wget http://downloads.sourceforge.net/project/airtime/1.8.2/airtime-1.8.2.tar.gz') + run('tar xfz airtime-1.8.2.tar.gz') + sudo('cd ~/airtime-1.8.2/install && php airtime-install.php') + + reboot(45) + sudo('airtime-check-system') + +def airtime_194(): + run('wget http://downloads.sourceforge.net/project/airtime/1.9.4/airtime-1.9.4.tar.gz') + run('tar xfz airtime-1.9.4.tar.gz') + sudo('cd ~/airtime-1.9.4/install_full/ubuntu && ./airtime-full-install') + + +def airtime_200(): + pass diff --git a/utils/airtime-check-system.php b/utils/airtime-check-system.php index 4f7e61ee9..508f70db9 100644 --- a/utils/airtime-check-system.php +++ b/utils/airtime-check-system.php @@ -16,6 +16,9 @@ if (substr($sapi_type, 0, 3) == 'cli') { } class AirtimeCheck { + + private static $AIRTIME_STATUS_OK = true; + /** * Ensures that the user is running this PHP script with root * permissions. If not running with root permissions, causes the @@ -90,7 +93,14 @@ class AirtimeCheck { self::output_status("RABBITMQ_MEM_PERC", $p_status->services->rabbitmq->memory_perc); self::output_status("RABBITMQ_CPU_PERC", $p_status->services->rabbitmq->cpu_perc); - + if (self::$AIRTIME_STATUS_OK){ + echo PHP_EOL."-- Your installation of Airtime looks OK!".PHP_EOL; + exit(0); + } else { + echo PHP_EOL."-- There appears to be a problem with your Airtime installation.".PHP_EOL; + echo "-- Please visit http://wiki.sourcefabric.org/x/HABQ".PHP_EOL; + exit(1); + } } public static function output_status($key, $value){ @@ -101,6 +111,7 @@ class AirtimeCheck { if ($value == "FAILED"){ $color = $RED; + self::$AIRTIME_STATUS_OK = false; } echo sprintf("%-31s= %s", $key, self::term_color($value, $color)).PHP_EOL; From 99469307d205ae39b845dc3afab10938d1c97f32 Mon Sep 17 00:00:00 2001 From: martin Date: Thu, 6 Oct 2011 11:42:36 -0400 Subject: [PATCH 2/3] CC-2939: phone_home_stat crash -fixed --- utils/phone_home_stat.php | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/phone_home_stat.php b/utils/phone_home_stat.php index 65b6a57b5..cd36afe77 100644 --- a/utils/phone_home_stat.php +++ b/utils/phone_home_stat.php @@ -34,6 +34,7 @@ require_once($CC_CONFIG['phpDir'].'/application/models/StoredFile.php'); require_once($CC_CONFIG['phpDir'].'/application/models/Playlist.php'); require_once($CC_CONFIG['phpDir'].'/application/models/Schedule.php'); require_once($CC_CONFIG['phpDir'].'/application/models/Show.php'); +require_once($CC_CONFIG['phpDir'].'/application/models/ShowInstance.php'); require_once($CC_CONFIG['phpDir'].'/application/models/Preference.php'); //Pear classes. From 662e87debf3a7d2ba384f7dc960703e12f7195e5 Mon Sep 17 00:00:00 2001 From: martin Date: Thu, 6 Oct 2011 12:27:35 -0400 Subject: [PATCH 3/3] CC-2694: Create command line program for viewing/dumping log files -fixed --- utils/airtime-log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/airtime-log.php b/utils/airtime-log.php index 4e9fc7add..664432715 100644 --- a/utils/airtime-log.php +++ b/utils/airtime-log.php @@ -118,7 +118,7 @@ try { $opts = new Zend_Console_Getopt( array( 'view|v=s' => "Display log file\n" - ."\t\t$keys (ALL by default)", + ."\t\t$keys", 'dump|d-s' => "Collect all log files and compress into a tarball\n" ."\t\t$keys (ALL by default)", 'tail|t-s' => "View any new entries appended to log files in real-time\n"