Merge "[dovetail] split the sla check results into process recovery and service recov...
authorRex Lee <limingjiang@huawei.com>
Thu, 24 Jan 2019 01:40:54 +0000 (01:40 +0000)
committerGerrit Code Review <gerrit@opnfv.org>
Thu, 24 Jan 2019 01:40:54 +0000 (01:40 +0000)
16 files changed:
tests/opnfv/test_cases/opnfv_yardstick_tc019.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc045.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc046.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc047.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc048.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc053.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc056.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc058.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc088.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc089.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc090.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc091.yaml
yardstick/benchmark/scenarios/availability/monitor/monitor_multi.py
yardstick/benchmark/scenarios/availability/monitor/monitor_process.py
yardstick/tests/unit/benchmark/scenarios/availability/test_monitor_multi.py
yardstick/tests/unit/benchmark/scenarios/availability/test_monitor_process.py

index 08037d9..1ed3a3e 100644 (file)
@@ -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
index bc7cd3d..b23855d 100644 (file)
@@ -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
index 3b04cc4..5bbe726 100644 (file)
@@ -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
index d199e51..a8783d6 100644 (file)
@@ -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
index 2bca1fb..6a4dc87 100644 (file)
@@ -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
index c2a4f9e..7b5f778 100644 (file)
@@ -36,8 +36,6 @@ scenarios:
           host: {{attack_host}}
           monitor_time: 30
           monitor_number: 3
-          sla:
-            max_recover_time: 30
 
         -
           monitor_type: "openstack-cmd"
index 9194d9d..41314be 100644 (file)
@@ -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
index 06d4600..effb20a 100644 (file)
@@ -37,8 +37,6 @@ scenarios:
           host: {{attack_host}}
           key: "monitor-recovery"
           monitor_time: 30
-          sla:
-            max_recover_time: 30
 
         -
           monitor_type: "general-monitor"
index c2f1cbe..c1b0657 100644 (file)
@@ -38,8 +38,6 @@ scenarios:
           host: {{attack_host}}
           monitor_time: 30
           monitor_number: 3
-          sla:
-            max_recover_time: 30
 
       operations:
         -
index d10650e..9379d2f 100644 (file)
@@ -38,8 +38,6 @@ scenarios:
           host: {{attack_host}}
           monitor_time: 30
           monitor_number: 3
-          sla:
-            max_recover_time: 30
 
       operations:
         -
index 4137204..eaf14f6 100644 (file)
@@ -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
index d952464..54ef6f2 100644 (file)
@@ -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
index 971bae1..8f1f53c 100644 (file)
@@ -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
index 8d2f263..280e581 100644 (file)
@@ -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
index e9c6802..dc3a4b9 100644 (file)
@@ -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())
index a6d2ca3..8c73bf2 100644 (file)
@@ -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())