Skip to content

Commit 0c2ca1b

Browse files
committed
Wait for one WAL archive after changing parameters
This template can now be called multiple times to add different parameter changes to the WAL stream. The test still only changes one parameter once because waiting for restarts and archives is slow.
1 parent 7fb3901 commit 0c2ca1b

File tree

3 files changed

+31
-20
lines changed

3 files changed

+31
-20
lines changed

testing/chainsaw/e2e/pgbackrest-restore/chainsaw-test.yaml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,26 @@ spec:
2121

2222
steps:
2323
- name: 'Create Cluster with replica, tablespace'
24-
use:
24+
use:
2525
template: 'templates/create-cluster.yaml'
2626

2727
- name: 'Create Data'
28-
use:
28+
use:
2929
template: 'templates/psql-data.yaml'
3030
with:
3131
bindings:
3232
- name: target
3333
value: original
3434
- name: job
35-
value: original-data
35+
value: original-data
3636
- name: command
3737
value: |
3838
CREATE SCHEMA IF NOT EXISTS "original";
3939
CREATE TABLE important (data) AS VALUES ('treasure');
4040
CREATE TABLE cows (name) TABLESPACE barn AS VALUES ('nellie');
4141
4242
- name: 'Create Backup #1'
43-
use:
43+
use:
4444
template: 'templates/create-backup.yaml'
4545
with:
4646
bindings:
@@ -89,11 +89,16 @@ spec:
8989
kind: PostgresCluster
9090
name: clone-one
9191

92-
- name: 'Restart Cluster'
92+
- name: 'Update Cluster'
9393
description: >
94-
Sets a timestamp and restarts the cluster, using the timestamp for comparison
95-
use:
96-
template: 'templates/restart-cluster.yaml'
94+
Update the cluster with parameters that require attention during recovery
95+
use:
96+
template: 'templates/change-parameters.yaml'
97+
with:
98+
bindings:
99+
- name: parameters
100+
value:
101+
max_connections: 1000
97102

98103
- name: 'Update Data'
99104
use:
@@ -110,9 +115,9 @@ spec:
110115
- name: 'Verify WAL backup'
111116
use:
112117
template: 'templates/verify-backup.yaml'
113-
118+
114119
- name: 'Create Backup #2'
115-
use:
120+
use:
116121
template: 'templates/create-backup.yaml'
117122
with:
118123
bindings:
@@ -197,5 +202,5 @@ spec:
197202
- name: 'Confirm Replica'
198203
description: >
199204
Verify that the data has streamed and is streaming to the replica
200-
use:
205+
use:
201206
template: 'templates/verify-replica.yaml'

testing/chainsaw/e2e/pgbackrest-restore/templates/restart-cluster.yaml renamed to testing/chainsaw/e2e/pgbackrest-restore/templates/change-parameters.yaml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
apiVersion: chainsaw.kyverno.io/v1alpha1
22
kind: StepTemplate
33
metadata:
4-
name: restart-cluster
4+
name: change-parameters
55
spec:
6+
bindings:
7+
- name: parameters
8+
value: 'The key/value map of Postgres parameters to change'
9+
610
try:
711
-
812
description: >
@@ -54,12 +58,11 @@ spec:
5458
name: original
5559
spec:
5660
config:
57-
parameters:
58-
max_connections: 1000
61+
parameters: ($parameters)
5962

6063
-
6164
description: >
62-
Wait for Postgres to restart
65+
Wait for Postgres to restart, signal the WAL archiver, then wait for WAL to archive
6366
script:
6467
skipCommandOutput: true
6568
timeout: 30s
@@ -78,6 +81,11 @@ spec:
7881
done
7982
echo "${START} != ${BEFORE}"
8083
81-
# Reset counters in the "pg_stat_archiver" view.
84+
# Reset counters in the "pg_stat_archiver" view and signal the archiver.
8285
kubectl exec --namespace "${NAMESPACE}" "${PRIMARY}" \
83-
-- psql -qb --command "SELECT pg_stat_reset_shared('archiver')" --output /dev/null
86+
-- psql -qb --command "SELECT pg_stat_reset_shared('archiver'), pg_switch_wal()"
87+
88+
while [ 0 = "$(
89+
kubectl exec --namespace "${NAMESPACE}" "${PRIMARY}" \
90+
-- psql -qAt --command 'SELECT archived_count FROM pg_stat_archiver'
91+
)" ]; do sleep 1; done

testing/chainsaw/e2e/pgbackrest-restore/templates/lose-data.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ spec:
6262
- --command
6363
- DROP TABLE original.important
6464
- --command
65-
- SELECT pg_stat_reset_shared('archiver')
66-
- --command
67-
- SELECT pg_switch_wal()
65+
- SELECT pg_stat_reset_shared('archiver'), pg_switch_wal()
6866

6967
-
7068
description: >

0 commit comments

Comments
 (0)