def test_all_success_tr_success(self):
     """
     All-success trigger rule success
     """
     ti = self._get_task_instance(TriggerRule.ALL_SUCCESS,
                                  upstream_task_ids=["FakeTaskID"])
     dep_statuses = tuple(TriggerRuleDep()._evaluate_trigger_rule(
         ti=ti,
         successes=1,
         skipped=0,
         failed=0,
         upstream_failed=0,
         done=1,
         flag_upstream_failed=False,
         session="Fake Session"))
     self.assertEqual(len(dep_statuses), 0)
Пример #2
0
 def test_one_failure_tr_failure(self):
     """
     One-failure trigger rule failure
     """
     ti = self._get_task_instance(TriggerRule.ONE_FAILED)
     dep_statuses = tuple(TriggerRuleDep()._evaluate_trigger_rule(
         ti=ti,
         successes=2,
         skipped=0,
         failed=0,
         upstream_failed=0,
         done=2,
         flag_upstream_failed=False,
         session="Fake Session"))
     self.assertEqual(len(dep_statuses), 1)
     self.assertFalse(dep_statuses[0].passed)
Пример #3
0
 def test_one_success_tr_success(self):
     """
     One-success trigger rule success
     """
     ti = self._get_task_instance(TriggerRule.ONE_SUCCESS,
                                  State.UP_FOR_RETRY)
     dep_statuses = tuple(TriggerRuleDep()._evaluate_trigger_rule(
         ti=ti,
         successes=1,
         skipped=2,
         failed=2,
         upstream_failed=2,
         done=2,
         flag_upstream_failed=False,
         session="Fake Session"))
     self.assertEqual(len(dep_statuses), 0)
Пример #4
0
 def test_none_failed_or_skipped_tr_success(self):
     """
     All success including skip trigger rule success
     """
     ti = self._get_task_instance(
         TriggerRule.NONE_FAILED_OR_SKIPPED,
         upstream_task_ids=["FakeTaskID", "OtherFakeTaskID"])
     dep_statuses = tuple(TriggerRuleDep()._evaluate_trigger_rule(
         ti=ti,
         successes=1,
         skipped=1,
         failed=0,
         upstream_failed=0,
         done=2,
         flag_upstream_failed=False,
         session="Fake Session"))
     self.assertEqual(len(dep_statuses), 0)
Пример #5
0
    def test_one_failure_tr_failure(self):
        """
        One-failure trigger rule failure
        """
        task = FakeTask(trigger_rule=TriggerRule.ONE_FAILED,
                        upstream_task_ids=[])
        ti = FakeTI(task=task)

        dep_statuses = tuple(TriggerRuleDep()._evaluate_trigger_rule(
            ti=ti,
            successes=2,
            skipped=0,
            failed=0,
            upstream_failed=0,
            done=2,
            flag_upstream_failed=False,
            session="Fake Session"))
Пример #6
0
 def test_all_done_tr_failure(self):
     """
     All-done trigger rule failure
     """
     ti = self._get_task_instance(
         TriggerRule.ALL_DONE,
         upstream_task_ids=["FakeTaskID", "OtherFakeTaskID"])
     dep_statuses = tuple(TriggerRuleDep()._evaluate_trigger_rule(
         ti=ti,
         successes=1,
         skipped=0,
         failed=0,
         upstream_failed=0,
         done=1,
         flag_upstream_failed=False,
         session="Fake Session"))
     self.assertEqual(len(dep_statuses), 1)
     self.assertFalse(dep_statuses[0].passed)
Пример #7
0
 def test_none_failed_or_skipped_tr_skipped(self):
     """
     All success including all upstream skips trigger rule success
     """
     ti = self._get_task_instance(
         TriggerRule.NONE_FAILED_OR_SKIPPED,
         upstream_task_ids=["FakeTaskID", "OtherFakeTaskID"])
     dep_statuses = tuple(TriggerRuleDep()._evaluate_trigger_rule(
         ti=ti,
         successes=0,
         skipped=2,
         failed=0,
         upstream_failed=0,
         done=2,
         flag_upstream_failed=True,
         session=Mock()))
     self.assertEqual(len(dep_statuses), 0)
     self.assertEqual(ti.state, State.SKIPPED)
 def test_all_failed_tr_success(self):
     """
     All-failed trigger rule success
     """
     ti = self._get_task_instance(
         TriggerRule.ALL_FAILED,
         upstream_task_ids=["FakeTaskID", "OtherFakeTaskID"])
     dep_statuses = tuple(TriggerRuleDep()._evaluate_trigger_rule(
         ti=ti,
         successes=0,
         skipped=0,
         failed=2,
         upstream_failed=0,
         done=2,
         flag_upstream_failed=False,
         session="Fake Session",
     ))
     self.assertEqual(len(dep_statuses), 0)
Пример #9
0
 def test_all_success_tr_skip(self):
     """
     All-success trigger rule fails when some upstream tasks are skipped.
     """
     ti = self._get_task_instance(
         TriggerRule.ALL_SUCCESS,
         upstream_task_ids=["FakeTaskID", "OtherFakeTaskID"])
     dep_statuses = tuple(TriggerRuleDep()._evaluate_trigger_rule(
         ti=ti,
         successes=1,
         skipped=1,
         failed=0,
         upstream_failed=0,
         done=2,
         flag_upstream_failed=False,
         session="Fake Session"))
     self.assertEqual(len(dep_statuses), 1)
     self.assertFalse(dep_statuses[0].passed)
Пример #10
0
    def test_unknown_tr(self):
        """
        Unknown trigger rules should cause this dep to fail
        """
        ti = self._get_task_instance()
        ti.task.trigger_rule = "Unknown Trigger Rule"
        dep_statuses = tuple(TriggerRuleDep()._evaluate_trigger_rule(
            ti=ti,
            successes=1,
            skipped=0,
            failed=0,
            upstream_failed=0,
            done=1,
            flag_upstream_failed=False,
            session="Fake Session"))

        self.assertEqual(len(dep_statuses), 1)
        self.assertFalse(dep_statuses[0].passed)
Пример #11
0
 def test_one_success_tr_failure(self):
     """
     One-success trigger rule failure
     """
     ti = self._get_task_instance(TriggerRule.ONE_SUCCESS)
     dep_statuses = tuple(
         TriggerRuleDep()._evaluate_trigger_rule(
             ti=ti,
             successes=0,
             skipped=2,
             failed=2,
             upstream_failed=2,
             done=2,
             flag_upstream_failed=False,
             session="Fake Session",
         )
     )
     assert len(dep_statuses) == 1
     assert not dep_statuses[0].passed
Пример #12
0
    def test_one_success_tr_success(self):
        """
        One-success trigger rule success
        """
        task = FakeTask(trigger_rule=TriggerRule.ONE_SUCCESS,
                        upstream_task_ids=[])
        ti = FakeTI(task=task)

        dep_statuses = tuple(TriggerRuleDep()._evaluate_trigger_rule(
            ti=ti,
            successes=1,
            skipped=2,
            failed=2,
            upstream_failed=2,
            done=2,
            flag_upstream_failed=False,
            session="Fake Session"))

        self.assertEqual(len(dep_statuses), 0)
Пример #13
0
    def test_all_done_tr_success(self):
        """
        All-done trigger rule success
        """
        task = FakeTask(trigger_rule=TriggerRule.ALL_DONE,
                        upstream_task_ids=["FakeTaskID", "OtherFakeTaskID"])
        ti = FakeTI(task=task)

        dep_statuses = tuple(TriggerRuleDep()._evaluate_trigger_rule(
            ti=ti,
            successes=2,
            skipped=0,
            failed=0,
            upstream_failed=0,
            done=2,
            flag_upstream_failed=False,
            session="Fake Session"))

        self.assertEqual(len(dep_statuses), 0)
Пример #14
0
 def test_all_done_tr_success(self):
     """
     All-done trigger rule success
     """
     ti = self._get_task_instance(
         TriggerRule.ALL_DONE, upstream_task_ids=["FakeTaskID", "OtherFakeTaskID"]
     )
     dep_statuses = tuple(
         TriggerRuleDep()._evaluate_trigger_rule(
             ti=ti,
             successes=2,
             skipped=0,
             failed=0,
             upstream_failed=0,
             done=2,
             flag_upstream_failed=False,
             session="Fake Session",
         )
     )
     assert len(dep_statuses) == 0
Пример #15
0
    def test_all_failed_tr_failure(self):
        """
        All-failed trigger rule failure
        """
        task = FakeTask(trigger_rule=TriggerRule.ALL_FAILED,
                        upstream_task_ids=["FakeTaskID", "OtherFakeTaskID"])
        ti = FakeTI(task=task)

        dep_statuses = tuple(TriggerRuleDep()._evaluate_trigger_rule(
            ti=ti,
            successes=2,
            skipped=0,
            failed=0,
            upstream_failed=0,
            done=2,
            flag_upstream_failed=False,
            session="Fake Session"))

        self.assertEqual(len(dep_statuses), 1)
        self.assertFalse(dep_statuses[0].passed)
Пример #16
0
 def test_all_success_tr_skip_flag_upstream(self):
     """
     All-success trigger rule fails when some upstream tasks are skipped. The state of the ti
     should be set to SKIPPED when flag_upstream_failed is True.
     """
     ti = self._get_task_instance(
         TriggerRule.ALL_SUCCESS,
         upstream_task_ids=["FakeTaskID", "OtherFakeTaskID"])
     dep_statuses = tuple(TriggerRuleDep()._evaluate_trigger_rule(
         ti=ti,
         successes=1,
         skipped=1,
         failed=0,
         upstream_failed=0,
         done=2,
         flag_upstream_failed=True,
         session=Mock()))
     self.assertEqual(len(dep_statuses), 1)
     self.assertFalse(dep_statuses[0].passed)
     self.assertEqual(ti.state, State.SKIPPED)
Пример #17
0
 def test_all_failed_tr_failure(self):
     """
     All-failed trigger rule failure
     """
     ti = self._get_task_instance(
         TriggerRule.ALL_FAILED, upstream_task_ids=["FakeTaskID", "OtherFakeTaskID"]
     )
     dep_statuses = tuple(
         TriggerRuleDep()._evaluate_trigger_rule(
             ti=ti,
             successes=2,
             skipped=0,
             failed=0,
             upstream_failed=0,
             done=2,
             flag_upstream_failed=False,
             session="Fake Session",
         )
     )
     assert len(dep_statuses) == 1
     assert not dep_statuses[0].passed
 def test_none_failed_tr_failure(self):
     """
     All success including skip trigger rule failure
     """
     ti = self._get_task_instance(TriggerRule.NONE_FAILED,
                                  upstream_task_ids=[
                                      "FakeTaskID", "OtherFakeTaskID",
                                      "FailedFakeTaskID"
                                  ])
     dep_statuses = tuple(TriggerRuleDep()._evaluate_trigger_rule(
         ti=ti,
         successes=1,
         skipped=1,
         failed=1,
         upstream_failed=0,
         done=3,
         flag_upstream_failed=False,
         session="Fake Session",
     ))
     self.assertEqual(len(dep_statuses), 1)
     self.assertFalse(dep_statuses[0].passed)
Пример #19
0
 def test_dummy_tr(self):
     """
     The dummy trigger rule should always pass this dep
     """
     ti = self._get_task_instance(TriggerRule.DUMMY, State.UP_FOR_RETRY)
     self.assertTrue(TriggerRuleDep().is_met(ti=ti))
Пример #20
0
 def test_no_upstream_tasks(self):
     """
     If the TI has no upstream TIs then there is nothing to check and the dep is passed
     """
     ti = self._get_task_instance(TriggerRule.ALL_DONE, State.UP_FOR_RETRY)
     self.assertTrue(TriggerRuleDep().is_met(ti=ti))