def test_should_pass_if_task_was_started_immediately(self): dag = self._prepare_parent_child_dag() dag.id = '1' tasks = [ TaskLog(id='parent_1', workflow='1', task_id='parent', started=0.0, finished=10.0, vm=1, result='OK'), TaskLog(id='child1_1', workflow='1', task_id='child1', started=10.0, finished=13.0, vm=1, result='OK'), TaskLog(id='child2_1', workflow='1', task_id='child2', started=10.0, finished=15.0, vm=2, result='OK')] result = order_validator.validate(dag, tasks) self.assertTrue(result.is_valid)
def test_should_fail_when_task_has_not_ended(self): task = TaskLog(finished=single_task_validator.MISSING_VALUE, started=5.0, **IRRELEVANT_TASK_ATTRIBUTES) result = single_task_validator.validate_task(task) self.assertFalse(result.is_valid)
def test_should_return_some_message_when_fails(self): task = TaskLog(started=single_task_validator.MISSING_VALUE, finished=single_task_validator.MISSING_VALUE, **IRRELEVANT_TASK_ATTRIBUTES) result = single_task_validator.validate_task(task) self.assertTrue(result.message)
def test_should_fail_if_any_following_task_was_finished_before(self): dag = self._prepare_parent_child_dag() dag.id = '1' tasks = [ TaskLog(id='parent_1', workflow='1', task_id='parent', started=0.0, finished=10.0, vm=1, result='OK'), TaskLog(id='child1_1', workflow='1', task_id='child1', started=11.0, finished=13.0, vm=1, result='OK'), TaskLog(id='child2_1', workflow='1', task_id='child2', started=5.0, finished=8.0, vm=2, result='OK')] result = order_validator.validate(dag, tasks) self.assertFalse(result.is_valid) self.assertIn('child2', result.errors[0])
def test_should_pass_when_order_is_correct(self): dag = self._prepare_parent_child_dag() dag.id = '1' tasks = [ TaskLog(id='parent_1', workflow='1', task_id='parent', started=0.0, finished=10.0, vm=1, result='OK'), TaskLog(id='child1_1', workflow='1', task_id='child1', started=11.0, finished=13.0, vm=1, result='OK'), TaskLog(id='child2_1', workflow='1', task_id='child2', started=12.0, finished=15.0, vm=2, result='OK')] result = order_validator.validate(dag, tasks) self.assertTrue(result.is_valid) self.assertListEqual([], result.errors)
def test_should_fail_if_file_was_not_uploaded_at_all(self): dag = self._prepare_file_transfer_dag() dag.id = '1' tasks = [ TaskLog(id='before_1', workflow='1', task_id='before', started=0.0, finished=10.0, vm=1, result='OK'), TaskLog(id='after_1', workflow='1', task_id='after', started=13.0, finished=18.0, vm=1, result='OK')] transfers = [ TransferLog( id='234', job_id='after_1', vm=1, started=12.0, finished=13.0, direction='DOWNLOAD', file_id='transferred.txt')] result = order_validator.validate_transfers(dag, tasks, transfers) self.assertFalse(result.is_valid)
def test_should_pass_if_transfers_are_ok(self): dag = self._prepare_file_transfer_dag() dag.id = '1' tasks = [ TaskLog(id='before_1', workflow='1', task_id='before', started=0.0, finished=10.0, vm=1, result='OK'), TaskLog(id='after_1', workflow='1', task_id='after', started=13.0, finished=18.0, vm=1, result='OK')] transfers = [ TransferLog(id='123', job_id='before_1', vm=1, started=10.0, finished=12.0, direction='UPLOAD', file_id='transferred.txt'), TransferLog(id='234', job_id='after_1', vm=1, started=12.0, finished=13.0, direction='DOWNLOAD', file_id='transferred.txt')] result = order_validator.validate_transfers(dag, tasks, transfers) self.assertTrue(result.is_valid) self.assertListEqual([], result.errors)
def test_should_hold_task_time_order(self): task = TaskLog(started=5.0, finished=3.0, **IRRELEVANT_TASK_ATTRIBUTES) result = single_task_validator.validate_task(task) self.assertFalse(result.is_valid)
def test_should_pass_when_valid_task(self): task = TaskLog(started=3.0, finished=5.0, **IRRELEVANT_TASK_ATTRIBUTES) result = single_task_validator.validate_task(task) self.assertTrue(result.is_valid)