@@ -973,14 +973,15 @@ func TestMaxWaitTimeWorker(t *testing.T) {
973973 {
974974 skip_install_trust
975975 admin localhost:2999
976- metrics
977976 http_port ` + testPort + `
977+ metrics
978978
979979 frankenphp {
980+ num_threads 2
980981 max_wait_time 1ns
981982 worker {
982- name service
983983 num 1
984+ name service
984985 file ../testdata/sleep.php
985986 }
986987 }
@@ -1001,24 +1002,31 @@ func TestMaxWaitTimeWorker(t *testing.T) {
10011002 wg .Add (10 )
10021003 for i := 0 ; i < 10 ; i ++ {
10031004 go func () {
1004- statusCode := getStatusCode ("http://localhost:" + testPort + "/sleep.php?sleep=100" , t )
1005- fmt .Printf ("Status code: %d\n " , statusCode )
1005+ statusCode := getStatusCode ("http://localhost:" + testPort + "/sleep.php?sleep=10000&iteration=1" , t )
10061006 if statusCode == http .StatusGatewayTimeout {
10071007 success .Store (true )
10081008 }
10091009 wg .Done ()
10101010 }()
10111011 }
10121012 wg .Wait ()
1013-
10141013 require .True (t , success .Load (), "At least one request should have failed with a 504 Gateway Timeout status" )
1014+
1015+ // Fetch metrics
1016+ resp , err := http .Get ("http://localhost:2999/metrics" )
1017+ require .NoError (t , err , "failed to fetch metrics" )
1018+ defer resp .Body .Close ()
1019+
1020+ // Read and parse metrics
1021+ metrics := new (bytes.Buffer )
1022+ _ , err = metrics .ReadFrom (resp .Body )
1023+
10151024 expectedMetrics := `
10161025 # TYPE frankenphp_worker_queue_depth gauge
1017- frankenphp_worker_queue_depth{worker="service"} 0
1026+ frankenphp_worker_queue_depth{worker="service"} 9
10181027 `
10191028
10201029 ctx := caddy .ActiveContext ()
1021- fmt .Printf ("Metrics: %d\n " , testutil .CollectAndCount (ctx .GetMetricsRegistry (), "frankenphp_worker_queue_depth" ))
10221030 require .NoError (t ,
10231031 testutil .GatherAndCompare (
10241032 ctx .GetMetricsRegistry (),
0 commit comments