예제 #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
파일: test_check.py 프로젝트: 0-T-0/copr
    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
파일: test_check.py 프로젝트: 0-T-0/copr
    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
파일: test_check.py 프로젝트: 0-T-0/copr
    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
파일: test_check.py 프로젝트: 0-T-0/copr
    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"]