From 4416de1c9638f58ba74e636ddac4498699d6ab72 Mon Sep 17 00:00:00 2001 From: tjuyinkanglin <14_ykl@tongji.edu.cn> Date: Mon, 25 Jul 2016 12:24:18 +0800 Subject: Code Clean for HA Testing Framework JIRA: YARDSTICK-272 Change-Id: Icf41642fe0c31584f92c68cc9f97fa3f1e90b66e Signed-off-by: tjuyinkanglin <14_ykl@tongji.edu.cn> --- tests/unit/benchmark/scenarios/availability/test_attacker_general.py | 1 + tests/unit/benchmark/scenarios/availability/test_monitor_general.py | 2 ++ tests/unit/benchmark/scenarios/availability/test_operation_general.py | 2 ++ .../benchmark/scenarios/availability/test_result_checker_general.py | 1 + .../benchmark/scenarios/availability/attacker/attacker_general.py | 3 ++- yardstick/benchmark/scenarios/availability/monitor/monitor_general.py | 4 +++- .../benchmark/scenarios/availability/operation/operation_general.py | 4 +++- .../scenarios/availability/result_checker/result_checker_general.py | 3 ++- 8 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/unit/benchmark/scenarios/availability/test_attacker_general.py b/tests/unit/benchmark/scenarios/availability/test_attacker_general.py index 643c1e7ac..aa2e0cc4d 100644 --- a/tests/unit/benchmark/scenarios/availability/test_attacker_general.py +++ b/tests/unit/benchmark/scenarios/availability/test_attacker_general.py @@ -33,6 +33,7 @@ class GeneralAttackerServiceTestCase(unittest.TestCase): 'action_parameter':{'process_name':'nova_api'}, 'rollback_parameter':{'process_name':'nova_api'}, 'key':'stop-service', + 'attack_key':'stop-service', 'host': 'node1', } diff --git a/tests/unit/benchmark/scenarios/availability/test_monitor_general.py b/tests/unit/benchmark/scenarios/availability/test_monitor_general.py index b48434c99..de7d26cbf 100644 --- a/tests/unit/benchmark/scenarios/availability/test_monitor_general.py +++ b/tests/unit/benchmark/scenarios/availability/test_monitor_general.py @@ -32,6 +32,7 @@ class GeneralMonitorServiceTestCase(unittest.TestCase): self.monitor_cfg = { 'monitor_type': 'general-monitor', 'key': 'service-status', + 'monitor_key': 'service-status', 'host': 'node1', 'monitor_time': 3, 'parameter': {'serviceName': 'haproxy'}, @@ -40,6 +41,7 @@ class GeneralMonitorServiceTestCase(unittest.TestCase): self.monitor_cfg_noparam = { 'monitor_type': 'general-monitor', 'key': 'service-status', + 'monitor_key': 'service-status', 'host': 'node1', 'monitor_time': 3, 'sla': {'max_outage_time': 1} diff --git a/tests/unit/benchmark/scenarios/availability/test_operation_general.py b/tests/unit/benchmark/scenarios/availability/test_operation_general.py index 6713733a8..26cd3f7c4 100644 --- a/tests/unit/benchmark/scenarios/availability/test_operation_general.py +++ b/tests/unit/benchmark/scenarios/availability/test_operation_general.py @@ -34,11 +34,13 @@ class GeneralOperaionTestCase(unittest.TestCase): 'action_parameter': {'ins_cup': 2}, 'rollback_parameter': {'ins_id': 'id123456'}, 'key': 'nova-create-instance', + 'operation_key': 'nova-create-instance', 'host': 'node1', } self.operation_cfg_noparam = { 'operation_type': 'general-operation', 'key': 'nova-create-instance', + 'operation_key': 'nova-create-instance', 'host': 'node1', } diff --git a/tests/unit/benchmark/scenarios/availability/test_result_checker_general.py b/tests/unit/benchmark/scenarios/availability/test_result_checker_general.py index 88a9b9d20..bbadf0ac3 100644 --- a/tests/unit/benchmark/scenarios/availability/test_result_checker_general.py +++ b/tests/unit/benchmark/scenarios/availability/test_result_checker_general.py @@ -38,6 +38,7 @@ class GeneralResultCheckerTestCase(unittest.TestCase): 'condition' : 'eq', 'expectedValue' : 1, 'key' : 'process-checker', + 'checker_key' : 'process-checker', 'host': 'node1' } diff --git a/yardstick/benchmark/scenarios/availability/attacker/attacker_general.py b/yardstick/benchmark/scenarios/availability/attacker/attacker_general.py index 018362a15..816e7e37d 100644 --- a/yardstick/benchmark/scenarios/availability/attacker/attacker_general.py +++ b/yardstick/benchmark/scenarios/availability/attacker/attacker_general.py @@ -31,6 +31,7 @@ class GeneralAttacker(BaseAttacker): LOG.debug("ssh host success!") self.key = self._config['key'] + self.attack_key = self._config['attack_key'] if "action_parameter" in self._config: actionParameter = self._config['action_parameter'] @@ -50,7 +51,7 @@ class GeneralAttacker(BaseAttacker): l = list(item for item in rollbackParameter.values()) self.rollback_param = str.format(*l) - self.fault_cfg = BaseAttacker.attacker_cfgs.get(self.key) + self.fault_cfg = BaseAttacker.attacker_cfgs.get(self.attack_key) self.inject_script = self.get_script_fullpath( self.fault_cfg['inject_script']) self.recovery_script = self.get_script_fullpath( diff --git a/yardstick/benchmark/scenarios/availability/monitor/monitor_general.py b/yardstick/benchmark/scenarios/availability/monitor/monitor_general.py index e7e4d5bce..61efc0520 100644 --- a/yardstick/benchmark/scenarios/availability/monitor/monitor_general.py +++ b/yardstick/benchmark/scenarios/availability/monitor/monitor_general.py @@ -27,6 +27,7 @@ class GeneralMonitor(basemonitor.BaseMonitor): user = host.get("user", "root") key_filename = host.get("key_filename", "~/.ssh/id_rsa") self.key = self._config["key"] + self.monitor_key = self._config["monitor_key"] self.monitor_type = self._config["monitor_type"] if "parameter" in self._config: @@ -35,7 +36,8 @@ class GeneralMonitor(basemonitor.BaseMonitor): l = list(item for item in parameter.values()) self.cmd_param = str.format(*l) - self.monitor_cfg = basemonitor.BaseMonitor.monitor_cfgs.get(self.key) + self.monitor_cfg = basemonitor.BaseMonitor.monitor_cfgs.get( + self.monitor_key) self.monitor_script = self.get_script_fullpath( self.monitor_cfg['monitor_script']) self.connection = ssh.SSH(user, ip, key_filename=key_filename) diff --git a/yardstick/benchmark/scenarios/availability/operation/operation_general.py b/yardstick/benchmark/scenarios/availability/operation/operation_general.py index d41371629..e43f6e1d5 100644 --- a/yardstick/benchmark/scenarios/availability/operation/operation_general.py +++ b/yardstick/benchmark/scenarios/availability/operation/operation_general.py @@ -30,6 +30,7 @@ class GeneralOperaion(BaseOperation): LOG.debug("ssh host success!") self.key = self._config['key'] + self.operation_key = self._config['operation_key'] if "action_parameter" in self._config: actionParameter = self._config['action_parameter'] @@ -43,7 +44,8 @@ class GeneralOperaion(BaseOperation): l = list(item for item in rollbackParameter.values()) self.rollback_param = str.format(*l) - self.operation_cfgs = BaseOperation.operation_cfgs.get(self.key) + self.operation_cfgs = BaseOperation.operation_cfgs.get( + self.operation_key) self.action_script = self.get_script_fullpath( self.operation_cfgs['action_script']) self.rollback_script = self.get_script_fullpath( diff --git a/yardstick/benchmark/scenarios/availability/result_checker/result_checker_general.py b/yardstick/benchmark/scenarios/availability/result_checker/result_checker_general.py index 70bf9aea6..681fbf63f 100644 --- a/yardstick/benchmark/scenarios/availability/result_checker/result_checker_general.py +++ b/yardstick/benchmark/scenarios/availability/result_checker/result_checker_general.py @@ -32,6 +32,7 @@ class GeneralResultChecker(BaseResultChecker): LOG.debug("ssh host success!") self.key = self._config['key'] + self.resultchecker_key = self._config['checker_key'] self.type = self._config['checker_type'] self.condition = self._config['condition'] self.expectedResult = self._config['expectedValue'] @@ -45,7 +46,7 @@ class GeneralResultChecker(BaseResultChecker): self.shell_cmd = str.format(*l) self.resultchecker_cfgs = BaseResultChecker.resultchecker_cfgs.get( - self.key) + self.resultchecker_key) self.verify_script = self.get_script_fullpath( self.resultchecker_cfgs['verify_script']) -- cgit 1.2.3-korg