Skip to content

Commit

Permalink
Merge pull request #625 from rstudio/workbench-unit-tests-again
Browse files Browse the repository at this point in the history
Adding more unit tests for the rstudio-workbench chart
  • Loading branch information
jforest authored Dec 6, 2024
2 parents a34cf7f + 6ba0a1a commit f30fe61
Show file tree
Hide file tree
Showing 5 changed files with 321 additions and 5 deletions.
2 changes: 1 addition & 1 deletion charts/rstudio-workbench/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: rstudio-workbench
description: Official Helm chart for Posit Workbench
version: 0.8.8
version: 0.8.9
apiVersion: v2
appVersion: 2024.09.1
icon: https://rstudio.com/wp-content/uploads/2018/10/RStudio-Logo-Flat.png
Expand Down
4 changes: 4 additions & 0 deletions charts/rstudio-workbench/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.8.9

- Fix a logic bug where the resource limit key was set even if `resources.limits.enabled` is false

## 0.8.8

- Bump Chronicle Agent to version 2024.11.0
Expand Down
6 changes: 3 additions & 3 deletions charts/rstudio-workbench/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Posit Workbench

![Version: 0.8.8](https://img.shields.io/badge/Version-0.8.8-informational?style=flat-square) ![AppVersion: 2024.09.1](https://img.shields.io/badge/AppVersion-2024.09.1-informational?style=flat-square)
![Version: 0.8.9](https://img.shields.io/badge/Version-0.8.9-informational?style=flat-square) ![AppVersion: 2024.09.1](https://img.shields.io/badge/AppVersion-2024.09.1-informational?style=flat-square)

#### _Official Helm chart for Posit Workbench_

Expand All @@ -24,11 +24,11 @@ To ensure a stable production deployment:

## Installing the chart

To install the chart with the release name `my-release` at version 0.8.8:
To install the chart with the release name `my-release` at version 0.8.9:

```{.bash}
helm repo add rstudio https://helm.rstudio.com
helm upgrade --install my-release rstudio/rstudio-workbench --version=0.8.8
helm upgrade --install my-release rstudio/rstudio-workbench --version=0.8.9
```

To explore other chart versions, look at:
Expand Down
2 changes: 1 addition & 1 deletion charts/rstudio-workbench/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ containers:
cpu: "{{ .Values.resources.requests.cpu }}"
ephemeral-storage: "{{ .Values.resources.requests.ephemeralStorage }}"
{{- end }}
limits:
{{- if .Values.resources.limits.enabled }}
limits:
memory: "{{ .Values.resources.limits.memory }}"
cpu: "{{ .Values.resources.limits.cpu }}"
ephemeral-storage: "{{ .Values.resources.limits.ephemeralStorage }}"
Expand Down
312 changes: 312 additions & 0 deletions ci/rstudio-workbench/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,34 @@ tests:
path: 'spec.template.spec.containers[0].volumeMounts[?(@.name=="rstudio-user")]'
- notExists:
path: 'spec.template.spec.volumes[?(@.name=="rstudio-user")]'
- it: should specify a volumeMount and a volume for launcher if launcher.enabled is true
template: deployment.yaml
set:
config:
defaultMode:
launcher: 0755
launcher:
enabled: true
asserts:
- equal:
path: 'spec.template.spec.containers[0].volumeMounts[?(@.name=="rstudio-launcher-startup")].mountPath'
value: "/startup/launcher"
- equal:
path: 'spec.template.spec.volumes[?(@.name=="rstudio-launcher-startup")].configMap.name'
value: "RELEASE-NAME-rstudio-workbench-start-launcher"
- equal:
path: 'spec.template.spec.volumes[?(@.name=="rstudio-launcher-startup")].configMap.defaultMode'
value: 0755
- it: should not specify a volumeMount and a volume for launcher if launcher.enabled is false
template: deployment.yaml
set:
launcher:
enabled: false
asserts:
- notExists:
path: 'spec.template.spec.containers[0].volumeMounts[?(@.name=="rstudio-launcher-startup")]'
- notExists:
path: 'spec.template.spec.volumes[?(@.name=="rstudio-launcher-startup")]'
- it: should specify a volumeMount and a volume for startupUserProvisioning if config.startupUserProvisioning is defined and not empty
template: deployment.yaml
set:
Expand Down Expand Up @@ -416,3 +444,287 @@ tests:
path: 'spec.template.spec.containers[0].volumeMounts[?(@.name=="rstudio-pam")]'
- notExists:
path: 'spec.template.spec.volumes[?(@.name=="rstudio-pam")]'
- it: should specify a volumeMount and a volume for the old style jobJsonOverridesFiles if jobJsonOverridesFiles is defined and not empty
template: deployment.yaml
set:
config:
defaultMode:
jobJsonOverrides: 0644
jobJsonOverridesFiles:
- name: "test"
asserts:
- equal:
path: 'spec.template.spec.containers[0].volumeMounts[?(@.name=="rstudio-job-overrides-old")].mountPath'
value: "/mnt/job-json-overrides"
- equal:
path: 'spec.template.spec.containers[0].volumeMounts[?(@.name=="rstudio-job-overrides-old")].name'
value: "rstudio-job-overrides-old"
- equal:
path: 'spec.template.spec.volumes[?(@.name=="rstudio-job-overrides-old")].name'
value: "rstudio-job-overrides-old"
- equal:
path: 'spec.template.spec.volumes[?(@.name=="rstudio-job-overrides-old")].configMap.name'
value: "RELEASE-NAME-rstudio-workbench-overrides-old"
- equal:
path: 'spec.template.spec.volumes[?(@.name=="rstudio-job-overrides-old")].configMap.defaultMode'
value: 0644
- it: should not specify a volumeMount and a volume for the old style jobJsonOverridesFiles if jobJsonOverridesFiles is not defined
template: deployment.yaml
set:
config:
defaultMode:
jobJsonOverrides: 0644
jobJsonOverridesFiles: {}
asserts:
- notExists:
path: 'spec.template.spec.containers[0].volumeMounts[?(@.name=="rstudio-job-overrides-old")]'
- notExists:
path: 'spec.template.spec.volumes[?(@.name=="rstudio-job-overrides-old")]'

# $useNewOverrides is defined as {- $useNewerOverrides := and (not (hasKey .Values.config.server "launcher.kubernetes.profiles.conf")) (not .Values.launcher.useTemplates) }}
- it: should specify a volumeMount and a volume for the new style jobJsonOverridesFiles if $useNewerOverrides is true
template: deployment.yaml
set:
config:
defaultMode:
jobJsonOverrides: 0644
launcher:
useTemplates: false
asserts:
- equal:
path: 'spec.template.spec.containers[0].volumeMounts[?(@.name=="rstudio-job-overrides-new")].mountPath'
value: "/mnt/job-json-overrides-new"
- equal:
path: 'spec.template.spec.containers[0].volumeMounts[?(@.name=="rstudio-job-overrides-new")].name'
value: "rstudio-job-overrides-new"
- equal:
path: 'spec.template.spec.volumes[?(@.name=="rstudio-job-overrides-new")].name'
value: "rstudio-job-overrides-new"
- equal:
path: 'spec.template.spec.volumes[?(@.name=="rstudio-job-overrides-new")].configMap.name'
value: "RELEASE-NAME-rstudio-workbench-overrides-new"
- equal:
path: 'spec.template.spec.volumes[?(@.name=="rstudio-job-overrides-new")].configMap.defaultMode'
value: 0644
- it: should not specify a volumeMount and a volume for the new style jobJsonOverridesFiles if $useNewerOverrides is false
template: deployment.yaml
set:
config:
server:
launcher.kubernetes.profiles.conf:
thing: "test"
launcher:
useTemplates: true
asserts:
- notExists:
path: 'spec.template.spec.containers[0].volumeMounts[?(@.name=="rstudio-job-overrides-new")]'
- notExists:
path: 'spec.template.spec.volumes[?(@.name=="rstudio-job-overrides-new")]'
- it: should specify 3 volumeMounts and a volume if Values.launcher.useTemplates is true
template: deployment.yaml
set:
config:
defaultMode:
server: 0644
launcher:
useTemplates: true
asserts:
- contains:
path: 'spec.template.spec.containers[0].volumeMounts'
content:
name: "session-templates"
mountPath: "/var/lib/rstudio-launcher/Kubernetes/rstudio-library-templates-data.tpl"
subPath: "rstudio-library-templates-data.tpl"
any: true
- contains:
path: 'spec.template.spec.containers[0].volumeMounts'
content:
name: "session-templates"
mountPath: "/var/lib/rstudio-launcher/Kubernetes/job.tpl"
subPath: "job.tpl"
any: true
- contains:
path: 'spec.template.spec.containers[0].volumeMounts'
content:
name: "session-templates"
mountPath: "/var/lib/rstudio-launcher/Kubernetes/service.tpl"
subPath: "service.tpl"
any: true
- equal:
path: 'spec.template.spec.volumes[?(@.name=="session-templates")].name'
value: "session-templates"
- equal:
path: 'spec.template.spec.volumes[?(@.name=="session-templates")].configMap.name'
value: "RELEASE-NAME-rstudio-workbench-templates"
- equal:
path: 'spec.template.spec.volumes[?(@.name=="session-templates")].configMap.defaultMode'
value: 0644
- it: should not specify any volumeMounts or a volume if Values.launcher.useTemplates is false
template: deployment.yaml
set:
launcher:
useTemplates: false
asserts:
- notContains:
path: 'spec.template.spec.containers[0].volumeMounts'
content:
name: "session-templates"
mountPath: "/var/lib/rstudio-launcher/Kubernetes/rstudio-library-templates-data.tpl"
subPath: "rstudio-library-templates-data.tpl"
any: true
- notContains:
path: 'spec.template.spec.containers[0].volumeMounts'
content:
name: "session-templates"
mountPath: "/var/lib/rstudio-launcher/Kubernetes/job.tpl"
subPath: "job.tpl"
any: true
- notContains:
path: 'spec.template.spec.containers[0].volumeMounts'
content:
name: "session-templates"
mountPath: "/var/lib/rstudio-launcher/Kubernetes/service.tpl"
subPath: "service.tpl"
any: true
- notExists:
path: 'spec.template.spec.volumes[?(@.name=="session-templates")]'
- notExists:
path: 'spec.template.spec.volumeMounts[?(@.name=="session-templates")]'
- it: should have the pod volumemounts defined by the user
template: deployment.yaml
set:
pod:
volumeMounts:
- name: "test"
mountPath: "/mnt/test"
- name: "secondTest"
mountPath: "/mnt/secondTest"
asserts:
- contains:
path: 'spec.template.spec.containers[0].volumeMounts'
content:
name: "test"
mountPath: "/mnt/test"
any: true
- contains:
path: 'spec.template.spec.containers[0].volumeMounts'
content:
name: "secondTest"
mountPath: "/mnt/secondTest"
any: true
- it: should set the resource requests if enabled
template: deployment.yaml
set:
resources:
requests:
enabled: true
cpu: "100m"
memory: "128Mi"
asserts:
- equal:
path: 'spec.template.spec.containers[0].resources.requests.cpu'
value: "100m"
- equal:
path: 'spec.template.spec.containers[0].resources.requests.memory'
value: "128Mi"
- notExists:
path: 'spec.template.spec.containers[0].resources.limits'
- it: should set the resource limits if enabled
template: deployment.yaml
set:
resources:
limits:
enabled: true
cpu: "1000m"
memory: "1024Mi"
asserts:
- equal:
path: 'spec.template.spec.containers[0].resources.limits.cpu'
value: "1000m"
- equal:
path: 'spec.template.spec.containers[0].resources.limits.memory'
value: "1024Mi"
- notExists:
path: 'spec.template.spec.containers[0].resources.requests'
- it: should configure the livenessProbe if values.livenessProbe.enabled is true
template: deployment.yaml
set:
livenessProbe:
enabled: true
initialDelaySeconds: 10
periodSeconds: 20
asserts:
- equal:
path: 'spec.template.spec.containers[0].livenessProbe.initialDelaySeconds'
value: 10
- equal:
path: 'spec.template.spec.containers[0].livenessProbe.periodSeconds'
value: 20
- it: should not configure the livenessProbe if values.livenessProbe.enabled is false
template: deployment.yaml
set:
livenessProbe:
enabled: false
initialDelaySeconds: 10
periodSeconds: 20
asserts:
- notExists:
path: 'spec.template.spec.containers[0].livenessProbe'
- it: should configure the startupProbe if values.startupsProbe.enabled is true
template: deployment.yaml
set:
startupProbe:
enabled: true
initialDelaySeconds: 10
periodSeconds: 20
asserts:
- equal:
path: 'spec.template.spec.containers[0].startupProbe.initialDelaySeconds'
value: 10
- equal:
path: 'spec.template.spec.containers[0].startupProbe.periodSeconds'
value: 20
- it: should not configure the startupProbe if values.startupProbe.enabled is false
template: deployment.yaml
set:
startupProbe:
enabled: false
initialDelaySeconds: 10
periodSeconds: 20
asserts:
- notExists:
path: 'spec.template.spec.containers[0].startupProbe'
- it: should configure the readinessProbe if values.readinessProbe.enabled is true
template: deployment.yaml
set:
readinessProbe:
enabled: true
initialDelaySeconds: 10
periodSeconds: 20
asserts:
- equal:
path: 'spec.template.spec.containers[0].readinessProbe.initialDelaySeconds'
value: 10
- equal:
path: 'spec.template.spec.containers[0].readinessProbe.periodSeconds'
value: 20
- it: should not configure the readinessProbe if values.readinessProbe.enabled is false
template: deployment.yaml
set:
readinessProbe:
enabled: false
initialDelaySeconds: 10
periodSeconds: 20
asserts:
- notExists:
path: 'spec.template.spec.containers[0].readinessProbe'
- it: should create a sidecar container if pod.sidecar is defined
template: deployment.yaml
set:
pod:
sidecar:
- name: "sidecarTest"
image: "test"
asserts:
- exists:
path: 'spec.template.spec.containers[?(@.name=="sidecarTest")]'

0 comments on commit f30fe61

Please sign in to comment.