From 9eb50a72642696e65db5d5e20748d0078f8556e9 Mon Sep 17 00:00:00 2001 From: prithiv Date: Wed, 4 Oct 2017 14:19:25 +0100 Subject: [PATCH] Refactoring the test codes Signed-off-by: prithiv --- .../alarm_details/acknowledge_alarm.json | 0 ...alarm_differentName_differentInstance.json | 0 ...eate_alarm_differentName_sameInstance.json | 0 ...eate_alarm_sameName_differentInstance.json | 0 .../create_alarm_sameName_sameInstance.json | 0 .../create_alarm/operation_invalid.json | 0 .../create_alarm/operation_valid.json | 0 .../create_alarm/statistic_invalid.json | 0 .../create_alarm/statistic_valid.json | 0 .../create_metric_req_invalid.json | 0 .../create_metric_req_valid.json | 0 .../delete_alarm/name_invalid.json | 0 .../delete_alarm/name_valid.json | 0 .../delete_alarm/name_valid_delete1.json | 0 .../delete_alarm/name_valid_delete2.json | 0 .../delete_alarm/name_valid_delete3.json | 0 .../delete_alarm/name_valid_delete4.json | 0 .../delete_metric_req_invalid.json | 0 .../delete_metric_req_valid.json | 0 .../list_alarm_valid_no_arguments.json | 0 .../list_alarm_valid_one_argument.json | 0 .../list_alarm_valid_two_arguments.json | 0 .../list_metric_req_invalid.json | 0 .../list_metrics}/list_metric_req_valid.json | 0 .../read_coll_period_req_invalid.json | 0 .../read_coll_period_req_valid.json | 0 .../read_metric_name_req_invalid.json | 0 .../read_metric_name_req_valid.json | 0 .../update_alarm/name_invalid.json | 0 .../update_alarm/name_valid.json | 0 .../update_alarm/operation_invalid.json | 0 .../update_alarm/operation_valid.json | 0 .../update_alarm/statistic_invalid.json | 0 .../update_alarm/statistic_valid.json | 0 .../update_alarm/update_alarm_new_alarm.json | 0 .../update_metric_req_invalid.json | 0 .../update_metric_req_valid.json | 0 .../CloudWatch/unit_tests_alarms.py | 70 +++++++++---------- .../CloudWatch/unit_tests_metrics.py | 30 ++++---- .../core/test_producer.py | 10 +-- 40 files changed, 55 insertions(+), 55 deletions(-) rename {plugins/CloudWatch/Unit Testing => test/CloudWatch/test_schemas}/alarm_details/acknowledge_alarm.json (100%) rename {plugins/CloudWatch/Unit Testing => test/CloudWatch/test_schemas}/create_alarm/create_alarm_differentName_differentInstance.json (100%) rename {plugins/CloudWatch/Unit Testing => test/CloudWatch/test_schemas}/create_alarm/create_alarm_differentName_sameInstance.json (100%) rename {plugins/CloudWatch/Unit Testing => test/CloudWatch/test_schemas}/create_alarm/create_alarm_sameName_differentInstance.json (100%) rename {plugins/CloudWatch/Unit Testing => test/CloudWatch/test_schemas}/create_alarm/create_alarm_sameName_sameInstance.json (100%) rename {plugins/CloudWatch/Unit Testing => test/CloudWatch/test_schemas}/create_alarm/operation_invalid.json (100%) rename {plugins/CloudWatch/Unit Testing => test/CloudWatch/test_schemas}/create_alarm/operation_valid.json (100%) rename {plugins/CloudWatch/Unit Testing => test/CloudWatch/test_schemas}/create_alarm/statistic_invalid.json (100%) rename {plugins/CloudWatch/Unit Testing => test/CloudWatch/test_schemas}/create_alarm/statistic_valid.json (100%) rename {plugins/CloudWatch/Unit Testing/create metrics => test/CloudWatch/test_schemas/create_metrics}/create_metric_req_invalid.json (100%) rename {plugins/CloudWatch/Unit Testing/create metrics => test/CloudWatch/test_schemas/create_metrics}/create_metric_req_valid.json (100%) rename {plugins/CloudWatch/Unit Testing => test/CloudWatch/test_schemas}/delete_alarm/name_invalid.json (100%) rename {plugins/CloudWatch/Unit Testing => test/CloudWatch/test_schemas}/delete_alarm/name_valid.json (100%) rename {plugins/CloudWatch/Unit Testing => test/CloudWatch/test_schemas}/delete_alarm/name_valid_delete1.json (100%) rename {plugins/CloudWatch/Unit Testing => test/CloudWatch/test_schemas}/delete_alarm/name_valid_delete2.json (100%) rename {plugins/CloudWatch/Unit Testing => test/CloudWatch/test_schemas}/delete_alarm/name_valid_delete3.json (100%) rename {plugins/CloudWatch/Unit Testing => test/CloudWatch/test_schemas}/delete_alarm/name_valid_delete4.json (100%) rename {plugins/CloudWatch/Unit Testing/Delete metrics => test/CloudWatch/test_schemas/delete_metrics}/delete_metric_req_invalid.json (100%) rename {plugins/CloudWatch/Unit Testing/Delete metrics => test/CloudWatch/test_schemas/delete_metrics}/delete_metric_req_valid.json (100%) rename {plugins/CloudWatch/Unit Testing => test/CloudWatch/test_schemas}/list_alarm/list_alarm_valid_no_arguments.json (100%) rename {plugins/CloudWatch/Unit Testing => test/CloudWatch/test_schemas}/list_alarm/list_alarm_valid_one_argument.json (100%) rename {plugins/CloudWatch/Unit Testing => test/CloudWatch/test_schemas}/list_alarm/list_alarm_valid_two_arguments.json (100%) rename {plugins/CloudWatch/Unit Testing/List metrics => test/CloudWatch/test_schemas/list_metrics}/list_metric_req_invalid.json (100%) rename {plugins/CloudWatch/Unit Testing/List metrics => test/CloudWatch/test_schemas/list_metrics}/list_metric_req_valid.json (100%) rename {plugins/CloudWatch/Unit Testing/Read metrics data => test/CloudWatch/test_schemas/read_metrics_data}/read_coll_period_req_invalid.json (100%) rename {plugins/CloudWatch/Unit Testing/Read metrics data => test/CloudWatch/test_schemas/read_metrics_data}/read_coll_period_req_valid.json (100%) rename {plugins/CloudWatch/Unit Testing/Read metrics data => test/CloudWatch/test_schemas/read_metrics_data}/read_metric_name_req_invalid.json (100%) rename {plugins/CloudWatch/Unit Testing/Read metrics data => test/CloudWatch/test_schemas/read_metrics_data}/read_metric_name_req_valid.json (100%) rename {plugins/CloudWatch/Unit Testing => test/CloudWatch/test_schemas}/update_alarm/name_invalid.json (100%) rename {plugins/CloudWatch/Unit Testing => test/CloudWatch/test_schemas}/update_alarm/name_valid.json (100%) rename {plugins/CloudWatch/Unit Testing => test/CloudWatch/test_schemas}/update_alarm/operation_invalid.json (100%) rename {plugins/CloudWatch/Unit Testing => test/CloudWatch/test_schemas}/update_alarm/operation_valid.json (100%) rename {plugins/CloudWatch/Unit Testing => test/CloudWatch/test_schemas}/update_alarm/statistic_invalid.json (100%) rename {plugins/CloudWatch/Unit Testing => test/CloudWatch/test_schemas}/update_alarm/statistic_valid.json (100%) rename {plugins/CloudWatch/Unit Testing => test/CloudWatch/test_schemas}/update_alarm/update_alarm_new_alarm.json (100%) rename {plugins/CloudWatch/Unit Testing/Update metrics => test/CloudWatch/test_schemas/update_metrics}/update_metric_req_invalid.json (100%) rename {plugins/CloudWatch/Unit Testing/Update metrics => test/CloudWatch/test_schemas/update_metrics}/update_metric_req_valid.json (100%) rename {plugins => test}/CloudWatch/unit_tests_alarms.py (88%) rename {plugins => test}/CloudWatch/unit_tests_metrics.py (81%) rename core/message_bus/test_producer_AWS.py => test/core/test_producer.py (93%) diff --git a/plugins/CloudWatch/Unit Testing/alarm_details/acknowledge_alarm.json b/test/CloudWatch/test_schemas/alarm_details/acknowledge_alarm.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/alarm_details/acknowledge_alarm.json rename to test/CloudWatch/test_schemas/alarm_details/acknowledge_alarm.json diff --git a/plugins/CloudWatch/Unit Testing/create_alarm/create_alarm_differentName_differentInstance.json b/test/CloudWatch/test_schemas/create_alarm/create_alarm_differentName_differentInstance.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/create_alarm/create_alarm_differentName_differentInstance.json rename to test/CloudWatch/test_schemas/create_alarm/create_alarm_differentName_differentInstance.json diff --git a/plugins/CloudWatch/Unit Testing/create_alarm/create_alarm_differentName_sameInstance.json b/test/CloudWatch/test_schemas/create_alarm/create_alarm_differentName_sameInstance.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/create_alarm/create_alarm_differentName_sameInstance.json rename to test/CloudWatch/test_schemas/create_alarm/create_alarm_differentName_sameInstance.json diff --git a/plugins/CloudWatch/Unit Testing/create_alarm/create_alarm_sameName_differentInstance.json b/test/CloudWatch/test_schemas/create_alarm/create_alarm_sameName_differentInstance.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/create_alarm/create_alarm_sameName_differentInstance.json rename to test/CloudWatch/test_schemas/create_alarm/create_alarm_sameName_differentInstance.json diff --git a/plugins/CloudWatch/Unit Testing/create_alarm/create_alarm_sameName_sameInstance.json b/test/CloudWatch/test_schemas/create_alarm/create_alarm_sameName_sameInstance.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/create_alarm/create_alarm_sameName_sameInstance.json rename to test/CloudWatch/test_schemas/create_alarm/create_alarm_sameName_sameInstance.json diff --git a/plugins/CloudWatch/Unit Testing/create_alarm/operation_invalid.json b/test/CloudWatch/test_schemas/create_alarm/operation_invalid.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/create_alarm/operation_invalid.json rename to test/CloudWatch/test_schemas/create_alarm/operation_invalid.json diff --git a/plugins/CloudWatch/Unit Testing/create_alarm/operation_valid.json b/test/CloudWatch/test_schemas/create_alarm/operation_valid.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/create_alarm/operation_valid.json rename to test/CloudWatch/test_schemas/create_alarm/operation_valid.json diff --git a/plugins/CloudWatch/Unit Testing/create_alarm/statistic_invalid.json b/test/CloudWatch/test_schemas/create_alarm/statistic_invalid.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/create_alarm/statistic_invalid.json rename to test/CloudWatch/test_schemas/create_alarm/statistic_invalid.json diff --git a/plugins/CloudWatch/Unit Testing/create_alarm/statistic_valid.json b/test/CloudWatch/test_schemas/create_alarm/statistic_valid.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/create_alarm/statistic_valid.json rename to test/CloudWatch/test_schemas/create_alarm/statistic_valid.json diff --git a/plugins/CloudWatch/Unit Testing/create metrics/create_metric_req_invalid.json b/test/CloudWatch/test_schemas/create_metrics/create_metric_req_invalid.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/create metrics/create_metric_req_invalid.json rename to test/CloudWatch/test_schemas/create_metrics/create_metric_req_invalid.json diff --git a/plugins/CloudWatch/Unit Testing/create metrics/create_metric_req_valid.json b/test/CloudWatch/test_schemas/create_metrics/create_metric_req_valid.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/create metrics/create_metric_req_valid.json rename to test/CloudWatch/test_schemas/create_metrics/create_metric_req_valid.json diff --git a/plugins/CloudWatch/Unit Testing/delete_alarm/name_invalid.json b/test/CloudWatch/test_schemas/delete_alarm/name_invalid.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/delete_alarm/name_invalid.json rename to test/CloudWatch/test_schemas/delete_alarm/name_invalid.json diff --git a/plugins/CloudWatch/Unit Testing/delete_alarm/name_valid.json b/test/CloudWatch/test_schemas/delete_alarm/name_valid.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/delete_alarm/name_valid.json rename to test/CloudWatch/test_schemas/delete_alarm/name_valid.json diff --git a/plugins/CloudWatch/Unit Testing/delete_alarm/name_valid_delete1.json b/test/CloudWatch/test_schemas/delete_alarm/name_valid_delete1.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/delete_alarm/name_valid_delete1.json rename to test/CloudWatch/test_schemas/delete_alarm/name_valid_delete1.json diff --git a/plugins/CloudWatch/Unit Testing/delete_alarm/name_valid_delete2.json b/test/CloudWatch/test_schemas/delete_alarm/name_valid_delete2.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/delete_alarm/name_valid_delete2.json rename to test/CloudWatch/test_schemas/delete_alarm/name_valid_delete2.json diff --git a/plugins/CloudWatch/Unit Testing/delete_alarm/name_valid_delete3.json b/test/CloudWatch/test_schemas/delete_alarm/name_valid_delete3.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/delete_alarm/name_valid_delete3.json rename to test/CloudWatch/test_schemas/delete_alarm/name_valid_delete3.json diff --git a/plugins/CloudWatch/Unit Testing/delete_alarm/name_valid_delete4.json b/test/CloudWatch/test_schemas/delete_alarm/name_valid_delete4.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/delete_alarm/name_valid_delete4.json rename to test/CloudWatch/test_schemas/delete_alarm/name_valid_delete4.json diff --git a/plugins/CloudWatch/Unit Testing/Delete metrics/delete_metric_req_invalid.json b/test/CloudWatch/test_schemas/delete_metrics/delete_metric_req_invalid.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/Delete metrics/delete_metric_req_invalid.json rename to test/CloudWatch/test_schemas/delete_metrics/delete_metric_req_invalid.json diff --git a/plugins/CloudWatch/Unit Testing/Delete metrics/delete_metric_req_valid.json b/test/CloudWatch/test_schemas/delete_metrics/delete_metric_req_valid.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/Delete metrics/delete_metric_req_valid.json rename to test/CloudWatch/test_schemas/delete_metrics/delete_metric_req_valid.json diff --git a/plugins/CloudWatch/Unit Testing/list_alarm/list_alarm_valid_no_arguments.json b/test/CloudWatch/test_schemas/list_alarm/list_alarm_valid_no_arguments.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/list_alarm/list_alarm_valid_no_arguments.json rename to test/CloudWatch/test_schemas/list_alarm/list_alarm_valid_no_arguments.json diff --git a/plugins/CloudWatch/Unit Testing/list_alarm/list_alarm_valid_one_argument.json b/test/CloudWatch/test_schemas/list_alarm/list_alarm_valid_one_argument.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/list_alarm/list_alarm_valid_one_argument.json rename to test/CloudWatch/test_schemas/list_alarm/list_alarm_valid_one_argument.json diff --git a/plugins/CloudWatch/Unit Testing/list_alarm/list_alarm_valid_two_arguments.json b/test/CloudWatch/test_schemas/list_alarm/list_alarm_valid_two_arguments.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/list_alarm/list_alarm_valid_two_arguments.json rename to test/CloudWatch/test_schemas/list_alarm/list_alarm_valid_two_arguments.json diff --git a/plugins/CloudWatch/Unit Testing/List metrics/list_metric_req_invalid.json b/test/CloudWatch/test_schemas/list_metrics/list_metric_req_invalid.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/List metrics/list_metric_req_invalid.json rename to test/CloudWatch/test_schemas/list_metrics/list_metric_req_invalid.json diff --git a/plugins/CloudWatch/Unit Testing/List metrics/list_metric_req_valid.json b/test/CloudWatch/test_schemas/list_metrics/list_metric_req_valid.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/List metrics/list_metric_req_valid.json rename to test/CloudWatch/test_schemas/list_metrics/list_metric_req_valid.json diff --git a/plugins/CloudWatch/Unit Testing/Read metrics data/read_coll_period_req_invalid.json b/test/CloudWatch/test_schemas/read_metrics_data/read_coll_period_req_invalid.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/Read metrics data/read_coll_period_req_invalid.json rename to test/CloudWatch/test_schemas/read_metrics_data/read_coll_period_req_invalid.json diff --git a/plugins/CloudWatch/Unit Testing/Read metrics data/read_coll_period_req_valid.json b/test/CloudWatch/test_schemas/read_metrics_data/read_coll_period_req_valid.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/Read metrics data/read_coll_period_req_valid.json rename to test/CloudWatch/test_schemas/read_metrics_data/read_coll_period_req_valid.json diff --git a/plugins/CloudWatch/Unit Testing/Read metrics data/read_metric_name_req_invalid.json b/test/CloudWatch/test_schemas/read_metrics_data/read_metric_name_req_invalid.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/Read metrics data/read_metric_name_req_invalid.json rename to test/CloudWatch/test_schemas/read_metrics_data/read_metric_name_req_invalid.json diff --git a/plugins/CloudWatch/Unit Testing/Read metrics data/read_metric_name_req_valid.json b/test/CloudWatch/test_schemas/read_metrics_data/read_metric_name_req_valid.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/Read metrics data/read_metric_name_req_valid.json rename to test/CloudWatch/test_schemas/read_metrics_data/read_metric_name_req_valid.json diff --git a/plugins/CloudWatch/Unit Testing/update_alarm/name_invalid.json b/test/CloudWatch/test_schemas/update_alarm/name_invalid.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/update_alarm/name_invalid.json rename to test/CloudWatch/test_schemas/update_alarm/name_invalid.json diff --git a/plugins/CloudWatch/Unit Testing/update_alarm/name_valid.json b/test/CloudWatch/test_schemas/update_alarm/name_valid.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/update_alarm/name_valid.json rename to test/CloudWatch/test_schemas/update_alarm/name_valid.json diff --git a/plugins/CloudWatch/Unit Testing/update_alarm/operation_invalid.json b/test/CloudWatch/test_schemas/update_alarm/operation_invalid.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/update_alarm/operation_invalid.json rename to test/CloudWatch/test_schemas/update_alarm/operation_invalid.json diff --git a/plugins/CloudWatch/Unit Testing/update_alarm/operation_valid.json b/test/CloudWatch/test_schemas/update_alarm/operation_valid.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/update_alarm/operation_valid.json rename to test/CloudWatch/test_schemas/update_alarm/operation_valid.json diff --git a/plugins/CloudWatch/Unit Testing/update_alarm/statistic_invalid.json b/test/CloudWatch/test_schemas/update_alarm/statistic_invalid.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/update_alarm/statistic_invalid.json rename to test/CloudWatch/test_schemas/update_alarm/statistic_invalid.json diff --git a/plugins/CloudWatch/Unit Testing/update_alarm/statistic_valid.json b/test/CloudWatch/test_schemas/update_alarm/statistic_valid.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/update_alarm/statistic_valid.json rename to test/CloudWatch/test_schemas/update_alarm/statistic_valid.json diff --git a/plugins/CloudWatch/Unit Testing/update_alarm/update_alarm_new_alarm.json b/test/CloudWatch/test_schemas/update_alarm/update_alarm_new_alarm.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/update_alarm/update_alarm_new_alarm.json rename to test/CloudWatch/test_schemas/update_alarm/update_alarm_new_alarm.json diff --git a/plugins/CloudWatch/Unit Testing/Update metrics/update_metric_req_invalid.json b/test/CloudWatch/test_schemas/update_metrics/update_metric_req_invalid.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/Update metrics/update_metric_req_invalid.json rename to test/CloudWatch/test_schemas/update_metrics/update_metric_req_invalid.json diff --git a/plugins/CloudWatch/Unit Testing/Update metrics/update_metric_req_valid.json b/test/CloudWatch/test_schemas/update_metrics/update_metric_req_valid.json similarity index 100% rename from plugins/CloudWatch/Unit Testing/Update metrics/update_metric_req_valid.json rename to test/CloudWatch/test_schemas/update_metrics/update_metric_req_valid.json diff --git a/plugins/CloudWatch/unit_tests_alarms.py b/test/CloudWatch/unit_tests_alarms.py similarity index 88% rename from plugins/CloudWatch/unit_tests_alarms.py rename to test/CloudWatch/unit_tests_alarms.py index 49a03b4..e34586b 100644 --- a/plugins/CloudWatch/unit_tests_alarms.py +++ b/test/CloudWatch/unit_tests_alarms.py @@ -6,8 +6,8 @@ import json import os import time from jsmin import jsmin -sys.path.append("../../core/message-bus") -from test_producer_AWS import KafkaProducer +sys.path.append("../../test/core/") +from test_producer import KafkaProducer from kafka import KafkaConsumer try: import boto @@ -31,7 +31,7 @@ cloudwatch_conn = connections_res['cloudwatch_connection'] #-------------------------------------------------------------------------------------------------------------------------------------- '''Test E2E Flow : Test cases has been tested one at a time. -1) Commom Request is generated using request function in test_producer_AWS.py(/core/message-bus) +1) Commom Request is generated using request function in test_producer.py(/test/core) 2) The request is then consumed by the comsumer (plugin) 3) The response is sent back on the message bus in plugin_alarm.py using response functions in producer.py(/core/message-bus) @@ -47,7 +47,7 @@ class config_alarm_name_test(unittest.TestCase): #To generate a request of testing new alarm name and new instance id in create alarm request def test_differentName_differentInstance(self): time.sleep(2) - producer.request("Unit Testing/create_alarm/create_alarm_differentName_differentInstance.json",'create_alarm_request', '','alarm_request') + producer.request("test_schemas/create_alarm/create_alarm_differentName_differentInstance.json",'create_alarm_request', '','alarm_request') server = {'server': 'localhost:9092', 'topic': 'alarm_request'} _consumer = KafkaConsumer(bootstrap_servers=server['server']) @@ -64,7 +64,7 @@ class config_alarm_name_test(unittest.TestCase): #To generate a request of testing new alarm name and existing instance id in create alarm request def test_differentName_sameInstance(self): time.sleep(2) - producer.request("Unit Testing/create_alarm/create_alarm_differentName_sameInstance.json",'create_alarm_request', '','alarm_request') + producer.request("test_schemas/create_alarm/create_alarm_differentName_sameInstance.json",'create_alarm_request', '','alarm_request') server = {'server': 'localhost:9092', 'topic': 'alarm_request'} _consumer = KafkaConsumer(bootstrap_servers=server['server']) @@ -75,14 +75,14 @@ class config_alarm_name_test(unittest.TestCase): info = json.loads(json.loads(message.value)) print info time.sleep(1) - producer.request("Unit Testing/delete_alarm/name_valid_delete1.json",'delete_alarm_request','','alarm_request') + producer.request("test_schemas/delete_alarm/name_valid_delete1.json",'delete_alarm_request','','alarm_request') self.assertTrue(info['alarm_create_response']['status']) return #To generate a request of testing existing alarm name and new instance id in create alarm request def test_sameName_differentInstance(self): time.sleep(2) - producer.request("Unit Testing/create_alarm/create_alarm_sameName_differentInstance.json",'create_alarm_request', '','alarm_request') + producer.request("test_schemas/create_alarm/create_alarm_sameName_differentInstance.json",'create_alarm_request', '','alarm_request') server = {'server': 'localhost:9092', 'topic': 'alarm_request'} _consumer = KafkaConsumer(bootstrap_servers=server['server']) @@ -93,14 +93,14 @@ class config_alarm_name_test(unittest.TestCase): info = json.loads(json.loads(message.value)) print info time.sleep(1) - producer.request("Unit Testing/delete_alarm/name_valid_delete2.json",'delete_alarm_request', '','alarm_request') + producer.request("test_schemas/delete_alarm/name_valid_delete2.json",'delete_alarm_request', '','alarm_request') self.assertTrue(info['alarm_create_response']['status']) return #To generate a request of testing existing alarm name and existing instance id in create alarm request def test_sameName_sameInstance(self): time.sleep(2) - producer.request("Unit Testing/create_alarm/create_alarm_sameName_sameInstance.json",'create_alarm_request', '','alarm_request') + producer.request("test_schemas/create_alarm/create_alarm_sameName_sameInstance.json",'create_alarm_request', '','alarm_request') server = {'server': 'localhost:9092', 'topic': 'alarm_request'} _consumer = KafkaConsumer(bootstrap_servers=server['server']) @@ -111,14 +111,14 @@ class config_alarm_name_test(unittest.TestCase): info = json.loads(json.loads(message.value)) print info,"---" time.sleep(1) - producer.request("Unit Testing/delete_alarm/name_valid.json",'delete_alarm_request', '','alarm_request') + producer.request("test_schemas/delete_alarm/name_valid.json",'delete_alarm_request', '','alarm_request') self.assertEqual(info, None) return #To generate a request of testing valid statistics in create alarm request def test_statisticValid(self): time.sleep(2) - producer.request("Unit Testing/create_alarm/statistic_valid.json",'create_alarm_request', '','alarm_request') + producer.request("test_schemas/create_alarm/statistic_valid.json",'create_alarm_request', '','alarm_request') server = {'server': 'localhost:9092', 'topic': 'alarm_request'} _consumer = KafkaConsumer(bootstrap_servers=server['server']) @@ -129,14 +129,14 @@ class config_alarm_name_test(unittest.TestCase): info = json.loads(json.loads(message.value)) print info time.sleep(1) - producer.request("Unit Testing/delete_alarm/name_valid_delete3.json",'delete_alarm_request', '','alarm_request') + producer.request("test_schemas/delete_alarm/name_valid_delete3.json",'delete_alarm_request', '','alarm_request') self.assertTrue(info['alarm_create_response']['status']) return #To generate a request of testing Invalid statistics in create alarm request def test_statisticValidNot(self): time.sleep(2) - producer.request("Unit Testing/create_alarm/statistic_invalid.json",'create_alarm_request', '','alarm_request') + producer.request("test_schemas/create_alarm/statistic_invalid.json",'create_alarm_request', '','alarm_request') server = {'server': 'localhost:9092', 'topic': 'alarm_request'} _consumer = KafkaConsumer(bootstrap_servers=server['server']) @@ -147,14 +147,14 @@ class config_alarm_name_test(unittest.TestCase): info = json.loads(json.loads(message.value)) print info,"---" time.sleep(1) - producer.request("Unit Testing/delete_alarm/name_valid_delete3.json",'delete_alarm_request', '','alarm_request') + producer.request("test_schemas/delete_alarm/name_valid_delete3.json",'delete_alarm_request', '','alarm_request') self.assertEqual(info, None) return #To generate a request of testing valid operation in create alarm request def test_operationValid(self): time.sleep(2) - producer.request("Unit Testing/create_alarm/operation_valid.json",'create_alarm_request', '','alarm_request') + producer.request("test_schemas/create_alarm/operation_valid.json",'create_alarm_request', '','alarm_request') server = {'server': 'localhost:9092', 'topic': 'alarm_request'} _consumer = KafkaConsumer(bootstrap_servers=server['server']) @@ -165,14 +165,14 @@ class config_alarm_name_test(unittest.TestCase): info = json.loads(json.loads(message.value)) print info time.sleep(1) - producer.request("Unit Testing/delete_alarm/name_valid_delete3.json",'delete_alarm_request', '','alarm_request') + producer.request("test_schemas/delete_alarm/name_valid_delete3.json",'delete_alarm_request', '','alarm_request') self.assertTrue(info['alarm_create_response']['status']) return #To generate a request of testing Invalid operation in create alarm request def test_operationValidNot(self): time.sleep(2) - producer.request("Unit Testing/create_alarm/operation_invalid.json",'create_alarm_request', '','alarm_request') + producer.request("test_schemas/create_alarm/operation_invalid.json",'create_alarm_request', '','alarm_request') server = {'server': 'localhost:9092', 'topic': 'alarm_request'} _consumer = KafkaConsumer(bootstrap_servers=server['server']) @@ -192,9 +192,9 @@ class update_alarm_name_test(unittest.TestCase): #To generate a request of testing valid alarm_id in update alarm request def test_nameValid(self): - producer.request("Unit Testing/update_alarm/update_alarm_new_alarm.json",'create_alarm_request', '','alarm_request') + producer.request("test_schemas/update_alarm/update_alarm_new_alarm.json",'create_alarm_request', '','alarm_request') time.sleep(2) - producer.request("Unit Testing/update_alarm/name_valid.json",'update_alarm_request', '','alarm_request') + producer.request("test_schemas/update_alarm/name_valid.json",'update_alarm_request', '','alarm_request') server = {'server': 'localhost:9092', 'topic': 'alarm_request'} _consumer = KafkaConsumer(bootstrap_servers=server['server']) @@ -205,14 +205,14 @@ class update_alarm_name_test(unittest.TestCase): info = json.loads(json.loads(json.loads(message.value))) print info time.sleep(1) - producer.request("Unit Testing/delete_alarm/name_valid_delete4.json",'delete_alarm_request', '','alarm_request') + producer.request("test_schemas/delete_alarm/name_valid_delete4.json",'delete_alarm_request', '','alarm_request') self.assertTrue(info['alarm_update_response']['status']) return #To generate a request of testing invalid alarm_id in update alarm request def test_nameInvalid(self): time.sleep(2) - producer.request("Unit Testing/update_alarm/name_invalid.json",'update_alarm_request', '','alarm_request') + producer.request("test_schemas/update_alarm/name_invalid.json",'update_alarm_request', '','alarm_request') server = {'server': 'localhost:9092', 'topic': 'alarm_request'} _consumer = KafkaConsumer(bootstrap_servers=server['server']) @@ -228,9 +228,9 @@ class update_alarm_name_test(unittest.TestCase): #To generate a request of testing valid statistics in update alarm request def test_statisticValid(self): - producer.request("Unit Testing/create_alarm/create_alarm_differentName_differentInstance.json",'create_alarm_request', '','alarm_request') + producer.request("test_schemas/create_alarm/create_alarm_differentName_differentInstance.json",'create_alarm_request', '','alarm_request') time.sleep(2) - producer.request("Unit Testing/update_alarm/statistic_valid.json",'update_alarm_request', '','alarm_request') + producer.request("test_schemas/update_alarm/statistic_valid.json",'update_alarm_request', '','alarm_request') server = {'server': 'localhost:9092', 'topic': 'alarm_request'} _consumer = KafkaConsumer(bootstrap_servers=server['server']) @@ -241,14 +241,14 @@ class update_alarm_name_test(unittest.TestCase): info = json.loads(json.loads(json.loads(message.value))) print info time.sleep(1) - producer.request("Unit Testing/delete_alarm/name_valid.json",'delete_alarm_request', '','alarm_request') + producer.request("test_schemas/delete_alarm/name_valid.json",'delete_alarm_request', '','alarm_request') self.assertTrue(info['alarm_update_response']['status']) return #To generate a request of testing Invalid statistics in update alarm request def test_statisticInvalid(self): time.sleep(2) - producer.request("Unit Testing/update_alarm/statistic_invalid.json",'update_alarm_request', '','alarm_request') + producer.request("test_schemas/update_alarm/statistic_invalid.json",'update_alarm_request', '','alarm_request') server = {'server': 'localhost:9092', 'topic': 'alarm_request'} _consumer = KafkaConsumer(bootstrap_servers=server['server']) @@ -264,9 +264,9 @@ class update_alarm_name_test(unittest.TestCase): #To generate a request of testing valid operation in update alarm request def test_operationValid(self): - producer.request("Unit Testing/create_alarm/create_alarm_differentName_differentInstance.json",'create_alarm_request', '','alarm_request') + producer.request("test_schemas/create_alarm/create_alarm_differentName_differentInstance.json",'create_alarm_request', '','alarm_request') time.sleep(2) - producer.request("Unit Testing/update_alarm/operation_valid.json",'update_alarm_request', '','alarm_request') + producer.request("test_schemas/update_alarm/operation_valid.json",'update_alarm_request', '','alarm_request') server = {'server': 'localhost:9092', 'topic': 'alarm_request'} _consumer = KafkaConsumer(bootstrap_servers=server['server']) @@ -277,7 +277,7 @@ class update_alarm_name_test(unittest.TestCase): info = json.loads(json.loads(json.loads(message.value))) print info time.sleep(1) - producer.request("Unit Testing/delete_alarm/name_valid.json",'delete_alarm_request', '','alarm_request') + producer.request("test_schemas/delete_alarm/name_valid.json",'delete_alarm_request', '','alarm_request') self.assertTrue(info['alarm_update_response']['status']) return @@ -286,9 +286,9 @@ class delete_alarm_test(unittest.TestCase): #To generate a request of testing valid alarm_id in delete alarm request def test_nameValid(self): - producer.request("Unit Testing/create_alarm/create_alarm_differentName_differentInstance.json",'create_alarm_request', '','alarm_request') + producer.request("test_schemas/create_alarm/create_alarm_differentName_differentInstance.json",'create_alarm_request', '','alarm_request') time.sleep(2) - producer.request("Unit Testing/delete_alarm/name_valid.json",'delete_alarm_request', '','alarm_request') + producer.request("test_schemas/delete_alarm/name_valid.json",'delete_alarm_request', '','alarm_request') server = {'server': 'localhost:9092', 'topic': 'alarm_request'} _consumer = KafkaConsumer(bootstrap_servers=server['server']) @@ -305,7 +305,7 @@ class delete_alarm_test(unittest.TestCase): #To generate a request of testing Invalid alarm_id in delete alarm request def test_nameInvalid(self): time.sleep(2) - producer.request("Unit Testing/delete_alarm/name_invalid.json",'delete_alarm_request', '','alarm_request') + producer.request("test_schemas/delete_alarm/name_invalid.json",'delete_alarm_request', '','alarm_request') server = {'server': 'localhost:9092', 'topic': 'alarm_request'} _consumer = KafkaConsumer(bootstrap_servers=server['server']) @@ -325,7 +325,7 @@ class list_alarm_test(unittest.TestCase): #To generate a request of testing valid input fields in alarm list request def test_valid_no_arguments(self): time.sleep(2) - producer.request("Unit Testing/list_alarm/list_alarm_valid_no_arguments.json",'alarm_list_request', '','alarm_request') + producer.request("test_schemas/list_alarm/list_alarm_valid_no_arguments.json",'alarm_list_request', '','alarm_request') server = {'server': 'localhost:9092', 'topic': 'alarm_request'} _consumer = KafkaConsumer(bootstrap_servers=server['server']) @@ -342,7 +342,7 @@ class list_alarm_test(unittest.TestCase): #To generate a request of testing valid input fields in alarm list request def test_valid_one_arguments(self): time.sleep(2) - producer.request("Unit Testing/list_alarm/list_alarm_valid_one_arguments.json",'alarm_list_request', '','alarm_request') + producer.request("test_schemas/list_alarm/list_alarm_valid_one_arguments.json",'alarm_list_request', '','alarm_request') server = {'server': 'localhost:9092', 'topic': 'alarm_request'} _consumer = KafkaConsumer(bootstrap_servers=server['server']) @@ -359,7 +359,7 @@ class list_alarm_test(unittest.TestCase): #To generate a request of testing valid input fields in alarm list request def test_valid_two_arguments(self): time.sleep(2) - producer.request("Unit Testing/list_alarm/list_alarm_valid_two_arguments.json",'alarm_list_request', '','alarm_request') + producer.request("test_schemas/list_alarm/list_alarm_valid_two_arguments.json",'alarm_list_request', '','alarm_request') server = {'server': 'localhost:9092', 'topic': 'alarm_request'} _consumer = KafkaConsumer(bootstrap_servers=server['server']) @@ -380,7 +380,7 @@ class alarm_details_test(unittest.TestCase): #To generate a request of testing valid input fields in acknowledge alarm def test_Valid(self): time.sleep(2) - producer.request("Unit Testing/alarm_details/acknowledge_alarm.json",'acknowledge_alarm', '','alarm_request') + producer.request("test_schemas/alarm_details/acknowledge_alarm.json",'acknowledge_alarm', '','alarm_request') server = {'server': 'localhost:9092', 'topic': 'alarm_request'} _consumer = KafkaConsumer(bootstrap_servers=server['server']) diff --git a/plugins/CloudWatch/unit_tests_metrics.py b/test/CloudWatch/unit_tests_metrics.py similarity index 81% rename from plugins/CloudWatch/unit_tests_metrics.py rename to test/CloudWatch/unit_tests_metrics.py index eefc60a..625e872 100644 --- a/plugins/CloudWatch/unit_tests_metrics.py +++ b/test/CloudWatch/unit_tests_metrics.py @@ -6,8 +6,8 @@ import json import os import time from jsmin import jsmin -sys.path.append("../../core/message_bus") -from test_producer_AWS import KafkaProducer +sys.path.append("../../test/core/") +from test_producer import KafkaProducer from kafka import KafkaConsumer try: import boto @@ -36,7 +36,7 @@ _consumer.subscribe(['metric_response']) #-------------------------------------------------------------------------------------------------------------------------------------- '''Test E2E Flow : Test cases has been tested one at a time. -1) Commom Request is generated using request function in test_producer_AWS.py(/core/message-bus) +1) Commom Request is generated using request function in test_producer.py(/core/message-bus) 2) The request is then consumed by the comsumer (plugin) 3) The response is sent back on the message bus in plugin_metrics.py using response functions in producer.py(/core/message-bus) @@ -48,7 +48,7 @@ class test_create_metrics(unittest.TestCase): def test_status_positive(self): time.sleep(2) # To generate Request of testing valid meric_name in create metrics requests - producer.request("Unit Testing/create metrics/create_metric_req_valid.json",'create_metric_request', '','metric_request') + producer.request("create_metrics/create_metric_req_valid.json",'create_metric_request', '','metric_request') for message in _consumer: if message.key == "create_metric_response": @@ -61,7 +61,7 @@ class test_create_metrics(unittest.TestCase): def test_status_negative(self): time.sleep(2) # To generate Request of testing invalid meric_name in create metrics requests - producer.request("Unit Testing/create metrics/create_metric_req_invalid.json",'create_metric_request', '','metric_request') + producer.request("create_metrics/create_metric_req_invalid.json",'create_metric_request', '','metric_request') for message in _consumer: if message.key == "create_metric_response": @@ -76,7 +76,7 @@ class test_metrics_data(unittest.TestCase): def test_met_name_positive(self): time.sleep(2) # To generate Request of testing valid meric_name in read_metric_data_request - producer.request("Unit Testing/Read metrics data/read_metric_name_req_valid.json",'read_metric_data_request', '','metric_request') + producer.request("read_metrics_data/read_metric_name_req_valid.json",'read_metric_data_request', '','metric_request') for message in _consumer: if message.key == "read_metric_data_response": resp = json.loads(json.loads(json.loads(message.value))) @@ -87,7 +87,7 @@ class test_metrics_data(unittest.TestCase): def test_met_name_negative(self): time.sleep(2) # To generate Request of testing invalid meric_name in read_metric_data_request - producer.request("Unit Testing/Read metrics data/read_metric_name_req_invalid.json",'read_metric_data_request', '','metric_request') + producer.request("read_metrics_data/read_metric_name_req_invalid.json",'read_metric_data_request', '','metric_request') for message in _consumer: if message.key == "read_metric_data_response": resp = json.loads(json.loads(json.loads(message.value))) @@ -99,7 +99,7 @@ class test_metrics_data(unittest.TestCase): # To generate Request of testing valid collection_period in read_metric_data_request # For AWS metric_data_stats collection period should be a multiple of 60 time.sleep(2) - producer.request("Unit Testing/Read metrics data/read_coll_period_req_valid.json",'read_metric_data_request', '','metric_request') + producer.request("read_metrics_data/read_coll_period_req_valid.json",'read_metric_data_request', '','metric_request') for message in _consumer: if message.key == "read_metric_data_response": resp = json.loads(json.loads(json.loads(message.value))) @@ -110,7 +110,7 @@ class test_metrics_data(unittest.TestCase): def test_coll_period_negative(self): time.sleep(2) # To generate Request of testing invalid collection_period in read_metric_data_request - producer.request("Unit Testing/Read metrics data/read_coll_period_req_invalid.json",'read_metric_data_request', '','metric_request') + producer.request("read_metrics_data/read_coll_period_req_invalid.json",'read_metric_data_request', '','metric_request') for message in _consumer: if message.key == "read_metric_data_response": resp = json.loads(json.loads(json.loads(message.value))) @@ -123,7 +123,7 @@ class test_update_metrics(unittest.TestCase): def test_upd_status_positive(self): time.sleep(2) # To generate Request of testing valid meric_name in update metrics requests - producer.request("Unit Testing/Update metrics/update_metric_req_valid.json",'update_metric_request', '','metric_request') + producer.request("update_metrics/update_metric_req_valid.json",'update_metric_request', '','metric_request') for message in _consumer: if message.key == "update_metric_response": resp = json.loads(json.loads(json.loads(message.value))) @@ -135,7 +135,7 @@ class test_update_metrics(unittest.TestCase): def test_upd_status_negative(self): time.sleep(2) # To generate Request of testing invalid meric_name in update metrics requests - producer.request("Unit Testing/Update metrics/update_metric_req_invalid.json",'update_metric_request', '','metric_request') + producer.request("update_metrics/update_metric_req_invalid.json",'update_metric_request', '','metric_request') for message in _consumer: if message.key == "update_metric_response": resp = json.loads(json.loads(json.loads(message.value))) @@ -149,7 +149,7 @@ class test_delete_metrics(unittest.TestCase): def test_del_met_name_positive(self): time.sleep(2) # To generate Request of testing valid meric_name in delete metrics requests - producer.request("Unit Testing/Delete metrics/delete_metric_req_valid.json",'delete_metric_request', '','metric_request') + producer.request("delete_metrics/delete_metric_req_valid.json",'delete_metric_request', '','metric_request') for message in _consumer: if message.key == "delete_metric_response": resp = json.loads(json.loads(json.loads(message.value))) @@ -160,7 +160,7 @@ class test_delete_metrics(unittest.TestCase): def test_del_met_name_negative(self): time.sleep(2) # To generate Request of testing invalid meric_name in delete metrics requests - producer.request("Unit Testing/Delete metrics/delete_metric_req_invalid.json",'delete_metric_request', '','metric_request') + producer.request("delete_metrics/delete_metric_req_invalid.json",'delete_metric_request', '','metric_request') for message in _consumer: if message.key == "delete_metric_response": resp = json.loads(json.loads(json.loads(message.value))) @@ -173,7 +173,7 @@ class test_list_metrics(unittest.TestCase): def test_list_met_name_positive(self): time.sleep(2) # To generate Request of testing valid meric_name in list metrics requests - producer.request("Unit Testing/List metrics/list_metric_req_valid.json",'list_metric_request', '','metric_request') + producer.request("list_metrics/list_metric_req_valid.json",'list_metric_request', '','metric_request') for message in _consumer: if message.key == "list_metrics_response": resp = json.loads(json.loads(json.loads(message.value))) @@ -184,7 +184,7 @@ class test_list_metrics(unittest.TestCase): def test_list_met_name_negitive(self): time.sleep(2) # To generate Request of testing invalid meric_name in list metrics requests - producer.request("Unit Testing/List metrics/list_metric_req_invalid.json",'list_metric_request', '','metric_request') + producer.request("list_metrics/list_metric_req_invalid.json",'list_metric_request', '','metric_request') for message in _consumer: if message.key == "list_metrics_response": resp = json.loads(json.loads(json.loads(message.value))) diff --git a/core/message_bus/test_producer_AWS.py b/test/core/test_producer.py similarity index 93% rename from core/message_bus/test_producer_AWS.py rename to test/core/test_producer.py index c369b79..fa2881b 100644 --- a/core/message_bus/test_producer_AWS.py +++ b/test/core/test_producer.py @@ -21,8 +21,7 @@ ## ''' -This is a kafka producer app that interacts with the SO and the plugins of the -datacenters like OpenStack, VMWare, AWS. +This is a kafka producer with a common request function to test the plugins. ''' @@ -33,9 +32,10 @@ import logging as log import json import jsmin import os +import sys from os import listdir from jsmin import jsmin - +import os.path as path @@ -77,7 +77,7 @@ class KafkaProducer(object): except KafkaError: pass - json_path = os.path.join(os.pardir+"/models/") + json_path = path.abspath(path.join(os.getcwd(),"../..")) def request(self, path, key, message, topic): #External to MON @@ -86,4 +86,4 @@ class KafkaProducer(object): value = json.loads(payload_create_alarm), topic=topic) - \ No newline at end of file + -- 2.25.1