mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-01-09 14:45:47 +02:00
6de8b16403
This new facility has the advantage on not relying on static data when generating the tests making the whole facility more robust. This is basically taken from the upstream project pg_rman and adapted for the sake of this pet project, so most of the credit go to Kyotaro Horiguchi and Amit Langote regarding this facility. However I have adapted a bunch of things and fixed a lot of redundancy and code duplication.
72 lines
2.2 KiB
Bash
72 lines
2.2 KiB
Bash
#!/bin/bash
|
|
|
|
#============================================================================
|
|
# This is a test script for init command of pg_arman.
|
|
#============================================================================
|
|
|
|
# Load common rules
|
|
. sql/common.sh init
|
|
|
|
# clean and create database cluster
|
|
pg_ctl stop -m immediate > /dev/null 2>&1
|
|
rm -fr ${PGDATA}
|
|
rm -fr ${BACKUP_PATH}
|
|
rm -fr ${ARCLOG_PATH} && mkdir -p ${ARCLOG_PATH}
|
|
|
|
initdb --no-locale > /dev/null 2>&1
|
|
cp ${PGDATA}/postgresql.conf ${PGDATA}/postgresql.conf_org
|
|
cat << EOF >> ${PGDATA}/postgresql.conf
|
|
wal_level = hot_standby
|
|
archive_mode = on
|
|
archive_command = 'cp "%p" "${ARCLOG_PATH}/%f"'
|
|
EOF
|
|
|
|
echo '###### INIT COMMAND TEST-0001 ######'
|
|
echo '###### success with archive_command ######'
|
|
pg_arman -B ${BACKUP_PATH} init --quiet;echo $?
|
|
find results/init/backup | xargs ls -Fd | sort
|
|
|
|
echo '###### INIT COMMAND TEST-0002 ######'
|
|
echo '###### success with archive_command and log_directory ######'
|
|
rm -rf ${BACKUP_PATH}
|
|
cp ${PGDATA_PATH}/postgresql.conf_org ${PGDATA_PATH}/postgresql.conf
|
|
cat << EOF >> ${PGDATA}/postgresql.conf
|
|
wal_level = hot_standby
|
|
archive_mode = on
|
|
archive_command = 'cp "%p" "${ARCLOG_PATH}/%f"'
|
|
log_directory = '${SRVLOG_PATH}'
|
|
EOF
|
|
pg_arman -B ${BACKUP_PATH} init --quiet;echo $?
|
|
find results/init/backup | xargs ls -Fd | sort
|
|
|
|
echo '###### INIT COMMAND TEST-0003 ######'
|
|
echo '###### success without archive_command ######'
|
|
rm -rf ${BACKUP_PATH}
|
|
cp ${PGDATA_PATH}/postgresql.conf_org ${PGDATA_PATH}/postgresql.conf
|
|
cat << EOF >> ${PGDATA}/postgresql.conf
|
|
wal_level = hot_standby
|
|
archive_mode = on
|
|
log_directory = '${SRVLOG_PATH}'
|
|
EOF
|
|
pg_arman -B ${BACKUP_PATH} init --quiet;echo $?
|
|
find results/init/backup | xargs ls -Fd | sort
|
|
|
|
echo '###### INIT COMMAND TEST-0004 ######'
|
|
echo '###### failure with backup catalog already existed ######'
|
|
pg_arman -B ${BACKUP_PATH} init;echo $?
|
|
echo ''
|
|
|
|
echo '###### INIT COMMAND TEST-0005 ######'
|
|
echo '###### failure with backup catalog should be given as absolute path ######'
|
|
rm -rf ${BACKUP_PATH}
|
|
pg_arman --backup-path=resuts/init/backup init;echo $?
|
|
echo ''
|
|
|
|
|
|
# clean up the temporal test data
|
|
pg_ctl stop -m immediate > /dev/null 2>&1
|
|
rm -fr ${PGDATA}
|
|
rm -fr ${BACKUP_PATH}
|
|
rm -fr ${ARCLOG_PATH}
|
|
rm -fr ${SRVLOG_PATH}
|