...
1
16
17 package tests
18
19 import (
20 "testing"
21
22 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23 "k8s.io/apimachinery/pkg/types"
24
25 v1 "sigs.k8s.io/gateway-api/apis/v1"
26 "sigs.k8s.io/gateway-api/conformance/utils/kubernetes"
27 "sigs.k8s.io/gateway-api/conformance/utils/suite"
28 )
29
30 func init() {
31 ConformanceTests = append(ConformanceTests, HTTPRouteInvalidParentRefNotMatchingListenerPort)
32 }
33
34 var HTTPRouteInvalidParentRefNotMatchingListenerPort = suite.ConformanceTest{
35 ShortName: "HTTPRouteInvalidParentRefNotMatchingListenerPort",
36 Description: "A single HTTPRoute in the gateway-conformance-infra namespace should set the Accepted status to False with reason NoMatchingParent when attempting to bind to a Gateway that does not have a matching ListenerPort.",
37 Features: []suite.SupportedFeature{
38 suite.SupportGateway,
39 suite.SupportHTTPRoute,
40 suite.SupportHTTPRouteDestinationPortMatching,
41 },
42 Manifests: []string{"tests/httproute-invalid-parentref-not-matching-listener-port.yaml"},
43 Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
44 routeNN := types.NamespacedName{Name: "httproute-listener-not-matching-route-port", Namespace: "gateway-conformance-infra"}
45 gwNN := types.NamespacedName{Name: "same-namespace", Namespace: "gateway-conformance-infra"}
46 kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN)
47
48
49 t.Run("HTTPRoute with no matching port in ParentRef has an Accepted Condition with status False and Reason NoMatchingParent", func(t *testing.T) {
50 acceptedCond := metav1.Condition{
51 Type: string(v1.RouteConditionAccepted),
52 Status: metav1.ConditionFalse,
53 Reason: string(v1.RouteReasonNoMatchingParent),
54 }
55
56 kubernetes.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, acceptedCond)
57 })
58
59 t.Run("Route should not have Parents accepted in status", func(t *testing.T) {
60 kubernetes.HTTPRouteMustHaveNoAcceptedParents(t, suite.Client, suite.TimeoutConfig, routeNN)
61 })
62
63 t.Run("Gateway should have 0 Routes attached", func(t *testing.T) {
64 kubernetes.GatewayMustHaveZeroRoutes(t, suite.Client, suite.TimeoutConfig, gwNN)
65 })
66 },
67 }
68
View as plain text