Skip to content

Commit

Permalink
Improve agent sts pvc tests (#185)
Browse files Browse the repository at this point in the history
Co-authored-by: Robert Kaussow <[email protected]>
  • Loading branch information
pat-s and xoxys authored Apr 18, 2024
1 parent 8319618 commit 092e60e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
5 changes: 1 addition & 4 deletions charts/woodpecker/charts/agent/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if or (.Values.persistence.enabled) (.Values.extraVolumeMounts) }}
{{- if or (and (.Values.persistence.enabled) (.Values.persistence.existingClaim)) (.Values.extraVolumeMounts) }}
volumes:
{{- if .Values.persistence.enabled }}
{{- if .Values.persistence.existingClaim }}
Expand Down Expand Up @@ -130,7 +130,4 @@ spec:
resources:
requests:
storage: {{ .Values.persistence.size }}
{{- else if (not .Values.persistence.enabled) }}
- name: data
emptyDir: {}
{{- end }}
32 changes: 22 additions & 10 deletions charts/woodpecker/charts/agent/unittests/statefulset/pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,39 @@ suite: test deployment
templates:
- templates/statefulset.yaml
tests:
- it: persistence is enabled
- it: persistence enabled
set:
persistence:
enabled: true
asserts:
- equal:
path: spec.volumeClaimTemplates[0].spec.accessModes[0]
value: 'ReadWriteOnce'
# this should only exist with existingClaim and is otherwise taken care of automatically
- equal:
path: spec.template.spec.volumes
value: null
- it: persistence with existingClaim
- it: persistence enabled with existingClaim
set:
persistence:
enabled: true
existingClaim: foo
existingClaim: 'my-claim'
asserts:
- notExists:
path: spec.volumeClaimTemplates[0].spec.accessModes[0]
- equal:
path: spec.template.spec.volumes
value:
- persistentVolumeClaim:
claimName: foo
name: agent-config
- name: agent-config
persistentVolumeClaim:
claimName: my-claim
- it: persistence disabled
set:
persistence:
enabled: false
asserts:
- notExists:
path: spec.template.spec.volumes
- notExists:
path: spec.template.spec.containers[0].volumeMounts
value:
- mountPath: /data
name: data
- notExists:
path: spec.volumeClaimTemplates

0 comments on commit 092e60e

Please sign in to comment.