ybendana commented on a change in pull request #4291: [AIRFLOW-1488] Add the 
TriggeredDagRunSensor operator
URL: https://github.com/apache/airflow/pull/4291#discussion_r301832364
 
 

 ##########
 File path: tests/dags/test_triggered_dagrun_sensor_dag.py
 ##########
 @@ -0,0 +1,66 @@
+# -*- coding: utf-8 -*-
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from airflow import DAG
+from airflow.api.common.experimental.trigger_dag import trigger_dag
+from airflow.operators.bash_operator import BashOperator
+from airflow.operators.python_operator import PythonOperator
+from airflow.contrib.sensors.triggered_dagrun_sensor import 
TriggeredDagRunSensor
+from tests.contrib.sensors.test_triggered_dagrun_sensor import (
+    DEFAULT_DATE, TEST_DAG_CHILD, TEST_DAG_PARENT)
+
+args = {
+    'start_date': DEFAULT_DATE,
+    'owner': 'airflow',
+    'depends_on_past': False
+}
+
+# Child dag with a 3 second delay
+with DAG(dag_id=TEST_DAG_CHILD,
+         default_args=args,
+         start_date=DEFAULT_DATE,
+         schedule_interval=None) as dag_child:
+    t1 = BashOperator(
+        task_id='task_1',
+        bash_command="echo 'one'; sleep 3",
+    )
+    t2 = BashOperator(
+        task_id='task_2',
+        bash_command="echo 'two'",
+    )
+    t1 >> t2
+
+
+# Parent dag that triggers child dag and senses it
+with DAG(dag_id=TEST_DAG_PARENT,
+         default_args=args,
+         start_date=DEFAULT_DATE,
+         schedule_interval=None) as dag_parent:
 
 Review comment:
   Yes they do get loaded when I run `nosetests 
tests/test_triggered_dagrun_sensor.py` in the Docker container. The 
TEST_DAG_PARENT will get executed.  The TEST_DAG_CHILD will get triggered but 
doesn't execute, not sure why.  The TriggeredDagRunSensor will then timeout. 
Even though I don't see the typical "triggering dag" log message, I know the 
child dag gets triggered because when I run `airflow scheduler` the triggered 
child dag will execute. Another thing that makes debugging harder is that the 
log messages in the TriggeredDagRunSensor don't display in the nose output.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to