Repository: envoyproxy/gateway

Issue:
e2e tests for GatewayNamespace mode
E2E test for https://github.com/envoyproxy/gateway/pull/5137

Discussion:

Solution patch:
diff --git a/.github/workflows/build_and_test.yaml b/.github/workflows/build_and_test.yaml
index 200e7d571..580d2d741 100644
--- a/.github/workflows/build_and_test.yaml
+++ b/.github/workflows/build_and_test.yaml
@@ -127,13 +127,20 @@ jobs:
         target:
         - version: v1.30.10
           ipFamily: ipv4
+          profile: default
         - version: v1.31.6
           ipFamily: ipv4
+          profile: default
         - version: v1.32.3
           ipFamily: ipv6  # only run ipv6 test on this version to save time
+          profile: default
         # TODO: this's IPv4 first, need a way to test IPv6 first.
         - version: v1.33.0
           ipFamily: dual  # only run dual test on latest version to save time
+          profile: default
+        - version: v1.33.0
+          ipFamily: dual  # only run dual test on latest version to save time
+          profile: gateway-namespace-mode
     steps:
     - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683  # v4.2.2
     - uses: ./tools/github-actions/setup-deps
@@ -155,6 +162,7 @@ jobs:
         KIND_NODE_TAG: ${{ matrix.target.version }}
         IMAGE_PULL_POLICY: IfNotPresent
         IP_FAMILY: ${{ matrix.target.ipFamily }}
+        KUBE_DEPLOY_PROFILE: ${{ matrix.target.profile }}
         E2E_TIMEOUT: 1h
         NUM_WORKERS: 2
       run: make e2e



Test patch:
diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go
index 12a497380..c7de5de62 100644
--- a/test/e2e/e2e_test.go
+++ b/test/e2e/e2e_test.go
@@ -55,6 +55,30 @@ func TestE2E(t *testing.T) {
 	if tests.IPFamily == "ipv6" {
 		skipTests = append(skipTests,
 			tests.DynamicResolverBackendTest.ShortName,
+			tests.RateLimitCIDRMatchTest.ShortName,
+			tests.RateLimitMultipleListenersTest.ShortName,
+			tests.RateLimitGlobalSharedCidrMatchTest.ShortName,
+		)
+	}
+
+	// TODO: make these tests work in GatewayNamespaceMode
+	if tests.IsGatewayNamespaceMode() {
+		skipTests = append(skipTests,
+			tests.HTTPWasmTest.ShortName,
+			tests.OCIWasmTest.ShortName,
+			tests.ZoneAwareRoutingTest.ShortName,
+
+			// Skip RateLimit tests because they are not supported in GatewayNamespaceMode
+			tests.RateLimitCIDRMatchTest.ShortName,
+			tests.RateLimitHeaderMatchTest.ShortName,
+			tests.GlobalRateLimitHeaderInvertMatchTest.ShortName,
+			tests.RateLimitHeadersDisabled.ShortName,
+			tests.RateLimitBasedJwtClaimsTest.ShortName,
+			tests.RateLimitMultipleListenersTest.ShortName,
+			tests.RateLimitHeadersAndCIDRMatchTest.ShortName,
+			tests.UsageRateLimitTest.ShortName,
+			tests.RateLimitGlobalSharedCidrMatchTest.ShortName,
+			tests.RateLimitGlobalSharedGatewayHeaderMatchTest.ShortName,
 		)
 	}
 
@@ -68,7 +92,7 @@ func TestE2E(t *testing.T) {
 		RunTest:              *flags.RunTest,
 		// SupportedFeatures cannot be empty, so we set it to SupportGateway
 		// All e2e tests should leave Features empty.
-		SupportedFeatures: sets.New[features.FeatureName](features.SupportGateway),
+		SupportedFeatures: sets.New(features.SupportGateway),
 		SkipTests:         skipTests,
 		AllowCRDsMismatch: *flags.AllowCRDsMismatch,
 	})
diff --git a/test/e2e/testdata/metric-compressor.yaml b/test/e2e/testdata/metric-compressor.yaml
index e3bc342c5..17199be3e 100644
--- a/test/e2e/testdata/metric-compressor.yaml
+++ b/test/e2e/testdata/metric-compressor.yaml
@@ -25,6 +25,18 @@ metadata:
   namespace: gateway-conformance-infra
 spec:
   ipFamily: IPv4
+  provider:
+    type: Kubernetes
+    kubernetes:
+      envoyService:
+        patch:
+          value:
+            spec:
+              ports:
+                - name: metrics
+                  protocol: TCP
+                  port: 19001
+                  targetPort: 19001
   telemetry:
     metrics:
       prometheus:
@@ -94,31 +106,24 @@ metadata:
   namespace: gateway-conformance-infra
 spec:
   ipFamily: IPv4
+  provider:
+    type: Kubernetes
+    kubernetes:
+      envoyService:
+        patch:
+          value:
+            spec:
+              ports:
+                - name: metrics
+                  protocol: TCP
+                  port: 19001
+                  targetPort: 19001
   telemetry:
     metrics:
       prometheus:
         compression:
           type: Brotli
 ---
-apiVersion: v1
-kind: Service
-metadata:
-  name: brotli-gtw-metrics
-  namespace: envoy-gateway-system
-spec:
-  selector:
-    app.kubernetes.io/component: proxy
-    app.kubernetes.io/managed-by: envoy-gateway
-    app.kubernetes.io/name: envoy
-    gateway.envoyproxy.io/owning-gateway-name: brotli-gtw
-    gateway.envoyproxy.io/owning-gateway-namespace: gateway-conformance-infra
-  ports:
-    - name: metrics
-      protocol: TCP
-      port: 19001
-      targetPort: 19001
-  type: LoadBalancer
----
 apiVersion: gateway.networking.k8s.io/v1
 kind: HTTPRoute
 metadata:
diff --git a/test/e2e/testdata/metric.yaml b/test/e2e/testdata/metric.yaml
index b65c1d3af..7173c902e 100644
--- a/test/e2e/testdata/metric.yaml
+++ b/test/e2e/testdata/metric.yaml
@@ -61,25 +61,6 @@ spec:
 ---
 apiVersion: v1
 kind: Service
-metadata:
-  name: same-namespace-gw-metrics
-  namespace: envoy-gateway-system
-spec:
-  selector:
-    app.kubernetes.io/component: proxy
-    app.kubernetes.io/managed-by: envoy-gateway
-    app.kubernetes.io/name: envoy
-    gateway.envoyproxy.io/owning-gateway-name: same-namespace
-    gateway.envoyproxy.io/owning-gateway-namespace: gateway-conformance-infra
-  ports:
-    - name: metrics
-      protocol: TCP
-      port: 19001
-      targetPort: 19001
-  type: LoadBalancer
----
-apiVersion: v1
-kind: Service
 metadata:
   name: otel-collecot-prometheus
   namespace: monitoring
diff --git a/test/e2e/tests/accesslog.go b/test/e2e/tests/accesslog.go
index 5df762868..ea07349fd 100644
--- a/test/e2e/tests/accesslog.go
+++ b/test/e2e/tests/accesslog.go
@@ -9,6 +9,7 @@ package tests
 
 import (
 	"context"
+	"fmt"
 	"testing"
 	"time"
 
@@ -29,9 +30,10 @@ var FileAccessLogTest = suite.ConformanceTest{
 	Description: "Make sure file access log is working",
 	Manifests:   []string{"testdata/accesslog-file.yaml"},
 	Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
+		gatwayNS := GetGatewayResourceNamespace()
 		labels := map[string]string{
-			"job":       "envoy-gateway-system/envoy",
-			"namespace": "envoy-gateway-system",
+			"job":       fmt.Sprintf("%s/envoy", gatwayNS),
+			"namespace": gatwayNS,
 			"container": "envoy",
 		}
 		match := "test-annotation-value"
diff --git a/test/e2e/tests/envoy_shutdown.go b/test/e2e/tests/envoy_shutdown.go
index 14a223dde..646154c3d 100644
--- a/test/e2e/tests/envoy_shutdown.go
+++ b/test/e2e/tests/envoy_shutdown.go
@@ -51,8 +51,7 @@ var EnvoyShutdownTest = suite.ConformanceTest{
 				t.Errorf("Failed to get proxy deployment")
 			}
 
-			// Wait for the grpc ext auth service pod to be ready
-			WaitForPods(t, suite.Client, "envoy-gateway-system", map[string]string{"gateway.envoyproxy.io/owning-gateway-name": name}, corev1.PodRunning, PodReady)
+			WaitForPods(t, suite.Client, dp.Namespace, map[string]string{"gateway.envoyproxy.io/owning-gateway-name": name}, corev1.PodRunning, PodReady)
 
 			// wait for route to be programmed on envoy
 			expectedResponse := http.ExpectedResponse{
@@ -103,8 +102,13 @@ func getDeploymentForGateway(namespace, name string, c client.Client) (*appsv1.D
 	}
 	ctx := context.Background()
 
+	gwNs := "envoy-gateway-system"
+	if IsGatewayNamespaceMode() {
+		// use the namespace of Gateway resource
+		gwNs = namespace
+	}
 	listOpts := []client.ListOption{
-		client.InNamespace("envoy-gateway-system"),
+		client.InNamespace(gwNs),
 		client.MatchingLabelsSelector{Selector: labels.SelectorFromSet(dpLabels)},
 	}
 
diff --git a/test/e2e/tests/envoyproxy.go b/test/e2e/tests/envoyproxy.go
index b8980bd09..d366d05ab 100644
--- a/test/e2e/tests/envoyproxy.go
+++ b/test/e2e/tests/envoyproxy.go
@@ -36,11 +36,13 @@ var EnvoyProxyCustomNameTest = suite.ConformanceTest{
 	Description: "Test running Envoy with custom name",
 	Manifests:   []string{"testdata/envoyproxy-custom-name.yaml"},
 	Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
+		gatwayNS := GetGatewayResourceNamespace()
+
 		t.Run("Deployment", func(t *testing.T) {
 			ns := "gateway-conformance-infra"
 			routeNN := types.NamespacedName{Name: "deploy-route", Namespace: ns}
 			gwNN := types.NamespacedName{Name: "deploy-custom-name", Namespace: ns}
-			OkResp := http.ExpectedResponse{
+			okResp := http.ExpectedResponse{
 				Request: http.Request{
 					Path: "/deploy",
 				},
@@ -51,17 +53,17 @@ var EnvoyProxyCustomNameTest = suite.ConformanceTest{
 			}
 
 			// Make sure there's deployment for the gateway
-			err := checkEnvoyProxyDeployment(t, suite, gwNN, fmt.Sprintf("envoy-%s-%s", gwNN.Namespace, gwNN.Name))
+			err := checkEnvoyProxyDeployment(t, suite, gwNN, gatwayNS, fmt.Sprintf("envoy-%s-%s", gwNN.Namespace, gwNN.Name))
 			if err != nil {
 				t.Fatalf("Failed to check EnvoyProxy deployment: %v", err)
 			}
-			err = checkEnvoyProxyService(t, suite, gwNN, fmt.Sprintf("envoy-%s-%s", gwNN.Namespace, gwNN.Name))
+			err = checkEnvoyProxyService(t, suite, gwNN, gatwayNS, fmt.Sprintf("envoy-%s-%s", gwNN.Namespace, gwNN.Name))
 			if err != nil {
 				t.Fatalf("Failed to check EnvoyProxy service: %v", err)
 			}
 			gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN)
 			// Send a request to a valid path and expect a successful response
-			http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, OkResp)
+			http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, okResp)
 
 			// Update the Gateway to use a custom name
 			gw := &gwapiv1.Gateway{}
@@ -81,17 +83,17 @@ var EnvoyProxyCustomNameTest = suite.ConformanceTest{
 				t.Fatalf("Failed to update Gateway: %v", err)
 			}
 
-			err = checkEnvoyProxyDeployment(t, suite, gwNN, "deploy-custom-name")
+			err = checkEnvoyProxyDeployment(t, suite, gwNN, gatwayNS, "deploy-custom-name")
 			if err != nil {
 				t.Fatalf("Failed to delete Gateway: %v", err)
 			}
-			err = checkEnvoyProxyService(t, suite, gwNN, "deploy-custom-name")
+			err = checkEnvoyProxyService(t, suite, gwNN, gatwayNS, "deploy-custom-name")
 			if err != nil {
 				t.Fatalf("Failed to check EnvoyProxy service: %v", err)
 			}
 			gwAddr = kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN)
 			// Send a request to a valid path and expect a successful response
-			http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, OkResp)
+			http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, okResp)
 
 			// Rollback the Gateway to without custom name
 			gw = &gwapiv1.Gateway{}
@@ -106,17 +108,17 @@ var EnvoyProxyCustomNameTest = suite.ConformanceTest{
 			}
 
 			// Make sure there's deployment for the gateway
-			err = checkEnvoyProxyDeployment(t, suite, gwNN, fmt.Sprintf("envoy-%s-%s", gwNN.Namespace, gwNN.Name))
+			err = checkEnvoyProxyDeployment(t, suite, gwNN, gatwayNS, fmt.Sprintf("envoy-%s-%s", gwNN.Namespace, gwNN.Name))
 			if err != nil {
 				t.Fatalf("Failed to check EnvoyProxy deployment: %v", err)
 			}
-			err = checkEnvoyProxyService(t, suite, gwNN, fmt.Sprintf("envoy-%s-%s", gwNN.Namespace, gwNN.Name))
+			err = checkEnvoyProxyService(t, suite, gwNN, gatwayNS, fmt.Sprintf("envoy-%s-%s", gwNN.Namespace, gwNN.Name))
 			if err != nil {
 				t.Fatalf("Failed to check EnvoyProxy service: %v", err)
 			}
 			gwAddr = kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN)
 			// Send a request to a valid path and expect a successful response
-			http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, OkResp)
+			http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, okResp)
 		})
 
 		t.Run("DaemonSet", func(t *testing.T) {
@@ -134,11 +136,11 @@ var EnvoyProxyCustomNameTest = suite.ConformanceTest{
 			}
 
 			// Make sure there's DaemonSet for the gateway
-			err := checkEnvoyProxyDaemonSet(t, suite, gwNN, fmt.Sprintf("envoy-%s-%s", gwNN.Namespace, gwNN.Name))
+			err := checkEnvoyProxyDaemonSet(t, suite, gwNN, gatwayNS, fmt.Sprintf("envoy-%s-%s", gwNN.Namespace, gwNN.Name))
 			if err != nil {
 				t.Fatalf("Failed to check EnvoyProxy deployment: %v", err)
 			}
-			err = checkEnvoyProxyService(t, suite, gwNN, fmt.Sprintf("envoy-%s-%s", gwNN.Namespace, gwNN.Name))
+			err = checkEnvoyProxyService(t, suite, gwNN, gatwayNS, fmt.Sprintf("envoy-%s-%s", gwNN.Namespace, gwNN.Name))
 			if err != nil {
 				t.Fatalf("Failed to check EnvoyProxy service: %v", err)
 			}
@@ -164,11 +166,11 @@ var EnvoyProxyCustomNameTest = suite.ConformanceTest{
 				t.Fatalf("Failed to update Gateway: %v", err)
 			}
 
-			err = checkEnvoyProxyDaemonSet(t, suite, gwNN, "ds-custom-name")
+			err = checkEnvoyProxyDaemonSet(t, suite, gwNN, gatwayNS, "ds-custom-name")
 			if err != nil {
 				t.Fatalf("Failed to delete Gateway: %v", err)
 			}
-			err = checkEnvoyProxyService(t, suite, gwNN, "ds-custom-name")
+			err = checkEnvoyProxyService(t, suite, gwNN, gatwayNS, "ds-custom-name")
 			if err != nil {
 				t.Fatalf("Failed to check EnvoyProxy service: %v", err)
 			}
@@ -195,11 +197,11 @@ var EnvoyProxyCustomNameTest = suite.ConformanceTest{
 			}
 
 			// Make sure there's DaemonSet for the gateway
-			err = checkEnvoyProxyDaemonSet(t, suite, gwNN, fmt.Sprintf("envoy-%s-%s", gwNN.Namespace, gwNN.Name))
+			err = checkEnvoyProxyDaemonSet(t, suite, gwNN, gatwayNS, fmt.Sprintf("envoy-%s-%s", gwNN.Namespace, gwNN.Name))
 			if err != nil {
 				t.Fatalf("Failed to check EnvoyProxy deployment: %v", err)
 			}
-			err = checkEnvoyProxyService(t, suite, gwNN, fmt.Sprintf("envoy-%s-%s", gwNN.Namespace, gwNN.Name))
+			err = checkEnvoyProxyService(t, suite, gwNN, gatwayNS, fmt.Sprintf("envoy-%s-%s", gwNN.Namespace, gwNN.Name))
 			if err != nil {
 				t.Fatalf("Failed to check EnvoyProxy service: %v", err)
 			}
@@ -210,12 +212,12 @@ var EnvoyProxyCustomNameTest = suite.ConformanceTest{
 	},
 }
 
-func checkEnvoyProxyDeployment(t *testing.T, suite *suite.ConformanceTestSuite, gwNN types.NamespacedName, exceptName string) error {
+func checkEnvoyProxyDeployment(t *testing.T, suite *suite.ConformanceTestSuite, gwNN types.NamespacedName, exceptNs, exceptName string) error {
 	// Make sure there's deployment for the gateway
 	return wait.PollUntilContextTimeout(context.TODO(), time.Second, suite.TimeoutConfig.CreateTimeout, true, func(ctx context.Context) (bool, error) {
 		deploys := &appsv1.DeploymentList{}
 		err := suite.Client.List(ctx, deploys, &client.ListOptions{
-			Namespace: "envoy-gateway-system",
+			Namespace: exceptNs,
 			LabelSelector: labels.SelectorFromSet(map[string]string{
 				"app.kubernetes.io/managed-by":                   "envoy-gateway",
 				"app.kubernetes.io/name":                         "envoy",
@@ -246,12 +248,12 @@ func checkEnvoyProxyDeployment(t *testing.T, suite *suite.ConformanceTestSuite,
 	})
 }
 
-func checkEnvoyProxyService(t *testing.T, suite *suite.ConformanceTestSuite, gwNN types.NamespacedName, exceptName string) error {
+func checkEnvoyProxyService(t *testing.T, suite *suite.ConformanceTestSuite, gwNN types.NamespacedName, exceptNs, exceptName string) error {
 	// Make sure there's deployment for the gateway
 	return wait.PollUntilContextTimeout(context.TODO(), time.Second, suite.TimeoutConfig.CreateTimeout, true, func(ctx context.Context) (bool, error) {
 		svcList := &corev1.ServiceList{}
 		err := suite.Client.List(ctx, svcList, &client.ListOptions{
-			Namespace: "envoy-gateway-system",
+			Namespace: exceptNs,
 			LabelSelector: labels.SelectorFromSet(map[string]string{
 				"app.kubernetes.io/managed-by":                   "envoy-gateway",
 				"app.kubernetes.io/name":                         "envoy",
@@ -278,12 +280,12 @@ func checkEnvoyProxyService(t *testing.T, suite *suite.ConformanceTestSuite, gwN
 	})
 }
 
-func checkEnvoyProxyDaemonSet(t *testing.T, suite *suite.ConformanceTestSuite, gwNN types.NamespacedName, exceptName string) error {
+func checkEnvoyProxyDaemonSet(t *testing.T, suite *suite.ConformanceTestSuite, gwNN types.NamespacedName, exceptNs, exceptName string) error {
 	// Make sure there's deployment for the gateway
 	return wait.PollUntilContextTimeout(context.TODO(), time.Second, suite.TimeoutConfig.CreateTimeout, true, func(ctx context.Context) (bool, error) {
 		dsList := &appsv1.DaemonSetList{}
 		err := suite.Client.List(ctx, dsList, &client.ListOptions{
-			Namespace: "envoy-gateway-system",
+			Namespace: exceptNs,
 			LabelSelector: labels.SelectorFromSet(map[string]string{
 				"app.kubernetes.io/managed-by":                   "envoy-gateway",
 				"app.kubernetes.io/name":                         "envoy",
diff --git a/test/e2e/tests/envoyproxy_hpa.go b/test/e2e/tests/envoyproxy_hpa.go
index 4e4a830e0..8901a407a 100644
--- a/test/e2e/tests/envoyproxy_hpa.go
+++ b/test/e2e/tests/envoyproxy_hpa.go
@@ -42,9 +42,11 @@ var EnvoyProxyHPATest = suite.ConformanceTest{
 				Namespace: ns,
 			}
 
+			expectedNs := GetGatewayResourceNamespace()
+
 			// Make sure there's a deployment/HPA for the gateway
-			ExpectEnvoyProxyDeploymentCount(t, suite, gwNN, 1)
-			ExpectEnvoyProxyHPACount(t, suite, gwNN, 1)
+			ExpectEnvoyProxyDeploymentCount(t, suite, gwNN, expectedNs, 1)
+			ExpectEnvoyProxyHPACount(t, suite, gwNN, expectedNs, 1)
 
 			// Send a request to a valid path and expect a successful response
 			http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, OkResp)
@@ -61,8 +63,8 @@ var EnvoyProxyHPATest = suite.ConformanceTest{
 				t.Fatalf("Failed to update Gateway: %v", err)
 			}
 
-			ExpectEnvoyProxyDeploymentCount(t, suite, gwNN, 1)
-			ExpectEnvoyProxyHPACount(t, suite, gwNN, 0)
+			ExpectEnvoyProxyDeploymentCount(t, suite, gwNN, expectedNs, 1)
+			ExpectEnvoyProxyHPACount(t, suite, gwNN, expectedNs, 0)
 		})
 	},
 }
diff --git a/test/e2e/tests/metric.go b/test/e2e/tests/metric.go
index ec1eb2019..f61ead25a 100644
--- a/test/e2e/tests/metric.go
+++ b/test/e2e/tests/metric.go
@@ -57,13 +57,16 @@ var MetricTest = suite.ConformanceTest{
 			// let's check the metric
 			if err := wait.PollUntilContextTimeout(context.TODO(), time.Second, time.Minute, true,
 				func(_ context.Context) (done bool, err error) {
-					if err := ScrapeMetrics(t, suite.Client, types.NamespacedName{
-						Namespace: "envoy-gateway-system",
-						Name:      "same-namespace-gw-metrics",
-					}, 19001, "/stats/prometheus"); err != nil {
+					pql := fmt.Sprintf(`envoy_cluster_default_total_match_count{app_kubernetes_io_component="proxy", app_kubernetes_io_managed_by="envoy-gateway", app_kubernetes_io_name="envoy", envoy_cluster_name="xds_cluster", gateway_envoyproxy_io_owning_gateway_name="%s"}`, "same-namespace")
+					v, err := prometheus.QueryPrometheus(suite.Client, pql)
+					if err != nil {
 						tlog.Logf(t, "failed to get metric: %v", err)
 						return false, nil
 					}
+					if v != nil {
+						tlog.Logf(t, "got expected value: %v", v)
+						return true, nil
+					}
 					return true, nil
 				}); err != nil {
 				t.Errorf("failed to scrape metrics: %v", err)
@@ -175,25 +178,8 @@ func runMetricCompressorTest(t *testing.T, suite *suite.ConformanceTestSuite, ns
 	}
 	httputils.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, expectedResponse)
 
-	// make sure compression work as expected
-	statsNN := types.NamespacedName{Namespace: "envoy-gateway-system", Name: fmt.Sprintf("%s-gtw-metrics", compressor)}
-	var statsHost string
-	if err := wait.PollUntilContextTimeout(context.TODO(), time.Second, time.Minute, true, func(_ context.Context) (done bool, err error) {
-		addr, err := ServiceHost(suite.Client, statsNN, 19001)
-		if err != nil {
-			tlog.Logf(t, "failed to get service host %s: %v", statsNN, err)
-			return false, nil
-		}
-		if addr != "" {
-			statsHost = addr
-			return true, nil
-		}
-		return false, nil
-	}); err != nil {
-		t.Errorf("failed to get service host %s: %v", statsNN, err)
-		return
-	}
-
+	// stats exposed at port 19001
+	statsHost := strings.Replace(gwAddr, ":80", ":19001", 1)
 	statsAddr := fmt.Sprintf("http://%s/stats/prometheus", statsHost)
 	tlog.Logf(t, "check stats from %s", statsAddr)
 
diff --git a/test/e2e/tests/ratelimit.go b/test/e2e/tests/ratelimit.go
index a425a23a3..da8cff9fd 100644
--- a/test/e2e/tests/ratelimit.go
+++ b/test/e2e/tests/ratelimit.go
@@ -48,10 +48,6 @@ 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}
@@ -514,10 +510,6 @@ 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}
@@ -755,10 +747,6 @@ var RateLimitGlobalSharedCidrMatchTest = suite.ConformanceTest{
 	Description: "Limit all requests that match CIDR across multiple routes with a shared rate limit",
 	Manifests:   []string{"testdata/ratelimit-global-shared-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 with shared rate limit across routes with different paths", func(t *testing.T) {
 			ns := "gateway-conformance-infra"
 			route1NN := types.NamespacedName{Name: "cidr-ratelimit-1", Namespace: ns}
diff --git a/test/e2e/tests/utils.go b/test/e2e/tests/utils.go
index 824e75218..5700f82af 100644
--- a/test/e2e/tests/utils.go
+++ b/test/e2e/tests/utils.go
@@ -46,7 +46,10 @@ import (
 	tb "github.com/envoyproxy/gateway/internal/troubleshoot"
 )
 
-var IPFamily = os.Getenv("IP_FAMILY")
+var (
+	IPFamily      = os.Getenv("IP_FAMILY")
+	DeployProfile = os.Getenv("KUBE_DEPLOY_PROFILE")
+)
 
 const defaultServiceStartupTimeout = 5 * time.Minute
 
@@ -645,11 +648,11 @@ func ContentEncoding(compressorType egv1a1.CompressorType) string {
 	return encoding
 }
 
-func ExpectEnvoyProxyDeploymentCount(t *testing.T, suite *suite.ConformanceTestSuite, gwNN types.NamespacedName, expectedCount int) {
+func ExpectEnvoyProxyDeploymentCount(t *testing.T, suite *suite.ConformanceTestSuite, gwNN types.NamespacedName, expectedNs string, expectedCount int) {
 	err := wait.PollUntilContextTimeout(context.TODO(), time.Second, suite.TimeoutConfig.DeleteTimeout, true, func(ctx context.Context) (bool, error) {
 		deploys := &appsv1.DeploymentList{}
 		err := suite.Client.List(ctx, deploys, &client.ListOptions{
-			Namespace: "envoy-gateway-system",
+			Namespace: expectedNs,
 			LabelSelector: labels.SelectorFromSet(map[string]string{
 				"app.kubernetes.io/managed-by":                   "envoy-gateway",
 				"app.kubernetes.io/name":                         "envoy",
@@ -668,11 +671,11 @@ func ExpectEnvoyProxyDeploymentCount(t *testing.T, suite *suite.ConformanceTestS
 	}
 }
 
-func ExpectEnvoyProxyHPACount(t *testing.T, suite *suite.ConformanceTestSuite, gwNN types.NamespacedName, expectedCount int) {
+func ExpectEnvoyProxyHPACount(t *testing.T, suite *suite.ConformanceTestSuite, gwNN types.NamespacedName, expectedNs string, expectedCount int) {
 	err := wait.PollUntilContextTimeout(context.TODO(), time.Second, suite.TimeoutConfig.DeleteTimeout, true, func(ctx context.Context) (bool, error) {
 		hpa := &autoscalingv2.HorizontalPodAutoscalerList{}
 		err := suite.Client.List(ctx, hpa, &client.ListOptions{
-			Namespace: "envoy-gateway-system",
+			Namespace: expectedNs,
 			LabelSelector: labels.SelectorFromSet(map[string]string{
 				"gateway.envoyproxy.io/owning-gateway-name":      gwNN.Name,
 				"gateway.envoyproxy.io/owning-gateway-namespace": gwNN.Namespace,
@@ -688,3 +691,14 @@ func ExpectEnvoyProxyHPACount(t *testing.T, suite *suite.ConformanceTestSuite, g
 		t.Fatalf("Failed to check HPA count(%d) for the Gateway: %v", expectedCount, err)
 	}
 }
+
+func IsGatewayNamespaceMode() bool {
+	return DeployProfile == "gateway-namespace-mode"
+}
+
+func GetGatewayResourceNamespace() string {
+	if IsGatewayNamespaceMode() {
+		return "gateway-conformance-infra"
+	}
+	return "envoy-gateway-system"
+}
diff --git a/test/e2e/upgrade/eg_upgrade_test.go b/test/e2e/upgrade/eg_upgrade_test.go
index 9af99c81c..509b874fb 100644
--- a/test/e2e/upgrade/eg_upgrade_test.go
+++ b/test/e2e/upgrade/eg_upgrade_test.go
@@ -57,17 +57,25 @@ func TestEGUpgrade(t *testing.T) {
 		ManifestFS:           []fs.FS{e2e.UpgradeManifests},
 		RunTest:              *flags.RunTest,
 		BaseManifests:        "upgrade/manifests.yaml",
-		SupportedFeatures:    sets.New[features.FeatureName](features.SupportGateway),
+		SupportedFeatures:    sets.New(features.SupportGateway),
 		SkipTests:            skipTests,
 	})
 	if err != nil {
 		t.Fatalf("Failed to create test suite: %v", err)
 	}
 
-	// upgrade tests should be executed in a specific order
-	tests.UpgradeTests = []suite.ConformanceTest{
-		tests.EnvoyShutdownTest,
-		tests.EGUpgradeTest,
+	if tests.IsGatewayNamespaceMode() {
+		tests.UpgradeTests = []suite.ConformanceTest{
+			tests.EnvoyShutdownTest,
+			// TODO: enable EGUpgradeTest in gateway namespace mode
+			// tests.EGUpgradeTest,
+		}
+	} else {
+		// upgrade tests should be executed in a specific order
+		tests.UpgradeTests = []suite.ConformanceTest{
+			tests.EnvoyShutdownTest,
+			tests.EGUpgradeTest,
+		}
 	}
 
 	tlog.Logf(t, "Running %d Upgrade tests", len(tests.UpgradeTests))