From 626417a23a29ee4852a1cc1d267c54f5cb6f399e Mon Sep 17 00:00:00 2001 From: feistel <6742251-feistel@users.noreply.gitlab.com> Date: Thu, 22 Apr 2021 02:05:04 +0200 Subject: Fix acceptance tests not running on IPv4-only systems --- test/acceptance/helpers_test.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'test/acceptance/helpers_test.go') diff --git a/test/acceptance/helpers_test.go b/test/acceptance/helpers_test.go index d2c3c31e..cc27299e 100644 --- a/test/acceptance/helpers_test.go +++ b/test/acceptance/helpers_test.go @@ -22,6 +22,7 @@ import ( "github.com/pires/go-proxyproto" "github.com/stretchr/testify/require" + "golang.org/x/net/nettest" "gitlab.com/gitlab-org/gitlab-pages/internal/request" "gitlab.com/gitlab-org/gitlab-pages/test/acceptance/testdata" @@ -142,6 +143,13 @@ type ListenSpec struct { Port string } +func SupportedListeners() []ListenSpec { + if !nettest.SupportsIPv6() { + return ipv4Listeners + } + return listeners +} + func (l ListenSpec) URL(suffix string) string { scheme := request.SchemeHTTP if l.Type == request.SchemeHTTPS || l.Type == "https-proxyv2" { @@ -319,7 +327,7 @@ func runPagesProcess(t *testing.T, wait bool, pagesBinary string, listeners []Li } if wait { - for _, spec := range listeners { + for _, spec := range SupportedListeners() { if err := spec.WaitUntilRequestSucceeds(waitCh); err != nil { cleanup() t.Fatal(err) @@ -335,7 +343,7 @@ func getPagesArgs(t *testing.T, listeners []ListenSpec, promPort string, extraAr args = append(args, "-log-verbose=true") - for _, spec := range listeners { + for _, spec := range SupportedListeners() { args = append(args, "-listen-"+spec.Type, spec.JoinHostPort()) if spec.Type == request.SchemeHTTPS { @@ -519,7 +527,7 @@ func ClientWithConfig(tlsConfig *tls.Config) (*http.Client, func()) { func waitForRoundtrips(t *testing.T, listeners []ListenSpec, timeout time.Duration) { nListening := 0 start := time.Now() - for _, spec := range listeners { + for _, spec := range SupportedListeners() { for time.Since(start) < timeout { req, err := http.NewRequest("GET", spec.URL("/"), nil) if err != nil { -- cgit v1.2.3