def test_operator_trigger_fails_operator_run_when_all_runs_are_complete_and_no_threshold_is_met(self, create_jobs_from_chaining): operator_run = OperatorRun.objects.prefetch_related("runs").first() run_ids = [run.id for run in operator_run.runs.all()] for run_id in run_ids: message = dict(details="done") fail_job(run_id, message) process_triggers() operator_run.refresh_from_db() self.assertEqual(operator_run.status, RunStatus.FAILED)
def test_operator_trigger_fails_operator_run_when_all_runs_are_complete_and_no_threshold_is_met( self, create_jobs_from_chaining, memcache_task_lock, send_notification, set_for_restart ): set_for_restart.return_value = None memcache_task_lock.return_value = True send_notification.return_value = False operator_run = OperatorRun.objects.prefetch_related("runs").first() run_ids = [run.id for run in operator_run.runs.all()] for run_id in run_ids: message = dict(details="done") fail_job(run_id, message) process_triggers() operator_run.refresh_from_db() self.assertEqual(operator_run.status, RunStatus.FAILED)
def test_run_fail_job(self, mock_get_pipeline): with open('runner/tests/run/pair-workflow.cwl', 'r') as f: app = json.load(f) with open('runner/tests/run/inputs.json', 'r') as f: inputs = json.load(f) mock_get_pipeline.return_value = app run = RunObject.from_cwl_definition(str(self.run.id), inputs) run.to_db() operator_run = OperatorRun.objects.first() operator_run.runs.add(run.run_obj) num_failed_runs = operator_run.num_failed_runs fail_job(run.run_id, {'details': 'Error has happened'}) operator_run.refresh_from_db() self.assertEqual(operator_run.num_failed_runs, num_failed_runs + 1) run_obj = RunObject.from_db(run.run_id) self.assertEqual(run_obj.message, {'details': 'Error has happened'})
def test_run_fail_job(self, mock_get_pipeline, memcache_task_lock, send_notification, set_for_restart): with open("runner/tests/run/pair-workflow.cwl", "r") as f: app = json.load(f) with open("runner/tests/run/inputs.json", "r") as f: inputs = json.load(f) set_for_restart.return_value = None mock_get_pipeline.return_value = app memcache_task_lock.return_value = True send_notification.return_value = False run = RunObjectFactory.from_definition(str(self.run.id), inputs) run.to_db() operator_run = OperatorRun.objects.first() operator_run.runs.add(run.run_obj) num_failed_runs = operator_run.num_failed_runs fail_job(run.run_id, {"details": "Error has happened"}) operator_run.refresh_from_db() self.assertEqual(operator_run.num_failed_runs, num_failed_runs + 1) run_obj = RunObjectFactory.from_db(run.run_id) self.assertEqual(run_obj.message, {"details": "Error has happened"})