Skip to content

Commit

Permalink
Merge pull request #2477 from danehans/issue_2402
Browse files Browse the repository at this point in the history
Conformance: Adds Test to Exercise Gateway AttachedRoutes
  • Loading branch information
k8s-ci-robot authored Oct 25, 2023
2 parents 203d400 + 8b76391 commit 22b7f77
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
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,
},
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

0 comments on commit 22b7f77

Please sign in to comment.