Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions testing/chainsaw/e2e/pgbackrest-restore/chainsaw-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,26 @@ spec:

steps:
- name: 'Create Cluster with replica, tablespace'
use:
use:
template: 'templates/create-cluster.yaml'

- name: 'Create Data'
use:
use:
template: 'templates/psql-data.yaml'
with:
bindings:
- name: target
value: original
- name: job
value: original-data
value: original-data
- name: command
value: |
CREATE SCHEMA IF NOT EXISTS "original";
CREATE TABLE important (data) AS VALUES ('treasure');
CREATE TABLE cows (name) TABLESPACE barn AS VALUES ('nellie');

- name: 'Create Backup #1'
use:
use:
template: 'templates/create-backup.yaml'
with:
bindings:
Expand Down Expand Up @@ -89,11 +89,16 @@ spec:
kind: PostgresCluster
name: clone-one

- name: 'Restart Cluster'
- name: 'Update Cluster'
description: >
Sets a timestamp and restarts the cluster, using the timestamp for comparison
use:
template: 'templates/restart-cluster.yaml'
Update the cluster with parameters that require attention during recovery
use:
template: 'templates/change-parameters.yaml'
with:
bindings:
- name: parameters
value:
max_connections: 1000

- name: 'Update Data'
use:
Expand All @@ -110,9 +115,9 @@ spec:
- name: 'Verify WAL backup'
use:
template: 'templates/verify-backup.yaml'

- name: 'Create Backup #2'
use:
use:
template: 'templates/create-backup.yaml'
with:
bindings:
Expand Down Expand Up @@ -197,5 +202,5 @@ spec:
- name: 'Confirm Replica'
description: >
Verify that the data has streamed and is streaming to the replica
use:
use:
template: 'templates/verify-replica.yaml'
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: StepTemplate
metadata:
name: restart-cluster
name: change-parameters
spec:
bindings:
- name: parameters
value: 'The key/value map of Postgres parameters to change'

try:
-
description: >
Expand Down Expand Up @@ -54,12 +58,11 @@ spec:
name: original
spec:
config:
parameters:
max_connections: 1000
parameters: ($parameters)

-
description: >
Wait for Postgres to restart
Wait for Postgres to restart, signal the WAL archiver, then wait for WAL to archive
script:
skipCommandOutput: true
timeout: 30s
Expand All @@ -78,6 +81,11 @@ spec:
done
echo "${START} != ${BEFORE}"

# Reset counters in the "pg_stat_archiver" view.
# Reset counters in the "pg_stat_archiver" view and signal the archiver.
kubectl exec --namespace "${NAMESPACE}" "${PRIMARY}" \
-- psql -qb --command "SELECT pg_stat_reset_shared('archiver')" --output /dev/null
-- psql -qb --command "SELECT pg_stat_reset_shared('archiver'), pg_switch_wal()"

while [ 0 = "$(
kubectl exec --namespace "${NAMESPACE}" "${PRIMARY}" \
-- psql -qAt --command 'SELECT archived_count FROM pg_stat_archiver'
)" ]; do sleep 1; done
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ spec:
- --command
- DROP TABLE original.important
- --command
- SELECT pg_stat_reset_shared('archiver')
- --command
- SELECT pg_switch_wal()
- SELECT pg_stat_reset_shared('archiver'), pg_switch_wal()

-
description: >
Expand Down
Loading