@@ -948,8 +948,6 @@ func TestMaxWaitTime(t *testing.T) {
948948 }
949949 ` , "caddyfile" )
950950
951- ctx := caddy .ActiveContext ()
952-
953951 // send 10 requests simultaneously, at least one request should be stalled longer than 1ns
954952 // since we only have 1 thread, this will cause a 504 Gateway Timeout
955953 wg := sync.WaitGroup {}
@@ -967,19 +965,65 @@ func TestMaxWaitTime(t *testing.T) {
967965 wg .Wait ()
968966
969967 require .True (t , success .Load (), "At least one request should have failed with a 504 Gateway Timeout status" )
970- // Check metrics
968+ }
969+
970+ func TestMaxWaitTimeWorker (t * testing.T ) {
971+ tester := caddytest .NewTester (t )
972+ tester .InitServer (`
973+ {
974+ skip_install_trust
975+ admin localhost:2999
976+ metrics
977+ http_port ` + testPort + `
978+
979+ frankenphp {
980+ max_wait_time 1ns
981+ worker {
982+ name service
983+ num 1
984+ file ../testdata/sleep.php
985+ }
986+ }
987+ }
988+
989+ localhost:` + testPort + ` {
990+ route {
991+ root ../testdata
992+ php
993+ }
994+ }
995+ ` , "caddyfile" )
996+
997+ // send 10 requests simultaneously, at least one request should be stalled longer than 1ns
998+ // since we only have 1 thread, this will cause a 504 Gateway Timeout
999+ wg := sync.WaitGroup {}
1000+ success := atomic.Bool {}
1001+ wg .Add (10 )
1002+ for i := 0 ; i < 10 ; i ++ {
1003+ go func () {
1004+ statusCode := getStatusCode ("http://localhost:" + testPort + "/sleep.php?sleep=100" , t )
1005+ fmt .Printf ("Status code: %d\n " , statusCode )
1006+ if statusCode == http .StatusGatewayTimeout {
1007+ success .Store (true )
1008+ }
1009+ wg .Done ()
1010+ }()
1011+ }
1012+ wg .Wait ()
1013+
1014+ require .True (t , success .Load (), "At least one request should have failed with a 504 Gateway Timeout status" )
9711015 expectedMetrics := `
972- # HELP frankenphp_queue_depth Number of regular queued requests
973- # TYPE frankenphp_queue_depth gauge
974- frankenphp_queue_depth{worker="service"} 0
1016+ # TYPE frankenphp_worker_queue_depth gauge
1017+ frankenphp_worker_queue_depth{worker="service"} 0
9751018 `
9761019
1020+ ctx := caddy .ActiveContext ()
1021+ fmt .Printf ("Metrics: %d\n " , testutil .CollectAndCount (ctx .GetMetricsRegistry (), "frankenphp_worker_queue_depth" ))
9771022 require .NoError (t ,
9781023 testutil .GatherAndCompare (
9791024 ctx .GetMetricsRegistry (),
9801025 strings .NewReader (expectedMetrics ),
981- "frankenphp_total_workers" ,
982- "frankenphp_ready_workers" ,
1026+ "frankenphp_worker_queue_depth" ,
9831027 ))
9841028}
9851029
0 commit comments