From f41d7301d4c736fb8b3e734cad72107d9154e59f Mon Sep 17 00:00:00 2001 From: rexlee8776 Date: Sat, 26 Aug 2017 01:37:10 +0000 Subject: 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 --- .../scenarios/availability/test_basemonitor.py | 45 ++++++++++++++++++---- 1 file changed, 37 insertions(+), 8 deletions(-) (limited to 'tests/unit') 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() -- cgit 1.2.3-korg