From cee0ff48819394cb01cde56c7d891a10b30b2c1a Mon Sep 17 00:00:00 2001 From: drigato Date: Thu, 5 Feb 2015 14:31:20 -0500 Subject: [PATCH] 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. --- airtime_mvc/application/configs/conf.php | 5 +++++ airtime_mvc/application/models/RabbitMq.php | 8 +++++++- .../airtime_analyzer/tests/analyzer_pipeline_tests.py | 6 ++++-- .../tests/cloud_storage_uploader_tests.py | 5 ++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/airtime_mvc/application/configs/conf.php b/airtime_mvc/application/configs/conf.php index 75a69d751..6af950882 100644 --- a/airtime_mvc/application/configs/conf.php +++ b/airtime_mvc/application/configs/conf.php @@ -43,6 +43,11 @@ class Config { // Parse separate conf file for cloud storage values $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); $CC_CONFIG["supportedStorageBackends"] = array('amazon_S3'); diff --git a/airtime_mvc/application/models/RabbitMq.php b/airtime_mvc/application/models/RabbitMq.php index 9ab7e6c22..435036a6e 100644 --- a/airtime_mvc/application/models/RabbitMq.php +++ b/airtime_mvc/application/models/RabbitMq.php @@ -89,7 +89,13 @@ class Application_Model_RabbitMq if (array_key_exists("dev_env", $CC_CONFIG)) { $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"], $config["rabbitmq"]["port"], $config["rabbitmq"]["user"], diff --git a/python_apps/airtime_analyzer/tests/analyzer_pipeline_tests.py b/python_apps/airtime_analyzer/tests/analyzer_pipeline_tests.py index fecfb3182..e5230448f 100644 --- a/python_apps/airtime_analyzer/tests/analyzer_pipeline_tests.py +++ b/python_apps/airtime_analyzer/tests/analyzer_pipeline_tests.py @@ -5,6 +5,7 @@ import multiprocessing import Queue import datetime 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_IMPORT_DEST = u'Test Artist/Test Album/44100Hz-16bit-mono.mp3' @@ -20,10 +21,11 @@ def teardown(): def test_basic(): filename = os.path.basename(DEFAULT_AUDIO_FILE) 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'' #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() assert metadata['track_title'] == u'Test Title' assert metadata['artist_name'] == u'Test Artist' diff --git a/python_apps/airtime_analyzer/tests/cloud_storage_uploader_tests.py b/python_apps/airtime_analyzer/tests/cloud_storage_uploader_tests.py index d54e4573a..44fa8e414 100644 --- a/python_apps/airtime_analyzer/tests/cloud_storage_uploader_tests.py +++ b/python_apps/airtime_analyzer/tests/cloud_storage_uploader_tests.py @@ -1,6 +1,7 @@ from nose.tools import * from airtime_analyzer.cloud_storage_uploader import CloudStorageUploader from airtime_analyzer.airtime_analyzer import AirtimeAnalyzerServer +from airtime_analyzer import config_file def setup(): pass @@ -9,5 +10,7 @@ def teardown(): pass 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" \ No newline at end of file