Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 36 additions & 8 deletions conformance/tests/httproute-request-header-modifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"k8s.io/apimachinery/pkg/types"

"sigs.k8s.io/gateway-api/conformance/utils/echo"
"sigs.k8s.io/gateway-api/conformance/utils/http"
"sigs.k8s.io/gateway-api/conformance/utils/kubernetes"
"sigs.k8s.io/gateway-api/conformance/utils/suite"
Expand All @@ -43,7 +44,13 @@ var HTTPRouteBackendRequestHeaderModifier = suite.ConformanceTest{
features.SupportHTTPRouteBackendRequestHeaderModification,
},
Manifests: []string{"tests/httproute-request-header-modifier-backend.yaml"},
Test: HTTPRouteRequestHeaderModifier.Test,
MeshFeatures: []features.FeatureName{
features.SupportMesh,
features.SupportHTTPRoute,
features.SupportMeshHTTPRouteBackendRequestHeaderModification,
},
MeshManifests: []string{"tests/mesh/httproute-request-header-modifier-backend.yaml"},
Test: HTTPRouteRequestHeaderModifier.Test,
}

var HTTPRouteRequestHeaderModifier = suite.ConformanceTest{
Expand All @@ -54,12 +61,26 @@ var HTTPRouteRequestHeaderModifier = suite.ConformanceTest{
features.SupportHTTPRoute,
},
Manifests: []string{"tests/httproute-request-header-modifier.yaml"},
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
ns := "gateway-conformance-infra"
routeNN := types.NamespacedName{Name: "request-header-modifier", Namespace: ns}
gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns}
gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN)
kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN)
MeshFeatures: []features.FeatureName{
features.SupportMesh,
features.SupportHTTPRoute,
},
MeshManifests: []string{"tests/mesh/httproute-request-header-modifier.yaml"},
Test: func(t *testing.T, s *suite.ConformanceTestSuite) {
var ns string
var gwAddr string
var client echo.MeshPod

if !s.CurrentTest.IsMesh {
ns = "gateway-conformance-infra"
routeNN := types.NamespacedName{Name: "request-header-modifier", Namespace: ns}
gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns}
gwAddr = kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, s.Client, s.TimeoutConfig, s.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN)
kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, s.Client, s.TimeoutConfig, routeNN, gwNN)
} else {
ns = "gateway-conformance-mesh"
client = echo.ConnectToApp(t, s, echo.MeshAppEchoV1)
}

testCases := []http.ExpectedResponse{{
Request: http.Request{
Expand Down Expand Up @@ -207,9 +228,16 @@ var HTTPRouteRequestHeaderModifier = suite.ConformanceTest{
// Declare tc here to avoid loop variable
// reuse issues across parallel tests.
tc := testCases[i]
if s.CurrentTest.IsMesh {
tc.Backend = "echo-v1"
}
t.Run(tc.GetTestCaseName(i), func(t *testing.T) {
t.Parallel()
http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, tc)
if !s.CurrentTest.IsMesh {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: a helper around calling the gtw vs the mesh pod would be helpful to avoid needing this if on each case

http.MakeRequestAndExpectEventuallyConsistentResponse(t, s.RoundTripper, s.TimeoutConfig, gwAddr, tc)
} else {
client.MakeRequestAndExpectEventuallyConsistentResponse(t, tc, s.TimeoutConfig)
}
})
}
},
Expand Down
47 changes: 33 additions & 14 deletions conformance/tests/httproute-simple-same-namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"k8s.io/apimachinery/pkg/types"

"sigs.k8s.io/gateway-api/apis/v1beta1"
"sigs.k8s.io/gateway-api/conformance/utils/echo"
"sigs.k8s.io/gateway-api/conformance/utils/http"
"sigs.k8s.io/gateway-api/conformance/utils/kubernetes"
"sigs.k8s.io/gateway-api/conformance/utils/suite"
Expand All @@ -40,20 +41,38 @@ var HTTPRouteSimpleSameNamespace = suite.ConformanceTest{
features.SupportHTTPRoute,
},
Manifests: []string{"tests/httproute-simple-same-namespace.yaml"},
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
ns := v1beta1.Namespace("gateway-conformance-infra")
routeNN := types.NamespacedName{Name: "gateway-conformance-infra-test", Namespace: string(ns)}
gwNN := types.NamespacedName{Name: "same-namespace", Namespace: string(ns)}
gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN)
kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN)

t.Run("Simple HTTP request should reach infra-backend", func(t *testing.T) {
http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, http.ExpectedResponse{
Request: http.Request{Path: "/"},
Response: http.Response{StatusCode: 200},
Backend: "infra-backend-v1",
Namespace: "gateway-conformance-infra",
MeshFeatures: []features.FeatureName{
features.SupportMesh,
features.SupportHTTPRoute,
},
MeshManifests: []string{"tests/mesh/httproute-simple-same-namespace.yaml"},
Test: func(t *testing.T, s *suite.ConformanceTestSuite) {
if !s.CurrentTest.IsMesh {
ns := v1beta1.Namespace("gateway-conformance-infra")
routeNN := types.NamespacedName{Name: "gateway-conformance-infra-test", Namespace: string(ns)}
gwNN := types.NamespacedName{Name: "same-namespace", Namespace: string(ns)}
gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, s.Client, s.TimeoutConfig, s.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN)
kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, s.Client, s.TimeoutConfig, routeNN, gwNN)

t.Run("Simple HTTP request should reach infra-backend", func(t *testing.T) {
http.MakeRequestAndExpectEventuallyConsistentResponse(t, s.RoundTripper, s.TimeoutConfig, gwAddr, http.ExpectedResponse{
Request: http.Request{Path: "/"},
Response: http.Response{StatusCode: 200},
Backend: "infra-backend-v1",
Namespace: "gateway-conformance-infra",
})
})
} else {
ns := "gateway-conformance-mesh"
client := echo.ConnectToApp(t, s, echo.MeshAppEchoV1)
t.Run("Simple HTTP request should reach infra-backend", func(t *testing.T) {
client.MakeRequestAndExpectEventuallyConsistentResponse(t, http.ExpectedResponse{
Request: http.Request{Path: "/", Host: "echo"},
Response: http.Response{StatusCode: 200},
Backend: "echo-v1",
Namespace: ns,
}, s.TimeoutConfig)
})
})
}
},
}
213 changes: 0 additions & 213 deletions conformance/tests/mesh/httproute-request-header-modifier.go

This file was deleted.

Loading