@@ -865,14 +865,15 @@ func TestMaxWaitTimeWorker(t *testing.T) {
865865 {
866866 skip_install_trust
867867 admin localhost:2999
868- metrics
869868 http_port ` + testPort + `
869+ metrics
870870
871871 frankenphp {
872+ num_threads 2
872873 max_wait_time 1ns
873874 worker {
874- name service
875875 num 1
876+ name service
876877 file ../testdata/sleep.php
877878 }
878879 }
@@ -893,24 +894,31 @@ func TestMaxWaitTimeWorker(t *testing.T) {
893894 wg .Add (10 )
894895 for i := 0 ; i < 10 ; i ++ {
895896 go func () {
896- statusCode := getStatusCode ("http://localhost:" + testPort + "/sleep.php?sleep=100" , t )
897- fmt .Printf ("Status code: %d\n " , statusCode )
897+ statusCode := getStatusCode ("http://localhost:" + testPort + "/sleep.php?sleep=10000&iteration=1" , t )
898898 if statusCode == http .StatusGatewayTimeout {
899899 success .Store (true )
900900 }
901901 wg .Done ()
902902 }()
903903 }
904904 wg .Wait ()
905-
906905 require .True (t , success .Load (), "At least one request should have failed with a 504 Gateway Timeout status" )
906+
907+ // Fetch metrics
908+ resp , err := http .Get ("http://localhost:2999/metrics" )
909+ require .NoError (t , err , "failed to fetch metrics" )
910+ defer resp .Body .Close ()
911+
912+ // Read and parse metrics
913+ metrics := new (bytes.Buffer )
914+ _ , err = metrics .ReadFrom (resp .Body )
915+
907916 expectedMetrics := `
908917 # TYPE frankenphp_worker_queue_depth gauge
909- frankenphp_worker_queue_depth{worker="service"} 0
918+ frankenphp_worker_queue_depth{worker="service"} 9
910919 `
911920
912921 ctx := caddy .ActiveContext ()
913- fmt .Printf ("Metrics: %d\n " , testutil .CollectAndCount (ctx .GetMetricsRegistry (), "frankenphp_worker_queue_depth" ))
914922 require .NoError (t ,
915923 testutil .GatherAndCompare (
916924 ctx .GetMetricsRegistry (),
0 commit comments