Issue: https://github.com/coder/coder/issues/5249 While running tests in parallel, the web server seems to be overloaded and responds with HTTP 502. require.Eventually expects correct HTTP responses.
(ctx context.Context, t require.TestingT, client *codersdk.Client, method, path string, body interface{}, opts ...codersdk.RequestOption)
| 15 | // require.Eventually expects correct HTTP responses. |
| 16 | |
| 17 | func requestWithRetries(ctx context.Context, t require.TestingT, client *codersdk.Client, method, path string, body interface{}, opts ...codersdk.RequestOption) (*http.Response, error) { |
| 18 | var resp *http.Response |
| 19 | var err error |
| 20 | require.Eventually(t, func() bool { |
| 21 | // nolint // only requests which are not passed upstream have a body closed |
| 22 | resp, err = client.Request(ctx, method, path, body, opts...) |
| 23 | if resp != nil && resp.StatusCode == http.StatusBadGateway { |
| 24 | if resp.Body != nil { |
| 25 | resp.Body.Close() |
| 26 | } |
| 27 | return false |
| 28 | } |
| 29 | return true |
| 30 | }, testutil.WaitLong, testutil.IntervalFast) |
| 31 | return resp, err |
| 32 | } |
no test coverage detected