Skip to content

Commit

Permalink
test: Updating tests to match new implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcollom committed Oct 11, 2023
1 parent f5888d2 commit 286a146
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 15 deletions.
8 changes: 4 additions & 4 deletions deploy/charts/version-checker/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ spec:
metadata:
labels:
{{- include "version-checker.labels" . | nindent 8 }}
{{- if .Values.pod.labels }}
{{ toYaml .Values.pod.labels | nindent 8 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | nindent 8 }}
{{- end }}
annotations:
prometheus.io/path: "/metrics"
prometheus.io/scrape: "true"
prometheus.io/port: "8080"
enable.version-checker.io/{{ $chartname }}: "true"
{{- if .Values.pod.annotations }}
{{ toYaml .Values.pod.annotations | nindent 8 }}
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ $chartname }}
Expand Down
8 changes: 4 additions & 4 deletions deploy/charts/version-checker/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ metadata:
labels:
app: {{ include "version-checker.name" . }}
{{ include "version-checker.labels" . | nindent 4 }}
{{- if .Values.svc.annotations }}
{{ toYaml .Values.pod.annotations | nindent 4 }}
{{- if .Values.service.labels }}
{{ toYaml .Values.service.labels | nindent 4 }}
{{- end }}
{{- if .Values.svc.annotations }}
{{- if .Values.service.annotations }}
annotations:
{{ toYaml .Values.pod.annotations | nindent 4 }}
{{ toYaml .Values.service.annotations | nindent 4 }}
{{- end }}
spec:
ports:
Expand Down
83 changes: 83 additions & 0 deletions deploy/charts/version-checker/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,57 @@ tests:
- isNullOrEmpty:
path: spec.template.spec.volumes

# Custom Envs
- it: Custom Env vars
set:
env:
- name: CUSTOM_ENV_VAR
value: CUSTOM_ENV_VALUE
asserts:
- contains:
path: spec.template.spec.containers[0].env
count: 1
content:
name: CUSTOM_ENV_VAR
value: CUSTOM_ENV_VALUE

# Param changes
- it: imageCacheTimeout
set:
versionChecker.imageCacheTimeout: 60m
asserts:
- contains:
path: spec.template.spec.containers[0].args
count: 1
content: "--image-cache-timeout=60m"

- it: logLevel
set:
versionChecker.logLevel: debug
asserts:
- contains:
path: spec.template.spec.containers[0].args
count: 1
content: "--log-level=debug"

- it: metricsServingAddress
set:
versionChecker.metricsServingAddress: 0.0.0.0:9999
asserts:
- contains:
path: spec.template.spec.containers[0].args
count: 1
content: "--metrics-serving-address=0.0.0.0:9999"

- it: testAllContainers
set:
versionChecker.testAllContainers: false
asserts:
- contains:
path: spec.template.spec.containers[0].args
count: 1
content: "--test-all-containers=false"

# ACR
- it: ACR should work
set:
Expand Down Expand Up @@ -306,3 +357,35 @@ tests:
name: version-checker
secret:
secretName: version-checker

- it: Resources are reflected
set:
resources:
limits:
cpu: 100m
memory: 512Mi
asserts:
- equal:
path: spec.template.spec.containers[0].resources
value:
limits:
cpu: 100m
memory: 512Mi

- it: Custom Labels to Pod
set:
additionalLabels:
foo: bar
asserts:
- equal:
path: spec.template.metadata.labels["foo"]
value: bar

- it: Custom Annotations to Pod
set:
additionalAnnotations:
foo: bar
asserts:
- equal:
path: spec.template.metadata.annotations["foo"]
value: bar
29 changes: 29 additions & 0 deletions deploy/charts/version-checker/tests/service_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,38 @@ tests:
kind: Service
apiVersion: v1
name: version-checker
- equal:
path: spec.ports[0].port
value: 8080
- equal:
path: spec.ports[0].targetPort
value: 8080
- equal:
path: spec.ports[0].name
value: web

- it: Custom Port
set:
service.port: 9999
asserts:
- equal:
path: spec.ports[0].port
value: 9999

- it: Custom Labels
set:
service.labels:
foo: bar
asserts:
- equal:
path: metadata.labels["foo"]
value: bar

- it: Custom Annotations
set:
service.annotations:
foo: bar
asserts:
- equal:
path: metadata.annotations["foo"]
value: bar
11 changes: 4 additions & 7 deletions deploy/charts/version-checker/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@

replicaCount: 1

pod:
labels: {}
annotations: {}

svc:
labels: {}
annotations: {}
additionalLabels: {}
additionalAnnotations: {}

image:
repository: quay.io/jetstack/version-checker
Expand All @@ -19,6 +14,8 @@ image:
pullPolicy: IfNotPresent

service:
labels: {}
annotations: {}
port: 8080

versionChecker:
Expand Down

0 comments on commit 286a146

Please sign in to comment.