Esempio n. 1
0
def _check_status_code(resp, expected_code):
    if resp.status_code != expected_code:
        resp_text = resp.text
        # cleaning tomcat error message
        message = resp_text.split("<HR size=\"1\" noshade=\"noshade\">")[1]
        message = message.replace("</p><p>", "\n")
        message = re.sub('<[^<]+?>', ' ', message)
        raise ex.OozieException(message)
Esempio n. 2
0
    def test_run_job_handles_exceptions_with_run_job(self, canceljob, runjob,
                                                     job_ex_get, job_ex_upd):
        runjob.side_effect = ex.OozieException("run_job failed")
        job, job_exec = u.create_job_exec(edp.JOB_TYPE_PIG)
        job_exec.engine_job_id = "fake_oozie_id"
        job_ex_get.return_value = job_exec

        job_manager.run_job(job_exec.id)

        self.assertEqual(1, job_ex_get.call_count)
        self.assertEqual(1, job_ex_upd.call_count)

        new_status = job_ex_upd.call_args[0][2]["info"]["status"]
        self.assertEqual(edp.JOB_STATUS_FAILED, new_status)
        self.assertEqual(1, canceljob.call_count)