This is an automated email from the ASF dual-hosted git repository.
pierrejeambrun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 8ee6f583811 Add number of queries guard for ui dashboard (#57956)
8ee6f583811 is described below
commit 8ee6f583811bb56732c5fae243eb803a54284de5
Author: Pierre Jeambrun <[email protected]>
AuthorDate: Thu Nov 6 15:44:30 2025 +0100
Add number of queries guard for ui dashboard (#57956)
---
.../api_fastapi/core_api/routes/ui/test_dashboard.py | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git
a/airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_dashboard.py
b/airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_dashboard.py
index 1c29990fc9c..6c638bd57a6 100644
--- a/airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_dashboard.py
+++ b/airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_dashboard.py
@@ -28,6 +28,7 @@ from airflow.providers.standard.operators.empty import
EmptyOperator
from airflow.utils.state import DagRunState, TaskInstanceState
from airflow.utils.types import DagRunType
+from tests_common.test_utils.asserts import assert_queries_count
from tests_common.test_utils.db import clear_db_runs
pytestmark = pytest.mark.db_test
@@ -309,7 +310,8 @@ class TestHistoricalMetricsDataEndpoint:
)
@pytest.mark.usefixtures("freeze_time_for_dagruns", "make_dag_runs")
def test_should_response_200(self, test_client, params, expected):
- response = test_client.get("/dashboard/historical_metrics_data",
params=params)
+ with assert_queries_count(4):
+ response = test_client.get("/dashboard/historical_metrics_data",
params=params)
assert response.status_code == 200
assert response.json() == expected
@@ -329,7 +331,8 @@ class TestHistoricalMetricsDataEndpoint:
class TestDagStatsEndpoint:
@pytest.mark.usefixtures("freeze_time_for_dagruns", "make_multiple_dags")
def test_should_response_200_multiple_dags(self, test_client):
- response = test_client.get("/dashboard/dag_stats")
+ with assert_queries_count(3):
+ response = test_client.get("/dashboard/dag_stats")
assert response.status_code == 200
assert response.json() == {
"active_dag_count": 4,
@@ -340,7 +343,8 @@ class TestDagStatsEndpoint:
@pytest.mark.usefixtures("freeze_time_for_dagruns", "make_dag_runs")
def test_should_response_200_single_dag(self, test_client):
- response = test_client.get("/dashboard/dag_stats")
+ with assert_queries_count(3):
+ response = test_client.get("/dashboard/dag_stats")
assert response.status_code == 200
assert response.json() == {
"active_dag_count": 1,
@@ -351,7 +355,8 @@ class TestDagStatsEndpoint:
@pytest.mark.usefixtures("freeze_time_for_dagruns", "make_failed_dag_runs")
def test_should_response_200_failed_dag(self, test_client):
- response = test_client.get("/dashboard/dag_stats")
+ with assert_queries_count(3):
+ response = test_client.get("/dashboard/dag_stats")
assert response.status_code == 200
assert response.json() == {
"active_dag_count": 1,
@@ -362,7 +367,8 @@ class TestDagStatsEndpoint:
@pytest.mark.usefixtures("freeze_time_for_dagruns", "make_queued_dag_runs")
def test_should_response_200_queued_dag(self, test_client):
- response = test_client.get("/dashboard/dag_stats")
+ with assert_queries_count(3):
+ response = test_client.get("/dashboard/dag_stats")
assert response.status_code == 200
assert response.json() == {
"active_dag_count": 1,
@@ -373,7 +379,8 @@ class TestDagStatsEndpoint:
@pytest.mark.usefixtures("freeze_time_for_dagruns")
def test_should_response_200_no_dag_runs(self, test_client):
- response = test_client.get("/dashboard/dag_stats")
+ with assert_queries_count(3):
+ response = test_client.get("/dashboard/dag_stats")
assert response.status_code == 200
assert response.json() == {
"active_dag_count": 0,