From 2c5a7d8669a8967c6d3f2d0fe0eacc8bf7c80447 Mon Sep 17 00:00:00 2001 From: Mattia Lavacca Date: Mon, 23 Jan 2023 11:09:21 +0100 Subject: [PATCH] conformance: HTTPRoute resolvedRefs condition In the conformance tests, the ResolvedRefs condition existence is always checked, even when true. Signed-off-by: Mattia Lavacca --- .../tests/httproute-cross-namespace.go | 7 ++++ .../tests/httproute-exact-path-matching.go | 7 ++++ .../tests/httproute-header-matching.go | 7 ++++ .../tests/httproute-hostname-intersection.go | 7 ++++ .../httproute-listener-hostname-matching.go | 33 +++++++++++++------ .../tests/httproute-matching-across-routes.go | 12 +++++++ conformance/tests/httproute-matching.go | 7 ++++ .../tests/httproute-method-matching.go | 7 ++++ .../httproute-observed-generation-bump.go | 28 ++++++++-------- .../tests/httproute-query-param-matching.go | 17 ++++++---- .../httproute-redirect-host-and-status.go | 7 ++++ conformance/tests/httproute-redirect-path.go | 7 ++++ conformance/tests/httproute-redirect-port.go | 7 ++++ .../tests/httproute-redirect-scheme.go | 7 ++++ .../tests/httproute-reference-grant.go | 13 ++++++-- .../httproute-request-header-modifier.go | 7 ++++ .../httproute-response-header-modifier.go | 7 ++++ conformance/tests/httproute-rewrite-host.go | 7 ++++ conformance/tests/httproute-rewrite-path.go | 7 ++++ .../tests/httproute-simple-same-namespace.go | 6 ++++ 20 files changed, 175 insertions(+), 32 deletions(-) diff --git a/conformance/tests/httproute-cross-namespace.go b/conformance/tests/httproute-cross-namespace.go index db6ff61109..ec256794b1 100644 --- a/conformance/tests/httproute-cross-namespace.go +++ b/conformance/tests/httproute-cross-namespace.go @@ -19,8 +19,10 @@ package tests import ( "testing" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/gateway-api/apis/v1beta1" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" @@ -38,6 +40,11 @@ var HTTPRouteCrossNamespace = suite.ConformanceTest{ routeNN := types.NamespacedName{Name: "cross-namespace", Namespace: "gateway-conformance-web-backend"} gwNN := types.NamespacedName{Name: "backend-namespaces", Namespace: "gateway-conformance-infra"} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) + kubernetes.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, metav1.Condition{ + Type: string(v1beta1.RouteConditionResolvedRefs), + Status: metav1.ConditionTrue, + Reason: string(v1beta1.RouteReasonResolvedRefs), + }) t.Run("Simple HTTP request should reach web-backend", func(t *testing.T) { http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, http.ExpectedResponse{ diff --git a/conformance/tests/httproute-exact-path-matching.go b/conformance/tests/httproute-exact-path-matching.go index a543834aa5..1b4e6854f9 100644 --- a/conformance/tests/httproute-exact-path-matching.go +++ b/conformance/tests/httproute-exact-path-matching.go @@ -19,8 +19,10 @@ package tests import ( "testing" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/gateway-api/apis/v1beta1" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" @@ -39,6 +41,11 @@ var HTTPExactPathMatching = suite.ConformanceTest{ routeNN := types.NamespacedName{Name: "exact-matching", 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.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, metav1.Condition{ + Type: string(v1beta1.RouteConditionResolvedRefs), + Status: metav1.ConditionTrue, + Reason: string(v1beta1.RouteReasonResolvedRefs), + }) testCases := []http.ExpectedResponse{ { diff --git a/conformance/tests/httproute-header-matching.go b/conformance/tests/httproute-header-matching.go index 51349f5018..7624e73011 100644 --- a/conformance/tests/httproute-header-matching.go +++ b/conformance/tests/httproute-header-matching.go @@ -19,8 +19,10 @@ package tests import ( "testing" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/gateway-api/apis/v1beta1" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" @@ -39,6 +41,11 @@ var HTTPRouteHeaderMatching = suite.ConformanceTest{ routeNN := types.NamespacedName{Name: "header-matching", 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.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, metav1.Condition{ + Type: string(v1beta1.RouteConditionResolvedRefs), + Status: metav1.ConditionTrue, + Reason: string(v1beta1.RouteReasonResolvedRefs), + }) testCases := []http.ExpectedResponse{{ Request: http.Request{Path: "/", Headers: map[string]string{"Version": "one"}}, diff --git a/conformance/tests/httproute-hostname-intersection.go b/conformance/tests/httproute-hostname-intersection.go index cd52d4fede..56bdc62d10 100644 --- a/conformance/tests/httproute-hostname-intersection.go +++ b/conformance/tests/httproute-hostname-intersection.go @@ -52,6 +52,13 @@ var HTTPRouteHostnameIntersection = suite.ConformanceTest{ {Namespace: ns, Name: "wildcard-host-matches-listener-wildcard-host"}, } gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routes...) + for _, routeNN := range routes { + kubernetes.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, metav1.Condition{ + Type: string(v1beta1.RouteConditionResolvedRefs), + Status: metav1.ConditionTrue, + Reason: string(v1beta1.RouteReasonResolvedRefs), + }) + } var testCases []http.ExpectedResponse diff --git a/conformance/tests/httproute-listener-hostname-matching.go b/conformance/tests/httproute-listener-hostname-matching.go index 9ab780b64e..5ebc95d600 100644 --- a/conformance/tests/httproute-listener-hostname-matching.go +++ b/conformance/tests/httproute-listener-hostname-matching.go @@ -19,8 +19,10 @@ package tests import ( "testing" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/gateway-api/apis/v1beta1" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" @@ -41,17 +43,28 @@ var HTTPRouteListenerHostnameMatching = suite.ConformanceTest{ // namespace so we have to wait for it to be ready. kubernetes.NamespacesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, []string{ns}) + routeNN1 := types.NamespacedName{Name: "backend-v1", Namespace: ns} + routeNN2 := types.NamespacedName{Name: "backend-v2", Namespace: ns} + routeNN3 := types.NamespacedName{Name: "backend-v3", Namespace: ns} gwNN := types.NamespacedName{Name: "httproute-listener-hostname-matching", Namespace: ns} - - _ = kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN, "listener-1"), - types.NamespacedName{Namespace: ns, Name: "backend-v1"}, - ) - _ = kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN, "listener-2"), - types.NamespacedName{Namespace: ns, Name: "backend-v2"}, - ) - gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN, "listener-3", "listener-4"), - types.NamespacedName{Namespace: ns, Name: "backend-v3"}, - ) + kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN, "listener-1"), routeNN1) + kubernetes.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN1, gwNN, metav1.Condition{ + Type: string(v1beta1.RouteConditionResolvedRefs), + Status: metav1.ConditionTrue, + Reason: string(v1beta1.RouteReasonResolvedRefs), + }) + kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN, "listener-2"), routeNN2) + kubernetes.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN2, gwNN, metav1.Condition{ + Type: string(v1beta1.RouteConditionResolvedRefs), + Status: metav1.ConditionTrue, + Reason: string(v1beta1.RouteReasonResolvedRefs), + }) + gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN, "listener-3", "listener-4"), routeNN3) + kubernetes.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN3, gwNN, metav1.Condition{ + Type: string(v1beta1.RouteConditionResolvedRefs), + Status: metav1.ConditionTrue, + Reason: string(v1beta1.RouteReasonResolvedRefs), + }) testCases := []http.ExpectedResponse{{ Request: http.Request{Host: "bar.com", Path: "/"}, diff --git a/conformance/tests/httproute-matching-across-routes.go b/conformance/tests/httproute-matching-across-routes.go index 4ab46a3d92..3bf1fed8ad 100644 --- a/conformance/tests/httproute-matching-across-routes.go +++ b/conformance/tests/httproute-matching-across-routes.go @@ -19,8 +19,10 @@ package tests import ( "testing" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/gateway-api/apis/v1beta1" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" @@ -40,6 +42,16 @@ var HTTPRouteMatchingAcrossRoutes = suite.ConformanceTest{ routeNN2 := types.NamespacedName{Name: "matching-part2", Namespace: ns} gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN1, routeNN2) + kubernetes.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN1, gwNN, metav1.Condition{ + Type: string(v1beta1.RouteConditionResolvedRefs), + Status: metav1.ConditionTrue, + Reason: string(v1beta1.RouteReasonResolvedRefs), + }) + kubernetes.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN2, gwNN, metav1.Condition{ + Type: string(v1beta1.RouteConditionResolvedRefs), + Status: metav1.ConditionTrue, + Reason: string(v1beta1.RouteReasonResolvedRefs), + }) testCases := []http.ExpectedResponse{{ Request: http.Request{ diff --git a/conformance/tests/httproute-matching.go b/conformance/tests/httproute-matching.go index 596f04cbf5..b570274f0a 100644 --- a/conformance/tests/httproute-matching.go +++ b/conformance/tests/httproute-matching.go @@ -19,8 +19,10 @@ package tests import ( "testing" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/gateway-api/apis/v1beta1" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" @@ -39,6 +41,11 @@ var HTTPRouteMatching = suite.ConformanceTest{ routeNN := types.NamespacedName{Name: "matching", 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.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, metav1.Condition{ + Type: string(v1beta1.RouteConditionResolvedRefs), + Status: metav1.ConditionTrue, + Reason: string(v1beta1.RouteReasonResolvedRefs), + }) testCases := []http.ExpectedResponse{{ Request: http.Request{Path: "/"}, diff --git a/conformance/tests/httproute-method-matching.go b/conformance/tests/httproute-method-matching.go index dc136cc4a0..b2eb924a99 100644 --- a/conformance/tests/httproute-method-matching.go +++ b/conformance/tests/httproute-method-matching.go @@ -19,8 +19,10 @@ package tests import ( "testing" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/gateway-api/apis/v1beta1" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" @@ -40,6 +42,11 @@ var HTTPRouteMethodMatching = suite.ConformanceTest{ routeNN := types.NamespacedName{Name: "method-matching", 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.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, metav1.Condition{ + Type: string(v1beta1.RouteConditionResolvedRefs), + Status: metav1.ConditionTrue, + Reason: string(v1beta1.RouteReasonResolvedRefs), + }) testCases := []http.ExpectedResponse{ { diff --git a/conformance/tests/httproute-observed-generation-bump.go b/conformance/tests/httproute-observed-generation-bump.go index 590dcc6fed..5c6ebb3961 100644 --- a/conformance/tests/httproute-observed-generation-bump.go +++ b/conformance/tests/httproute-observed-generation-bump.go @@ -38,26 +38,19 @@ var HTTPRouteObservedGenerationBump = suite.ConformanceTest{ ShortName: "HTTPRouteObservedGenerationBump", Description: "A HTTPRoute in the gateway-conformance-infra namespace should update the observedGeneration in all of it's Status.Conditions after an update to the spec", Manifests: []string{"tests/httproute-observed-generation-bump.yaml"}, - Test: func(t *testing.T, s *suite.ConformanceTestSuite) { - + Test: func(t *testing.T, suite *suite.ConformanceTestSuite) { routeNN := types.NamespacedName{Name: "observed-generation-bump", Namespace: "gateway-conformance-infra"} gwNN := types.NamespacedName{Name: "same-namespace", Namespace: "gateway-conformance-infra"} - acceptedCondition := metav1.Condition{ - Type: string(v1beta1.RouteConditionAccepted), - Status: metav1.ConditionTrue, - Reason: "", // any reason - } - t.Run("observedGeneration should increment", func(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() namespaces := []string{"gateway-conformance-infra"} - kubernetes.NamespacesMustBeAccepted(t, s.Client, s.TimeoutConfig, namespaces) + kubernetes.NamespacesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, namespaces) original := &v1beta1.HTTPRoute{} - err := s.Client.Get(ctx, routeNN, original) + err := suite.Client.Get(ctx, routeNN, original) require.NoErrorf(t, err, "error getting HTTPRoute: %v", err) // Sanity check @@ -65,13 +58,22 @@ var HTTPRouteObservedGenerationBump = suite.ConformanceTest{ mutate := original.DeepCopy() mutate.Spec.Rules[0].BackendRefs[0].Name = "infra-backend-v2" - err = s.Client.Update(ctx, mutate) + err = suite.Client.Update(ctx, mutate) require.NoErrorf(t, err, "error updating the HTTPRoute: %v", err) - kubernetes.HTTPRouteMustHaveCondition(t, s.Client, s.TimeoutConfig, routeNN, gwNN, acceptedCondition) + kubernetes.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, metav1.Condition{ + Type: string(v1beta1.RouteConditionAccepted), + Status: metav1.ConditionTrue, + Reason: "", // any reason + }) + kubernetes.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, metav1.Condition{ + Type: string(v1beta1.RouteConditionResolvedRefs), + Status: metav1.ConditionTrue, + Reason: string(v1beta1.RouteReasonResolvedRefs), + }) updated := &v1beta1.HTTPRoute{} - err = s.Client.Get(ctx, routeNN, updated) + err = suite.Client.Get(ctx, routeNN, updated) require.NoErrorf(t, err, "error getting Gateway: %v", err) // Sanity check diff --git a/conformance/tests/httproute-query-param-matching.go b/conformance/tests/httproute-query-param-matching.go index e5a513150e..17f2d587cc 100644 --- a/conformance/tests/httproute-query-param-matching.go +++ b/conformance/tests/httproute-query-param-matching.go @@ -19,8 +19,10 @@ package tests import ( "testing" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/gateway-api/apis/v1beta1" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" @@ -36,12 +38,15 @@ var HTTPRouteQueryParamMatching = suite.ConformanceTest{ Manifests: []string{"tests/httproute-query-param-matching.yaml"}, Features: []suite.SupportedFeature{suite.SupportHTTPRouteQueryParamMatching}, Test: func(t *testing.T, suite *suite.ConformanceTestSuite) { - var ( - ns = "gateway-conformance-infra" - routeNN = types.NamespacedName{Namespace: ns, Name: "query-param-matching"} - gwNN = types.NamespacedName{Namespace: ns, Name: "same-namespace"} - gwAddr = kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) - ) + ns := "gateway-conformance-infra" + routeNN := types.NamespacedName{Namespace: ns, Name: "query-param-matching"} + gwNN := types.NamespacedName{Namespace: ns, Name: "same-namespace"} + gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) + kubernetes.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, metav1.Condition{ + Type: string(v1beta1.RouteConditionResolvedRefs), + Status: metav1.ConditionTrue, + Reason: string(v1beta1.RouteReasonResolvedRefs), + }) testCases := []http.ExpectedResponse{{ Request: http.Request{Path: "/?animal=whale"}, diff --git a/conformance/tests/httproute-redirect-host-and-status.go b/conformance/tests/httproute-redirect-host-and-status.go index d360abb28f..97faec284f 100644 --- a/conformance/tests/httproute-redirect-host-and-status.go +++ b/conformance/tests/httproute-redirect-host-and-status.go @@ -19,8 +19,10 @@ package tests import ( "testing" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/gateway-api/apis/v1beta1" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/roundtripper" @@ -40,6 +42,11 @@ var HTTPRouteRedirectHostAndStatus = suite.ConformanceTest{ routeNN := types.NamespacedName{Name: "redirect-host-and-status", 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.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, metav1.Condition{ + Type: string(v1beta1.RouteConditionResolvedRefs), + Status: metav1.ConditionTrue, + Reason: string(v1beta1.RouteReasonResolvedRefs), + }) testCases := []http.ExpectedResponse{{ Request: http.Request{ diff --git a/conformance/tests/httproute-redirect-path.go b/conformance/tests/httproute-redirect-path.go index 880fb053ea..84a209719c 100644 --- a/conformance/tests/httproute-redirect-path.go +++ b/conformance/tests/httproute-redirect-path.go @@ -19,8 +19,10 @@ package tests import ( "testing" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/gateway-api/apis/v1beta1" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/roundtripper" @@ -41,6 +43,11 @@ var HTTPRouteRedirectPath = suite.ConformanceTest{ routeNN := types.NamespacedName{Name: "redirect-path", 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.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, metav1.Condition{ + Type: string(v1beta1.RouteConditionResolvedRefs), + Status: metav1.ConditionTrue, + Reason: string(v1beta1.RouteReasonResolvedRefs), + }) testCases := []http.ExpectedResponse{{ Request: http.Request{ diff --git a/conformance/tests/httproute-redirect-port.go b/conformance/tests/httproute-redirect-port.go index 58d4fd6b12..75f3103801 100644 --- a/conformance/tests/httproute-redirect-port.go +++ b/conformance/tests/httproute-redirect-port.go @@ -19,8 +19,10 @@ package tests import ( "testing" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/gateway-api/apis/v1beta1" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/roundtripper" @@ -41,6 +43,11 @@ var HTTPRouteRedirectPort = suite.ConformanceTest{ routeNN := types.NamespacedName{Name: "redirect-port", 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.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, metav1.Condition{ + Type: string(v1beta1.RouteConditionResolvedRefs), + Status: metav1.ConditionTrue, + Reason: string(v1beta1.RouteReasonResolvedRefs), + }) testCases := []http.ExpectedResponse{{ Request: http.Request{ diff --git a/conformance/tests/httproute-redirect-scheme.go b/conformance/tests/httproute-redirect-scheme.go index d2cc34f251..5ebd955b5f 100644 --- a/conformance/tests/httproute-redirect-scheme.go +++ b/conformance/tests/httproute-redirect-scheme.go @@ -19,8 +19,10 @@ package tests import ( "testing" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/gateway-api/apis/v1beta1" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/roundtripper" @@ -41,6 +43,11 @@ var HTTPRouteRedirectScheme = suite.ConformanceTest{ routeNN := types.NamespacedName{Name: "redirect-scheme", 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.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, metav1.Condition{ + Type: string(v1beta1.RouteConditionResolvedRefs), + Status: metav1.ConditionTrue, + Reason: string(v1beta1.RouteReasonResolvedRefs), + }) testCases := []http.ExpectedResponse{{ Request: http.Request{ diff --git a/conformance/tests/httproute-reference-grant.go b/conformance/tests/httproute-reference-grant.go index ae096ecadf..c502416afe 100644 --- a/conformance/tests/httproute-reference-grant.go +++ b/conformance/tests/httproute-reference-grant.go @@ -19,8 +19,10 @@ package tests import ( "testing" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/gateway-api/apis/v1beta1" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" @@ -35,13 +37,18 @@ var HTTPRouteReferenceGrant = suite.ConformanceTest{ Description: "A single HTTPRoute in the gateway-conformance-infra namespace, with a backendRef in the gateway-conformance-web-backend namespace, should attach to Gateway in the gateway-conformance-infra namespace", Features: []suite.SupportedFeature{suite.SupportReferenceGrant}, Manifests: []string{"tests/httproute-reference-grant.yaml"}, - Test: func(t *testing.T, s *suite.ConformanceTestSuite) { + Test: func(t *testing.T, suite *suite.ConformanceTestSuite) { routeNN := types.NamespacedName{Name: "reference-grant", Namespace: "gateway-conformance-infra"} gwNN := types.NamespacedName{Name: "same-namespace", Namespace: "gateway-conformance-infra"} - gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, s.Client, s.TimeoutConfig, s.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) + gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) + kubernetes.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, metav1.Condition{ + Type: string(v1beta1.RouteConditionResolvedRefs), + Status: metav1.ConditionTrue, + Reason: string(v1beta1.RouteReasonResolvedRefs), + }) t.Run("Simple HTTP request should reach web-backend", func(t *testing.T) { - http.MakeRequestAndExpectEventuallyConsistentResponse(t, s.RoundTripper, s.TimeoutConfig, gwAddr, http.ExpectedResponse{ + http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, http.ExpectedResponse{ Request: http.Request{ Method: "GET", Path: "/", diff --git a/conformance/tests/httproute-request-header-modifier.go b/conformance/tests/httproute-request-header-modifier.go index 14220b3442..b170447e32 100644 --- a/conformance/tests/httproute-request-header-modifier.go +++ b/conformance/tests/httproute-request-header-modifier.go @@ -19,8 +19,10 @@ package tests import ( "testing" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/gateway-api/apis/v1beta1" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" @@ -39,6 +41,11 @@ var HTTPRouteRequestHeaderModifier = suite.ConformanceTest{ 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.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, metav1.Condition{ + Type: string(v1beta1.RouteConditionResolvedRefs), + Status: metav1.ConditionTrue, + Reason: string(v1beta1.RouteReasonResolvedRefs), + }) testCases := []http.ExpectedResponse{{ Request: http.Request{ diff --git a/conformance/tests/httproute-response-header-modifier.go b/conformance/tests/httproute-response-header-modifier.go index dd6323545c..9a03b07ec1 100644 --- a/conformance/tests/httproute-response-header-modifier.go +++ b/conformance/tests/httproute-response-header-modifier.go @@ -19,8 +19,10 @@ package tests import ( "testing" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/gateway-api/apis/v1beta1" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" @@ -40,6 +42,11 @@ var HTTPRouteResponseHeaderModifier = suite.ConformanceTest{ routeNN := types.NamespacedName{Name: "response-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.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, metav1.Condition{ + Type: string(v1beta1.RouteConditionResolvedRefs), + Status: metav1.ConditionTrue, + Reason: string(v1beta1.RouteReasonResolvedRefs), + }) testCases := []http.ExpectedResponse{{ Request: http.Request{ diff --git a/conformance/tests/httproute-rewrite-host.go b/conformance/tests/httproute-rewrite-host.go index 59a392874e..a45f328e95 100644 --- a/conformance/tests/httproute-rewrite-host.go +++ b/conformance/tests/httproute-rewrite-host.go @@ -19,8 +19,10 @@ package tests import ( "testing" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/gateway-api/apis/v1beta1" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" @@ -40,6 +42,11 @@ var HTTPRouteRewriteHost = suite.ConformanceTest{ routeNN := types.NamespacedName{Name: "rewrite-host", 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.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, metav1.Condition{ + Type: string(v1beta1.RouteConditionResolvedRefs), + Status: metav1.ConditionTrue, + Reason: string(v1beta1.RouteReasonResolvedRefs), + }) testCases := []http.ExpectedResponse{ { diff --git a/conformance/tests/httproute-rewrite-path.go b/conformance/tests/httproute-rewrite-path.go index 2e8539e9e7..6e6df7e15f 100644 --- a/conformance/tests/httproute-rewrite-path.go +++ b/conformance/tests/httproute-rewrite-path.go @@ -19,8 +19,10 @@ package tests import ( "testing" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/gateway-api/apis/v1beta1" "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" @@ -40,6 +42,11 @@ var HTTPRouteRewritePath = suite.ConformanceTest{ routeNN := types.NamespacedName{Name: "rewrite-path", 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.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, metav1.Condition{ + Type: string(v1beta1.RouteConditionResolvedRefs), + Status: metav1.ConditionTrue, + Reason: string(v1beta1.RouteReasonResolvedRefs), + }) testCases := []http.ExpectedResponse{ { diff --git a/conformance/tests/httproute-simple-same-namespace.go b/conformance/tests/httproute-simple-same-namespace.go index 910b901d52..7293343ba7 100644 --- a/conformance/tests/httproute-simple-same-namespace.go +++ b/conformance/tests/httproute-simple-same-namespace.go @@ -19,6 +19,7 @@ package tests import ( "testing" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/gateway-api/apis/v1beta1" @@ -40,6 +41,11 @@ var HTTPRouteSimpleSameNamespace = suite.ConformanceTest{ 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.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, metav1.Condition{ + Type: string(v1beta1.RouteConditionResolvedRefs), + Status: metav1.ConditionTrue, + Reason: string(v1beta1.RouteReasonResolvedRefs), + }) t.Run("Simple HTTP request should reach infra-backend", func(t *testing.T) { http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, http.ExpectedResponse{