From b6c5cec44c62244bd84b11198655c352b77e3d0e Mon Sep 17 00:00:00 2001 From: zirain Date: Fri, 15 Nov 2024 20:41:39 +0800 Subject: [PATCH 1/2] skip test Signed-off-by: zirain --- test/e2e/tests/backend_dualstack.go | 19 +++++-------------- test/e2e/tests/httproute_dualstack.go | 20 +++++--------------- test/e2e/tests/ratelimit.go | 12 ++++++++++++ test/e2e/tests/utils.go | 3 +++ 4 files changed, 25 insertions(+), 29 deletions(-) diff --git a/test/e2e/tests/backend_dualstack.go b/test/e2e/tests/backend_dualstack.go index c7db450824e..1ebed96161a 100644 --- a/test/e2e/tests/backend_dualstack.go +++ b/test/e2e/tests/backend_dualstack.go @@ -9,7 +9,6 @@ package tests import ( - "os" "testing" "k8s.io/apimachinery/pkg/types" @@ -20,11 +19,7 @@ import ( // If the environment is not dual, the IPv6 manifest cannot be applied, so the test will be skipped. func init() { - if os.Getenv("IP_FAMILY") == "dual" { - ConformanceTests = append(ConformanceTests, BackendDualStackTest) - } else { - ConformanceTests = append(ConformanceTests, SkipBackendDualStackTest) - } + ConformanceTests = append(ConformanceTests, BackendDualStackTest) } var BackendDualStackTest = suite.ConformanceTest{ @@ -32,6 +27,10 @@ var BackendDualStackTest = suite.ConformanceTest{ Description: "Test IPv6 and Dual Stack support for backends", Manifests: []string{"testdata/backend-dualstack.yaml"}, Test: func(t *testing.T, suite *suite.ConformanceTestSuite) { + if ipFamily != "dual" { + t.Skip("Skipping test as IP_FAMILY is not dual") + } + ns := "gateway-conformance-infra" gwNN := types.NamespacedName{Name: "dualstack-gateway", Namespace: ns} @@ -63,11 +62,3 @@ func runBackendDualStackTest(t *testing.T, suite *suite.ConformanceTestSuite, ns http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, expectedResponse) } - -var SkipBackendDualStackTest = suite.ConformanceTest{ - ShortName: "BackendDualStack", - Description: "Skipping BackendDualStack test as IP_FAMILY is not dual", - Test: func(t *testing.T, suite *suite.ConformanceTestSuite) { - t.Skip("Skipping BackendDualStack test as IP_FAMILY is not dual") - }, -} diff --git a/test/e2e/tests/httproute_dualstack.go b/test/e2e/tests/httproute_dualstack.go index 0e969577870..cd43a332959 100644 --- a/test/e2e/tests/httproute_dualstack.go +++ b/test/e2e/tests/httproute_dualstack.go @@ -9,7 +9,6 @@ package tests import ( - "os" "testing" "k8s.io/apimachinery/pkg/types" @@ -18,13 +17,8 @@ import ( "sigs.k8s.io/gateway-api/conformance/utils/suite" ) -// If the environment is not dual, the IPv6 manifest cannot be applied, so the test will be skipped. func init() { - if os.Getenv("IP_FAMILY") == "dual" { - ConformanceTests = append(ConformanceTests, HTTPRouteDualStackTest) - } else { - ConformanceTests = append(ConformanceTests, SkipHTTPRouteDualStackTest) - } + ConformanceTests = append(ConformanceTests, HTTPRouteDualStackTest) } var HTTPRouteDualStackTest = suite.ConformanceTest{ @@ -32,6 +26,10 @@ var HTTPRouteDualStackTest = suite.ConformanceTest{ Description: "Test HTTPRoute support for IPv6 only, dual-stack, and IPv4 only services", Manifests: []string{"testdata/httproute-dualstack.yaml"}, Test: func(t *testing.T, suite *suite.ConformanceTestSuite) { + if ipFamily != "dual" { + t.Skip("Skipping test as IP_FAMILY is not dual") + } + ns := "gateway-conformance-infra" gwNN := types.NamespacedName{Name: "dualstack-gateway", Namespace: ns} @@ -63,11 +61,3 @@ func runHTTPRouteTest(t *testing.T, suite *suite.ConformanceTestSuite, ns string http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, expectedResponse) } - -var SkipHTTPRouteDualStackTest = suite.ConformanceTest{ - ShortName: "HTTPRouteDualStack", - Description: "Skipping HTTPRouteDualStack test as IP_FAMILY is not dual", - Test: func(t *testing.T, suite *suite.ConformanceTestSuite) { - t.Skip("Skipping HTTPRouteDualStack test as IP_FAMILY is not dual") - }, -} diff --git a/test/e2e/tests/ratelimit.go b/test/e2e/tests/ratelimit.go index 17ce6d245cf..2f276caa769 100644 --- a/test/e2e/tests/ratelimit.go +++ b/test/e2e/tests/ratelimit.go @@ -37,6 +37,10 @@ var RateLimitCIDRMatchTest = suite.ConformanceTest{ Description: "Limit all requests that match CIDR", Manifests: []string{"testdata/ratelimit-cidr-match.yaml"}, Test: func(t *testing.T, suite *suite.ConformanceTestSuite) { + if ipFamily == "ipv6" { + t.Skip("Skipping test as IP_FAMILY is IPv6") + } + t.Run("block all ips", func(t *testing.T) { ns := "gateway-conformance-infra" routeNN := types.NamespacedName{Name: "cidr-ratelimit", Namespace: ns} @@ -484,6 +488,10 @@ var RateLimitMultipleListenersTest = suite.ConformanceTest{ Description: "Limit requests on multiple listeners", Manifests: []string{"testdata/ratelimit-multiple-listeners.yaml"}, Test: func(t *testing.T, suite *suite.ConformanceTestSuite) { + if ipFamily == "ipv6" { + t.Skip("Skipping test as IP_FAMILY is IPv6") + } + t.Run("block all ips on listener 80 and 8080", func(t *testing.T) { ns := "gateway-conformance-infra" routeNN := types.NamespacedName{Name: "cidr-ratelimit", Namespace: ns} @@ -549,6 +557,10 @@ var RateLimitHeadersAndCIDRMatchTest = suite.ConformanceTest{ gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) t.Run("all matched both headers and cidr can got limited", func(t *testing.T) { + if ipFamily == "ipv6" { + t.Skip("Skipping test as IP_FAMILY is IPv6") + } + requestHeaders := map[string]string{ "x-user-id": "one", "x-user-org": "acme", diff --git a/test/e2e/tests/utils.go b/test/e2e/tests/utils.go index c63cad1e579..c63e235295a 100644 --- a/test/e2e/tests/utils.go +++ b/test/e2e/tests/utils.go @@ -14,6 +14,7 @@ import ( "net" "net/http" "net/url" + "os" "strconv" "strings" "testing" @@ -44,6 +45,8 @@ import ( tb "github.com/envoyproxy/gateway/internal/troubleshoot" ) +var ipFamily = os.Getenv("IP_FAMILY") + const defaultServiceStartupTimeout = 5 * time.Minute var PodReady = corev1.PodCondition{Type: corev1.PodReady, Status: corev1.ConditionTrue} From 50008800a19b48b17f6168ca4a4eba77a67ea323 Mon Sep 17 00:00:00 2001 From: zirain Date: Fri, 15 Nov 2024 22:13:09 +0800 Subject: [PATCH 2/2] fix Signed-off-by: zirain --- test/e2e/e2e_test.go | 16 +++++++++++++--- test/e2e/tests/backend_dualstack.go | 4 ---- test/e2e/tests/httproute_dualstack.go | 4 ---- test/e2e/tests/ratelimit.go | 6 +++--- test/e2e/tests/utils.go | 2 +- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index 7267bbd2d75..8e980152e3d 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -39,6 +39,18 @@ func TestE2E(t *testing.T) { *flags.GatewayClassName, *flags.CleanupBaseResources, *flags.ShowDebug) } + skipTests := []string{ + tests.GatewayInfraResourceTest.ShortName, // https://github.com/envoyproxy/gateway/issues/3191 + } + + // Skip test only work on DualStack cluster + if tests.IPFamily != "dual" { + skipTests = append(skipTests, + tests.BackendDualStackTest.ShortName, + tests.HTTPRouteDualStackTest.ShortName, + ) + } + cSuite, err := suite.NewConformanceTestSuite(suite.ConformanceOptions{ Client: c, RestConfig: cfg, @@ -50,9 +62,7 @@ func TestE2E(t *testing.T) { // SupportedFeatures cannot be empty, so we set it to SupportGateway // All e2e tests should leave Features empty. SupportedFeatures: sets.New[features.FeatureName](features.SupportGateway), - SkipTests: []string{ - tests.GatewayInfraResourceTest.ShortName, // https://github.com/envoyproxy/gateway/issues/3191 - }, + SkipTests: skipTests, AllowCRDsMismatch: *flags.AllowCRDsMismatch, }) if err != nil { diff --git a/test/e2e/tests/backend_dualstack.go b/test/e2e/tests/backend_dualstack.go index 1ebed96161a..63d23f69341 100644 --- a/test/e2e/tests/backend_dualstack.go +++ b/test/e2e/tests/backend_dualstack.go @@ -27,10 +27,6 @@ var BackendDualStackTest = suite.ConformanceTest{ Description: "Test IPv6 and Dual Stack support for backends", Manifests: []string{"testdata/backend-dualstack.yaml"}, Test: func(t *testing.T, suite *suite.ConformanceTestSuite) { - if ipFamily != "dual" { - t.Skip("Skipping test as IP_FAMILY is not dual") - } - ns := "gateway-conformance-infra" gwNN := types.NamespacedName{Name: "dualstack-gateway", Namespace: ns} diff --git a/test/e2e/tests/httproute_dualstack.go b/test/e2e/tests/httproute_dualstack.go index cd43a332959..b01fc392a12 100644 --- a/test/e2e/tests/httproute_dualstack.go +++ b/test/e2e/tests/httproute_dualstack.go @@ -26,10 +26,6 @@ var HTTPRouteDualStackTest = suite.ConformanceTest{ Description: "Test HTTPRoute support for IPv6 only, dual-stack, and IPv4 only services", Manifests: []string{"testdata/httproute-dualstack.yaml"}, Test: func(t *testing.T, suite *suite.ConformanceTestSuite) { - if ipFamily != "dual" { - t.Skip("Skipping test as IP_FAMILY is not dual") - } - ns := "gateway-conformance-infra" gwNN := types.NamespacedName{Name: "dualstack-gateway", Namespace: ns} diff --git a/test/e2e/tests/ratelimit.go b/test/e2e/tests/ratelimit.go index 2f276caa769..799b6bbece0 100644 --- a/test/e2e/tests/ratelimit.go +++ b/test/e2e/tests/ratelimit.go @@ -37,7 +37,7 @@ var RateLimitCIDRMatchTest = suite.ConformanceTest{ Description: "Limit all requests that match CIDR", Manifests: []string{"testdata/ratelimit-cidr-match.yaml"}, Test: func(t *testing.T, suite *suite.ConformanceTestSuite) { - if ipFamily == "ipv6" { + if IPFamily == "ipv6" { t.Skip("Skipping test as IP_FAMILY is IPv6") } @@ -488,7 +488,7 @@ var RateLimitMultipleListenersTest = suite.ConformanceTest{ Description: "Limit requests on multiple listeners", Manifests: []string{"testdata/ratelimit-multiple-listeners.yaml"}, Test: func(t *testing.T, suite *suite.ConformanceTestSuite) { - if ipFamily == "ipv6" { + if IPFamily == "ipv6" { t.Skip("Skipping test as IP_FAMILY is IPv6") } @@ -557,7 +557,7 @@ var RateLimitHeadersAndCIDRMatchTest = suite.ConformanceTest{ gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) t.Run("all matched both headers and cidr can got limited", func(t *testing.T) { - if ipFamily == "ipv6" { + if IPFamily == "ipv6" { t.Skip("Skipping test as IP_FAMILY is IPv6") } diff --git a/test/e2e/tests/utils.go b/test/e2e/tests/utils.go index c63e235295a..a7834fbaaa3 100644 --- a/test/e2e/tests/utils.go +++ b/test/e2e/tests/utils.go @@ -45,7 +45,7 @@ import ( tb "github.com/envoyproxy/gateway/internal/troubleshoot" ) -var ipFamily = os.Getenv("IP_FAMILY") +var IPFamily = os.Getenv("IP_FAMILY") const defaultServiceStartupTimeout = 5 * time.Minute