You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ColtenOuO (via GitHub)" <gi...@apache.org> on 2026/08/30 16:18:20 UTC
[PR] Add deadline alert coverage to DAG endpoint tests [airflow]
ColtenOuO opened a new pull request, #72296:
URL: https://github.com/apache/airflow/pull/72296
### Summary
Although PR #64815 was closed, issue #50992 remains on the roadmap for AIP-86, so I've opened this PR to address it.
- Add tests verifying the public DAG API endpoints work correctly with deadline-bearing DAGs
- Cover `GET /dags`, `GET /dags/{id}`, `GET /dags/{id}/details`, `PATCH /dags/{id}`, `PATCH /dags`, and `DELETE /dags/{id}`
- Add `clear_db_deadline` and `clear_db_deadline_alert` to test cleanup to prevent FK constraint issues
### Details
The public DAG endpoint tests (`test_dags.py`) never created DAGs with deadline alerts, so there was
no coverage for how the API behaves when `DagModel._deadline` has data and
`SerializedDagModel.deadline_alerts` has FK-linked records.
7 new test methods across 6 test classes. No existing tests modified.
closes: #50992
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes — Claude Code (Sonnet 5)
Generated-by: Claude Code (Sonnet 5) following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add deadline alert coverage to Dag endpoint tests [airflow]
Posted by "shahar1 (via GitHub)" <gi...@apache.org>.
shahar1 merged PR #72296:
URL: https://github.com/apache/airflow/pull/72296
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add deadline alert coverage to DAG endpoint tests [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on code in PR #72296:
URL: https://github.com/apache/airflow/pull/72296#discussion_r3963555707
##########
airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dags.py:
##########
@@ -863,6 +879,53 @@ def test_get_dags_no_n_plus_one_queries(self, session, test_client):
f"({first_query_count} → {second_query_count}), suggesting n+1 queries for tags"
)
+ def test_get_dags_includes_dag_with_deadline(self, dag_maker, test_client, session):
+ deadline_dag_id = "test_dag_with_deadline"
+ with dag_maker(
+ deadline_dag_id,
+ schedule=None,
+ start_date=DAG1_START_DATE,
+ deadline=DeadlineAlert(
+ reference=DeadlineReference.DAGRUN_LOGICAL_DATE,
+ interval=timedelta(hours=1),
+ callback=_deadline_callback(),
+ ),
+ ):
+ EmptyOperator(task_id="task1")
+ dag_maker.sync_dagbag_to_db()
+
+ response = test_client.get("/dags")
Review Comment:
Could you add an assertion to each of these that the deadline actually landed in the DB? Right now if you strip the deadline out of the dag_maker call, these tests should still pass since nothing here is deadline-specific. You already take `session` as a fixture so asserting the `deadline_alert` rows exist should be easy.
These two tests are also almost identical, which usually smells like a case for parameterizing the tests. Maybe combine them into one with a parameterized deadline and expected_row_count? Up to you.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add deadline alert coverage to DAG endpoint tests [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on PR #72296:
URL: https://github.com/apache/airflow/pull/72296#issuecomment-5593810448
Does shivaam deserve co-author credit or is this a substantial change over the closed PR?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add deadline alert coverage to DAG endpoint tests [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on PR #72296:
URL: https://github.com/apache/airflow/pull/72296#issuecomment-5609134071
@bbovenzi - Did you ant to review this since it's touching the API? It's just adding additional testing, so shouldn't be a problem.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add deadline alert coverage to DAG endpoint tests [airflow]
Posted by "ColtenOuO (via GitHub)" <gi...@apache.org>.
ColtenOuO commented on code in PR #72296:
URL: https://github.com/apache/airflow/pull/72296#discussion_r3971006727
##########
airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dags.py:
##########
@@ -863,6 +879,53 @@ def test_get_dags_no_n_plus_one_queries(self, session, test_client):
f"({first_query_count} → {second_query_count}), suggesting n+1 queries for tags"
)
+ def test_get_dags_includes_dag_with_deadline(self, dag_maker, test_client, session):
+ deadline_dag_id = "test_dag_with_deadline"
+ with dag_maker(
+ deadline_dag_id,
+ schedule=None,
+ start_date=DAG1_START_DATE,
+ deadline=DeadlineAlert(
+ reference=DeadlineReference.DAGRUN_LOGICAL_DATE,
+ interval=timedelta(hours=1),
+ callback=_deadline_callback(),
+ ),
+ ):
+ EmptyOperator(task_id="task1")
+ dag_maker.sync_dagbag_to_db()
+
+ response = test_client.get("/dags")
Review Comment:
Thanks for pointing that out.
I only just realized the test wasn't actually covering the deadline at all :O
I've updated it now!
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add deadline alert coverage to DAG endpoint tests [airflow]
Posted by "ColtenOuO (via GitHub)" <gi...@apache.org>.
ColtenOuO commented on PR #72296:
URL: https://github.com/apache/airflow/pull/72296#issuecomment-5605572018
> Does shivaam deserve co-author credit or is this a substantial change over the closed PR?
Sure! I think this is worthful to add shivaam to co-author, because the overall logic was based on his implementation.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add deadline alert coverage to DAG endpoint tests [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on PR #72296:
URL: https://github.com/apache/airflow/pull/72296#issuecomment-5609116410
LGTM. Thanks for adding the tests
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add deadline alert coverage to Dag endpoint tests [airflow]
Posted by "ColtenOuO (via GitHub)" <gi...@apache.org>.
ColtenOuO commented on PR #72296:
URL: https://github.com/apache/airflow/pull/72296#issuecomment-5738543967
> Could you please fix conflicts?
Sure!
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org