Test Workflow Trigger is flaky
- Dominant language
- Python
- Stars
- 46.9k
- Forks
- 17.8k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 483
Description
### Body
The suite of tests in TestWorkflowTrigger regarding the async io
seems pretty flaky - it keeps on failing randomly and we keep
on adding more tests as flaky.
We likely should address it more generically and implement better
harness for those tests.
The tests are in `tests/triggers/test_external_task.py`
Example failure case: https://github.com/apache/airflow/actions/runs/10158045390/job/28089723094#step:7:7069
```python
____________ TestWorkflowTrigger.test_task_workflow_trigger_skipped ____________
self =
mock_get_count =
@mock.patch("airflow.triggers.external_task._get_count")
@pytest.mark.asyncio
async def test_task_workflow_trigger_skipped(self, mock_get_count):
mock_get_count.side_effect = mocked_get_count
trigger = WorkflowTrigger(
external_dag_id=self.DAG_ID,
execution_dates=[timezone.datetime(2022, 1, 1)],
external_task_ids=[self.TASK_ID],
skipped_states=self.STATES,
poke_interval=0.2,
)
gen = trigger.run()
trigger_task = asyncio.create_task(gen.__anext__())
fake_task = asyncio.create_task(fake_async_fun())
await trigger_task
> assert fake_task.done() # confirm that get_count is done in an async fashion
E AssertionError: assert False
E + where False = ()
E + where = wait_for=>.done
```
### Committer
- [X] I acknowledge that I am a maintainer/committer of the Apache Airflow project.
Contributor guide
Research direction
Start with tests/triggers/test_external_task.py, especially TestWorkflowTrigger and test_task_workflow_trigger_skipped, then review the linked failure output. Investigate how the async generator and fake task are scheduled. Done means the tests use a more reliable async harness and no longer fail intermittently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100