Commit 65abcbb
authored
test: stop autoscale tests from hanging on request failure (#2413)
`TestAutoScaleRegularThreadsOnAutomaticThreadLimit` (and its sibling
`TestAutoScaleWorkerThreads`) in `caddy/admin_test.go` would burn the
package-wide 10 minute Go test timeout whenever the PHP server returned
a connection error during the load loop. This was observed on the PHP
8.5 / Linux CI matrix on #2412
(and on #2381 for the related
`TestAddModuleWorkerViaAdminApi`).
Root cause: `caddytest.AssertGetResponse` calls `t.Fatalf` on connection
errors. From a non-test goroutine that triggers `runtime.Goexit`, which
skips the plain `wg.Done()` after it, so `wg.Wait()` blocks forever and
the retry loop never gets to check `amountOfThreads` or break out.
Two surgical changes:
- `defer wg.Done()` so a `Fatalf`'d goroutine still decrements the
WaitGroup.
- Break out of the retry loop once `t.Failed()` is true so we don't keep
hammering an already-broken server for another 9 rounds.
Net diff: +6 / -2 lines per test, no new imports.1 parent 6ae610c commit 65abcbb
1 file changed
Lines changed: 6 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| 165 | + | |
| 166 | + | |
165 | 167 | | |
166 | | - | |
167 | 168 | | |
168 | 169 | | |
169 | 170 | | |
170 | 171 | | |
171 | 172 | | |
172 | | - | |
| 173 | + | |
173 | 174 | | |
174 | 175 | | |
175 | 176 | | |
| |||
214 | 215 | | |
215 | 216 | | |
216 | 217 | | |
| 218 | + | |
| 219 | + | |
217 | 220 | | |
218 | | - | |
219 | 221 | | |
220 | 222 | | |
221 | 223 | | |
222 | 224 | | |
223 | 225 | | |
224 | | - | |
| 226 | + | |
225 | 227 | | |
226 | 228 | | |
227 | 229 | | |
| |||
0 commit comments