(t *testing.T)
| 84 | } |
| 85 | |
| 86 | func TestThreadDebugStateMetricsAfterRequests(t *testing.T) { |
| 87 | tester := caddytest.NewTester(t) |
| 88 | tester.InitServer(` |
| 89 | { |
| 90 | skip_install_trust |
| 91 | admin localhost:2999 |
| 92 | http_port `+testPort+` |
| 93 | |
| 94 | frankenphp { |
| 95 | num_threads 2 |
| 96 | worker ../testdata/worker-with-counter.php 1 |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | localhost:`+testPort+` { |
| 101 | route { |
| 102 | root ../testdata |
| 103 | rewrite worker-with-counter.php |
| 104 | php |
| 105 | } |
| 106 | } |
| 107 | `, "caddyfile") |
| 108 | |
| 109 | // make a few requests so counters are populated |
| 110 | tester.AssertGetResponse("http://localhost:"+testPort+"/", http.StatusOK, "requests:1") |
| 111 | tester.AssertGetResponse("http://localhost:"+testPort+"/", http.StatusOK, "requests:2") |
| 112 | tester.AssertGetResponse("http://localhost:"+testPort+"/", http.StatusOK, "requests:3") |
| 113 | |
| 114 | debugState := getDebugState(t, tester) |
| 115 | |
| 116 | hasRequestCount := false |
| 117 | for _, ts := range debugState.ThreadDebugStates { |
| 118 | if ts.RequestCount > 0 { |
| 119 | hasRequestCount = true |
| 120 | assert.Greater(t, ts.MemoryUsage, int64(0), "thread %d (%s) should report memory usage", ts.Index, ts.Name) |
| 121 | } |
| 122 | } |
| 123 | assert.True(t, hasRequestCount, "at least one thread should have RequestCount > 0 after serving requests") |
| 124 | } |
| 125 | |
| 126 | func TestAutoScaleWorkerThreads(t *testing.T) { |
| 127 | wg := sync.WaitGroup{} |
nothing calls this directly
no test coverage detected