Skip to content

Commit

Permalink
Merge pull request #38 from vshn/e2e
Browse files Browse the repository at this point in the history
Add e2e test case for PostgreSQL
  • Loading branch information
ccremer authored Oct 26, 2022
2 parents 8e8f97a + 3986090 commit ec255ca
Show file tree
Hide file tree
Showing 12 changed files with 156 additions and 2 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
62 changes: 62 additions & 0 deletions test/e2e/postgresql/00-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
timeout: 600
---
apiVersion: exoscale.crossplane.io/v1
kind: PostgreSQL
metadata:
name: e2e-test-postgresql
annotations:
crossplane.io/external-name: e2e-test-postgresql
finalizers:
- finalizer.managedresource.crossplane.io
spec:
forProvider:
backup:
timeOfDay: '13:00:00'
ipFilter:
- 0.0.0.0/0
maintenance:
dayOfWeek: monday
timeOfDay: '12:00:00'
size:
plan: hobbyist-2
version: '14'
zone: ch-dk-2
pgSettings:
timezone: Europe/Zurich
providerConfigRef:
name: provider-config
writeConnectionSecretToRef:
name: e2e-test-postgresql-details
namespace: default
status:
atProvider:
backup:
timeOfDay: '13:00:00'
maintenance:
dayOfWeek: monday
timeOfDay: '12:00:00'
noteStates:
- name: e2e-test-postgresql-1
role: master
state: running
conditions:
- message: The service is running
reason: Available
status: 'True'
type: Ready
- reason: ReconcileSuccess
status: 'True'
type: Synced
---
apiVersion: v1
kind: Secret
type: connection.crossplane.io/v1alpha1
metadata:
name: e2e-test-postgresql-details
namespace: default
ownerReferences:
- apiVersion: exoscale.crossplane.io/v1
kind: PostgreSQL
name: e2e-test-postgresql
24 changes: 24 additions & 0 deletions test/e2e/postgresql/00-install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: exoscale.crossplane.io/v1
kind: PostgreSQL
metadata:
name: e2e-test-postgresql
spec:
forProvider:
backup:
timeOfDay: "13:00:00"
ipFilter:
- 0.0.0.0/0
maintenance:
dayOfWeek: monday
timeOfDay: "12:00:00"
size:
plan: hobbyist-2
version: "14"
zone: ch-dk-2
pgSettings:
timezone: Europe/Zurich
providerConfigRef:
name: provider-config
writeConnectionSecretToRef:
name: e2e-test-postgresql-details
namespace: default
11 changes: 11 additions & 0 deletions test/e2e/postgresql/01-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: batch/v1
kind: Job
metadata:
name: connect-postgresql
namespace: default
status:
conditions:
- type: Complete
status: 'True'
succeeded: 1
ready: 0
42 changes: 42 additions & 0 deletions test/e2e/postgresql/01-connect.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: batch/v1
kind: Job
metadata:
name: connect-postgresql
namespace: default
spec:
backoffLimit: 5
template:
metadata:
labels:
e2e-test: postgresql
spec:
restartPolicy: Never
containers:
- name: connect
image: docker.io/bitnami/postgresql:latest
imagePullPolicy: IfNotPresent
command:
- bash
securityContext:
# with an arbitrary user, "psql" complains it can't find the user ID.
# For e2e test using root should be ok
runAsUser: 0
args:
- -c
- echo "Testing Select...\n" && PGDATABASE="$POSTGRESQL_DB" PGUSER="$POSTGRESQL_USER" PGPASSWORD="$POSTGRESQL_PASSWORD" PGHOST="$POSTGRESQL_HOST" PGPORT="$POSTGRESQL_PORT" psql -c "select 1;"
env:
- name: PGSSLMODE
value: verify-ca
envFrom:
- secretRef:
name: e2e-test-postgresql-details
volumeMounts:
- name: ca
mountPath: /root/.postgresql
volumes:
- name: ca
secret:
secretName: e2e-test-postgresql-details
items:
- key: ca.crt
path: root.crt
14 changes: 14 additions & 0 deletions test/e2e/postgresql/02-delete.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
delete:
# This will wait until resources are really gone
- apiVersion: batch/v1
kind: Job
name: connect-postgresql
- apiVersion: v1
kind: Pod
labels:
e2e-test: postgresql
- apiVersion: exoscale.crossplane.io/v1
kind: PostgreSQL
name: e2e-test-postgresql
5 changes: 3 additions & 2 deletions test/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ test-e2e: $(kuttl_bin) $(mc_bin) local-install provider-config ## E2E tests
.PHONY: .e2e-test-clean
.e2e-test-clean: export KUBECONFIG = $(KIND_KUBECONFIG)
.e2e-test-clean:
if [ -f $(KIND_KUBECONFIG) ]; then kubectl delete buckets --all; else echo "no kubeconfig found"; fi
if [ -f $(KIND_KUBECONFIG) ]; then kubectl delete iamkeys --all; else echo "no kubeconfig found"; fi
@if [ -f $(KIND_KUBECONFIG) ]; then kubectl delete buckets --all; else echo "no kubeconfig found"; fi
@if [ -f $(KIND_KUBECONFIG) ]; then kubectl delete iamkeys --all; else echo "no kubeconfig found"; fi
@if [ -f $(KIND_KUBECONFIG) ]; then kubectl delete postgresql --all; else echo "no kubeconfig found"; fi
rm -f $(kuttl_bin) $(mc_bin)

0 comments on commit ec255ca

Please sign in to comment.