summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJing Lu <lvjing5@huawei.com>2018-06-28 07:36:33 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-06-28 07:36:33 +0000
commit441d5f55a6e2e155d01d4b396678d0d09bfb8413 (patch)
tree98178f047f6ed9e739c3e003d6c437a6eeba915e
parent405385acf890856390eb321cd1fc96c19ebfda0d (diff)
parentc9a9dcae22045cb0392f8445d9d4e00753f934b5 (diff)
Merge "Bugfix: HA kill process recovery has a conflict" into stable/fraser
-rwxr-xr-xyardstick/benchmark/scenarios/availability/serviceha.py15
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/availability/test_serviceha.py22
2 files changed, 31 insertions, 6 deletions
diff --git a/yardstick/benchmark/scenarios/availability/serviceha.py b/yardstick/benchmark/scenarios/availability/serviceha.py
index b6e840143..ee2eeb007 100755
--- a/yardstick/benchmark/scenarios/availability/serviceha.py
+++ b/yardstick/benchmark/scenarios/availability/serviceha.py
@@ -29,6 +29,7 @@ class ServiceHA(base.Scenario):
self.context_cfg = context_cfg
self.setup_done = False
self.data = {}
+ self.sla_pass = False
def setup(self):
"""scenario setup"""
@@ -69,23 +70,25 @@ class ServiceHA(base.Scenario):
self.monitorMgr.wait_monitors()
LOG.info("Monitor '%s' stop!", self.__scenario_type__)
- sla_pass = self.monitorMgr.verify_SLA()
+ self.sla_pass = self.monitorMgr.verify_SLA()
for k, v in self.data.items():
if v == 0:
- sla_pass = False
+ self.sla_pass = False
LOG.info("The service process (%s) not found in the host environment", k)
- result['sla_pass'] = 1 if sla_pass else 0
+ result['sla_pass'] = 1 if self.sla_pass else 0
self.monitorMgr.store_result(result)
- assert sla_pass is True, "The HA test case NOT pass the SLA"
+ assert self.sla_pass is True, "The HA test case NOT pass the SLA"
return
def teardown(self):
"""scenario teardown"""
- for attacker in self.attackers:
- attacker.recover()
+ # only recover when sla not pass
+ if not self.sla_pass:
+ for attacker in self.attackers:
+ attacker.recover()
def _test(): # pragma: no cover
diff --git a/yardstick/tests/unit/benchmark/scenarios/availability/test_serviceha.py b/yardstick/tests/unit/benchmark/scenarios/availability/test_serviceha.py
index dd656fbd5..5c9bda5e1 100644
--- a/yardstick/tests/unit/benchmark/scenarios/availability/test_serviceha.py
+++ b/yardstick/tests/unit/benchmark/scenarios/availability/test_serviceha.py
@@ -42,6 +42,13 @@ class ServicehaTestCase(unittest.TestCase):
}
sla = {"outage_time": 5}
self.args = {"options": options, "sla": sla}
+ self.test__serviceha = serviceha.ServiceHA(self.args, self.ctx)
+
+ def test___init__(self):
+
+ self.assertEqual(self.test__serviceha.data, {})
+ self.assertFalse(self.test__serviceha.setup_done)
+ self.assertFalse(self.test__serviceha.sla_pass)
# NOTE(elfoley): This should be split into test_setup and test_run
# NOTE(elfoley): This should explicitly test outcomes and states
@@ -73,3 +80,18 @@ class ServicehaTestCase(unittest.TestCase):
ret = {}
self.assertRaises(AssertionError, p.run, ret)
self.assertEqual(ret['sla_pass'], 0)
+
+ @mock.patch.object(serviceha, 'baseattacker')
+ @mock.patch.object(serviceha, 'basemonitor')
+ def test__serviceha_no_teardown_when_sla_pass(self, mock_monitor,
+ *args):
+ p = serviceha.ServiceHA(self.args, self.ctx)
+ p.setup()
+ self.assertTrue(p.setup_done)
+ mock_monitor.MonitorMgr().verify_SLA.return_value = True
+ ret = {}
+ p.run(ret)
+ attacker = mock.Mock()
+ p.attackers = [attacker]
+ p.teardown()
+ attacker.recover.assert_not_called()