3 ##############################################################################
4 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
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.monitor_process
17 from yardstick.benchmark.scenarios.availability.monitor import monitor_process
19 @mock.patch('yardstick.benchmark.scenarios.availability.monitor.monitor_process.ssh')
20 class MonitorProcessTestCase(unittest.TestCase):
26 "key_filename": "/root/.ssh/id_rsa"
28 self.context = {"node1": host}
30 'monitor_type': 'process',
31 'process_name': 'nova-api',
34 'sla': {'max_recover_time': 5}
37 def test__monitor_process_all_successful(self, mock_ssh):
39 ins = monitor_process.MonitorProcess(self.monitor_cfg, self.context)
41 mock_ssh.SSH().execute.return_value = (0, "1", '')
44 ins._result = {"outage_time": 0}
47 def test__monitor_process_down_failuer(self, mock_ssh):
49 ins = monitor_process.MonitorProcess(self.monitor_cfg, self.context)
51 mock_ssh.SSH().execute.return_value = (0, "0", '')
54 ins._result = {"outage_time": 10}