This is an automated email from the ASF dual-hosted git repository.
ash pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 7c9852fd66 Add DAG cycle test for Label use within Task Groups (#23300)
7c9852fd66 is described below
commit 7c9852fd66a017e360a6a663e04294b61c5b6c66
Author: Josh Fell <[email protected]>
AuthorDate: Thu Apr 28 05:16:04 2022 -0400
Add DAG cycle test for Label use within Task Groups (#23300)
To guard against any future regressions, this PR adds a unit test to
ensure that a DAG cycle is not detected when using Labels alongside
tasks contained in Task Groups.
---
tests/utils/test_dag_cycle.py | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/tests/utils/test_dag_cycle.py b/tests/utils/test_dag_cycle.py
index 8270bfdab3..94ec3188e4 100644
--- a/tests/utils/test_dag_cycle.py
+++ b/tests/utils/test_dag_cycle.py
@@ -23,6 +23,8 @@ from airflow import DAG
from airflow.exceptions import AirflowDagCycleException
from airflow.operators.empty import EmptyOperator
from airflow.utils.dag_cycle_tester import check_cycle
+from airflow.utils.edgemodifier import Label
+from airflow.utils.task_group import TaskGroup
from tests.models import DEFAULT_DATE
@@ -150,3 +152,17 @@ class TestCycleTester(unittest.TestCase):
with pytest.raises(AirflowDagCycleException):
assert not check_cycle(dag)
+
+ def test_cycle_task_group_with_edge_labels(self):
+ # Test a cycle is not detected when Labels are used between tasks in
Task Groups.
+
+ dag = DAG('dag', start_date=DEFAULT_DATE, default_args={'owner':
'owner1'})
+
+ with dag:
+ with TaskGroup(group_id="group"):
+ op1 = EmptyOperator(task_id='A')
+ op2 = EmptyOperator(task_id='B')
+
+ op1 >> Label("label") >> op2
+
+ assert not check_cycle(dag)