File tree Expand file tree Collapse file tree 11 files changed +201
-0
lines changed Expand file tree Collapse file tree 11 files changed +201
-0
lines changed Original file line number Diff line number Diff line change 1
1
backup-enable-disable
2
2
custom-extensions
3
3
custom-tls
4
+ database-init-sql
4
5
demand-backup
5
6
finalizers
6
7
init-deploy
Original file line number Diff line number Diff line change 1
1
backup-enable-disable
2
2
custom-extensions
3
3
custom-tls
4
+ database-init-sql
4
5
demand-backup
5
6
finalizers
6
7
init-deploy
Original file line number Diff line number Diff line change 1
1
backup-enable-disable
2
2
custom-extensions
3
3
custom-tls
4
+ database-init-sql
4
5
demand-backup
5
6
finalizers
6
7
init-deploy
Original file line number Diff line number Diff line change
1
+ apiVersion : kuttl.dev/v1beta1
2
+ kind : TestAssert
3
+ timeout : 120
4
+ ---
5
+ apiVersion : apiextensions.k8s.io/v1
6
+ kind : CustomResourceDefinition
7
+ metadata :
8
+ name : perconapgclusters.pgv2.percona.com
9
+ spec :
10
+ group : pgv2.percona.com
11
+ names :
12
+ kind : PerconaPGCluster
13
+ listKind : PerconaPGClusterList
14
+ plural : perconapgclusters
15
+ singular : perconapgcluster
16
+ scope : Namespaced
17
+ ---
18
+ apiVersion : kuttl.dev/v1beta1
19
+ kind : TestAssert
20
+ metadata :
21
+ name : check-operator-deploy-status
22
+ timeout : 120
23
+ commands :
24
+ - script : kubectl assert exist-enhanced deployment percona-postgresql-operator -n ${OPERATOR_NS:-$NAMESPACE} --field-selector status.readyReplicas=1
Original file line number Diff line number Diff line change
1
+ apiVersion : kuttl.dev/v1beta1
2
+ kind : TestStep
3
+ timeout : 10
4
+ commands :
5
+ - script : |-
6
+ set -o errexit
7
+ set -o xtrace
8
+
9
+ source ../../functions
10
+ init_temp_dir # do this only in the first TestStep
11
+
12
+ deploy_operator
13
+ deploy_client
Original file line number Diff line number Diff line change
1
+ apiVersion : kuttl.dev/v1beta1
2
+ kind : TestAssert
3
+ timeout : 30
4
+ ---
5
+ apiVersion : v1
6
+ kind : ConfigMap
7
+ metadata :
8
+ name : init-database-sql
9
+ data :
10
+ init.sql : |
11
+ CREATE TABLE e2e_init_table(id INT PRIMARY KEY);
12
+ INSERT INTO e2e_init_table VALUES (42);
Original file line number Diff line number Diff line change
1
+ apiVersion : v1
2
+ kind : ConfigMap
3
+ metadata :
4
+ name : init-database-sql
5
+ data :
6
+ init.sql : |
7
+ CREATE TABLE e2e_init_table(id INT PRIMARY KEY);
8
+ INSERT INTO e2e_init_table VALUES (42);
Original file line number Diff line number Diff line change
1
+ apiVersion : kuttl.dev/v1beta1
2
+ kind : TestAssert
3
+ timeout : 300
4
+ ---
5
+ kind : StatefulSet
6
+ apiVersion : apps/v1
7
+ metadata :
8
+ labels :
9
+ postgres-operator.crunchydata.com/cluster : database-init-sql
10
+ postgres-operator.crunchydata.com/data : postgres
11
+ postgres-operator.crunchydata.com/instance-set : instance1
12
+ ownerReferences :
13
+ - apiVersion : postgres-operator.crunchydata.com/v1beta1
14
+ kind : PostgresCluster
15
+ name : database-init-sql
16
+ controller : true
17
+ blockOwnerDeletion : true
18
+ status :
19
+ observedGeneration : 1
20
+ replicas : 1
21
+ readyReplicas : 1
22
+ updatedReplicas : 1
23
+ collisionCount : 0
24
+ ---
25
+ kind : Deployment
26
+ apiVersion : apps/v1
27
+ metadata :
28
+ name : database-init-sql-pgbouncer
29
+ labels :
30
+ postgres-operator.crunchydata.com/cluster : database-init-sql
31
+ postgres-operator.crunchydata.com/role : pgbouncer
32
+ annotations :
33
+ deployment.kubernetes.io/revision : ' 1'
34
+ ownerReferences :
35
+ - apiVersion : postgres-operator.crunchydata.com/v1beta1
36
+ kind : PostgresCluster
37
+ name : database-init-sql
38
+ controller : true
39
+ blockOwnerDeletion : true
40
+ status :
41
+ observedGeneration : 1
42
+ replicas : 3
43
+ updatedReplicas : 3
44
+ readyReplicas : 3
45
+ ---
46
+ apiVersion : postgres-operator.crunchydata.com/v1beta1
47
+ kind : PostgresCluster
48
+ metadata :
49
+ name : database-init-sql
50
+ ownerReferences :
51
+ - apiVersion : pgv2.percona.com/v2
52
+ kind : PerconaPGCluster
53
+ name : database-init-sql
54
+ controller : true
55
+ blockOwnerDeletion : true
56
+ finalizers :
57
+ - postgres-operator.crunchydata.com/finalizer
58
+ spec :
59
+ backups :
60
+ pgbackrest : {}
61
+ status :
62
+ instances :
63
+ - name : instance1
64
+ readyReplicas : 3
65
+ replicas : 3
66
+ updatedReplicas : 3
67
+ observedGeneration : 1
68
+ proxy :
69
+ pgBouncer :
70
+ readyReplicas : 3
71
+ replicas : 3
72
+ ---
73
+ apiVersion : pgv2.percona.com/v2
74
+ kind : PerconaPGCluster
75
+ metadata :
76
+ name : database-init-sql
77
+ status :
78
+ pgbouncer :
79
+ ready : 3
80
+ size : 3
81
+ postgres :
82
+ instances :
83
+ - name : instance1
84
+ ready : 3
85
+ size : 3
86
+ ready : 3
87
+ size : 3
88
+ state : ready
Original file line number Diff line number Diff line change
1
+ apiVersion : kuttl.dev/v1beta1
2
+ kind : TestStep
3
+ timeout : 10
4
+ commands :
5
+ - script : |-
6
+ set -o errexit
7
+ set -o xtrace
8
+
9
+ source ../../functions
10
+
11
+ get_cr \
12
+ | yq '.spec.databaseInitSQL.name = "init-database-sql"' \
13
+ | yq '.spec.databaseInitSQL.key = "init.sql"' \
14
+ | kubectl -n "${NAMESPACE}" apply -f -
Original file line number Diff line number Diff line change
1
+ apiVersion : kuttl.dev/v1beta1
2
+ kind : TestStep
3
+ commands :
4
+ - script : |-
5
+ set -o errexit
6
+ set -o xtrace
7
+
8
+ source ../../functions
9
+
10
+ result=$(run_psql_local \
11
+ "SELECT id FROM e2e_init_table WHERE id = 42" \
12
+ "postgres:$(get_psql_user_pass database-init-sql-pguser-postgres)@$(get_psql_user_host database-init-sql-pguser-postgres)/postgres")
13
+
14
+ if [[ "$result" != *"42"* ]]; then
15
+ echo "Database has not been initialized"
16
+ exit 1
17
+ fi
18
+ timeout: 360
You can’t perform that action at this time.
0 commit comments