From 4ed023a3e15cfb7029ee612e21252cabdc1974d2 Mon Sep 17 00:00:00 2001 From: rexlee8776 Date: Tue, 22 Jan 2019 03:34:30 +0000 Subject: [dovetail] split the sla check results into process recovery and service recovery for HA tcs make sla check for process recovery optional: only check when sla is set. JIRA: YARDSTICK-1512 Change-Id: I717d39614a1af2ee9e62dec3b8a32d7d611f557e Signed-off-by: rexlee8776 (cherry picked from commit 39d89761aca4aaf724010a9f8cac73725b798b33) --- tests/opnfv/test_cases/opnfv_yardstick_tc019.yaml | 2 -- tests/opnfv/test_cases/opnfv_yardstick_tc045.yaml | 2 -- tests/opnfv/test_cases/opnfv_yardstick_tc046.yaml | 2 -- tests/opnfv/test_cases/opnfv_yardstick_tc047.yaml | 2 -- tests/opnfv/test_cases/opnfv_yardstick_tc048.yaml | 2 -- tests/opnfv/test_cases/opnfv_yardstick_tc053.yaml | 2 -- tests/opnfv/test_cases/opnfv_yardstick_tc056.yaml | 2 -- tests/opnfv/test_cases/opnfv_yardstick_tc058.yaml | 2 -- tests/opnfv/test_cases/opnfv_yardstick_tc088.yaml | 2 -- tests/opnfv/test_cases/opnfv_yardstick_tc089.yaml | 2 -- tests/opnfv/test_cases/opnfv_yardstick_tc090.yaml | 2 -- tests/opnfv/test_cases/opnfv_yardstick_tc091.yaml | 2 -- .../availability/monitor/monitor_multi.py | 27 +++++++++++----------- .../availability/monitor/monitor_process.py | 12 +++++----- .../scenarios/availability/test_monitor_multi.py | 17 ++++++++++++++ .../scenarios/availability/test_monitor_process.py | 16 +++++++++++++ 16 files changed, 52 insertions(+), 44 deletions(-) diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc019.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc019.yaml index 08037d9fa..1ed3a3ea6 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc019.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc019.yaml @@ -40,8 +40,6 @@ scenarios: host: {{attack_host}} monitor_time: 30 monitor_number: 3 - sla: - max_recover_time: 30 nodes: {{attack_host}}: {{attack_host}}.LF diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc045.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc045.yaml index bc7cd3d28..b23855dc1 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc045.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc045.yaml @@ -38,8 +38,6 @@ scenarios: host: {{attack_host}} monitor_time: 30 monitor_number: 3 - sla: - max_recover_time: 30 nodes: {{attack_host}}: {{attack_host}}.LF diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc046.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc046.yaml index 3b04cc4bd..5bbe72610 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc046.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc046.yaml @@ -38,8 +38,6 @@ scenarios: host: {{attack_host}} monitor_time: 30 monitor_number: 3 - sla: - max_recover_time: 30 nodes: {{attack_host}}: {{attack_host}}.LF diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc047.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc047.yaml index d199e5117..a8783d6e8 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc047.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc047.yaml @@ -38,8 +38,6 @@ scenarios: host: {{attack_host}} monitor_time: 30 monitor_number: 3 - sla: - max_recover_time: 30 nodes: {{attack_host}}: {{attack_host}}.LF diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc048.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc048.yaml index 2bca1fb9d..6a4dc8798 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc048.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc048.yaml @@ -38,8 +38,6 @@ scenarios: host: {{attack_host}} monitor_time: 30 monitor_number: 3 - sla: - max_recover_time: 30 nodes: {{attack_host}}: {{attack_host}}.LF diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc053.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc053.yaml index c2a4f9ede..7b5f77813 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc053.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc053.yaml @@ -36,8 +36,6 @@ scenarios: host: {{attack_host}} monitor_time: 30 monitor_number: 3 - sla: - max_recover_time: 30 - monitor_type: "openstack-cmd" diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc056.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc056.yaml index 9194d9d4e..41314be27 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc056.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc056.yaml @@ -61,8 +61,6 @@ scenarios: process_name: "{{ attack_process }}" host: {{attack_host}} monitor_time: 30 - sla: - max_recover_time: 30 nodes: {{attack_host}}: {{attack_host}}.LF diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc058.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc058.yaml index 06d460032..effb20a48 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc058.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc058.yaml @@ -37,8 +37,6 @@ scenarios: host: {{attack_host}} key: "monitor-recovery" monitor_time: 30 - sla: - max_recover_time: 30 - monitor_type: "general-monitor" diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc088.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc088.yaml index c2f1cbe33..c1b065711 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc088.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc088.yaml @@ -38,8 +38,6 @@ scenarios: host: {{attack_host}} monitor_time: 30 monitor_number: 3 - sla: - max_recover_time: 30 operations: - diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc089.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc089.yaml index d10650e03..9379d2f75 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc089.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc089.yaml @@ -38,8 +38,6 @@ scenarios: host: {{attack_host}} monitor_time: 30 monitor_number: 3 - sla: - max_recover_time: 30 operations: - diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc090.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc090.yaml index 41372045d..eaf14f60e 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc090.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc090.yaml @@ -57,8 +57,6 @@ scenarios: host: {{attack_host}} monitor_time: {{monitor_time}} monitor_number: 3 - sla: - max_recover_time: 30 nodes: {{attack_host}}: {{attack_host}}.LF diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc091.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc091.yaml index d952464a1..54ef6f237 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc091.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc091.yaml @@ -38,8 +38,6 @@ scenarios: host: {{attack_host}} monitor_time: 30 monitor_number: 3 - sla: - max_recover_time: 30 nodes: {{attack_host}}: {{attack_host}}.LF diff --git a/yardstick/benchmark/scenarios/availability/monitor/monitor_multi.py b/yardstick/benchmark/scenarios/availability/monitor/monitor_multi.py index 971bae1e9..8f1f53cde 100644 --- a/yardstick/benchmark/scenarios/availability/monitor/monitor_multi.py +++ b/yardstick/benchmark/scenarios/availability/monitor/monitor_multi.py @@ -62,20 +62,19 @@ class MultiMonitor(basemonitor.BaseMonitor): outage_time = ( last_outage - first_outage if last_outage > first_outage else 0 ) + self._result = {"outage_time": outage_time} LOG.debug("outage_time is: %f", outage_time) max_outage_time = 0 - if "max_outage_time" in self._config["sla"]: - max_outage_time = self._config["sla"]["max_outage_time"] - elif "max_recover_time" in self._config["sla"]: - max_outage_time = self._config["sla"]["max_recover_time"] - else: - raise RuntimeError("'max_outage_time' or 'max_recover_time' " - "config is not found") - self._result = {"outage_time": outage_time} - - if outage_time > max_outage_time: - LOG.error("SLA failure: %f > %f", outage_time, max_outage_time) - return False - else: - return True + if self._config.get("sla"): + if "max_outage_time" in self._config["sla"]: + max_outage_time = self._config["sla"]["max_outage_time"] + elif "max_recover_time" in self._config["sla"]: + max_outage_time = self._config["sla"]["max_recover_time"] + else: + raise RuntimeError("'max_outage_time' or 'max_recover_time' " + "config is not found") + if outage_time > max_outage_time: + LOG.error("SLA failure: %f > %f", outage_time, max_outage_time) + return False + return True diff --git a/yardstick/benchmark/scenarios/availability/monitor/monitor_process.py b/yardstick/benchmark/scenarios/availability/monitor/monitor_process.py index 8d2f2633c..280e5811d 100644 --- a/yardstick/benchmark/scenarios/availability/monitor/monitor_process.py +++ b/yardstick/benchmark/scenarios/availability/monitor/monitor_process.py @@ -46,12 +46,12 @@ class MonitorProcess(basemonitor.BaseMonitor): def verify_SLA(self): outage_time = self._result.get('outage_time', None) - max_outage_time = self._config["sla"]["max_recover_time"] - if outage_time > max_outage_time: - LOG.info("SLA failure: %f > %f", outage_time, max_outage_time) - return False - else: - return True + if self._config.get("sla"): + max_outage_time = self._config["sla"]["max_recover_time"] + if outage_time > max_outage_time: + LOG.info("SLA failure: %f > %f", outage_time, max_outage_time) + return False + return True def _test(): # pragma: no cover diff --git a/yardstick/tests/unit/benchmark/scenarios/availability/test_monitor_multi.py b/yardstick/tests/unit/benchmark/scenarios/availability/test_monitor_multi.py index e9c680257..dc3a4b99a 100644 --- a/yardstick/tests/unit/benchmark/scenarios/availability/test_monitor_multi.py +++ b/yardstick/tests/unit/benchmark/scenarios/availability/test_monitor_multi.py @@ -63,3 +63,20 @@ class MultiMonitorServiceTestCase(unittest.TestCase): ins.start_monitor() ins.wait_monitor() ins.verify_SLA() + + def test__monitor_multi_no_sla(self, mock_open, mock_ssh): + monitor_cfg = { + 'monitor_type': 'general-monitor', + 'monitor_number': 3, + 'key': 'service-status', + 'monitor_key': 'service-status', + 'host': 'node1', + 'monitor_time': 0.1, + 'parameter': {'serviceName': 'haproxy'} + } + ins = monitor_multi.MultiMonitor( + monitor_cfg, self.context, {"nova-api": 10}) + mock_ssh.SSH.from_node().execute.return_value = (0, "running", '') + ins.start_monitor() + ins.wait_monitor() + self.assertTrue(ins.verify_SLA()) diff --git a/yardstick/tests/unit/benchmark/scenarios/availability/test_monitor_process.py b/yardstick/tests/unit/benchmark/scenarios/availability/test_monitor_process.py index a6d2ca398..8c73bf221 100644 --- a/yardstick/tests/unit/benchmark/scenarios/availability/test_monitor_process.py +++ b/yardstick/tests/unit/benchmark/scenarios/availability/test_monitor_process.py @@ -55,3 +55,19 @@ class MonitorProcessTestCase(unittest.TestCase): ins.monitor_func() ins._result = {"outage_time": 10} ins.verify_SLA() + + def test__monitor_process_no_sla(self, mock_ssh): + + monitor_cfg = { + 'monitor_type': 'process', + 'process_name': 'nova-api', + 'host': "node1", + 'monitor_time': 1, + } + ins = monitor_process.MonitorProcess(monitor_cfg, self.context, {"nova-api": 10}) + + mock_ssh.SSH.from_node().execute.return_value = (0, "0", '') + ins.setup() + ins.monitor_func() + ins._result = {"outage_time": 10} + self.assertTrue(ins.verify_SLA()) -- cgit 1.2.3-korg