Пример #1
0
    def test_check_health_pubsub_publish_error(self, mc_ans_runner, mc_grc):
        mc_conn = MagicMock()
        mc_ans_runner.return_value = mc_conn
        mc_conn.run.return_value = {"contacted": [self.vm_ip]}

        mc_grc.side_effect = ConnectionError()

        # didn't raise exception
        check_health(self.opts, self.vm_name, self.vm_ip)

        assert mc_conn.run.called
        assert mc_grc.called
Пример #2
0
    def test_check_health_pubsub_publish_error(self, mc_ans_runner, mc_grc):
        mc_conn = MagicMock()
        mc_ans_runner.return_value = mc_conn
        mc_conn.run.return_value = {"contacted": [self.vm_ip]}

        mc_grc.side_effect = ConnectionError()

        # didn't raise exception
        check_health(self.opts, self.vm_name, self.vm_ip)

        assert mc_conn.run.called
        assert mc_grc.called
Пример #3
0
    def test_check_health_runner_ok(self, mc_ans_runner, mc_grc):
        mc_conn = MagicMock()
        mc_ans_runner.return_value = mc_conn
        mc_conn.run.return_value = {"contacted": [self.vm_ip]}

        mc_rc = MagicMock()
        mc_grc.return_value = mc_rc

        # didn't raise exception
        check_health(self.opts, self.vm_name, self.vm_ip)
        assert mc_rc.publish.call_args[0][0] == PUBSUB_MB
        dict_result = json.loads(mc_rc.publish.call_args[0][1])
        assert dict_result["result"] == "OK"
Пример #4
0
    def test_check_health_runner_ok(self, mc_ans_runner, mc_grc):
        mc_conn = MagicMock()
        mc_ans_runner.return_value = mc_conn
        mc_conn.run.return_value = {"contacted": [self.vm_ip]}

        mc_rc = MagicMock()
        mc_grc.return_value = mc_rc

        # didn't raise exception
        check_health(self.opts, self.vm_name, self.vm_ip)
        assert mc_rc.publish.call_args[0][0] == PUBSUB_MB
        dict_result = json.loads(mc_rc.publish.call_args[0][1])
        assert dict_result["result"] == "OK"
Пример #5
0
    def test_check_health_runner_no_response(self, mc_ans_runner, mc_grc):
        mc_runner = MagicMock()
        mc_ans_runner.return_value = mc_runner
        # mc_runner.connection.side_effect = IOError()

        mc_rc = MagicMock()
        mc_grc.return_value = mc_rc

        # didn't raise exception
        check_health(self.opts, self.vm_name, self.vm_ip)
        assert mc_rc.publish.call_args[0][0] == PUBSUB_MB
        dict_result = json.loads(mc_rc.publish.call_args[0][1])
        assert dict_result["result"] == "failed"
        assert "VM is not responding to the testing playbook." in dict_result["msg"]
Пример #6
0
    def test_check_health_runner_exception(self, mc_ans_runner, mc_grc):
        mc_conn = MagicMock()
        mc_ans_runner.return_value = mc_conn
        mc_conn.run.side_effect = IOError()

        mc_rc = MagicMock()
        mc_grc.return_value = mc_rc

        # didn't raise exception
        check_health(self.opts, self.vm_name, self.vm_ip)
        assert mc_rc.publish.call_args[0][0] == PUBSUB_MB
        dict_result = json.loads(mc_rc.publish.call_args[0][1])
        assert dict_result["result"] == "failed"
        assert "Failed to check  VM" in dict_result["msg"]
        assert "due to ansible error:" in dict_result["msg"]
Пример #7
0
    def test_check_health_runner_no_response(self, mc_ans_runner, mc_grc):
        mc_runner = MagicMock()
        mc_ans_runner.return_value = mc_runner
        # mc_runner.connection.side_effect = IOError()

        mc_rc = MagicMock()
        mc_grc.return_value = mc_rc

        # didn't raise exception
        check_health(self.opts, self.vm_name, self.vm_ip)
        assert mc_rc.publish.call_args[0][0] == PUBSUB_MB
        dict_result = json.loads(mc_rc.publish.call_args[0][1])
        assert dict_result["result"] == "failed"
        assert "VM is not responding to the testing playbook." in dict_result[
            "msg"]
Пример #8
0
    def test_check_health_runner_exception(self, mc_ans_runner, mc_grc):
        mc_conn = MagicMock()
        mc_ans_runner.return_value = mc_conn
        mc_conn.run.side_effect = IOError()

        mc_rc = MagicMock()
        mc_grc.return_value = mc_rc

        # didn't raise exception
        check_health(self.opts, self.vm_name, self.vm_ip)
        assert mc_rc.publish.call_args[0][0] == PUBSUB_MB
        dict_result = json.loads(mc_rc.publish.call_args[0][1])
        assert dict_result["result"] == "failed"
        assert "Failed to check  VM" in dict_result["msg"]
        assert "due to ansible error:" in dict_result["msg"]