1+ apiVersion : chainsaw.kyverno.io/v1alpha1
2+ kind : Test
3+ metadata :
4+ name : create-cluster
5+ spec :
6+ bindings :
7+ - name : cluster
8+ value : create-cluster
9+
10+ - name : postgresVersion
11+ value : (to_string($values.versions.postgres))
12+
13+ - name : psql
14+ value :
15+ image : ($values.images.psql)
16+ connect : { name: PGCONNECT_TIMEOUT, value: '5' }
17+
18+ - name : confirmQuery
19+ value : |
20+ DO $script$
21+ DECLARE
22+ pg_is_in_recovery boolean;
23+ pgVer TEXT;
24+ BEGIN
25+ SELECT pg_is_in_recovery() INTO pg_is_in_recovery;
26+ SELECT postgresVersion into pgVer;
27+ RAISE NOTICE 'pgVer is %', pgVer;
28+ RAISE NOTICE 'version() is %', version();
29+ ASSERT pg_is_in_recovery = FALSE AND
30+ position('PostgreSQL ' || pgVer in version()) > 0;
31+ END $script$;
32+
33+ steps :
34+
35+ - name : ' Create Cluster with PGO CLI'
36+ use :
37+ template : ' ../templates/create-cluster.yaml'
38+
39+ - name : ' Confirm cluster is created'
40+ use :
41+ template : ' ../templates/confirm-created.yaml'
42+
43+ - name : ' Confirm Replica backup completed'
44+ use :
45+ template : ' ../templates/replica-backup-complete.yaml'
46+
47+ - name : ' Verify Postgres is running correct version'
48+ description : >
49+ Confirm that Postgres is running and using the expected version
50+ use :
51+ template : ' ../templates/psql-data.yaml'
52+ with :
53+ bindings :
54+ - name : target
55+ value : ($cluster)
56+ - name : job
57+ value : (join('-', [$cluster, 'verify-version']))
58+ - name : command
59+ value : (replace_all($confirmQuery, 'postgresVersion', $postgresVersion))
60+ ---
61+ apiVersion : chainsaw.kyverno.io/v1alpha1
62+ kind : Test
63+ metadata :
64+ name : create-cluster-without-backups
65+ spec :
66+ bindings :
67+ - name : cluster
68+ value : create-cluster-without-backups
69+
70+ - name : postgresVersion
71+ value : (to_string($values.versions.postgres))
72+
73+ - name : psql
74+ value :
75+ image : ($values.images.psql)
76+ connect : { name: PGCONNECT_TIMEOUT, value: '5' }
77+
78+ - name : confirmQuery
79+ value : |
80+ DO $script$
81+ DECLARE
82+ pg_is_in_recovery boolean;
83+ pgVer TEXT;
84+ BEGIN
85+ SELECT pg_is_in_recovery() INTO pg_is_in_recovery;
86+ SELECT postgresVersion into pgVer;
87+ RAISE NOTICE 'pgVer is %', pgVer;
88+ RAISE NOTICE 'version() is %', version();
89+ ASSERT pg_is_in_recovery = FALSE AND
90+ position('PostgreSQL ' || pgVer in version()) > 0;
91+ END $script$;
92+
93+ steps :
94+
95+ - name : ' Create Cluster with PGO CLI'
96+ use :
97+ template : ' ../templates/create-cluster-without-backups.yaml'
98+
99+ - name : ' Confirm cluster is created'
100+ use :
101+ template : ' ../templates/confirm-created.yaml'
102+
103+ - name : ' Verify Postgres is running correct version'
104+ description : >
105+ Confirm that Postgres is running and using the expected version
106+ use :
107+ template : ' ../templates/psql-data.yaml'
108+ with :
109+ bindings :
110+ - name : target
111+ value : ($cluster)
112+ - name : job
113+ value : (join('-', [$cluster, 'verify-version']))
114+ - name : command
115+ value : (replace_all($confirmQuery, 'postgresVersion', $postgresVersion))
116+
117+ - name : Confirm spec.backups is not in the manifest
118+ try :
119+ - error :
120+ resource :
121+ apiVersion : postgres-operator.crunchydata.com/v1beta1
122+ kind : PostgresCluster
123+ metadata :
124+ name : ($cluster)
125+ spec :
126+ backups : {}
0 commit comments