From 7f2d0c97ca4be27d1a0ac5e60f01df86ad57d65a Mon Sep 17 00:00:00 2001 From: akshayjnambiar Date: Mon, 3 Nov 2025 16:24:39 +0000 Subject: [PATCH] Add flags for using FQDN for host, appending port for all requests, and timeout config --- conformance/conformance.go | 10 +++++++++- conformance/mesh/manifests.yaml | 10 ++++++++++ conformance/utils/echo/pod.go | 5 +++++ conformance/utils/flags/flags.go | 3 +++ conformance/utils/http/http.go | 16 ++++++++++++++-- 5 files changed, 41 insertions(+), 3 deletions(-) diff --git a/conformance/conformance.go b/conformance/conformance.go index 642a6eb280..7bd4c71f22 100644 --- a/conformance/conformance.go +++ b/conformance/conformance.go @@ -17,6 +17,7 @@ limitations under the License. package conformance import ( + "encoding/json" "io/fs" "os" "testing" @@ -81,6 +82,13 @@ func DefaultOptions(t *testing.T) suite.ConformanceOptions { *flags.ImplementationContact, ) + timeoutConfig := conformanceconfig.DefaultTimeoutConfig() + + if *flags.TimeoutConfig != "" { + err := json.Unmarshal([]byte(*flags.TimeoutConfig), &timeoutConfig) + require.NoError(t, err, "error initializing timeout config from the input") + } + return suite.ConformanceOptions{ AllowCRDsMismatch: *flags.AllowCRDsMismatch, CleanupBaseResources: *flags.CleanupBaseResources, @@ -103,7 +111,7 @@ func DefaultOptions(t *testing.T) suite.ConformanceOptions { RunTest: *flags.RunTest, SkipTests: skipTests, SupportedFeatures: supportedFeatures, - TimeoutConfig: conformanceconfig.DefaultTimeoutConfig(), + TimeoutConfig: timeoutConfig, SkipProvisionalTests: *flags.SkipProvisionalTests, } } diff --git a/conformance/mesh/manifests.yaml b/conformance/mesh/manifests.yaml index 5725d145c8..59927ead6f 100644 --- a/conformance/mesh/manifests.yaml +++ b/conformance/mesh/manifests.yaml @@ -28,6 +28,11 @@ spec: - name: echo image: gcr.io/k8s-staging-gateway-api/echo-advanced:v20240412-v1.0.0-394-g40c666fd imagePullPolicy: IfNotPresent + ports: + - containerPort: 8080 + - containerPort: 8443 + - containerPort: 9090 + - containerPort: 7070 args: - --tcp=9090 - --port=8080 @@ -85,6 +90,11 @@ spec: - name: echo image: gcr.io/k8s-staging-gateway-api/echo-advanced:v20240412-v1.0.0-394-g40c666fd imagePullPolicy: IfNotPresent + ports: + - containerPort: 8080 + - containerPort: 8443 + - containerPort: 9090 + - containerPort: 7070 args: - --tcp=9090 - --port=8080 diff --git a/conformance/utils/echo/pod.go b/conformance/utils/echo/pod.go index 1a3e40fb6c..3a763fd739 100644 --- a/conformance/utils/echo/pod.go +++ b/conformance/utils/echo/pod.go @@ -34,6 +34,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/gateway-api/conformance/utils/config" + "sigs.k8s.io/gateway-api/conformance/utils/flags" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/suite" "sigs.k8s.io/gateway-api/conformance/utils/tlog" @@ -104,6 +105,10 @@ func makeRequest(t *testing.T, exp *http.ExpectedResponse) []string { exp.Response.StatusCodes = []int{200} } + if *flags.UseFQDNHost { + r.Host = fmt.Sprintf("%v.%v", strings.Split(r.Host, ".")[0], "gateway-conformance-mesh.svc.cluster.local") + } + host := http.CalculateHost(t, r.Host, protocol) args := []string{"client", fmt.Sprintf("%s://%s%s", protocol, host, r.Path)} if protocol != "grpc" && r.Method != "" { diff --git a/conformance/utils/flags/flags.go b/conformance/utils/flags/flags.go index 1465df68b9..3a76c963ad 100644 --- a/conformance/utils/flags/flags.go +++ b/conformance/utils/flags/flags.go @@ -50,4 +50,7 @@ var ( ConformanceProfiles = flag.String("conformance-profiles", "", "Comma-separated list of the conformance profiles to run") ReportOutput = flag.String("report-output", "", "The file where to write the conformance report") SkipProvisionalTests = flag.Bool("skip-provisional-tests", false, "Whether to skip provisional tests") + UseFQDNHost = flag.Bool("use-fqdn-host", false, "Use FQDN for hosts for all requests") + AppendPortToHost = flag.Bool("append-port-to-host", false, "add port to the host for all ports including 80 and 443") + TimeoutConfig = flag.String("timeout-config", "", "TimeoutConfig object in json format") ) diff --git a/conformance/utils/http/http.go b/conformance/utils/http/http.go index 2d116423c1..ae38cc1540 100644 --- a/conformance/utils/http/http.go +++ b/conformance/utils/http/http.go @@ -26,6 +26,7 @@ import ( "time" "sigs.k8s.io/gateway-api/conformance/utils/config" + "sigs.k8s.io/gateway-api/conformance/utils/flags" "sigs.k8s.io/gateway-api/conformance/utils/roundtripper" "sigs.k8s.io/gateway-api/conformance/utils/tlog" "sigs.k8s.io/gateway-api/conformance/utils/weight" @@ -202,12 +203,23 @@ func CalculateHost(t *testing.T, gwAddr, scheme string) string { if !strings.Contains(err.Error(), "missing port in address") { tlog.Logf(t, "Failed to parse host %q: %v", gwAddr, err) } + if *flags.AppendPortToHost { + if port != "" { + return gwAddr + } + if strings.ToLower(scheme) == "http" { + return fmt.Sprintf("%v:%v", gwAddr, "80") + } + if strings.ToLower(scheme) == "https" { + return fmt.Sprintf("%v:%v", gwAddr, "443") + } + } return gwAddr } - if strings.ToLower(scheme) == "http" && port == "80" { + if strings.ToLower(scheme) == "http" && port == "80" && !*flags.AppendPortToHost { return Ipv6SafeHost(host) } - if strings.ToLower(scheme) == "https" && port == "443" { + if strings.ToLower(scheme) == "https" && port == "443" && !*flags.AppendPortToHost { return Ipv6SafeHost(host) } return gwAddr