@@ -13,33 +13,29 @@ def exception_handler(exception_type, exception, traceback):
1313
1414
1515def assert_metric (role , metric ):
16- response = requests .get (f'http://airflow-{ role } -default:9102/metrics' )
17- assert response .status_code == 200 , \
18- f"Metrics could not be retrieved from the { role } ."
19- assert metric in response .text , \
20- f"The { role } metrics do not contain the metric { metric } ."
16+ response = requests .get (f"http://airflow-{ role } -default:9102/metrics" )
17+ assert response .status_code == 200 , f"Metrics could not be retrieved from the { role } ."
18+ assert metric in response .text , f"The { role } metrics do not contain the metric { metric } ."
2119
2220
2321# Trigger a DAG run to create metrics
24- dag_id = ' example_trigger_target_dag'
25- dag_conf = {' message' : "Hello World" }
22+ dag_id = " example_trigger_target_dag"
23+ dag_conf = {" message" : "Hello World" }
2624
27- rest_url = ' http://airflow-webserver-default:8080/api/v1'
28- auth = (' airflow' , ' airflow' )
25+ rest_url = " http://airflow-webserver-default:8080/api/v1"
26+ auth = (" airflow" , " airflow" )
2927
3028# allow a few moments for the DAGs to be registered to all roles
3129time .sleep (10 )
3230
33- response = requests .patch (
34- f'{ rest_url } /dags/{ dag_id } ' , auth = auth , json = {'is_paused' : False })
35- response = requests .post (
36- f'{ rest_url } /dags/{ dag_id } /dagRuns' , auth = auth , json = {'conf' : dag_conf })
31+ response = requests .patch (f"{ rest_url } /dags/{ dag_id } " , auth = auth , json = {"is_paused" : False })
32+ response = requests .post (f"{ rest_url } /dags/{ dag_id } /dagRuns" , auth = auth , json = {"conf" : dag_conf })
3733
3834assert response .status_code == 200 , "DAG run could not be triggered."
3935
4036# Wait for the metrics to be consumed by the statsd-exporter
4137time .sleep (4 )
4238
43- assert_metric (' scheduler' , ' airflow_scheduler_heartbeat' )
44- assert_metric (' webserver' , ' airflow_task_instance_created_BashOperator' )
45- assert_metric (' worker' , ' airflow_ti_successes' )
39+ assert_metric (" scheduler" , " airflow_scheduler_heartbeat" )
40+ assert_metric (" webserver" , " airflow_task_instance_created_BashOperator" )
41+ assert_metric (" worker" , " airflow_ti_successes" )
0 commit comments