def test__monitor_command_ssh_monitor_successful(self, mock_ssh, mock_subprocess): self.config["host"] = "node1" instance = monitor_command.MonitorOpenstackCmd(self.config, self.context) instance.setup() mock_ssh.SSH().execute.return_value = (0, "0", '') ret = instance.monitor_func()
def test__monitor_command_monitor_func_failure(self, mock_subprocess): mock_subprocess.check_output.return_value = (1, 'unittest') instance = monitor_command.MonitorOpenstackCmd(self.config, None) instance.setup() mock_subprocess.check_output.side_effect = RuntimeError ret = instance.monitor_func() self.assertEqual(ret, False) instance._result = {"outage_time": 10} instance.verify_SLA()
def test__monitor_command_monitor_func_successful(self, mock_subprocess): instance = monitor_command.MonitorOpenstackCmd(self.config, None) instance.setup() mock_subprocess.check_output.return_value = (0, 'unittest') ret = instance.monitor_func() self.assertEqual(ret, True) instance._result = {"outage_time": 0} instance.verify_SLA()
def test__monitor_command_ssh_monitor_successful(self, mock_ssh): self.mock_subprocess.check_output.return_value = (0, 'unittest') self.config["host"] = "node1" instance = monitor_command.MonitorOpenstackCmd(self.config, self.context, {"nova-api": 10}) instance.setup() mock_ssh.SSH.from_node().execute.return_value = (0, "0", '') ret = instance.monitor_func() self.assertTrue(ret)
def test__monitor_command_monitor_func_failure(self, mock_log): self.mock_subprocess.check_output.return_value = (1, 'unittest') instance = monitor_command.MonitorOpenstackCmd(self.config, None, {"nova-api": 10}) instance.setup() self.mock_subprocess.check_output.side_effect = RuntimeError ret = instance.monitor_func() self.assertFalse(ret) mock_log.error.assert_called_once() instance._result = {"outage_time": 10} instance.verify_SLA()