MCPcopy Index your code
hub / github.com/ddev/ddev / EnsureLocalHTTPContent

Function EnsureLocalHTTPContent

pkg/testcommon/testcommon.go:584–600  ·  view source on GitHub ↗

EnsureLocalHTTPContent will verify a URL responds with a 200, expected content string, and optional parameters. Parameters can be either: - HTTPRequestOpts struct with TimeoutSeconds and MaxRetries fields - int representing timeout seconds (for backward compatibility)

(t *testing.T, rawurl string, expectedContent string, params ...any)

Source from the content-addressed store, hash-verified

582// - HTTPRequestOpts struct with TimeoutSeconds and MaxRetries fields
583// - int representing timeout seconds (for backward compatibility)
584func EnsureLocalHTTPContent(t *testing.T, rawurl string, expectedContent string, params ...any) (*http.Response, error) {
585 options := parseHTTPRequestOpts(40, params...)
586 assert := asrt.New(t)
587
588 body, resp, err := GetLocalHTTPResponse(t, rawurl, options)
589 // We see intermittent php-fpm SIGBUS failures, only on macOS.
590 // That results in a 502/503. If we get a 502/503 on macOS, try again.
591 // It seems to be a 502 with nginx-fpm and a 503 with apache-fpm
592 if nodeps.IsMacOS() && resp != nil && (resp.StatusCode >= 500) {
593 t.Logf("Received %d error on macOS, retrying GetLocalHTTPResponse", resp.StatusCode)
594 time.Sleep(time.Second)
595 body, resp, err = GetLocalHTTPResponse(t, rawurl, options)
596 }
597 assert.NoError(err, "GetLocalHTTPResponse returned err on rawurl %s, resp=%v, body=%v: %v", rawurl, resp, body, err)
598 assert.Contains(body, expectedContent, "request %s got resp=%v, body:\n========\n%s\n==========\n", rawurl, resp, body)
599 return resp, err
600}
601
602// CheckGoroutineOutput makes sure that goroutines
603// aren't beyond specified level

Callers 13

TestPHPOverridesFunction · 0.92
TestDdevFullSiteSetupFunction · 0.92
TestMailpitFunction · 0.92
TestUseEphemeralPortFunction · 0.92
TestTraefikSimpleFunction · 0.92
TestTraefikVirtualHostFunction · 0.92
TestCmdLogsFunction · 0.92
TestCmdSSHFunction · 0.92

Calls 3

IsMacOSFunction · 0.92
parseHTTPRequestOptsFunction · 0.85
GetLocalHTTPResponseFunction · 0.85

Tested by 13

TestPHPOverridesFunction · 0.74
TestDdevFullSiteSetupFunction · 0.74
TestMailpitFunction · 0.74
TestUseEphemeralPortFunction · 0.74
TestTraefikSimpleFunction · 0.74
TestTraefikVirtualHostFunction · 0.74
TestCmdLogsFunction · 0.74
TestCmdSSHFunction · 0.74