1 ##############################################################################
2 # Copyright (c) 2016 Huan Li and others
3 # lihuansse@tongji.edu.cn
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
10 # Unittest for yardstick.benchmark.scenarios.availability.monitor
13 from __future__ import absolute_import
16 from yardstick.benchmark.scenarios.availability.monitor import monitor_multi
19 # pylint: disable=unused-argument
20 # disable this for now because I keep forgetting mock patch arg ordering
23 @mock.patch('yardstick.benchmark.scenarios.availability.monitor.'
24 'monitor_general.ssh')
25 @mock.patch('yardstick.benchmark.scenarios.availability.monitor.'
26 'monitor_general.open')
27 class MultiMonitorServiceTestCase(unittest.TestCase):
33 "key_filename": "/root/.ssh/id_rsa"
35 self.context = {"node1": host}
37 'monitor_type': 'general-monitor',
39 'key': 'service-status',
40 'monitor_key': 'service-status',
43 'parameter': {'serviceName': 'haproxy'},
44 'sla': {'max_outage_time': 1}
47 def test__monitor_multi_all_successful(self, mock_open, mock_ssh):
48 ins = monitor_multi.MultiMonitor(
49 self.monitor_cfg, self.context, {"nova-api": 10})
51 mock_ssh.SSH.from_node().execute.return_value = (0, "running", '')
57 def test__monitor_multi_all_fail(self, mock_open, mock_ssh):
58 ins = monitor_multi.MultiMonitor(
59 self.monitor_cfg, self.context, {"nova-api": 10})
61 mock_ssh.SSH.from_node().execute.return_value = (0, "running", '')