Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions conformance/tests/gateway-with-attached-routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var GatewayWithAttachedRoutes = suite.ConformanceTest{
Description: "A Gateway in the gateway-conformance-infra namespace should be attached to routes.",
Features: []suite.SupportedFeature{
suite.SupportGateway,
suite.SupportHTTPRoute,
Copy link
Contributor Author

@danehans danehans Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@robscott I added L39 and L149 based on your comments in #2477 (review).

},
Manifests: []string{"tests/gateway-with-attached-routes.yaml"},
Test: func(t *testing.T, s *suite.ConformanceTestSuite) {
Expand Down Expand Up @@ -90,6 +91,52 @@ var GatewayWithAttachedRoutes = suite.ConformanceTest{

kubernetes.GatewayStatusMustHaveListeners(t, s.Client, s.TimeoutConfig, gwNN, listeners)
})

t.Run("Gateway listener should have AttachedRoutes set even when Gateway has unresolved refs", 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)
})
},
}

Expand All @@ -99,6 +146,7 @@ var GatewayWithAttachedRoutesWithPort8080 = suite.ConformanceTest{
Features: []suite.SupportedFeature{
suite.SupportGateway,
suite.SupportGatewayPort8080,
suite.SupportHTTPRoute,
},
Manifests: []string{"tests/gateway-with-attached-routes-with-port-8080.yaml"},
Test: func(t *testing.T, s *suite.ConformanceTestSuite) {
Expand Down
44 changes: 44 additions & 0 deletions conformance/tests/gateway-with-attached-routes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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