vct tests

This commit is contained in:
Stavros kois
2024-03-10 00:08:00 +02:00
parent d3f7088314
commit 124c2b25e1
3 changed files with 60 additions and 9 deletions

View File

@@ -39,7 +39,7 @@ tests:
path: spec.volumeClaimTemplates[0].spec.resources.requests.storage
value: 100Gi
- documentIndex: *statefulSetDoc
isNull:
notExists:
path: spec.volumeClaimTemplates[0].spec.storageClassName
- it: should create vct with accessModes set as string
@@ -67,7 +67,35 @@ tests:
value:
- ReadWriteMany
- it: should create pvc with accessModes set as list
- it: should create vct with changed fallback accessModes
set:
fallbackDefaults:
accessModes:
- ReadWriteMany
- ReadWriteOnce
persistence:
my-volume1:
enabled: true
type: vct
mountPath: /some/path
workload:
main:
enabled: true
primary: true
type: StatefulSet
podSpec: {}
asserts:
- documentIndex: *statefulSetDoc
isKind:
of: StatefulSet
- documentIndex: *statefulSetDoc
equal:
path: spec.volumeClaimTemplates[0].spec.accessModes
value:
- ReadWriteMany
- ReadWriteOnce
- it: should create vct with accessModes set as list
set:
some_mode: ReadWriteMany
persistence:
@@ -95,7 +123,7 @@ tests:
- ReadWriteMany
- ReadWriteOnce
- it: should create pvc with size set
- it: should create vct with size set
set:
persistence:
my-volume1:
@@ -118,6 +146,30 @@ tests:
path: spec.volumeClaimTemplates[0].spec.resources.requests.storage
value: 20Gi
- it: should create vct with size set from tpl
set:
some_size: 40Gi
persistence:
my-volume1:
enabled: true
type: vct
mountPath: /some/path
size: "{{ .Values.some_size }}"
workload:
main:
enabled: true
primary: true
type: StatefulSet
podSpec: {}
asserts:
- documentIndex: *statefulSetDoc
isKind:
of: StatefulSet
- documentIndex: *statefulSetDoc
equal:
path: spec.volumeClaimTemplates[0].spec.resources.requests.storage
value: 40Gi
- it: should create vct with storageClass set "-"
set:
some_storage_class: "-"

View File

@@ -133,7 +133,6 @@
{{- end -}}
{{- include "tc.v1.common.lib.util.verifycrd" (dict "rootCtx" $rootCtx "crd" "clusters.postgresql.cnpg.io" "missing" "CloudNative-PG") }}
---
apiVersion: postgresql.cnpg.io/v1
kind: Cluster

View File

@@ -14,7 +14,7 @@ objectData: The object data to be used to render the Pod.
"name" $name "caller" "Volume Claim Templates"
"key" "persistence")) -}}
{{- if and (eq $enabled "true") (eq $vctValues.type "vct") -}}
{{- if and (eq $enabled "true") (eq $vctValues.type "vct") -}}
{{- $vct := (mustDeepCopy $vctValues) -}}
{{- $selected := false -}}
@@ -42,13 +42,13 @@ objectData: The object data to be used to render the Pod.
{{- $vctSize := $rootCtx.Values.fallbackDefaults.vctSize -}}
{{- with $vct.size -}}
{{- $vctSize = tpl . $rootCtx -}}
{{- end }}
{{- $_ := set $vct "size" $vctSize }}
{{- end -}}
{{- $_ := set $vct "size" $vctSize -}}
{{- $vctAccessModes := $rootCtx.Values.fallbackDefaults.vctAccessModes -}}
{{- with $vct.accessModes -}}
{{- $vctAccessModes = $vct.accessModes -}}
{{- end }}
{{- $vctAccessModes = . -}}
{{- end -}}
{{- $_ := set $vct "accessModes" $vctAccessModes }}
- metadata:
name: {{ include "tc.v1.common.lib.storage.pvc.name" (dict "rootCtx" $rootCtx "objectName" $vct.shortName "objectData" $vct) }}