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

SLT-1026: Update helm unit tests to work with latest version of the helm-unittest plugin #711

Merged
merged 13 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ workflows:
- run:
name: Helm unit tests
command: |
helm unittest ./charts/silta-release --helm3
helm unittest ./charts/drupal --helm3
helm unittest ./charts/silta-release
helm unittest ./charts/drupal

# Build job for feature environments.
# Other jobs defined below extend this job.
Expand Down
3 changes: 1 addition & 2 deletions charts/drupal/templates/backup-cron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ spec:
- containerPort: 3306
name: mariadb
resources:
requests:
{{- .Values.backup.resources | toYaml | nindent 14 }}
{{- .Values.backup.resources | toYaml | nindent 14 }}
restartPolicy: Never
volumes:
{{- include "drupal.volumes" . | nindent 12 }}
Expand Down
3 changes: 0 additions & 3 deletions charts/drupal/templates/varnish-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ spec:
name: web
- containerPort: 6082
name: admin
livenessProbe:
tcpSocket:
port: 80
env:
- name: VARNISH_STORAGE_BACKEND
value: {{ .Values.varnish.storageBackend | quote }}
Expand Down
5 changes: 2 additions & 3 deletions charts/drupal/tests/db_test.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
suite: drupal database
templates:
- drupal-deployment.yaml
- drupal-configmap.yaml
- drupal-deployment.yaml
- drupal-secret.yaml
capabilities:
apiVersions:
- pxc.percona.com/v1
Expand Down Expand Up @@ -96,5 +97,3 @@ tests:
content:
name: DB_HOST
value: RELEASE-NAME-proxysql


2 changes: 1 addition & 1 deletion charts/drupal/tests/drupal_cache_tags_test.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
suite: drupal cache tag exposure
templates:
- varnish-configmap-vcl.yaml
- drupal-configmap.yaml
- varnish-configmap-vcl.yaml
capabilities:
apiVersions:
- pxc.percona.com/v1
Expand Down
13 changes: 13 additions & 0 deletions charts/drupal/tests/drupal_cron_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,19 @@ tests:
limits:
cpu: 234m
memory: 2G
asserts:
- equal:
path: spec.jobTemplate.spec.template.spec.containers[0].resources.requests.cpu
value: 123m
- equal:
path: spec.jobTemplate.spec.template.spec.containers[0].resources.requests.memory
value: 1G
- equal:
path: spec.jobTemplate.spec.template.spec.containers[0].resources.limits.cpu
value: 234m
- equal:
path: spec.jobTemplate.spec.template.spec.containers[0].resources.limits.memory
value: 2G

- it: uses default resource requests and limits overriden by cronJobDefaults resources
template: drupal-cron.yaml
Expand Down
7 changes: 4 additions & 3 deletions charts/drupal/tests/drupal_deployment_test.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
suite: drupal deployment
templates:
- drupal-deployment.yaml
- drupal-configmap.yaml
- drupal-deployment.yaml
- drupal-secret.yaml
capabilities:
apiVersions:
- pxc.percona.com/v1
Expand Down Expand Up @@ -145,12 +146,12 @@ tests:
path: spec.template.spec.containers[0].env
content:
name: boolean_on
value: "true"
value: "on"
- contains:
path: spec.template.spec.containers[0].env
content:
name: boolean_off
value: "false"
value: "off"
- contains:
path: spec.template.spec.containers[0].env
content:
Expand Down
2 changes: 2 additions & 0 deletions charts/drupal/tests/drupal_hpa_test.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
suite: HorizontalPodAutoscaler
templates:
- drupal-configmap.yaml
- drupal-deployment.yaml
- drupal-secret.yaml
tests:
- it: HPA resource is present when autoscaler is enabled
template: drupal-deployment.yaml
Expand Down
44 changes: 27 additions & 17 deletions charts/drupal/tests/drupal_ingress_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ tests:
- networking.k8s.io/v1beta1
asserts:
- equal:
path: 'metadata.annotations.kubernetes\.io/ingress\.class'
path: metadata.annotations['kubernetes.io/ingress.class']
value: 'traefik'

- it: uses traefik ingress class (1.18+)
Expand All @@ -39,18 +39,18 @@ tests:
template: drupal-ingress.yaml
set:
environmentName: 'foo'
projectName: 'bar'
clusterDomain: 'baz'
projectName: 'bar'
clusterDomain: 'baz'
asserts:
- equal:
path: spec.rules[0].host
value: 'foo.bar.baz'

- it: sets correct hostname for deployment when projectName is absent
template: drupal-ingress.yaml
set:
environmentName: 'foo'
clusterDomain: 'baz'
clusterDomain: 'baz'
asserts:
- equal:
path: spec.rules[0].host
Expand Down Expand Up @@ -81,7 +81,7 @@ tests:
- equal:
path: spec.rules[0].http.paths[0].backend.service.name
value: 'RELEASE-NAME-drupal'

- it: directs traefik requests to varnish service when varnish is enabled (cm 0.8)
template: drupal-ingress.yaml
set:
Expand Down Expand Up @@ -206,7 +206,7 @@ tests:
asserts:
- documentIndex: 1
equal:
path: 'metadata.annotations.kubernetes\.io/ingress\.class'
path: metadata.annotations['kubernetes.io/ingress.class']
value: 'foo'

- it: exposeDomains - uses default ingress type and has correct hostname (1.18+)
Expand Down Expand Up @@ -241,6 +241,18 @@ tests:
path: spec.rules[0].host
value: 'foo.bar'

- it: exposeDomains - ssl redirect is enabled by default
template: drupal-ingress.yaml
set:
exposeDomains:
foo:
hostname: foo.bar
asserts:
- documentIndex: 1
equal:
path: metadata.annotations['ingress.kubernetes.io/ssl-redirect']
value: 'true'

- it: exposeDomains - can disable ssl for a certain ingress
template: drupal-ingress.yaml
set:
Expand All @@ -255,12 +267,11 @@ tests:
asserts:
- documentIndex: 1
equal:
path: 'metadata.annotations.traefik\.ingress\.kubernetes\.io\/frontend-entry-points'
path: metadata.annotations['traefik.ingress.kubernetes.io/frontend-entry-points']
value: 'http'
- documentIndex: 1
equal:
path: 'ingress\.kubernetes\.io\/ssl-redirect'
value: null
notExists:
path: metadata.annotations['ingress.kubernetes.io/ssl-redirect']

- it: exposeDomains - can disable ssl redirect
template: drupal-ingress.yaml
Expand All @@ -274,19 +285,18 @@ tests:
ingress: nossl
asserts:
- documentIndex: 1
equal:
path: 'metadata.annotations.ingress\.kubernetes\.io\/ssl-redirect'
value: null
notExists:
path: metadata.annotations['ingress.kubernetes.io/ssl-redirect']

- it: exposeDomains - multiple hostnames can use the same ingress
- it: exposeDomains - multiple hostnames can use the same ingress
template: drupal-ingress.yaml
set:
exposeDomains:
foo:
hostname: foo.baz
bar:
hostname: bar.baz

asserts:
- documentIndex: 1
equal:
Expand All @@ -310,7 +320,7 @@ tests:
asserts:
- documentIndex: 1
equal:
path: 'metadata.annotations.kubernetes\.io\/ingress\.global-static-ip-name'
path: metadata.annotations['kubernetes.io/ingress.global-static-ip-name']
value: 'baz'

- it: exposeDomains - non-gce ingress path wildcard for kubernetes <1.19
Expand Down
6 changes: 4 additions & 2 deletions charts/drupal/tests/drupal_node_selector_test.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
suite: node selector test
templates:
- drupal-deployment.yaml
- drupal-configmap.yaml
- drupal-cron.yaml
- drupal-deployment.yaml
- drupal-secret.yaml
- shell-configmap.yaml
- shell-deployment.yaml
- drupal-configmap.yaml
capabilities:
apiVersions:
- pxc.percona.com/v1
Expand Down
4 changes: 4 additions & 0 deletions charts/drupal/tests/drupal_php_env_test.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
suite: drupal php env
templates:
- drupal-configmap.yaml
- drupal-deployment.yaml
- drupal-secret.yaml
- shell-configmap.yaml
- shell-deployment.yaml
capabilities:
apiVersions:
Expand Down
3 changes: 2 additions & 1 deletion charts/drupal/tests/elasticsearch_test.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
suite: drupal elasticsearch
templates:
- drupal-deployment.yaml
- drupal-configmap.yaml
- drupal-deployment.yaml
- drupal-secret.yaml
capabilities:
apiVersions:
- pxc.percona.com/v1
Expand Down
3 changes: 2 additions & 1 deletion charts/drupal/tests/memcached_test.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
suite: drupal memcached
templates:
- drupal-deployment.yaml
- drupal-configmap.yaml
- drupal-deployment.yaml
- drupal-secret.yaml
capabilities:
apiVersions:
- pxc.percona.com/v1
Expand Down
11 changes: 6 additions & 5 deletions charts/drupal/tests/nginx-extra-config_test.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
suite: additional nginx configuration file
templates:
- drupal-deployment.yaml
- drupal-configmap.yaml
- drupal-deployment.yaml
- drupal-secret.yaml
capabilities:
apiVersions:
- pxc.percona.com/v1
Expand All @@ -10,7 +11,7 @@ tests:
template: drupal-configmap.yaml
set:
nginx.extraConfig: |
add_header X-Release-Name extraconfig-{{ .Release.Name }};
add_header X-Release-Name extraconfig-{{ .Release.Name }};
asserts:
- matchRegex:
path: data.extraConfig
Expand All @@ -19,7 +20,7 @@ tests:
template: drupal-configmap.yaml
set:
nginx.serverExtraConfig: |
# serverextraconfig test {{ .Release.Name }}
# serverextraconfig test {{ .Release.Name }}
asserts:
- matchRegex:
path: data.drupal_conf
Expand All @@ -28,7 +29,7 @@ tests:
template: drupal-configmap.yaml
set:
nginx.locationExtraConfig: |
# locationextraconfig test {{ .Release.Name }}
# locationextraconfig test {{ .Release.Name }}
asserts:
- matchRegex:
path: data.drupal_conf
Expand All @@ -39,7 +40,7 @@ tests:
nginx.extraConfig: |
server {
server_name exists.test;
}
}
asserts:
- contains:
path: spec.template.spec.containers[1].volumeMounts
Expand Down
5 changes: 3 additions & 2 deletions charts/drupal/tests/private_docker_image_test.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
suite: private docker image
templates:
- drupal-deployment.yaml
- drupal-configmap.yaml
- drupal-cron.yaml
- drupal-deployment.yaml
- drupal-secret.yaml
- post-release.yaml
- drupal-configmap.yaml
capabilities:
apiVersions:
- pxc.percona.com/v1
Expand Down
5 changes: 3 additions & 2 deletions charts/drupal/tests/private_files_test.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
suite: drupal private files
templates:
- drupal-configmap.yaml
- drupal-cron.yaml
- drupal-deployment.yaml
- drupal-secret.yaml
- drupal-volumes.yaml
- post-release.yaml
- drupal-cron.yaml
- drupal-configmap.yaml
capabilities:
apiVersions:
- pxc.percona.com/v1
Expand Down
3 changes: 2 additions & 1 deletion charts/drupal/tests/redis_test.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
suite: drupal redis
templates:
- drupal-deployment.yaml
- drupal-configmap.yaml
- drupal-deployment.yaml
- drupal-secret.yaml
capabilities:
apiVersions:
- pxc.percona.com/v1
Expand Down
13 changes: 7 additions & 6 deletions charts/drupal/tests/reference_data_test.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
suite: reference data
templates:
- post-release.yaml
- reference-data-cron.yaml
- drupal-configmap.yaml
- drupal-deployment.yaml
- drupal-secret.yaml
- drupal-volumes.yaml
- drupal-configmap.yaml
- post-release.yaml
- reference-data-cron.yaml
capabilities:
apiVersions:
- pxc.percona.com/v1
Expand Down Expand Up @@ -38,7 +39,7 @@ tests:
readOnly: true

- it: is not mounted on the main deployment
template: post-release.yaml
template: post-release.yaml
asserts:
- template: drupal-deployment.yaml
notContains:
Expand All @@ -53,7 +54,7 @@ tests:
content:
name: "reference-data-volume"
mountPath: "/app/reference-data"

- it: takes reference data information
template: post-release.yaml
set:
Expand Down Expand Up @@ -130,7 +131,7 @@ tests:
content:
name: "reference-data-volume"
persistentVolumeClaim:
claimName: foo-reference-data
claimName: foo-reference-data
- notContains:
path: spec.template.spec.containers[0].volumeMounts
content:
Expand Down
Loading