mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-04 17:07:04 +02:00
Signed-off-by: Christopher Larivière <lariviere.c@gmail.com> Co-authored-by: Christopher Larivière <lariviere.c@gmail.com> Co-authored-by: Markus Reiter <me@reitermark.us>
354 lines
9.8 KiB
YAML
354 lines
9.8 KiB
YAML
---
|
|
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
|
suite: route values
|
|
templates:
|
|
- common.yaml
|
|
tests:
|
|
- it: setting gateway should pass
|
|
set:
|
|
route.main:
|
|
enabled: true
|
|
parentRefs:
|
|
- name: parentName
|
|
namespace: parentNamespace
|
|
asserts:
|
|
- documentIndex: &HTTPRouteDocument 2
|
|
isKind:
|
|
of: HTTPRoute
|
|
- documentIndex: *HTTPRouteDocument
|
|
equal:
|
|
path: spec.parentRefs[0].name
|
|
value: parentName
|
|
- documentIndex: *HTTPRouteDocument
|
|
equal:
|
|
path: spec.parentRefs[0].namespace
|
|
value: parentNamespace
|
|
|
|
- it: custom host and path should pass
|
|
set:
|
|
route.main:
|
|
enabled: true
|
|
parentRefs:
|
|
- name: parentName
|
|
namespace: parentNamespace
|
|
hostnames:
|
|
- chart-test.local
|
|
asserts:
|
|
- documentIndex: &HTTPRouteDocument 2
|
|
isKind:
|
|
of: HTTPRoute
|
|
- documentIndex: *HTTPRouteDocument
|
|
equal:
|
|
path: spec.hostnames[0]
|
|
value: chart-test.local
|
|
|
|
- it: custom host with template
|
|
set:
|
|
route.main:
|
|
enabled: true
|
|
parentRefs:
|
|
- name: parentName
|
|
namespace: parentNamespace
|
|
hostnames:
|
|
- "{{ .Release.Name }}.local"
|
|
asserts:
|
|
- documentIndex: &HTTPRouteDocument 2
|
|
isKind:
|
|
of: HTTPRoute
|
|
- documentIndex: *HTTPRouteDocument
|
|
equal:
|
|
path: spec.hostnames[0]
|
|
value: RELEASE-NAME.local
|
|
|
|
- it: path matches should only be used for HTTPRoutes and GRPCRoutes
|
|
set:
|
|
route:
|
|
main:
|
|
enabled: true
|
|
kind: HTTPRoute
|
|
parentRefs:
|
|
- name: parentName
|
|
namespace: parentNamespace
|
|
rules:
|
|
- backendRefs:
|
|
- name: test
|
|
namespace: test
|
|
kind: Service
|
|
weight: 1
|
|
matches:
|
|
- path:
|
|
type: PathPrefix
|
|
value: /test
|
|
filters:
|
|
- type: URLRewrite
|
|
urlRewrite:
|
|
path:
|
|
type: ReplacePrefixMatch
|
|
replacePrefixMatch: ""
|
|
timeouts:
|
|
backendRequest: 30s
|
|
grpc:
|
|
enabled: true
|
|
kind: GRPCRoute
|
|
parentRefs:
|
|
- name: parentName
|
|
namespace: parentNamespace
|
|
rules:
|
|
- backendRefs:
|
|
- name: test
|
|
namespace: test
|
|
kind: Service
|
|
weight: 1
|
|
matches:
|
|
- path:
|
|
type: PathPrefix
|
|
value: /test
|
|
filters:
|
|
- type: URLRewrite
|
|
urlRewrite:
|
|
path:
|
|
type: ReplacePrefixMatch
|
|
replacePrefixMatch: ""
|
|
tcp:
|
|
enabled: true
|
|
kind: TCPRoute
|
|
parentRefs:
|
|
- name: parentName
|
|
namespace: parentNamespace
|
|
rules:
|
|
- backendRefs:
|
|
- name: test
|
|
namespace: test
|
|
kind: Service
|
|
weight: 1
|
|
matches:
|
|
- path:
|
|
type: PathPrefix
|
|
value: /test
|
|
filters:
|
|
- type: URLRewrite
|
|
urlRewrite:
|
|
path:
|
|
type: ReplacePrefixMatch
|
|
replacePrefixMatch: ""
|
|
tls:
|
|
enabled: true
|
|
kind: TLSRoute
|
|
parentRefs:
|
|
- name: parentName
|
|
namespace: parentNamespace
|
|
rules:
|
|
- backendRefs:
|
|
- name: test
|
|
namespace: test
|
|
kind: Service
|
|
weight: 1
|
|
matches:
|
|
- path:
|
|
type: PathPrefix
|
|
value: /test
|
|
filters:
|
|
- type: URLRewrite
|
|
urlRewrite:
|
|
path:
|
|
type: ReplacePrefixMatch
|
|
replacePrefixMatch: ""
|
|
udp:
|
|
enabled: true
|
|
kind: UDPRoute
|
|
parentRefs:
|
|
- name: parentName
|
|
namespace: parentNamespace
|
|
rules:
|
|
- backendRefs:
|
|
- name: test
|
|
namespace: test
|
|
kind: Service
|
|
weight: 1
|
|
matches:
|
|
- path:
|
|
type: PathPrefix
|
|
value: /test
|
|
filters:
|
|
- type: URLRewrite
|
|
urlRewrite:
|
|
path:
|
|
type: ReplacePrefixMatch
|
|
replacePrefixMatch: ""
|
|
asserts:
|
|
- documentIndex: &HTTPRouteDocument 2
|
|
isKind:
|
|
of: GRPCRoute
|
|
- documentIndex: &HTTPRouteDocument 2
|
|
equal:
|
|
path: spec.rules[0].matches
|
|
value:
|
|
- path:
|
|
type: PathPrefix
|
|
value: /test
|
|
- documentIndex: &HTTPRouteDocument 2
|
|
equal:
|
|
path: spec.rules[0].filters
|
|
value:
|
|
- type: URLRewrite
|
|
urlRewrite:
|
|
path:
|
|
type: ReplacePrefixMatch
|
|
replacePrefixMatch: ""
|
|
- documentIndex: &HTTPRouteDocument 3
|
|
isKind:
|
|
of: HTTPRoute
|
|
- documentIndex: &HTTPRouteDocument 3
|
|
equal:
|
|
path: spec.rules[0].matches
|
|
value:
|
|
- path:
|
|
type: PathPrefix
|
|
value: /test
|
|
- documentIndex: &HTTPRouteDocument 3
|
|
equal:
|
|
path: spec.rules[0].filters
|
|
value:
|
|
- type: URLRewrite
|
|
urlRewrite:
|
|
path:
|
|
type: ReplacePrefixMatch
|
|
replacePrefixMatch: ""
|
|
- documentIndex: &HTTPRouteDocument 4
|
|
isKind:
|
|
of: TCPRoute
|
|
- documentIndex: &HTTPRouteDocument 4
|
|
notExists:
|
|
path: spec.rules[0].matches
|
|
- documentIndex: &HTTPRouteDocument 4
|
|
notExists:
|
|
path: spec.rules[0].filters
|
|
- documentIndex: &HTTPRouteDocument 5
|
|
isKind:
|
|
of: TLSRoute
|
|
- documentIndex: &HTTPRouteDocument 5
|
|
notExists:
|
|
path: spec.rules[0].matches
|
|
- documentIndex: &HTTPRouteDocument 5
|
|
notExists:
|
|
path: spec.rules[0].filters
|
|
- documentIndex: &HTTPRouteDocument 6
|
|
isKind:
|
|
of: UDPRoute
|
|
- documentIndex: &HTTPRouteDocument 6
|
|
notExists:
|
|
path: spec.rules[0].matches
|
|
- documentIndex: &HTTPRouteDocument 6
|
|
notExists:
|
|
path: spec.rules[0].filters
|
|
- documentIndex: &HTTPRouteDocument 6
|
|
notExists:
|
|
path: spec.rules[0].timeouts
|
|
|
|
- it: hostnames shouldn't be used for TCPRoutes and UDPRoutes
|
|
set:
|
|
route:
|
|
main:
|
|
enabled: true
|
|
kind: TCPRoute
|
|
hostnames:
|
|
- chart-test.local
|
|
parentRefs:
|
|
- name: parentName
|
|
namespace: parentNamespace
|
|
udp:
|
|
enabled: true
|
|
kind: UDPRoute
|
|
hostnames:
|
|
- chart-test.local
|
|
parentRefs:
|
|
- name: parentName
|
|
namespace: parentNamespace
|
|
asserts:
|
|
- documentIndex: &HTTPRouteDocument 2
|
|
isKind:
|
|
of: TCPRoute
|
|
- documentIndex: &HTTPRouteDocument 2
|
|
notExists:
|
|
path: spec.hostnames
|
|
- documentIndex: &HTTPRouteDocument 3
|
|
isKind:
|
|
of: UDPRoute
|
|
- documentIndex: &HTTPRouteDocument 3
|
|
notExists:
|
|
path: spec.hostnames
|
|
|
|
- it: sectionName in parentRefs should be optional
|
|
set:
|
|
route:
|
|
main:
|
|
enabled: true
|
|
parentRefs:
|
|
- name: parentName
|
|
namespace: parentNamespace
|
|
second:
|
|
enabled: true
|
|
parentRefs:
|
|
- name: parentName
|
|
namespace: parentNamespace
|
|
sectionName: parentSection
|
|
asserts:
|
|
- documentIndex: &HTTPRouteDocument 2
|
|
isKind:
|
|
of: HTTPRoute
|
|
- documentIndex: &HTTPRouteDocument 2
|
|
notExists:
|
|
path: spec.parentRefs[0].sectionName
|
|
- documentIndex: &HTTPRouteDocument 3
|
|
isKind:
|
|
of: HTTPRoute
|
|
- documentIndex: &HTTPRouteDocument 3
|
|
equal:
|
|
path: spec.parentRefs[0].sectionName
|
|
value: parentSection
|
|
|
|
- it: timeouts should only be used for HTTPRoutes
|
|
set:
|
|
route:
|
|
main:
|
|
enabled: true
|
|
kind: HTTPRoute
|
|
parentRefs:
|
|
- name: parentName
|
|
namespace: parentNamespace
|
|
rules:
|
|
- backendRefs:
|
|
- name: test
|
|
namespace: test
|
|
timeouts:
|
|
backendRequest: 30s
|
|
grpc:
|
|
enabled: true
|
|
kind: GRPCRoute
|
|
parentRefs:
|
|
- name: parentName
|
|
namespace: parentNamespace
|
|
rules:
|
|
- backendRefs:
|
|
- name: test
|
|
namespace: test
|
|
matches:
|
|
- path:
|
|
type: PathPrefix
|
|
value: /test
|
|
timeouts:
|
|
backendRequest: 10s
|
|
asserts:
|
|
- documentIndex: &HTTPRouteDocument 2
|
|
isKind:
|
|
of: GRPCRoute
|
|
- documentIndex: &HTTPRouteDocument 2
|
|
notExists:
|
|
path: spec.rules[0].timeouts.backendRequest
|
|
- documentIndex: &HTTPRouteDocument 3
|
|
isKind:
|
|
of: HTTPRoute
|
|
- documentIndex: &HTTPRouteDocument 3
|
|
equal:
|
|
path: spec.rules[0].timeouts.backendRequest
|
|
value: 30s
|