ephraimbuddy commented on code in PR #71459:
URL: https://github.com/apache/airflow/pull/71459#discussion_r4006030710


##########
airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dag_run.py:
##########
@@ -438,6 +438,31 @@ def test_get_dag_run_not_found(self, test_client):
         body = response.json()
         assert body["detail"] == "The DagRun with dag_id: `test_dag1` and 
run_id: `invalid` was not found"
 
+    @pytest.mark.usefixtures("configure_git_connection_for_dag_bundle")
+    def test_get_dag_run_dag_versions_query_count_does_not_scale_with_ti_count(
+        self, test_client, dag_maker, session
+    ):
+        query_counts = []
+        for ti_count in (3, 20):
+            dag_id = f"test_get_dag_run_prefetch_{ti_count}"
+            with dag_maker(dag_id=dag_id, schedule=None, 
start_date=START_DATE1, serialized=True):
+                for i in range(ti_count):
+                    EmptyOperator(task_id=f"task_{i}")
+            dag_run = dag_maker.create_dagrun(run_id=f"run_{ti_count}", 
state=DagRunState.SUCCESS)
+            session.commit()
+
+            with count_queries() as result:
+                response = 
test_client.get(f"/dags/{dag_id}/dagRuns/{dag_run.run_id}")
+
+            assert response.status_code == 200
+            assert response.json()["dag_versions"]
+            query_counts.append(sum(result.values()))
+
+        assert query_counts[0] == query_counts[1], (

Review Comment:
   This test still passes with the entire get_dag_run() change reverted. Query 
count stays flat even when each query loads every TI/TIH row, so it doesn’t 
catch the reported regression. Please assert that response serialization leaves 
those collections unloaded, including for a bundle-versioned run with history.



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