示例#1
0
    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)
示例#2
0
    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])
示例#3
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)