Skip to content

Commit

Permalink
WIP: Adding backcompat testing
Browse files Browse the repository at this point in the history
Signed-off-by: W. Kavanaugh Latiolais <[email protected]>
  • Loading branch information
kav committed Oct 24, 2020
1 parent 6b5e7d1 commit 4d2343d
Show file tree
Hide file tree
Showing 9 changed files with 226 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ To run unit tests in this repository please install helm-unittest

```sh
helm plugin install https://github.com/quintush/helm-unittest
helm unittest -3 charts/velero
helm unittest charts/velero
```

## License
Expand Down
26 changes: 26 additions & 0 deletions charts/velero/ci/test-values-back-compat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
installCRDs: true

# Set provider name and backup storage location bucket name
configuration:
provider: aws
backupStorageLocation:
bucket: velero
config:
region: us-west-1
profile: test
volumeSnapshotLocation:
provider: aws
config:
bucket: velero
region: us-west-1

# Set a service account so that the CRD clean up job has proper permissions to delete CRDs
serviceAccount:
server:
name: velero

# Whether or not to clean up CustomResourceDefintions when deleting a release.
# Cleaning up CRDs will delete the BackupStorageLocation and VolumeSnapshotLocation instances, which would have to be reconfigured.
# Backup data in object storage will _not_ be deleted, however Backup instances in the Kubernetes API will.
# Always clean up CRDs in CI.
cleanUpCRDs: true
8 changes: 4 additions & 4 deletions charts/velero/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -79,28 +79,28 @@ Create the Restic priority class name.
Create the backup storage location name
*/}}
{{- define "velero.backupStorageLocation.name" -}}
{{ coalesce .Values.backupStorageLocation.name .Values.configuration.backupStorageLocation.name "default" }}
{{ coalesce .Values.configuration.backupStorageLocation.name .Values.backupStorageLocation.name "default" }}
{{- end -}}

{{/*
Create the backup storage location provider
*/}}
{{- define "velero.backupStorageLocation.provider" -}}
{{ coalesce .Values.backupStorageLocation.provider .Values.configuration.backupStorageLocation.provider .Values.provider }}
{{ coalesce .Values.configuration.backupStorageLocation.provider .Values.backupStorageLocation.provider .Values.configuration.provider .Values.provider }}
{{- end -}}

{{/*
Create the volume snapshot location name
*/}}
{{- define "velero.volumeSnapshotLocation.name" -}}
{{ coalesce .Values.volumeSnapshotLocation.name .Values.configuration.volumeSnapshotLocation.name "default" }}
{{ coalesce .Values.configuration.volumeSnapshotLocation.name .Values.volumeSnapshotLocation.name "default" }}
{{- end -}}

{{/*
Create the volume snapshot location provider
*/}}
{{- define "velero.volumeSnapshotLocation.provider" -}}
{{ coalesce .Values.volumeSnapshotLocation.provider .Values.configuration.volumeSnapshotLocation.provider .Values.provider}}
{{ coalesce .Values.configuration.volumeSnapshotLocation.provider .Values.volumeSnapshotLocation.provider .Values.configuration.provider .Values.provider}}
{{- end -}}

{{- define "velero.image-from-values" -}}
Expand Down
2 changes: 1 addition & 1 deletion charts/velero/templates/backupstoragelocation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ metadata:
helm.sh/chart: {{ include "velero.chart" . }}
spec:
provider: {{ include "velero.backupStorageLocation.provider" . }}
{{- with coalesce .Values.backupStorageLocation .Values.configuration.backupStorageLocation }}
{{- with coalesce .Values.configuration.backupStorageLocation .Values.backupStorageLocation }}
objectStorage:
bucket: {{ .bucket }}
{{- with .prefix }}
Expand Down
18 changes: 9 additions & 9 deletions charts/velero/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.provider -}}
{{- if or .Values.provider .Values.configuration.provider -}}
{{- $providers := list .Values.provider .Values.backupStorageLocation.provider .Values.volumeSnapshotLocation.provider .Values.configuration.backupStorageLocation.provider .Values.configuration.volumeSnapshotLocation.provider | compact | uniq -}}
{{- $provider := first $providers -}}
{{- $useSecret := or .Values.credentials.existingSecret (or .Values.credentials.secretContents .Values.credentials.extraEnvVars) -}}
Expand Down Expand Up @@ -57,25 +57,25 @@ spec:
args:
- server
{{- with .Values }}
{{- with coalesce .backupSyncPeriod .configuration.backupSyncPeriod }}
{{- with coalesce .configuration.backupSyncPeriod .backupSyncPeriod }}
- --backup-sync-period={{ . }}
{{- end }}
{{- with coalesce .resticTimeout .configuration.resticTimeout }}
{{- with coalesce .configuration.resticTimeout .resticTimeout}}
- --restic-timeout={{ . }}
{{- end }}
{{- if coalesce .restoreOnlyMode .configuration.restoreOnlyMode }}
{{- if coalesce .configuration.restoreOnlyMode .restoreOnlyMode}}
- --restore-only
{{- end }}
{{- with coalesce .restoreResourcePriorities .configuration.restoreResourcePriorities }}
{{- with coalesce .configuration.restoreResourcePriorities .restoreResourcePriorities }}
- --restore-resource-priorities={{ . }}
{{- end }}
{{- with coalesce .features .configuration.features }}
{{- with coalesce .configuration.features .features }}
- --features={{ . }}
{{- end }}
{{- with coalesce .configuration.logLevel }}
{{- with coalesce .configuration.logLevel .logLevel }}
- --log-level={{ . }}
{{- end }}
{{- with coalesce .configuration.logFormat }}
{{- with coalesce .configuration.logFormat .logFormat }}
- --log-format={{ . }}
{{- end }}
{{- end }}
Expand Down Expand Up @@ -120,7 +120,7 @@ spec:
value: /credentials/cloud
{{- end }}
{{- end }}
{{- with coalesce .Values.extraEnvVars .Values.configuration.extraEnvVars }}
{{- with coalesce .Values.configuration.extraEnvVars .Values.extraEnvVars }}
{{- range $key, $value := . }}
- name: {{ default "none" $key | quote }}
value: {{ default "none" $value | quote }}
Expand Down
10 changes: 5 additions & 5 deletions charts/velero/templates/restic-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ spec:
- restic
- server
{{- with .Values }}
{{- with coalesce .features .configuration.features }}
{{- with coalesce .configuration.features .features }}
- --features={{ . }}
{{- end }}
{{- with coalesce .logLevel .configuration.logLevel }}
{{- with coalesce .configuration.logLevel .logLevel }}
- --log-level={{ . }}
{{- end }}
{{- with coalesce .logFormat .configuration.logFormat }}
{{- with coalesce .configuration.logFormat .logFormat }}
- --log-format={{ . }}
{{- end }}
{{- end }}
Expand All @@ -88,7 +88,7 @@ spec:
{{- toYaml .Values.restic.extraVolumeMounts | nindent 12 }}
{{- end }}
env:
{{- with coalesce .Values.extraEnvVars .Values.configuration.extraEnvVars }}
{{- with coalesce .Values.configuration.extraEnvVars .Values.extraEnvVars }}
{{- range $key, $value := . }}
- name: {{ default "none" $key | quote }}
value: {{ default "none" $value | quote }}
Expand Down Expand Up @@ -119,7 +119,7 @@ spec:
value: /credentials/cloud
{{- end }}
{{- end }}
{{- with coalesce .Values.extraEnvVars .Values.configuration.extraEnvVars }}
{{- with coalesce .Values.configuration.extraEnvVars .Values.extraEnvVars }}
{{- range $key, $value := . }}
- name: {{ default "none" $key | quote }}
value: {{ default "none" $value | quote }}
Expand Down
2 changes: 1 addition & 1 deletion charts/velero/templates/volumesnapshotlocation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ metadata:
helm.sh/chart: {{ include "velero.chart" . }}
spec:
provider: {{ include "velero.volumeSnapshotLocation.provider" . }}
{{- with coalesce .Values.volumeSnapshotLocation.config .Values.configuration.volumeSnapshotLocation.config }}
{{- with coalesce .Values.configuration.volumeSnapshotLocation.config .Values.volumeSnapshotLocation.config }}
config:
{{ toYaml . | indent 4 }}
{{- end -}}
Expand Down
166 changes: 166 additions & 0 deletions charts/velero/tests/__snapshot__/back-compat-snapshot_test.yaml.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
manifest should match snapshot:
1: |
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Tiller
app.kubernetes.io/name: velero
helm.sh/chart: velero-2.14.0
name: RELEASE-NAME-velero
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: velero
template:
metadata:
annotations:
prometheus.io/path: /metrics
prometheus.io/port: "8085"
prometheus.io/scrape: "true"
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Tiller
app.kubernetes.io/name: velero
helm.sh/chart: velero-2.14.0
name: velero
spec:
containers:
- args:
- server
command:
- /velero
env:
- name: VELERO_SCRATCH_DIR
value: /scratch
- name: VELERO_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: LD_LIBRARY_PATH
value: /plugins
image: velero/velero:v1.4.2
imagePullPolicy: IfNotPresent
name: velero
ports:
- containerPort: 8085
name: monitoring
volumeMounts:
- mountPath: /plugins
name: plugins
initContainers:
- image: velero/velero-plugin-for-aws:v1.1.0
imagePullPolicy: IfNotPresent
name: velero-plugin-for-aws
volumeMounts:
- mountPath: /target
name: plugins
restartPolicy: Always
serviceAccountName: velero
volumes:
- emptyDir: {}
name: plugins
- emptyDir: {}
name: scratch
2: |
apiVersion: velero.io/v1
kind: BackupStorageLocation
metadata:
annotations:
helm.sh/hook: post-install,post-upgrade
helm.sh/hook-delete-policy: before-hook-creation
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Tiller
app.kubernetes.io/name: velero
helm.sh/chart: velero-2.14.0
name: default
spec:
config:
profile: test
region: us-west-1
objectStorage:
bucket: velero
provider: aws
3: |
apiVersion: apps/v1
kind: DaemonSet
metadata:
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Tiller
app.kubernetes.io/name: velero
helm.sh/chart: velero-2.14.0
name: restic
spec:
selector:
matchLabels:
name: restic
template:
metadata:
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Tiller
app.kubernetes.io/name: velero
helm.sh/chart: velero-2.14.0
name: restic
spec:
containers:
- args:
- restic
- server
command:
- /velero
env:
- name: VELERO_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: VELERO_SCRATCH_DIR
value: /scratch
image: velero/velero:v1.4.2
imagePullPolicy: IfNotPresent
name: restic
securityContext:
privileged: false
volumeMounts:
- mountPath: /host_pods
mountPropagation: HostToContainer
name: host-pods
- mountPath: /scratch
name: scratch
securityContext:
runAsUser: 0
serviceAccountName: velero
volumes:
- hostPath:
path: /var/lib/kubelet/pods
name: host-pods
- emptyDir: {}
name: scratch
4: |
apiVersion: velero.io/v1
kind: VolumeSnapshotLocation
metadata:
annotations:
helm.sh/hook: post-install,post-upgrade
helm.sh/hook-delete-policy: before-hook-creation
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Tiller
app.kubernetes.io/name: velero
helm.sh/chart: velero-2.14.0
name: default
spec:
config:
bucket: velero
region: us-west-1
provider: aws
13 changes: 13 additions & 0 deletions charts/velero/tests/back-compat-snapshot_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
templates:
- deployment.yaml
- backupstoragelocation.yaml
- restic-daemonset.yaml
- volumesnapshotlocation.yaml
tests:
- it: manifest should match snapshot
values:
- ../ci/test-values-back-compat.yaml
set:
restic.enabled: true
asserts:
- matchSnapshot: {}

0 comments on commit 4d2343d

Please sign in to comment.