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