Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a few more unittests for rstudio-workbench #615

Merged
merged 5 commits into from
Nov 19, 2024
Merged
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
58 changes: 58 additions & 0 deletions ci/rstudio-workbench/tests/ingress_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
suite: Workbench Ingress
templates:
- ingress.yaml
tests:
- it: should include the tls path if tls has values specified and ingress is enabled
template: ingress.yaml
set:
ingress:
enabled: true
tls:
- hosts:
- "example.com"
secretName: "example-tls"
asserts:
- exists:
path: "spec.tls"
- equal:
path: "spec.tls[0].hosts[0]"
value: "example.com"
- it: should not include the tls path if tls has no values specified and ingress is enabled
template: ingress.yaml
set:
ingress:
enabled: true
tls: []
asserts:
- notExists:
path: "spec.tls"
- it: should include the tls path if tls has values specified and ingress is enabled
template: ingress.yaml
set:
ingress:
enabled: true
tls:
- secretName: chart-example-tls
hosts:
- chart-example.local
asserts:
- exists:
path: "spec.tls"
- it: should include the ingressClassName if defined and ingress is enabled
template: ingress.yaml
set:
ingress:
enabled: true
ingressClassName: "alb"
asserts:
- equal:
path: "spec.ingressClassName"
value: "alb"
- it: should not include the ingressClassName if it is not defined and ingress is enabled
template: ingress.yaml
set:
ingress:
enabled: true
asserts:
- notExists:
path: "spec.ingressClassName"
87 changes: 87 additions & 0 deletions ci/rstudio-workbench/tests/prometheus_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
suite: Workbench prometheus configuration
templates:
- configmap-general.yaml
- configmap-graphite-exporter.yaml
- configmap-prestart.yaml
- configmap-secret.yaml
- configmap-session.yaml
- deployment.yaml
- svc.yaml
tests:
- it: should ensure the specified metrics port is used in the service if prometheus is enabled and legacy is not true
template: svc.yaml
set:
prometheus:
enabled: true
port: 8989
asserts:
- equal:
path: "spec.ports[1].name"
value: "metrics"
- equal:
path: "spec.ports[1].port"
value: 8989
- it: should ensure the legacy metrics port is used in the service if prometheus is enabled and legacy is true
template: svc.yaml
set:
prometheus:
enabled: true
legacy: true
port: 8989
asserts:
- equal:
path: "spec.ports[1].name"
value: "metrics"
- equal:
path: "spec.ports[1].port"
value: 9108
- it: should ensure the prometheus annotations are defined in the service, and that the graphite exporter checksum is non-existent
template: deployment.yaml
set:
prometheus:
enabled: true
port: 8989
asserts:
- isSubset:
path: spec.template.metadata.annotations
content:
prometheus.io/scrape: "true"
prometheus.io/path: "/metrics"
prometheus.io/port: "8989"
- notExists:
path: "spec.template.metadata.annotations.checksum/config-graphite"
- it: should ensure the legacy prometheus annotations are defined in the service, and that the graphite exporter checksum exists
template: deployment.yaml
set:
prometheus:
enabled: true
legacy: true
port: 8989
asserts:
- isSubset:
path: spec.template.metadata.annotations
content:
prometheus.io/scrape: "true"
prometheus.io/path: "/metrics"
prometheus.io/port: "9108"
- exists:
path: "spec.template.metadata.annotations.checksum/config-graphite"
- it: should ensure the legacy metrics port is used and that the graphite exporter container exists
template: deployment.yaml
set:
prometheus:
enabled: true
legacy: true
port: 8989
prometheusExporter:
enabled: true
asserts:
- equal:
path: "spec.template.spec.containers[1].name"
value: "exporter"
- equal:
path: "spec.template.spec.containers[1].ports[0].name"
value: "metrics"
- equal:
path: "spec.template.spec.containers[1].ports[0].containerPort"
value: 9108
34 changes: 34 additions & 0 deletions ci/rstudio-workbench/tests/update_strategy_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
suite: Workbench Deployment
templates:
- configmap-general.yaml
- configmap-prestart.yaml
- configmap-secret.yaml
- configmap-session.yaml
- deployment.yaml
tests:
- it: should not specify the RollingUpdate configuration if the strategy type is not RollingUpdate
template: deployment.yaml
set:
strategy:
type: "Recreate"
asserts:
- notExists:
path: "spec.strategy.rollingUpdate"
- it: should specify the RollingUpdate configuration if the strategy type is RollingUpdate
template: deployment.yaml
set:
strategy:
type: "RollingUpdate"
rollingUpdate:
maxUnavailable: 1
maxSurge: "50%"
asserts:
- equal:
path: "spec.strategy.type"
value: "RollingUpdate"
- equal:
path: "spec.strategy.rollingUpdate.maxUnavailable"
value: 1
- equal:
path: "spec.strategy.rollingUpdate.maxSurge"
value: "50%"