test(etcd): add e2e for etcd application and backup schedule
Adds two bats cases: a baseline Etcd managed-app deployment and a deployment with backup.enabled=true that verifies the EtcdBackupSchedule resource and the S3 credentials Secret are materialized. The backup case uses fake S3 credentials — the operator will not successfully push backups, but the schedule resource itself is reconciled, which is what this test validates. Also hardcodes the EtcdBackupSchedule and backup Secret names to 'etcd' / 'etcd-s3-creds' to match the existing hardcoded EtcdCluster name in the chart (one etcd per tenant namespace). Assisted-By: Claude <noreply@anthropic.com> Signed-off-by: Aleksei Sviridkin <f@lex.la>
This commit is contained in:
parent
51c8192e1e
commit
ee8ceecc0e
3 changed files with 61 additions and 3 deletions
58
hack/e2e-apps/etcd.bats
Normal file
58
hack/e2e-apps/etcd.bats
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
#!/usr/bin/env bats
|
||||
|
||||
@test "Create Etcd" {
|
||||
name='test'
|
||||
kubectl -n tenant-test delete etcd.apps.cozystack.io $name --ignore-not-found --timeout=2m || true
|
||||
kubectl apply -f- <<EOF
|
||||
apiVersion: apps.cozystack.io/v1alpha1
|
||||
kind: Etcd
|
||||
metadata:
|
||||
name: $name
|
||||
namespace: tenant-test
|
||||
spec:
|
||||
size: 1Gi
|
||||
replicas: 3
|
||||
storageClass: ""
|
||||
resources:
|
||||
cpu: 100m
|
||||
memory: 128Mi
|
||||
EOF
|
||||
sleep 5
|
||||
kubectl -n tenant-test wait hr etcd-$name --timeout=60s --for=condition=ready
|
||||
kubectl -n tenant-test wait etcdcluster.etcd.aenix.io etcd --timeout=120s --for=jsonpath='{.status.conditions[?(@.type=="Ready")].status}'=True
|
||||
kubectl -n tenant-test delete etcd.apps.cozystack.io $name
|
||||
}
|
||||
|
||||
@test "Create Etcd with backup schedule" {
|
||||
name='test-backup'
|
||||
kubectl -n tenant-test delete etcd.apps.cozystack.io $name --ignore-not-found --timeout=2m || true
|
||||
kubectl apply -f- <<EOF
|
||||
apiVersion: apps.cozystack.io/v1alpha1
|
||||
kind: Etcd
|
||||
metadata:
|
||||
name: $name
|
||||
namespace: tenant-test
|
||||
spec:
|
||||
size: 1Gi
|
||||
replicas: 3
|
||||
storageClass: ""
|
||||
resources:
|
||||
cpu: 100m
|
||||
memory: 128Mi
|
||||
backup:
|
||||
enabled: true
|
||||
schedule: "0 2 * * *"
|
||||
destinationPath: "s3://test-bucket/etcd-backups/"
|
||||
endpointURL: "http://minio-gateway-service:9000"
|
||||
forcePathStyle: true
|
||||
s3AccessKey: "test-access-key"
|
||||
s3SecretKey: "test-secret-key"
|
||||
successfulJobsHistoryLimit: 3
|
||||
failedJobsHistoryLimit: 1
|
||||
EOF
|
||||
sleep 5
|
||||
kubectl -n tenant-test wait hr etcd-$name --timeout=60s --for=condition=ready
|
||||
kubectl -n tenant-test wait etcdbackupschedule.etcd.aenix.io etcd --timeout=60s --for=jsonpath='{.spec.schedule}'='0 2 * * *'
|
||||
kubectl -n tenant-test get secret etcd-s3-creds
|
||||
kubectl -n tenant-test delete etcd.apps.cozystack.io $name
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ .Release.Name }}-s3-creds
|
||||
name: etcd-s3-creds
|
||||
stringData:
|
||||
AWS_ACCESS_KEY_ID: {{ required "s3AccessKey is not specified!" .Values.backup.s3AccessKey | quote }}
|
||||
AWS_SECRET_ACCESS_KEY: {{ required "s3SecretKey is not specified!" .Values.backup.s3SecretKey | quote }}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
apiVersion: etcd.aenix.io/v1alpha1
|
||||
kind: EtcdBackupSchedule
|
||||
metadata:
|
||||
name: {{ .Release.Name }}
|
||||
name: etcd
|
||||
spec:
|
||||
clusterRef:
|
||||
name: etcd
|
||||
|
|
@ -26,5 +26,5 @@ spec:
|
|||
{{- end }}
|
||||
forcePathStyle: {{ .Values.backup.forcePathStyle }}
|
||||
credentialsSecretRef:
|
||||
name: {{ .Release.Name }}-s3-creds
|
||||
name: etcd-s3-creds
|
||||
{{- end }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue