summaryrefslogtreecommitdiffstats
path: root/tests/unit/benchmark/scenarios/availability/test_basemonitor.py
diff options
context:
space:
mode:
authorrexlee8776 <limingjiang@huawei.com>2017-08-26 01:37:10 +0000
committerrexlee8776 <limingjiang@huawei.com>2017-09-01 02:06:59 +0000
commitf41d7301d4c736fb8b3e734cad72107d9154e59f (patch)
tree24fd8d9fd86f440e4ca61e9a2309bb4d3ba4585e /tests/unit/benchmark/scenarios/availability/test_basemonitor.py
parent952ccb549c08b620a35f20ae809e0cea88ae4d99 (diff)
Bugfix: ha test case criteria pass when sla not pass
ha test cases didn't store moniter info and report fail when sla didn't pass Change-Id: I0e5637e37a66e1bf03b47fe09d17e0a1acfa11c1 Signed-off-by: rexlee8776 <limingjiang@huawei.com>
Diffstat (limited to 'tests/unit/benchmark/scenarios/availability/test_basemonitor.py')
-rw-r--r--tests/unit/benchmark/scenarios/availability/test_basemonitor.py45
1 files changed, 37 insertions, 8 deletions
diff --git a/tests/unit/benchmark/scenarios/availability/test_basemonitor.py b/tests/unit/benchmark/scenarios/availability/test_basemonitor.py
index 3b7e07376..92ae8aa88 100644
--- a/tests/unit/benchmark/scenarios/availability/test_basemonitor.py
+++ b/tests/unit/benchmark/scenarios/availability/test_basemonitor.py
@@ -25,13 +25,32 @@ from yardstick.benchmark.scenarios.availability.monitor import basemonitor
class MonitorMgrTestCase(unittest.TestCase):
def setUp(self):
- config = {
- 'monitor_type': 'openstack-api',
- 'key': 'service-status'
- }
-
- self.monitor_configs = []
- self.monitor_configs.append(config)
+ self.monitor_configs = [
+ {
+ "monitor_type": "openstack-cmd",
+ "command_name": "openstack router list",
+ "monitor_time": 10,
+ "monitor_number": 3,
+ "sla": {
+ "max_outage_time": 5
+ }
+ },
+ {
+ "monitor_type": "process",
+ "process_name": "neutron-server",
+ "host": "node1",
+ "monitor_time": 20,
+ "monitor_number": 3,
+ "sla": {
+ "max_recover_time": 20
+ }
+ }
+ ]
+ self.MonitorMgr = basemonitor.MonitorMgr([])
+ self.MonitorMgr.init_monitors(self.monitor_configs, None)
+ self.monitor_list = self.MonitorMgr._monitor_list
+ for mo in self.monitor_list:
+ mo._result = {"outage_time": 10}
def test__MonitorMgr_setup_successful(self, mock_monitor):
instance = basemonitor.MonitorMgr({"nova-api": 10})
@@ -44,7 +63,13 @@ class MonitorMgrTestCase(unittest.TestCase):
def test_MonitorMgr_getitem(self, mock_monitor):
monitorMgr = basemonitor.MonitorMgr({"nova-api": 10})
monitorMgr.init_monitors(self.monitor_configs, None)
- monitorIns = monitorMgr['service-status']
+
+ def test_store_result(self, mock_monitor):
+ expect = {'process_neutron-server_outage_time': 10,
+ 'openstack-router-list_outage_time': 10}
+ result = {}
+ self.MonitorMgr.store_result(result)
+ self.assertDictEqual(result, expect)
class BaseMonitorTestCase(unittest.TestCase):
@@ -94,3 +119,7 @@ class BaseMonitorTestCase(unittest.TestCase):
except Exception:
pass
self.assertIsNone(cls)
+
+
+if __name__ == "__main__":
+ unittest.main()