@@ -75,7 +75,12 @@ private class FakeTrigger(
7575 override fun getDagRunState (
7676 dagId : String ,
7777 runId : String ,
78- ): String = states[polls++ .coerceAtMost(states.lastIndex)]
78+ ): String {
79+ val started = triggered.last()
80+ assertEquals(started.dagId, dagId)
81+ assertEquals(started.runId, runId)
82+ return states[polls++ .coerceAtMost(states.lastIndex)]
83+ }
7984
8085 override fun isDagPaused (dagId : String ): Boolean = paused
8186
@@ -292,6 +297,17 @@ internal class TriggerRunnerTest {
292297 assertTrue(transport.triggered.isEmpty())
293298 }
294299
300+ @Test
301+ @DisplayName(" Should trigger a Dag that is not paused though the task would fail on a paused one" )
302+ fun shouldTriggerUnpausedDagWhenFailingOnPaused () {
303+ val transport = FakeTrigger (paused = false )
304+
305+ val result = run (TriggerDagRun (" downstream" ).config(" fail_when_dag_is_paused" , true ), transport)
306+
307+ assertInstanceOf(SucceedTask ::class .java, result)
308+ assertEquals(listOf (" downstream" ), transport.triggered.map { it.dagId })
309+ }
310+
295311 @Test
296312 @DisplayName(" Should wait until the triggered run reaches an allowed state" )
297313 fun shouldWaitForCompletion () {
@@ -358,6 +374,31 @@ internal class TriggerRunnerTest {
358374 )
359375 }
360376
377+ @Test
378+ @DisplayName(" Should follow the default deferrable setting when the task sets none" )
379+ fun shouldDeferByDefaultWhenConfigured () {
380+ val result =
381+ run (
382+ TriggerDagRun (" downstream" ).config(" wait_for_completion" , true ),
383+ FakeTrigger (),
384+ env = mapOf (" AIRFLOW__OPERATORS__DEFAULT_DEFERRABLE" to " true" ),
385+ )
386+
387+ assertInstanceOf(DeferTask ::class .java, result)
388+ }
389+
390+ @Test
391+ @DisplayName(" Should leave the deferred task's queue unset when triggerer queues are not enabled" )
392+ fun shouldNotQueueDeferralWithoutTriggererQueues () {
393+ val result =
394+ run (
395+ TriggerDagRun (" downstream" ).config(" wait_for_completion" , true ).config(" deferrable" , true ),
396+ FakeTrigger (),
397+ )
398+
399+ assertNull(assertInstanceOf(DeferTask ::class .java, result).queue)
400+ }
401+
361402 @Test
362403 @DisplayName(" Should not defer a task that does not wait" )
363404 fun shouldNotDeferWithoutWaiting () {
0 commit comments