(t *testing.T)
| 157 | } |
| 158 | |
| 159 | func TestKeepRunningOnConnectionAbort(t *testing.T) { |
| 160 | runTest(t, func(handler func(http.ResponseWriter, *http.Request), _ *httptest.Server, i int) { |
| 161 | req := httptest.NewRequest("GET", "http://example.com/worker-with-counter.php", nil) |
| 162 | |
| 163 | ctx, cancel := context.WithCancel(req.Context()) |
| 164 | req = req.WithContext(ctx) |
| 165 | cancel() |
| 166 | body1, _ := testRequest(req, handler, t) |
| 167 | |
| 168 | assert.Equal(t, "requests:1", body1, "should have handled exactly one request") |
| 169 | body2, _ := testGet("http://example.com/worker-with-counter.php", handler, t) |
| 170 | |
| 171 | assert.Equal(t, "requests:2", body2, "should not have stopped execution after the first request was aborted") |
| 172 | }, &testOptions{workerScript: "worker-with-counter.php", nbWorkers: 1, nbParallelRequests: 1}) |
| 173 | } |
| 174 | |
| 175 | // TestWorkerMaxRequests verifies that a worker restarts after reaching max_requests. |
| 176 | func TestWorkerMaxRequests(t *testing.T) { |
nothing calls this directly
no test coverage detected