Skip to content

Commit 2f8e716

Browse files
committed
test: add test for queue depth
1 parent 5b7fc5e commit 2f8e716

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
@@ -840,6 +840,8 @@ func TestMaxWaitTime(t *testing.T) {
840840
}
841841
`, "caddyfile")
842842

843+
ctx := caddy.ActiveContext()
844+
843845
// send 10 requests simultaneously, at least one request should be stalled longer than 1ns
844846
// since we only have 1 thread, this will cause a 504 Gateway Timeout
845847
wg := sync.WaitGroup{}
@@ -857,6 +859,20 @@ func TestMaxWaitTime(t *testing.T) {
857859
wg.Wait()
858860

859861
require.True(t, success.Load(), "At least one request should have failed with a 504 Gateway Timeout status")
862+
// Check metrics
863+
expectedMetrics := `
864+
# HELP frankenphp_queue_depth Number of regular queued requests
865+
# TYPE frankenphp_queue_depth gauge
866+
frankenphp_queue_depth{worker="service"} 0
867+
`
868+
869+
require.NoError(t,
870+
testutil.GatherAndCompare(
871+
ctx.GetMetricsRegistry(),
872+
strings.NewReader(expectedMetrics),
873+
"frankenphp_total_workers",
874+
"frankenphp_ready_workers",
875+
))
860876
}
861877

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

0 commit comments

Comments
 (0)