diff --git a/conformance/tests/gateway-with-attached-routes.go b/conformance/tests/gateway-with-attached-routes.go index 1f180baa44..81de412d7b 100644 --- a/conformance/tests/gateway-with-attached-routes.go +++ b/conformance/tests/gateway-with-attached-routes.go @@ -76,5 +76,39 @@ var GatewayWithAttachedRoutes = suite.ConformanceTest{ kubernetes.GatewayStatusMustHaveListeners(t, s.Client, s.TimeoutConfig, gwNN, listeners) }) + + t.Run("Gateway listener should have attached route by specifying the sectionName", func(t *testing.T) { + gwNN := types.NamespacedName{Name: "gateway-with-two-listeners-and-one-attached-route", Namespace: "gateway-conformance-infra"} + listeners := []v1beta1.ListenerStatus{ + { + Name: v1beta1.SectionName("http-unattached"), + SupportedKinds: []v1beta1.RouteGroupKind{{ + Group: (*v1beta1.Group)(&v1beta1.GroupVersion.Group), + Kind: v1beta1.Kind("HTTPRoute"), + }}, + Conditions: []metav1.Condition{{ + Type: string(v1beta1.ListenerConditionAccepted), + Status: metav1.ConditionTrue, + Reason: "", // any reason + }}, + AttachedRoutes: 0, + }, + { + Name: v1beta1.SectionName("http"), + SupportedKinds: []v1beta1.RouteGroupKind{{ + Group: (*v1beta1.Group)(&v1beta1.GroupVersion.Group), + Kind: v1beta1.Kind("HTTPRoute"), + }}, + Conditions: []metav1.Condition{{ + Type: string(v1beta1.ListenerConditionAccepted), + Status: metav1.ConditionTrue, + Reason: "", // any reason + }}, + AttachedRoutes: 1, + }, + } + + kubernetes.GatewayStatusMustHaveListeners(t, s.Client, s.TimeoutConfig, gwNN, listeners) + }) }, } diff --git a/conformance/tests/gateway-with-attached-routes.yaml b/conformance/tests/gateway-with-attached-routes.yaml index b067f99c7b..c5a572c362 100644 --- a/conformance/tests/gateway-with-attached-routes.yaml +++ b/conformance/tests/gateway-with-attached-routes.yaml @@ -86,3 +86,44 @@ spec: - backendRefs: - name: infra-backend-v1 port: 8080 +--- +apiVersion: gateway.networking.k8s.io/v1beta1 +kind: Gateway +metadata: + name: gateway-with-two-listeners-and-one-attached-route + namespace: gateway-conformance-infra +spec: + gatewayClassName: "{GATEWAY_CLASS_NAME}" + listeners: + - name: http-unattached + port: 8080 + protocol: HTTP + allowedRoutes: + kinds: + - kind: HTTPRoute + namespaces: + from: All + - name: http + port: 80 + protocol: HTTP + allowedRoutes: + kinds: + - kind: HTTPRoute + namespaces: + from: All +--- +apiVersion: gateway.networking.k8s.io/v1beta1 +kind: HTTPRoute +metadata: + name: http-route-4 + namespace: gateway-conformance-infra +spec: + parentRefs: + - kind: Gateway + name: gateway-with-two-listeners-and-one-attached-route + namespace: gateway-conformance-infra + sectionName: http + rules: + - backendRefs: + - name: infra-backend-v1 + port: 8080