Skip to content

Commit 4d4ed91

Browse files
committed
test: add test for queue depth
1 parent 1d74b2c commit 4d4ed91

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

caddy/caddy_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,8 @@ func TestMaxWaitTime(t *testing.T) {
948948
}
949949
`, "caddyfile")
950950

951+
ctx := caddy.ActiveContext()
952+
951953
// send 10 requests simultaneously, at least one request should be stalled longer than 1ns
952954
// since we only have 1 thread, this will cause a 504 Gateway Timeout
953955
wg := sync.WaitGroup{}
@@ -965,6 +967,20 @@ func TestMaxWaitTime(t *testing.T) {
965967
wg.Wait()
966968

967969
require.True(t, success.Load(), "At least one request should have failed with a 504 Gateway Timeout status")
970+
// Check metrics
971+
expectedMetrics := `
972+
# HELP frankenphp_queue_depth Number of regular queued requests
973+
# TYPE frankenphp_queue_depth gauge
974+
frankenphp_queue_depth{worker="service"} 0
975+
`
976+
977+
require.NoError(t,
978+
testutil.GatherAndCompare(
979+
ctx.GetMetricsRegistry(),
980+
strings.NewReader(expectedMetrics),
981+
"frankenphp_total_workers",
982+
"frankenphp_ready_workers",
983+
))
968984
}
969985

970986
func getStatusCode(url string, t *testing.T) int {

0 commit comments

Comments
 (0)