feat(common): Release common 4.0.0 (#398)

Co-authored-by: lab-assistant[bot] <180935599+lab-assistant[bot]@users.noreply.github.com>
This commit is contained in:
Bernd Schorgers 2025-05-16 08:40:39 +02:00
parent 1e210f43e3
commit a01a89cb13
No known key found for this signature in database
327 changed files with 11181 additions and 7330 deletions

View file

@ -1,12 +1,12 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: route service reference
suite: route - fields - backendRefs
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: default should pass
- it: backendRefs can be configured by passing in a service name
set:
route.main:
parentRefs:
@ -20,12 +20,11 @@ tests:
namespace: NAMESPACE
port: 8080
weight: 1
documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: release-name
asserts:
- documentIndex: &HTTPRouteDocument 1
isKind:
of: HTTPRoute
- documentIndex: *HTTPRouteDocument
equal:
- equal:
path: spec.rules[0].backendRefs[0]
value:
group: ""
@ -35,6 +34,32 @@ tests:
port: 8080
weight: 1
- it: backendRefs can be configured by passing in a service identifier
values:
- ../_values/service_main_default.yaml
set:
route.main:
parentRefs:
- name: parentName
namespace: parentNamespace
rules:
- backendRefs:
- identifier: main
port: 8080
documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: release-name
asserts:
- equal:
path: spec.rules[0].backendRefs[0]
value:
group: ""
kind: Service
name: release-name
namespace: NAMESPACE
port: 8080
weight: 1
- it: custom service reference should pass
set:
route.main:
@ -48,12 +73,11 @@ tests:
port: 1234
namespace: serviceNamespace
weight: 123
documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: release-name
asserts:
- documentIndex: &HTTPRouteDocument 1
isKind:
of: HTTPRoute
- documentIndex: *HTTPRouteDocument
equal:
- equal:
path: spec.rules[0].backendRefs[0]
value:
group: test
@ -63,28 +87,6 @@ tests:
port: 1234
weight: 123
- it: custom service reference with filter should fail
set:
route.main:
parentRefs:
- name: parentName
namespace: parentNamespace
rules:
- backendRefs:
- group: test
name: pathService
port: 1234
namespace: serviceNamespace
weight: 123
filters:
- type: RequestRedirect
requestRedirect:
scheme: https
statusCode: 301
asserts:
- failedTemplate:
errorMessage: "backend refs and request redirect filters cannot co-exist."
- it: custom service with filter should pass
set:
route.main:
@ -97,18 +99,16 @@ tests:
requestRedirect:
scheme: https
statusCode: 301
documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: release-name
asserts:
- documentIndex: &HTTPRouteDocument 1
isKind:
of: HTTPRoute
- documentIndex: *HTTPRouteDocument
equal:
- equal:
path: spec.rules[0].filters[0]
value:
type: RequestRedirect
requestRedirect:
scheme: https
statusCode: 301
- documentIndex: *HTTPRouteDocument
notExists:
- notExists:
path: spec.rules[0].backendRefs[0]

View file

@ -0,0 +1,68 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: route - fields - hostnames
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: hostnames shouldn't be used for TCPRoutes and UDPRoutes
set:
route:
main:
kind: TCPRoute
hostnames:
- chart-test.local
parentRefs:
- name: parentName
namespace: parentNamespace
udp:
kind: UDPRoute
hostnames:
- chart-test.local
parentRefs:
- name: parentName
namespace: parentNamespace
asserts:
- documentSelector:
path: $[?(@.kind == "TCPRoute")].metadata.name
value: release-name-main
notExists:
path: spec.hostnames
- documentSelector:
path: $[?(@.kind == "UDPRoute")].metadata.name
value: release-name-udp
notExists:
path: spec.hostnames
- it: hostname can be configured
set:
route.main:
parentRefs:
- name: parentName
namespace: parentNamespace
hostnames:
- chart-test.local
documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: release-name
asserts:
- equal:
path: spec.hostnames[0]
value: chart-test.local
- it: hostnames support Helm templates
set:
route.main:
parentRefs:
- name: parentName
namespace: parentNamespace
hostnames:
- "{{ .Release.Name }}.local"
documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: release-name
asserts:
- equal:
path: spec.hostnames[0]
value: RELEASE-NAME.local

View file

@ -0,0 +1,67 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: route - fields - parentRefs
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: setting gateway should pass
set:
route.main:
parentRefs:
- name: parentName
namespace: parentNamespace
documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: release-name
asserts:
- equal:
path: spec.parentRefs[0].name
value: parentName
- equal:
path: spec.parentRefs[0].namespace
value: parentNamespace
- it: sectionName should be optional
set:
route:
main:
parentRefs:
- name: parentName
namespace: parentNamespace
second:
parentRefs:
- name: parentName
namespace: parentNamespace
sectionName: parentSection
asserts:
- documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: release-name-main
notExists:
path: spec.parentRefs[0].sectionName
- documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: release-name-second
equal:
path: spec.parentRefs[0].sectionName
value: parentSection
- it: should be possible to configure port on the parentRefs
set:
route.main:
parentRefs:
- name: parentName
namespace: parentNamespace
port: 443
documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: release-name
asserts:
- equal:
path: spec.parentRefs[0].name
value: parentName
- equal:
path: spec.parentRefs[0].port
value: 443

View file

@ -0,0 +1,134 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: route - fields - rules - filters
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: path matches should only be used for HTTPRoutes and GRPCRoutes
set:
route:
main:
kind: HTTPRoute
parentRefs:
- name: parentName
namespace: parentNamespace
rules:
- backendRefs:
- name: test
namespace: test
kind: Service
weight: 1
filters:
- type: URLRewrite
urlRewrite:
path:
type: ReplacePrefixMatch
replacePrefixMatch: ""
grpc:
kind: GRPCRoute
parentRefs:
- name: parentName
namespace: parentNamespace
rules:
- backendRefs:
- name: test
namespace: test
kind: Service
weight: 1
filters:
- type: URLRewrite
urlRewrite:
path:
type: ReplacePrefixMatch
replacePrefixMatch: ""
tcp:
kind: TCPRoute
parentRefs:
- name: parentName
namespace: parentNamespace
rules:
- backendRefs:
- name: test
namespace: test
kind: Service
weight: 1
filters:
- type: URLRewrite
urlRewrite:
path:
type: ReplacePrefixMatch
replacePrefixMatch: ""
tls:
kind: TLSRoute
parentRefs:
- name: parentName
namespace: parentNamespace
rules:
- backendRefs:
- name: test
namespace: test
kind: Service
weight: 1
filters:
- type: URLRewrite
urlRewrite:
path:
type: ReplacePrefixMatch
replacePrefixMatch: ""
udp:
kind: UDPRoute
parentRefs:
- name: parentName
namespace: parentNamespace
rules:
- backendRefs:
- name: test
namespace: test
kind: Service
weight: 1
filters:
- type: URLRewrite
urlRewrite:
path:
type: ReplacePrefixMatch
replacePrefixMatch: ""
asserts:
- documentSelector:
path: $[?(@.kind == "GRPCRoute")].metadata.name
value: release-name-grpc
equal:
path: spec.rules[0].filters
value:
- type: URLRewrite
urlRewrite:
path:
type: ReplacePrefixMatch
replacePrefixMatch: ""
- documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: release-name-main
equal:
path: spec.rules[0].filters
value:
- type: URLRewrite
urlRewrite:
path:
type: ReplacePrefixMatch
replacePrefixMatch: ""
- documentSelector:
path: $[?(@.kind == "TCPRoute")].metadata.name
value: release-name-tcp
notExists:
path: spec.rules[0].filters
- documentSelector:
path: $[?(@.kind == "TLSRoute")].metadata.name
value: release-name-tls
notExists:
path: spec.rules[0].filters
- documentSelector:
path: $[?(@.kind == "UDPRoute")].metadata.name
value: release-name-udp
notExists:
path: spec.rules[0].filters

View file

@ -0,0 +1,120 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: route - fields - rules - matches
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: path matches should only be used for HTTPRoutes and GRPCRoutes
set:
route:
main:
kind: HTTPRoute
parentRefs:
- name: parentName
namespace: parentNamespace
rules:
- backendRefs:
- name: test
namespace: test
kind: Service
weight: 1
matches:
- path:
type: PathPrefix
value: /test
grpc:
kind: GRPCRoute
parentRefs:
- name: parentName
namespace: parentNamespace
rules:
- backendRefs:
- name: test
namespace: test
kind: Service
weight: 1
matches:
- path:
type: PathPrefix
value: /test
tcp:
kind: TCPRoute
parentRefs:
- name: parentName
namespace: parentNamespace
rules:
- backendRefs:
- name: test
namespace: test
kind: Service
weight: 1
matches:
- path:
type: PathPrefix
value: /test
tls:
kind: TLSRoute
parentRefs:
- name: parentName
namespace: parentNamespace
rules:
- backendRefs:
- name: test
namespace: test
kind: Service
weight: 1
matches:
- path:
type: PathPrefix
value: /test
udp:
kind: UDPRoute
parentRefs:
- name: parentName
namespace: parentNamespace
rules:
- backendRefs:
- name: test
namespace: test
kind: Service
weight: 1
matches:
- path:
type: PathPrefix
value: /test
asserts:
- documentSelector:
path: $[?(@.kind == "GRPCRoute")].metadata.name
value: release-name-grpc
equal:
path: spec.rules[0].matches
value:
- path:
type: PathPrefix
value: /test
- documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: release-name-main
equal:
path: spec.rules[0].matches
value:
- path:
type: PathPrefix
value: /test
- documentSelector:
path: $[?(@.kind == "TCPRoute")].metadata.name
value: release-name-tcp
notExists:
path: spec.rules[0].matches
- documentSelector:
path: $[?(@.kind == "TLSRoute")].metadata.name
value: release-name-tls
notExists:
path: spec.rules[0].matches
- documentSelector:
path: $[?(@.kind == "UDPRoute")].metadata.name
value: release-name-udp
notExists:
path: spec.rules[0].matches

View file

@ -0,0 +1,118 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: route - fields - rules - sessionPersistence
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: sessionpersistence should only be used for HTTPRoutes and GRPCRoutes
set:
route:
main:
kind: HTTPRoute
parentRefs:
- name: parentName
namespace: parentNamespace
rules:
- backendRefs:
- name: test
namespace: test
kind: Service
weight: 1
sessionPersistence:
sessionName: test
grpc:
kind: GRPCRoute
parentRefs:
- name: parentName
namespace: parentNamespace
rules:
- backendRefs:
- name: test
namespace: test
kind: Service
weight: 1
sessionPersistence:
sessionName: test
tcp:
kind: TCPRoute
parentRefs:
- name: parentName
namespace: parentNamespace
rules:
- backendRefs:
- name: test
namespace: test
kind: Service
weight: 1
sessionPersistence:
sessionName: test
filters:
- type: URLRewrite
urlRewrite:
path:
type: ReplacePrefixMatch
replacePrefixMatch: ""
tls:
kind: TLSRoute
parentRefs:
- name: parentName
namespace: parentNamespace
rules:
- backendRefs:
- name: test
namespace: test
kind: Service
weight: 1
sessionPersistence:
sessionName: test
udp:
kind: UDPRoute
parentRefs:
- name: parentName
namespace: parentNamespace
rules:
- backendRefs:
- name: test
namespace: test
kind: Service
weight: 1
sessionPersistence:
sessionName: test
filters:
- type: URLRewrite
urlRewrite:
path:
type: ReplacePrefixMatch
replacePrefixMatch: ""
asserts:
- documentSelector:
path: $[?(@.kind == "GRPCRoute")].metadata.name
value: release-name-grpc
equal:
path: spec.rules[0].sessionPersistence
value:
sessionName: test
- documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: release-name-main
equal:
path: spec.rules[0].sessionPersistence
value:
sessionName: test
- documentSelector:
path: $[?(@.kind == "TCPRoute")].metadata.name
value: release-name-tcp
notExists:
path: spec.rules[0].sessionPersistence
- documentSelector:
path: $[?(@.kind == "TLSRoute")].metadata.name
value: release-name-tls
notExists:
path: spec.rules[0].sessionPersistence
- documentSelector:
path: $[?(@.kind == "UDPRoute")].metadata.name
value: release-name-udp
notExists:
path: spec.rules[0].sessionPersistence

View file

@ -0,0 +1,49 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: route - fields - rules - timeouts
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: timeouts should only be used for HTTPRoutes
set:
route:
main:
kind: HTTPRoute
parentRefs:
- name: parentName
namespace: parentNamespace
rules:
- backendRefs:
- name: test
namespace: test
timeouts:
backendRequest: 30s
grpc:
kind: GRPCRoute
parentRefs:
- name: parentName
namespace: parentNamespace
rules:
- backendRefs:
- name: test
namespace: test
matches:
- path:
type: PathPrefix
value: /test
timeouts:
backendRequest: 10s
asserts:
- documentSelector:
path: $[?(@.kind == "GRPCRoute")].metadata.name
value: release-name-grpc
notExists:
path: spec.rules[0].timeouts.backendRequest
- documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: release-name-main
equal:
path: spec.rules[0].timeouts.backendRequest
value: 30s

View file

@ -0,0 +1,48 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: route - metadata - annotations
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
set:
route.main.parentRefs:
- name: test
namespace: test
tests:
- it: no annotations are set by default
documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: release-name
asserts:
- notExists:
path: metadata.annotations
- it: custom annotations
set:
route.main.annotations:
test_annotation: test
documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: release-name
asserts:
- equal:
path: metadata.annotations
value:
test_annotation: test
- it: custom annotations mixed with global annotations
set:
global.annotations:
global_annotation: test
route.main.annotations:
test_annotation: test
documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: release-name
asserts:
- equal:
path: metadata.annotations
value:
global_annotation: test
test_annotation: test

View file

@ -0,0 +1,61 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: route - metadata - labels
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
set:
route.main.parentRefs:
- name: test
namespace: test
tests:
- it: default labels
documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: release-name
asserts:
- equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: common-test-1.0.0
- it: custom labels
set:
route.main.labels:
test_label: test
documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: release-name
asserts:
- equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: common-test-1.0.0
test_label: test
- it: custom labels mixed with global labels
set:
global.labels:
global_label: test
route.main.labels:
test_label: test
documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: release-name
asserts:
- equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME
global_label: test
helm.sh/chart: common-test-1.0.0
test_label: test

View file

@ -0,0 +1,189 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: route - metadata - name
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
set:
route.main:
parentRefs:
- name: test
namespace: test
tests:
- it: name defaults to chart fullName
asserts:
- containsDocument:
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1alpha2
name: release-name
any: true
- it: forceRename
set:
route.main.forceRename: forceRename
asserts:
- containsDocument:
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1alpha2
name: forcerename
any: true
- it: forceRename with template
set:
route.main.forceRename: "{{ .Chart.Name }}"
asserts:
- containsDocument:
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1alpha2
name: common-test
any: true
- it: prefix
set:
route.main.prefix: prefix
asserts:
- containsDocument:
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1alpha2
name: prefix-release-name
any: true
- it: prefix with template
set:
route.main.prefix: "{{ .Chart.Name }}"
asserts:
- containsDocument:
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1alpha2
name: common-test-release-name
any: true
- it: suffix
set:
route.main.suffix: suffix
asserts:
- containsDocument:
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1alpha2
name: release-name-suffix
any: true
- it: suffix with template
set:
route.main.suffix: "{{ .Chart.Name }}"
asserts:
- containsDocument:
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1alpha2
name: release-name-common-test
any: true
- it: both prefix and suffix
set:
route.main.prefix: prefix
route.main.suffix: suffix
asserts:
- containsDocument:
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1alpha2
name: prefix-release-name-suffix
any: true
- it: prefix, suffix and forceRename (illegal combination)
set:
route.main.forceRename: forceRename
route.main.prefix: prefix
route.main.suffix: suffix
asserts:
- failedTemplate:
errorPattern: "values don't meet the specifications of the schema"
- it: multiple items
set:
route.second:
parentRefs:
- name: test
namespace: test
asserts:
- containsDocument:
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1alpha2
name: release-name-main
any: true
- containsDocument:
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1alpha2
name: release-name-second
any: true
- it: multiple items with prefix
set:
route.second:
prefix: prefix
parentRefs:
- name: test
namespace: test
asserts:
- containsDocument:
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1alpha2
name: release-name-main
any: true
- containsDocument:
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1alpha2
name: prefix-release-name-second
any: true
- it: multiple items with suffix
set:
route.second:
suffix: suffix
parentRefs:
- name: test
namespace: test
asserts:
- containsDocument:
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1alpha2
name: release-name-main
any: true
- containsDocument:
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1alpha2
name: release-name-second-suffix
any: true
- it: multiple items with prefix and suffix
set:
route.second:
prefix: prefix
suffix: suffix
parentRefs:
- name: test
namespace: test
asserts:
- containsDocument:
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1alpha2
name: release-name-main
any: true
- containsDocument:
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1alpha2
name: prefix-release-name-second-suffix
any: true
- it: multiple items with prefix, suffix and forceRename (illegal combination)
set:
route.second:
forceRename: forceRename
prefix: prefix
suffix: suffix
parentRefs:
- name: test
namespace: test
asserts:
- failedTemplate:
errorPattern: "values don't meet the specifications of the schema"

View file

@ -1,94 +0,0 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: route metadata
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: default metadata should pass
set:
route.main:
parentRefs:
- name: test
namespace: test
asserts:
- documentIndex: &routeDocument 1
isKind:
of: HTTPRoute
- documentIndex: *routeDocument
notExists:
path: metadata.annotations
- documentIndex: *routeDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: common-test-1.0.0
- it: custom metadata should pass
set:
route.main:
annotations:
test_annotation: test
labels:
test_label: test
parentRefs:
- name: test
namespace: test
asserts:
- documentIndex: &routeDocument 1
isKind:
of: HTTPRoute
- documentIndex: *routeDocument
equal:
path: metadata.annotations
value:
test_annotation: test
- documentIndex: *routeDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: common-test-1.0.0
test_label: test
- it: custom metadata with global metadata should pass
set:
global:
labels:
global_label: test
annotations:
global_annotation: test
route.main:
annotations:
test_annotation: test
labels:
test_label: test
parentRefs:
- name: test
namespace: test
asserts:
- documentIndex: &routeDocument 1
isKind:
of: HTTPRoute
- documentIndex: *routeDocument
equal:
path: metadata.annotations
value:
global_annotation: test
test_annotation: test
- documentIndex: *routeDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME
global_label: test
helm.sh/chart: common-test-1.0.0
test_label: test

View file

@ -1,74 +0,0 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: route names
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: default name
set:
route.main:
enabled: true
parentRefs:
- name: test
namespace: test
documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: RELEASE-NAME
asserts:
- exists:
path: metadata.name
- it: custom name suffix
set:
route.main:
enabled: true
parentRefs:
- name: test
namespace: test
nameOverride: http
documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: RELEASE-NAME-http
asserts:
- exists:
path: metadata.name
- it: custom name suffix with template
set:
route.main:
enabled: true
parentRefs:
- name: test
namespace: test
nameOverride: "{{ .Chart.Name }}"
documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: RELEASE-NAME-common-test
asserts:
- exists:
path: metadata.name
- it: multiple routes
set:
route:
main:
parentRefs:
- name: main
namespace: main
test:
parentRefs:
- name: test
namespace: test
asserts:
- documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: RELEASE-NAME-main
exists:
path: metadata.name
- documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: RELEASE-NAME-test
exists:
path: metadata.name

View file

@ -1,6 +1,6 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: route presence
suite: route - presence
templates:
- common.yaml
values:
@ -12,7 +12,8 @@ tests:
containsDocument:
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1alpha2
name: RELEASE-NAME
name: release-name
any: true
- it: an HTTPRoute is not created when disabled
set:
@ -22,7 +23,8 @@ tests:
containsDocument:
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1alpha2
name: RELEASE-NAME
name: release-name
any: true
- it: an HTTPRoute is created when explicitly enabled
set:
@ -31,12 +33,12 @@ tests:
parentRefs:
- name: test
namespace: test
documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: RELEASE-NAME
asserts:
- exists:
path: metadata.name
- containsDocument:
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1alpha2
name: release-name
any: true
- it: multiple HTTPRoute are created when configured
set:
@ -50,13 +52,13 @@ tests:
- name: test
namespace: test
asserts:
- documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: RELEASE-NAME-main
exists:
path: metadata.name
- documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: RELEASE-NAME-test
exists:
path: metadata.name
- containsDocument:
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1alpha2
name: release-name-main
any: true
- containsDocument:
kind: HTTPRoute
apiVersion: gateway.networking.k8s.io/v1alpha2
name: release-name-test
any: true

View file

@ -0,0 +1,43 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: route - validations
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: service reference to non-existing service should fail
set:
route.main:
parentRefs:
- name: parentName
namespace: parentNamespace
rules:
- backendRefs:
- identifier: main
port: 8080
asserts:
- failedTemplate:
errorMessage: "No enabled Service found with this identifier. (route: 'main', identifier: 'main')"
- it: backend refs with redirect filter should fail
set:
route.main:
parentRefs:
- name: parentName
namespace: parentNamespace
rules:
- backendRefs:
- group: test
name: pathService
port: 1234
namespace: serviceNamespace
weight: 123
filters:
- type: RequestRedirect
requestRedirect:
scheme: https
statusCode: 301
asserts:
- failedTemplate:
errorMessage: "backend refs and request redirect filters cannot co-exist."

View file

@ -1,348 +0,0 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: route values
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
- it: setting gateway should pass
set:
route.main:
parentRefs:
- name: parentName
namespace: parentNamespace
asserts:
- documentIndex: &HTTPRouteDocument 1
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:
parentRefs:
- name: parentName
namespace: parentNamespace
hostnames:
- chart-test.local
asserts:
- documentIndex: &HTTPRouteDocument 1
isKind:
of: HTTPRoute
- documentIndex: *HTTPRouteDocument
equal:
path: spec.hostnames[0]
value: chart-test.local
- it: custom host with template
set:
route.main:
parentRefs:
- name: parentName
namespace: parentNamespace
hostnames:
- "{{ .Release.Name }}.local"
asserts:
- documentIndex: &HTTPRouteDocument 1
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:
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:
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:
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:
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:
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: &GRPCRouteDocument 1
isKind:
of: GRPCRoute
- documentIndex: *GRPCRouteDocument
equal:
path: spec.rules[0].matches
value:
- path:
type: PathPrefix
value: /test
- documentIndex: *GRPCRouteDocument
equal:
path: spec.rules[0].filters
value:
- type: URLRewrite
urlRewrite:
path:
type: ReplacePrefixMatch
replacePrefixMatch: ""
- documentIndex: &HTTPRouteDocument 2
isKind:
of: HTTPRoute
- documentIndex: *HTTPRouteDocument
equal:
path: spec.rules[0].matches
value:
- path:
type: PathPrefix
value: /test
- documentIndex: *HTTPRouteDocument
equal:
path: spec.rules[0].filters
value:
- type: URLRewrite
urlRewrite:
path:
type: ReplacePrefixMatch
replacePrefixMatch: ""
- documentIndex: &TCPRouteDocument 3
isKind:
of: TCPRoute
- documentIndex: *TCPRouteDocument
notExists:
path: spec.rules[0].matches
- documentIndex: *TCPRouteDocument
notExists:
path: spec.rules[0].filters
- documentIndex: &TLSRouteDocument 4
isKind:
of: TLSRoute
- documentIndex: *TLSRouteDocument
notExists:
path: spec.rules[0].matches
- documentIndex: *TLSRouteDocument
notExists:
path: spec.rules[0].filters
- documentIndex: &UDPRouteDocument 5
isKind:
of: UDPRoute
- documentIndex: *UDPRouteDocument
notExists:
path: spec.rules[0].matches
- documentIndex: *UDPRouteDocument
notExists:
path: spec.rules[0].filters
- documentIndex: *UDPRouteDocument
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: &TCPRouteDocument 1
isKind:
of: TCPRoute
- documentIndex: *TCPRouteDocument
notExists:
path: spec.hostnames
- documentIndex: &UDPRouteDocument 2
isKind:
of: UDPRoute
- documentIndex: *UDPRouteDocument
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: &HTTPRouteDocumentFirst 1
isKind:
of: HTTPRoute
- documentIndex: *HTTPRouteDocumentFirst
notExists:
path: spec.parentRefs[0].sectionName
- documentIndex: &HTTPRouteDocumentSecond 2
isKind:
of: HTTPRoute
- documentIndex: *HTTPRouteDocumentSecond
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: &GRPCRouteDocument 1
isKind:
of: GRPCRoute
- documentIndex: *GRPCRouteDocument
notExists:
path: spec.rules[0].timeouts.backendRequest
- documentIndex: &HTTPRouteDocument 2
isKind:
of: HTTPRoute
- documentIndex: *HTTPRouteDocument
equal:
path: spec.rules[0].timeouts.backendRequest
value: 30s