diff --git a/test/e2e/tests/gatewayt-with-envoyproxy.go b/test/e2e/tests/gatewayt-with-envoyproxy.go index ec9f7252a5e..e3100105f71 100644 --- a/test/e2e/tests/gatewayt-with-envoyproxy.go +++ b/test/e2e/tests/gatewayt-with-envoyproxy.go @@ -9,6 +9,7 @@ package tests import ( "context" + "net" "testing" "github.com/stretchr/testify/require" @@ -47,7 +48,7 @@ var GatewayWithEnvoyProxy = suite.ConformanceTest{ // Verify that the RouteType is set to Service by the attached EnvoyProxy Headers: map[string]string{ - "upstream-host": svc.Spec.ClusterIP + ":8080", + "upstream-host": net.JoinHostPort(svc.Spec.ClusterIP, "8080"), }, }, Namespace: ns, diff --git a/test/e2e/tests/utils.go b/test/e2e/tests/utils.go index 53aeb8b96a7..c63cad1e579 100644 --- a/test/e2e/tests/utils.go +++ b/test/e2e/tests/utils.go @@ -14,6 +14,7 @@ import ( "net" "net/http" "net/url" + "strconv" "strings" "testing" "time" @@ -400,7 +401,7 @@ func RetrieveURL(c client.Client, nn types.NamespacedName, port int32, path stri default: host = fmt.Sprintf("%s.%s.svc", nn.Name, nn.Namespace) } - return fmt.Sprintf("http://%s:%d%s", host, port, path), nil + return fmt.Sprintf("http://%s%s", net.JoinHostPort(host, strconv.Itoa(int(port))), path), nil } var metricParser = &expfmt.TextParser{} @@ -560,7 +561,7 @@ func QueryLogCountFromLoki(t *testing.T, c client.Client, keyValues map[string]s params := url.Values{} params.Add("query", q) params.Add("start", fmt.Sprintf("%d", time.Now().Add(-10*time.Minute).Unix())) // query logs from last 10 minutes - lokiQueryURL := fmt.Sprintf("http://%s:3100/loki/api/v1/query_range?%s", lokiHost, params.Encode()) + lokiQueryURL := fmt.Sprintf("http://%s/loki/api/v1/query_range?%s", net.JoinHostPort(lokiHost, "3100"), params.Encode()) res, err := http.DefaultClient.Get(lokiQueryURL) if err != nil { return -1, err