MCPcopy Index your code
hub / github.com/coder/coder / requestWithRetries

Function requestWithRetries

coderd/client_test.go:17–32  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

15// require.Eventually expects correct HTTP responses.
16
17func 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}

Callers 1

TestSwaggerFunction · 0.70

Calls 2

CloseMethod · 0.65
RequestMethod · 0.45

Tested by

no test coverage detected