Skip to content

Commit 6acd697

Browse files
committed
fix: remove loop spamming on response status != 200
1 parent adf2ffa commit 6acd697

1 file changed

Lines changed: 7 additions & 24 deletions

File tree

tests/templates/kuttl/mount-dags-gitsync/dag_metrics.py

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -62,27 +62,10 @@ def assert_metric(role, metric):
6262

6363
# Wait for the metrics to be consumed by the statsd-exporter
6464
time.sleep(5)
65-
# Test the DAG in a loop. Each time we call the script a new job will be started: we can avoid
66-
# or minimize this by looping over the check instead.
67-
iterations = 9
68-
loop = 0
69-
while True:
70-
try:
71-
logging.info(f"Response code: {response.status_code}")
72-
assert response.status_code == 200, "DAG run could not be triggered."
73-
# Worker is not deployed with the kubernetes executor so retrieve success metric from scheduler
74-
# (disable line-break flake checks)
75-
if (assert_metric("scheduler", "airflow_scheduler_heartbeat")) and (
76-
assert_metric(
77-
"scheduler", "airflow_dagrun_duration_success_sparkapp_dag_count"
78-
)
79-
): # noqa: W503, W504
80-
break
81-
time.sleep(10)
82-
loop += 1
83-
if loop == iterations:
84-
logging.error("Still waiting for metrics. Exiting to start a new loop....")
85-
# force re-try of script
86-
sys.exit(1)
87-
except AssertionError as error:
88-
logging.warning(f"Encountered: {error}")
65+
66+
logging.info(f"Response code: {response.status_code}")
67+
assert response.status_code == 200, "DAG run could not be triggered."
68+
# Worker is not deployed with the kubernetes executor so retrieve success metric from scheduler
69+
# (disable line-break flake checks)
70+
assert_metric("scheduler", "airflow_scheduler_heartbeat")
71+
assert_metric("scheduler", "airflow_dagrun_duration_success_sparkapp_dag_count")

0 commit comments

Comments
 (0)