Example #1
0
 def test_abort_from_submitting(self, add, delete, command_processor):
     """
     Testing when ABORT command is received when Job is in SUBMITTING state.
     Test if SUBMIT command received after is handled correctly and also the check status
     """
     command_processor.return_vaule = True
     job = Job.objects.create(
         type=PipelineType.CWL,
         app={
             "github": {
                 "version": "1.0.0",
                 "entrypoint": "test.cwl",
                 "repository": "",
             }
         },
         external_id="ext_id",
         status=Status.SUBMITTING,
     )
     add.return_value = True
     delete.return_value = True
     abort_job(job)
     job.refresh_from_db()
     self.assertEqual(job.status, Status.ABORTED)
     command_processor(Command(CommandType.SUBMIT, str(job.id)).to_dict())
     check_job_status(job)
     job.refresh_from_db()
     self.assertEqual(job.status, Status.ABORTED)
Example #2
0
 def test_running(self, status, init, get_job_info_path, command_processor):
     self.current_job.status = Status.PENDING
     self.current_job.save()
     init.return_value = None
     command_processor.return_value = True
     get_job_info_path.return_value = "sample/job/path"
     status.return_value = Status.RUNNING, None
     check_job_status(self.current_job)
     self.current_job.refresh_from_db()
     self.assertEqual(self.current_job.status, Status.RUNNING)
     self.assertNotEqual(self.current_job.started, None)
     self.assertEqual(self.current_job.finished, None)
Example #3
0
 def test_complete(self, get_outputs, status, init, get_job_info_path,
                   command_processor):
     self.current_job.status = Status.PENDING
     self.current_job.save()
     init.return_value = None
     command_processor.return_value = True
     get_outputs.return_value = {"outputs": True}, None
     get_job_info_path.return_value = "sample/job/path"
     status.return_value = Status.COMPLETED, None
     check_job_status(self.current_job)
     self.current_job.refresh_from_db()
     self.assertEqual(self.current_job.status, Status.COMPLETED)
     self.assertNotEqual(self.current_job.finished, None)
Example #4
0
 def test_failed(self, status, command_processor):
     job = Job.objects.create(
         type=PipelineType.CWL,
         app={
             "github": {
                 "version": "1.0.0",
                 "entrypoint": "test.cwl",
                 "repository": "",
             }
         },
         external_id="ext_id",
         status=Status.RUNNING,
     )
     status.return_value = Status.FAILED, ""
     command_processor.return_value = True
     check_job_status(job)
     job.refresh_from_db()
     self.assertEqual(job.status, Status.FAILED)
Example #5
0
 def test_fail_not_submitted(self, status, init, command_processor):
     init.return_value = None
     command_processor.return_value = True
     status.return_value = Status.PENDING, None
     self.current_job.status = Status.PENDING
     self.current_job.external_id = None
     self.current_job.save()
     check_job_status(self.current_job)
     self.current_job.refresh_from_db()
     self.assertEqual(self.current_job.status, Status.FAILED)
     self.assertNotEqual(self.current_job.finished, None)
     info_message = self.current_job.message["info"]
     failed_jobs = self.current_job.message["failed_jobs"]
     unknown_jobs = self.current_job.message["unknown_jobs"]
     expected_failed_jobs = {}
     expected_unknown_jobs = {}
     self.assertTrue("External id not provided" in info_message)
     self.assertEqual(failed_jobs, expected_failed_jobs)
     self.assertEqual(unknown_jobs, expected_unknown_jobs)
Example #6
0
 def test_abort_from_submitted(self, abort, command_processor):
     job = Job.objects.create(
         type=PipelineType.CWL,
         app={
             "github": {
                 "version": "1.0.0",
                 "entrypoint": "test.cwl",
                 "repository": "",
             }
         },
         external_id="ext_id",
         status=Status.SUBMITTED,
     )
     abort.return_value = True
     command_processor.return_value = True
     abort_job(job)
     job.refresh_from_db()
     self.assertEqual(job.status, Status.ABORTED)
     check_job_status(job)
     job.refresh_from_db()
     self.assertEqual(job.status, Status.ABORTED)
Example #7
0
 def test_running_to_completed(self, status, get_outputs, command_processor):
     job = Job.objects.create(
         type=PipelineType.CWL,
         app={
             "github": {
                 "version": "1.0.0",
                 "entrypoint": "test.cwl",
                 "repository": "",
             }
         },
         external_id="ext_id",
         status=Status.RUNNING,
     )
     status.return_value = Status.COMPLETED, ""
     outputs = {"output": "test_value"}
     get_outputs.return_value = outputs, None
     command_processor.return_value = None
     check_job_status(job)
     job.refresh_from_db()
     self.assertEqual(job.status, Status.COMPLETED)
     self.assertEqual(job.outputs, outputs)
Example #8
0
 def test_abort_from_created(self, command_processor):
     """
     Test reciving ABORT command when Job is in CREATED state
     """
     command_processor.return_vaule = True
     job = Job.objects.create(
         type=PipelineType.CWL,
         app={
             "github": {
                 "version": "1.0.0",
                 "entrypoint": "test.cwl",
                 "repository": "",
             }
         },
         external_id="ext_id",
         status=Status.CREATED,
     )
     abort_job(job)
     job.refresh_from_db()
     self.assertEqual(job.status, Status.ABORTED)
     check_job_status(job)
     job.refresh_from_db()
     self.assertEqual(job.status, Status.ABORTED)
Example #9
0
 def test_fail(self, status, init, get_job_info_path, command_processor):
     self.current_job.status = Status.PENDING
     self.current_job.save()
     init.return_value = None
     command_processor.return_value = True
     get_job_info_path.return_value = "sample/job/path"
     status.return_value = Status.FAILED, "submitter reason"
     check_job_status(self.current_job)
     self.current_job.refresh_from_db()
     self.assertEqual(self.current_job.status, Status.FAILED)
     self.assertNotEqual(self.current_job.finished, None)
     info_message = self.current_job.message["info"]
     failed_jobs = self.current_job.message["failed_jobs"]
     unknown_jobs = self.current_job.message["unknown_jobs"]
     expected_failed_jobs = {
         "failed_job_1": ["failed_job_1_id"],
         "failed_job_2": ["failed_job_2_id"],
     }
     expected_unknown_jobs = {
         "unknown_job": ["unknown_job_id_1", "unknown_job_id_2"]
     }
     self.assertEqual(info_message, "submitter reason")
     self.assertEqual(failed_jobs, expected_failed_jobs)
     self.assertEqual(unknown_jobs, expected_unknown_jobs)