SAAS-560: Deploy separate cloud storage config files for each development environment

Default to production config files if dev env specific files are not
found.
Fix analyzer unit tests.
This commit is contained in:
drigato 2015-02-05 14:31:20 -05:00
parent e2ff452b8a
commit cee0ff4881
4 changed files with 20 additions and 4 deletions

View File

@ -43,6 +43,11 @@ class Config {
// Parse separate conf file for cloud storage values // Parse separate conf file for cloud storage values
$cloudStorageConfig = "/etc/airtime-saas/".$CC_CONFIG['dev_env']."/cloud_storage.conf"; $cloudStorageConfig = "/etc/airtime-saas/".$CC_CONFIG['dev_env']."/cloud_storage.conf";
if (!file_exists($cloudStorageConfig)) {
// If the dev env specific cloud_storage.conf doesn't exist default
// to the production cloud_storage.conf
$cloudStorageConfig = "/etc/airtime-saas/production/cloud_storage.conf";
}
$cloudStorageValues = parse_ini_file($cloudStorageConfig, true); $cloudStorageValues = parse_ini_file($cloudStorageConfig, true);
$CC_CONFIG["supportedStorageBackends"] = array('amazon_S3'); $CC_CONFIG["supportedStorageBackends"] = array('amazon_S3');

View File

@ -89,7 +89,13 @@ class Application_Model_RabbitMq
if (array_key_exists("dev_env", $CC_CONFIG)) { if (array_key_exists("dev_env", $CC_CONFIG)) {
$devEnv = $CC_CONFIG["dev_env"]; $devEnv = $CC_CONFIG["dev_env"];
} }
$config = parse_ini_file("/etc/airtime-saas/".$devEnv."/rabbitmq-analyzer.ini", true); $rmq_config_path = "/etc/airtime-saas/".$devEnv."/rabbitmq-analyzer.ini";
if (!file_exists($rmq_config_path)) {
// If the dev env specific rabbitmq-analyzer.ini doesn't exist default
// to the production rabbitmq-analyzer.ini
$rmq_config_path = "/etc/airtime-saas/production/rabbitmq-analyzer.ini";
}
$config = parse_ini_file($rmq_config_path, true);
$conn = new AMQPConnection($config["rabbitmq"]["host"], $conn = new AMQPConnection($config["rabbitmq"]["host"],
$config["rabbitmq"]["port"], $config["rabbitmq"]["port"],
$config["rabbitmq"]["user"], $config["rabbitmq"]["user"],

View File

@ -5,6 +5,7 @@ import multiprocessing
import Queue import Queue
import datetime import datetime
from airtime_analyzer.analyzer_pipeline import AnalyzerPipeline from airtime_analyzer.analyzer_pipeline import AnalyzerPipeline
from airtime_analyzer import config_file
DEFAULT_AUDIO_FILE = u'tests/test_data/44100Hz-16bit-mono.mp3' DEFAULT_AUDIO_FILE = u'tests/test_data/44100Hz-16bit-mono.mp3'
DEFAULT_IMPORT_DEST = u'Test Artist/Test Album/44100Hz-16bit-mono.mp3' DEFAULT_IMPORT_DEST = u'Test Artist/Test Album/44100Hz-16bit-mono.mp3'
@ -20,10 +21,11 @@ def teardown():
def test_basic(): def test_basic():
filename = os.path.basename(DEFAULT_AUDIO_FILE) filename = os.path.basename(DEFAULT_AUDIO_FILE)
q = multiprocessing.Queue() q = multiprocessing.Queue()
cloud_storage_enabled = False cloud_storage_config_path = '/etc/airtime-saas/production/cloud_storage.conf'
cloud_storage_config = config_file.read_config_file(cloud_storage_config_path)
file_prefix = u'' file_prefix = u''
#This actually imports the file into the "./Test Artist" directory. #This actually imports the file into the "./Test Artist" directory.
AnalyzerPipeline.run_analysis(q, DEFAULT_AUDIO_FILE, u'.', filename, file_prefix, cloud_storage_enabled) AnalyzerPipeline.run_analysis(q, DEFAULT_AUDIO_FILE, u'.', filename, file_prefix, cloud_storage_config)
metadata = q.get() metadata = q.get()
assert metadata['track_title'] == u'Test Title' assert metadata['track_title'] == u'Test Title'
assert metadata['artist_name'] == u'Test Artist' assert metadata['artist_name'] == u'Test Artist'

View File

@ -1,6 +1,7 @@
from nose.tools import * from nose.tools import *
from airtime_analyzer.cloud_storage_uploader import CloudStorageUploader from airtime_analyzer.cloud_storage_uploader import CloudStorageUploader
from airtime_analyzer.airtime_analyzer import AirtimeAnalyzerServer from airtime_analyzer.airtime_analyzer import AirtimeAnalyzerServer
from airtime_analyzer import config_file
def setup(): def setup():
pass pass
@ -9,5 +10,7 @@ def teardown():
pass pass
def test_analyze(): def test_analyze():
cl = CloudStorageUploader() cloud_storage_config_path = '/etc/airtime-saas/production/cloud_storage.conf'
cloud_storage_config = config_file.read_config_file(cloud_storage_config_path)
cl = CloudStorageUploader(cloud_storage_config)
cl._storage_backend = "file" cl._storage_backend = "file"