示例#1
0
    def test_run_job_complex_1(self, *args, **kwargs):
        """
        Tests running a job consisting of complex dependencies.
        """
        T0 = self.create_task_class(('A', 'B'), (), ('A',))
        T1 = self.create_task_class(('D', 'D1'), ('A',), ('D'))
        T2 = self.create_task_class(('C',), ('A',), ('C',))
        T3 = self.create_task_class(('E',), ('B',), ('E',))
        T4 = self.create_task_class((), ('B',), ())
        T5 = self.create_task_class(('evt-5',), ('D',), ('evt-5',))
        T6 = self.create_task_class(('evt-6',), ('C'), ('evt-6',))
        T7 = self.create_task_class((), ('D1', 'A'), ())
        T8 = self.create_task_class((), ('evt-5', 'evt-6', 'E'), ())

        run_task(T0)

        # Make sure the tasks which didn't have the appropriate events raised
        # during execution were not executed. These are tasks T3 and T4 in this
        # instance.
        self.assert_executed_tasks_equal([T0, T1, T2, T5, T6, T7, T8])
        # Check execution order.
        self.assert_task_dependency_preserved(T0, [T1, T2, T7])
        ## Even though task T1 does not emit the event D1, it still needs to
        ## execute before task T7.
        self.assert_task_dependency_preserved(T1, [T5, T7])
        self.assert_task_dependency_preserved(T2, [T6])
        self.assert_task_dependency_preserved(T5, [T8])
        self.assert_task_dependency_preserved(T6, [T8])
 def handle(self, *args, **kwargs):
     additional_arguments = None
     if kwargs['force']:
         additional_arguments = {
             'force_update': True
         }
     run_task(UpdateRepositoriesTask, additional_arguments)
示例#3
0
    def test_run_job_with_fail_task(self, *args, **kwargs):
        """
        Tests that running a job where one task fails works as expected.
        """
        fail_task = self.create_task_class(('fail',), (), ('fail'), fail=True)

        run_task(fail_task)

        # The job has gracefully exited without raising an exception.
        self.assert_executed_tasks_equal([fail_task])
示例#4
0
    def test_run_job_no_dependency(self, *args, **kwargs):
        """
        Tests running a job consisting of no dependencies.
        """
        A = self.create_task_class(('a',), (), ('a',))
        B = self.create_task_class(('b',), (), ('b',))

        run_task(B)

        self.assert_executed_tasks_equal([B])
示例#5
0
    def test_run_job_no_events_emitted(self, *args, **kwargs):
        """
        Tests running a job consisting of a simple dependency, but the event is
        not emitted during execution.
        """
        A = self.create_task_class(('a',), (), ())
        B = self.create_task_class((), ('a',), ())

        run_task(A)

        self.assert_executed_tasks_equal([A])
示例#6
0
    def test_run_job_simple(self, *args, **kwargs):
        """
        Tests running a job consisting of a simple dependency.
        """
        A = self.create_task_class(('a',), (), ('a',))
        B = self.create_task_class((), ('a',), ())

        run_task(A)

        self.assert_executed_tasks_equal([A, B])
        self.assert_task_dependency_preserved(A, [B])
示例#7
0
    def test_run_job_by_task_name(self, *args, **kwargs):
        """
        Tests that the :func:`pts.core.tasks.run_task` function correctly
        runs a task when given its name, not a task class object.
        """
        A = self.create_task_class(('a',), (), ('a',))
        B = self.create_task_class((), ('a',), ())

        run_task(A.task_name())

        self.assert_executed_tasks_equal([A, B])
        self.assert_task_dependency_preserved(A, [B])
示例#8
0
    def test_run_job_with_fail_task_dependency(self, *args, **kwargs):
        """
        Tests that even though a task has failed, any events it raised while
        running affect the rest of the tasks.
        """
        root_task = self.create_task_class(('A',), (), ('A',))
        fail_task = self.create_task_class(('fail',), ('A',), ('fail',), True)
        depends_on_fail = self.create_task_class((), ('fail',), ())
        do_run = self.create_task_class((), ('A',), ())

        run_task(root_task)

        self.assert_executed_tasks_equal(
            [root_task, fail_task, depends_on_fail, do_run]
        )
示例#9
0
 def handle(self, *args, **kwargs):
     verbose = int(kwargs.get('verbosity', 1)) > 1
     additional_arguments = None
     if kwargs['force']:
         additional_arguments = {
             'force_update': True
         }
     for task_name in args:
         task_name = task_name.decode('utf-8')
         try:
             run_task(task_name, additional_arguments)
         except:
             if verbose:
                 self.stdout.write(task_name + ' failed!')
                 traceback.print_exc(file=self.stdout)
示例#10
0
    def test_run_job_complex_4(self, *args, **kwargs):
        """
        Tests running a job consisting of complex dependencies when the initial
        task is not the task which has 0 dependencies in the full tasks DAG.
        """
        T0 = self.create_task_class(('A', 'B'), (), ('B',))
        T1 = self.create_task_class(('D', 'D1'), ('A',), ('D'))
        T2 = self.create_task_class(('C',), ('A',), ('C',))
        T3 = self.create_task_class(('E',), ('B',), ('E',))
        T4 = self.create_task_class((), ('B',), ())
        T5 = self.create_task_class(('evt-5',), ('D',), ('evt-5',))
        T6 = self.create_task_class(('evt-6',), ('C'), ('evt-6',))
        T7 = self.create_task_class((), ('D1', 'A'), ())
        T8 = self.create_task_class((), ('evt-5', 'evt-6', 'E'), ())

        run_task(T1)

        self.assert_executed_tasks_equal([T1, T5, T8])
示例#11
0
    def test_run_job_complex_3(self, *args, **kwargs):
        """
        Tests running a job consisting of complex dependencies.
        """
        T0 = self.create_task_class(('A', 'B', 'B1'), (), ('B', 'B1'))
        T1 = self.create_task_class(('D', 'D1'), ('A',), ('D'))
        T2 = self.create_task_class(('C',), ('A',), ('C',))
        T3 = self.create_task_class(('E',), ('B',), ('E',))
        T4 = self.create_task_class((), ('B',), ())
        T5 = self.create_task_class(('evt-5',), ('D',), ('evt-5',))
        T6 = self.create_task_class(('evt-6',), ('C'), ('evt-6',))
        T7 = self.create_task_class((), ('D1', 'A', 'B1'), ())
        T8 = self.create_task_class((), ('evt-5', 'evt-6', 'E'), ())

        run_task(T0)

        self.assert_executed_tasks_equal([T0, T3, T4, T7, T8])
        self.assert_task_dependency_preserved(T0, [T3, T4, T7])
        self.assert_task_dependency_preserved(T3, [T8])
示例#12
0
    def test_run_job_complex_2(self, *args, **kwargs):
        """
        Tests running a job consisting of complex dependencies.
        """
        T0 = self.create_task_class(('A', 'B'), (), ('B',))
        T1 = self.create_task_class(('D', 'D1'), ('A',), ('D'))
        T2 = self.create_task_class(('C',), ('A',), ('C',))
        T3 = self.create_task_class(('E',), ('B',), ('E',))
        T4 = self.create_task_class((), ('B',), ())
        T5 = self.create_task_class(('evt-5',), ('D',), ('evt-5',))
        T6 = self.create_task_class(('evt-6',), ('C'), ('evt-6',))
        T7 = self.create_task_class((), ('D1', 'A'), ())
        T8 = self.create_task_class((), ('evt-5', 'evt-6', 'E'), ())

        run_task(T0)

        # In this test case, unlike test_run_job_complex_1, T0 emits event B so
        # no tasks depending on event A need to run.
        self.assert_executed_tasks_equal([T0, T3, T4, T8])
        # Check execution order.
        self.assert_task_dependency_preserved(T0, [T3, T4])
        self.assert_task_dependency_preserved(T3, [T8])
 def run_update(self):
     run_task(UpdateRepositoriesTask)