Skip to content

Commit

Permalink
Conformance: Adds Test to Exercise Gateway AttachedRoutes
Browse files Browse the repository at this point in the history
Signed-off-by: Daneyon Hansen <[email protected]>
  • Loading branch information
danehans committed Oct 18, 2023
1 parent 37d8159 commit fe8be7a
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
46 changes: 46 additions & 0 deletions conformance/tests/gateway-with-attached-routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
},
}

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

0 comments on commit fe8be7a

Please sign in to comment.