zhengdaodeguL commented on code in PR #77129:
URL: https://github.com/apache/airflow/pull/77129#discussion_r4584825692


##########
providers/standard/tests/unit/standard/triggers/test_external_task.py:
##########
@@ -119,6 +119,59 @@ async def test_task_workflow_trigger_failed(self, 
mock_get_count):
         with pytest.raises(StopAsyncIteration):
             await gen.__anext__()
 
+    @pytest.mark.parametrize(
+        ("failed_states", "skipped_states", "count", "expected_status", 
"expected_states"),
+        [
+            (["failed"], None, 1, "failed", ["failed"]),
+            (None, ["skipped"], 1, "skipped", ["skipped"]),
+            (None, None, 2, "success", ["success"]),
+        ],
+        ids=["partial-failure", "partial-skip", "all-tasks-allowed"],
+    )
+    
@mock.patch("airflow.sdk.execution_time.task_runner.RuntimeTaskInstance.get_ti_count")
+    @mock.patch(
+        "airflow.providers.standard.triggers.external_task.asyncio.sleep", 
new_callable=mock.AsyncMock
+    )
+    @pytest.mark.asyncio
+    async def test_task_workflow_trigger_multiple_task_counts(

Review Comment:
   Thanks for the suggestion — added 
`test_task_workflow_trigger_success_threshold` with three cases covering the 
success threshold directly (expected count is `len(task_ids) * len(runs)`):
   
   - Two tasks across three runs, allowed count 5 keeps polling, then 6 emits 
success (sleep awaited once, `get_ti_count` called twice).
   - Two tasks across three runs, allowed count 6 emits success immediately (no 
sleep).
   - One of two tasks succeeding in a single run (count 1) keeps polling, then 
2 emits success — partial success cannot finish the trigger early.
   
   The full focused test file passes (20 passed, 8 skipped Airflow 2-only 
tests) and ruff is clean. One verification note: these three cases also pass 
against the pre-fix code on the allowed path, because the old `int(count / 
len(task_ids))` division was arithmetically equivalent there — the actual 
behavioral change of this PR is in the failed/skipped paths, which the existing 
partial-failure and partial-skip cases cover. The new cases pin the 
`len(task_ids) * len(runs)` calculation so a future change to it fails loudly.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to