From 55333b449ede42b3ebb86a60eb321504bd914430 Mon Sep 17 00:00:00 2001 From: Mattia Lavacca Date: Fri, 10 Mar 2023 17:30:35 +0100 Subject: [PATCH] helper added Signed-off-by: Mattia Lavacca --- .../tests/httproute-cross-namespace.go | 8 +------ .../tests/httproute-disallowed-kind.go | 6 +---- .../tests/httproute-exact-path-matching.go | 8 +------ .../tests/httproute-header-matching.go | 8 +------ .../tests/httproute-hostname-intersection.go | 6 +---- .../httproute-listener-hostname-matching.go | 23 +++++-------------- .../tests/httproute-matching-across-routes.go | 14 ++--------- conformance/tests/httproute-matching.go | 8 +------ .../tests/httproute-method-matching.go | 8 +------ .../httproute-observed-generation-bump.go | 6 +---- .../tests/httproute-query-param-matching.go | 8 +------ .../httproute-redirect-host-and-status.go | 8 +------ conformance/tests/httproute-redirect-path.go | 8 +------ conformance/tests/httproute-redirect-port.go | 8 +------ .../tests/httproute-redirect-scheme.go | 8 +------ .../tests/httproute-reference-grant.go | 8 +------ .../httproute-request-header-modifier.go | 8 +------ .../httproute-response-header-modifier.go | 8 +------ conformance/tests/httproute-rewrite-host.go | 8 +------ conformance/tests/httproute-rewrite-path.go | 8 +------ .../tests/httproute-simple-same-namespace.go | 7 +----- .../tests/tlsroute-simple-same-namespace.go | 6 ----- conformance/utils/kubernetes/helpers.go | 10 ++++++++ 23 files changed, 37 insertions(+), 161 deletions(-) diff --git a/conformance/tests/httproute-cross-namespace.go b/conformance/tests/httproute-cross-namespace.go index ec256794b1..fbf58645b0 100644 --- a/conformance/tests/httproute-cross-namespace.go +++ b/conformance/tests/httproute-cross-namespace.go @@ -19,10 +19,8 @@ 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,11 +38,7 @@ 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), - }) + kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN) 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-disallowed-kind.go b/conformance/tests/httproute-disallowed-kind.go index f723f379c5..ce2a16ff22 100644 --- a/conformance/tests/httproute-disallowed-kind.go +++ b/conformance/tests/httproute-disallowed-kind.go @@ -43,11 +43,7 @@ var HTTPRouteDisallowedKind = suite.ConformanceTest{ routeNN := types.NamespacedName{Name: "disallowed-kind", Namespace: "gateway-conformance-infra"} gwNN := types.NamespacedName{Name: "tlsroutes-only", Namespace: "gateway-conformance-infra"} - kubernetes.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, metav1.Condition{ - Type: string(v1beta1.RouteConditionResolvedRefs), - Status: metav1.ConditionTrue, - Reason: string(v1beta1.RouteReasonResolvedRefs), - }) + kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN) t.Run("Route should not have been accepted with reason NotAllowedByListeners", func(t *testing.T) { kubernetes.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, metav1.Condition{ diff --git a/conformance/tests/httproute-exact-path-matching.go b/conformance/tests/httproute-exact-path-matching.go index 1b4e6854f9..fdc032e58a 100644 --- a/conformance/tests/httproute-exact-path-matching.go +++ b/conformance/tests/httproute-exact-path-matching.go @@ -19,10 +19,8 @@ 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,11 +39,7 @@ 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), - }) + kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN) testCases := []http.ExpectedResponse{ { diff --git a/conformance/tests/httproute-header-matching.go b/conformance/tests/httproute-header-matching.go index 7624e73011..3208bf2e06 100644 --- a/conformance/tests/httproute-header-matching.go +++ b/conformance/tests/httproute-header-matching.go @@ -19,10 +19,8 @@ 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,11 +39,7 @@ 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), - }) + kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN) 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 304a8e1344..7d97eaa02d 100644 --- a/conformance/tests/httproute-hostname-intersection.go +++ b/conformance/tests/httproute-hostname-intersection.go @@ -53,11 +53,7 @@ var HTTPRouteHostnameIntersection = suite.ConformanceTest{ } 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), - }) + kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN) } var testCases []http.ExpectedResponse diff --git a/conformance/tests/httproute-listener-hostname-matching.go b/conformance/tests/httproute-listener-hostname-matching.go index 9a1bf3b509..1b20a25176 100644 --- a/conformance/tests/httproute-listener-hostname-matching.go +++ b/conformance/tests/httproute-listener-hostname-matching.go @@ -19,10 +19,8 @@ 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" @@ -47,24 +45,15 @@ var HTTPRouteListenerHostnameMatching = suite.ConformanceTest{ 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"), routeNN1) - kubernetes.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN1, gwNN, metav1.Condition{ - Type: string(v1beta1.RouteConditionResolvedRefs), - Status: metav1.ConditionTrue, - Reason: string(v1beta1.RouteReasonResolvedRefs), - }) + kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN1, gwNN) + 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), - }) + kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN2, gwNN) + 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), - }) + kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN3, gwNN) 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 3bf1fed8ad..baedd9f338 100644 --- a/conformance/tests/httproute-matching-across-routes.go +++ b/conformance/tests/httproute-matching-across-routes.go @@ -19,10 +19,8 @@ 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" @@ -42,16 +40,8 @@ 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), - }) + kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN1, gwNN) + kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN2, gwNN) testCases := []http.ExpectedResponse{{ Request: http.Request{ diff --git a/conformance/tests/httproute-matching.go b/conformance/tests/httproute-matching.go index b570274f0a..3d5122a83c 100644 --- a/conformance/tests/httproute-matching.go +++ b/conformance/tests/httproute-matching.go @@ -19,10 +19,8 @@ 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,11 +39,7 @@ 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), - }) + kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN) testCases := []http.ExpectedResponse{{ Request: http.Request{Path: "/"}, diff --git a/conformance/tests/httproute-method-matching.go b/conformance/tests/httproute-method-matching.go index b2eb924a99..fb9491c06a 100644 --- a/conformance/tests/httproute-method-matching.go +++ b/conformance/tests/httproute-method-matching.go @@ -19,10 +19,8 @@ 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" @@ -42,11 +40,7 @@ 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), - }) + kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN) testCases := []http.ExpectedResponse{ { diff --git a/conformance/tests/httproute-observed-generation-bump.go b/conformance/tests/httproute-observed-generation-bump.go index a59d8e5b57..3a23666ba4 100644 --- a/conformance/tests/httproute-observed-generation-bump.go +++ b/conformance/tests/httproute-observed-generation-bump.go @@ -67,11 +67,7 @@ var HTTPRouteObservedGenerationBump = suite.ConformanceTest{ 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), - }) + kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN) updated := &v1beta1.HTTPRoute{} err = suite.Client.Get(ctx, routeNN, updated) diff --git a/conformance/tests/httproute-query-param-matching.go b/conformance/tests/httproute-query-param-matching.go index 17f2d587cc..bd981888c4 100644 --- a/conformance/tests/httproute-query-param-matching.go +++ b/conformance/tests/httproute-query-param-matching.go @@ -19,10 +19,8 @@ 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" @@ -42,11 +40,7 @@ var HTTPRouteQueryParamMatching = suite.ConformanceTest{ 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), - }) + kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN) 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 97faec284f..c57fc08eaf 100644 --- a/conformance/tests/httproute-redirect-host-and-status.go +++ b/conformance/tests/httproute-redirect-host-and-status.go @@ -19,10 +19,8 @@ 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" @@ -42,11 +40,7 @@ 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), - }) + kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN) testCases := []http.ExpectedResponse{{ Request: http.Request{ diff --git a/conformance/tests/httproute-redirect-path.go b/conformance/tests/httproute-redirect-path.go index 84a209719c..0ae24fc73a 100644 --- a/conformance/tests/httproute-redirect-path.go +++ b/conformance/tests/httproute-redirect-path.go @@ -19,10 +19,8 @@ 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" @@ -43,11 +41,7 @@ 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), - }) + kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN) testCases := []http.ExpectedResponse{{ Request: http.Request{ diff --git a/conformance/tests/httproute-redirect-port.go b/conformance/tests/httproute-redirect-port.go index 75f3103801..9ceeade802 100644 --- a/conformance/tests/httproute-redirect-port.go +++ b/conformance/tests/httproute-redirect-port.go @@ -19,10 +19,8 @@ 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" @@ -43,11 +41,7 @@ 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), - }) + kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN) testCases := []http.ExpectedResponse{{ Request: http.Request{ diff --git a/conformance/tests/httproute-redirect-scheme.go b/conformance/tests/httproute-redirect-scheme.go index 5ebd955b5f..0ef63a4f01 100644 --- a/conformance/tests/httproute-redirect-scheme.go +++ b/conformance/tests/httproute-redirect-scheme.go @@ -19,10 +19,8 @@ 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" @@ -43,11 +41,7 @@ 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), - }) + kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN) testCases := []http.ExpectedResponse{{ Request: http.Request{ diff --git a/conformance/tests/httproute-reference-grant.go b/conformance/tests/httproute-reference-grant.go index c502416afe..dd48076a86 100644 --- a/conformance/tests/httproute-reference-grant.go +++ b/conformance/tests/httproute-reference-grant.go @@ -19,10 +19,8 @@ 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,11 +39,7 @@ var HTTPRouteReferenceGrant = suite.ConformanceTest{ routeNN := types.NamespacedName{Name: "reference-grant", Namespace: "gateway-conformance-infra"} gwNN := types.NamespacedName{Name: "same-namespace", 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), - }) + kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN) 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-request-header-modifier.go b/conformance/tests/httproute-request-header-modifier.go index b170447e32..8b4c77fcbd 100644 --- a/conformance/tests/httproute-request-header-modifier.go +++ b/conformance/tests/httproute-request-header-modifier.go @@ -19,10 +19,8 @@ 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,11 +39,7 @@ 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), - }) + kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN) 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 9a03b07ec1..1f2c8f4a34 100644 --- a/conformance/tests/httproute-response-header-modifier.go +++ b/conformance/tests/httproute-response-header-modifier.go @@ -19,10 +19,8 @@ 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" @@ -42,11 +40,7 @@ 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), - }) + kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN) testCases := []http.ExpectedResponse{{ Request: http.Request{ diff --git a/conformance/tests/httproute-rewrite-host.go b/conformance/tests/httproute-rewrite-host.go index a45f328e95..fb3a96e3f8 100644 --- a/conformance/tests/httproute-rewrite-host.go +++ b/conformance/tests/httproute-rewrite-host.go @@ -19,10 +19,8 @@ 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" @@ -42,11 +40,7 @@ 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), - }) + kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN) testCases := []http.ExpectedResponse{ { diff --git a/conformance/tests/httproute-rewrite-path.go b/conformance/tests/httproute-rewrite-path.go index 6e6df7e15f..12adefdeae 100644 --- a/conformance/tests/httproute-rewrite-path.go +++ b/conformance/tests/httproute-rewrite-path.go @@ -19,10 +19,8 @@ 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" @@ -42,11 +40,7 @@ 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), - }) + kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN) testCases := []http.ExpectedResponse{ { diff --git a/conformance/tests/httproute-simple-same-namespace.go b/conformance/tests/httproute-simple-same-namespace.go index 7293343ba7..22080e1c83 100644 --- a/conformance/tests/httproute-simple-same-namespace.go +++ b/conformance/tests/httproute-simple-same-namespace.go @@ -19,7 +19,6 @@ package tests import ( "testing" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/gateway-api/apis/v1beta1" @@ -41,11 +40,7 @@ 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), - }) + 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{ diff --git a/conformance/tests/tlsroute-simple-same-namespace.go b/conformance/tests/tlsroute-simple-same-namespace.go index f04550ea21..eef8fcd092 100644 --- a/conformance/tests/tlsroute-simple-same-namespace.go +++ b/conformance/tests/tlsroute-simple-same-namespace.go @@ -23,7 +23,6 @@ import ( "time" v1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" @@ -55,11 +54,6 @@ var TLSRouteSimpleSameNamespace = suite.ConformanceTest{ t.Fatalf("unexpected error in test configuration, found %d hostnames", len(hostnames)) } serverStr := string(hostnames[0]) - kubernetes.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, metav1.Condition{ - Type: string(v1beta1.RouteConditionResolvedRefs), - Status: metav1.ConditionTrue, - Reason: string(v1beta1.RouteReasonResolvedRefs), - }) cPem, keyPem, err := GetTLSSecret(suite.Client, certNN) if err != nil { diff --git a/conformance/utils/kubernetes/helpers.go b/conformance/utils/kubernetes/helpers.go index 335e1e1ed1..702ea071a7 100644 --- a/conformance/utils/kubernetes/helpers.go +++ b/conformance/utils/kubernetes/helpers.go @@ -562,6 +562,16 @@ func HTTPRouteMustHaveCondition(t *testing.T, client client.Client, timeoutConfi require.NoErrorf(t, waitErr, "error waiting for HTTPRoute status to have a Condition matching expectations") } +// HTTPRouteMustHaveResolvedRefsConditionsTrue checks that the supplied HTTPRoute has the resolvedRefsCondition +// set to true. +func HTTPRouteMustHaveResolvedRefsConditionsTrue(t *testing.T, client client.Client, timeoutConfig config.TimeoutConfig, routeNN types.NamespacedName, gwNN types.NamespacedName) { + HTTPRouteMustHaveCondition(t, client, timeoutConfig, routeNN, gwNN, metav1.Condition{ + Type: string(v1beta1.RouteConditionResolvedRefs), + Status: metav1.ConditionTrue, + Reason: string(v1beta1.RouteReasonResolvedRefs), + }) +} + func parentRefToString(p v1beta1.ParentReference) string { if p.Namespace != nil && *p.Namespace != "" { return fmt.Sprintf("%v/%v", p.Namespace, p.Name)