Skip to content

Commit

Permalink
Merge pull request #615 from rstudio/add-more-unittests-workbench
Browse files Browse the repository at this point in the history
Add a few more unittests for rstudio-workbench
  • Loading branch information
jforest authored Nov 19, 2024
2 parents 23dbd10 + fa96405 commit 002bb89
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 0 deletions.
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%"

0 comments on commit 002bb89

Please sign in to comment.