diff --git a/conformance/tests/gateway-with-attached-routes.go b/conformance/tests/gateway-with-attached-routes.go index b49fcd2f66..cc75a378e3 100644 --- a/conformance/tests/gateway-with-attached-routes.go +++ b/conformance/tests/gateway-with-attached-routes.go @@ -90,6 +90,52 @@ var GatewayWithAttachedRoutes = suite.ConformanceTest{ kubernetes.GatewayStatusMustHaveListeners(t, s.Client, s.TimeoutConfig, gwNN, listeners) }) + + t.Run("Gateway listener should have an accepted http route attached when unresolved refs exist", func(t *testing.T) { + gwNN := types.NamespacedName{Name: "unresolved-gateway-with-one-attached-unresolved-route", Namespace: "gateway-conformance-infra"} + listeners := []v1.ListenerStatus{{ + Name: v1.SectionName("tls"), + SupportedKinds: []v1.RouteGroupKind{{ + Group: (*v1.Group)(&v1.GroupVersion.Group), + Kind: v1.Kind("HTTPRoute"), + }}, + Conditions: []metav1.Condition{ + { + Type: string(v1.ListenerConditionAccepted), + Status: metav1.ConditionTrue, + Reason: "", // any reason + }, + { + Type: string(v1.ListenerConditionProgrammed), + Status: metav1.ConditionFalse, + Reason: "", // any reason + }, + { + Type: string(v1.ListenerConditionResolvedRefs), + Status: metav1.ConditionFalse, + Reason: "", // any reason + }, + }, + AttachedRoutes: 1, + }} + + kubernetes.GatewayStatusMustHaveListeners(t, s.Client, s.TimeoutConfig, gwNN, listeners) + + hrouteNN := types.NamespacedName{Name: "http-route-4", Namespace: "gateway-conformance-infra"} + notAccepted := metav1.Condition{ + Type: string(v1.RouteConditionAccepted), + Status: metav1.ConditionTrue, + Reason: "", // any reason + } + unresolved := metav1.Condition{ + Type: string(v1.RouteConditionResolvedRefs), + Status: metav1.ConditionFalse, + Reason: "", // any reason + } + + kubernetes.HTTPRouteMustHaveCondition(t, s.Client, s.TimeoutConfig, hrouteNN, gwNN, notAccepted) + kubernetes.HTTPRouteMustHaveCondition(t, s.Client, s.TimeoutConfig, hrouteNN, gwNN, unresolved) + }) }, } diff --git a/conformance/tests/gateway-with-attached-routes.yaml b/conformance/tests/gateway-with-attached-routes.yaml index d4f051699b..04f4b9ee43 100644 --- a/conformance/tests/gateway-with-attached-routes.yaml +++ b/conformance/tests/gateway-with-attached-routes.yaml @@ -86,3 +86,47 @@ spec: - backendRefs: - name: infra-backend-v1 port: 8080 +--- +apiVersion: gateway.networking.k8s.io/v1beta1 +kind: Gateway +metadata: + name: unresolved-gateway-with-one-attached-unresolved-route + namespace: gateway-conformance-infra +spec: + gatewayClassName: "{GATEWAY_CLASS_NAME}" + listeners: + - name: tls + port: 443 + protocol: HTTPS + allowedRoutes: + kinds: + - kind: HTTPRoute + namespaces: + from: Selector + selector: + matchLabels: + # This label is added automatically as of K8s 1.22 + # to all namespaces + kubernetes.io/metadata.name: gateway-conformance-infra + tls: + certificateRefs: + - group: "" + kind: Secret + name: does-not-exist + mode: Terminate +--- +apiVersion: gateway.networking.k8s.io/v1beta1 +kind: HTTPRoute +metadata: + name: http-route-4 + namespace: gateway-conformance-infra +spec: + parentRefs: + - kind: Gateway + name: unresolved-gateway-with-one-attached-unresolved-route + namespace: gateway-conformance-infra + sectionName: tls + rules: + - backendRefs: + - name: does-not-exist + port: 8080