mirror of
https://0xacab.org/liberate/backupninja.git
synced 2024-11-23 03:02:32 +01:00
tests: use runaction and global vars in pqsql test
This commit is contained in:
parent
a5ab1cbe78
commit
0cf6e0a3c8
104
test/pgsql.bats
104
test/pgsql.bats
@ -13,7 +13,7 @@ begin_pgsql() {
|
|||||||
setup_pgsql() {
|
setup_pgsql() {
|
||||||
cat << EOF > "${BATS_TMPDIR}/backup.d/test.pgsql"
|
cat << EOF > "${BATS_TMPDIR}/backup.d/test.pgsql"
|
||||||
databases = all
|
databases = all
|
||||||
backupdir = /var/backups/postgres
|
backupdir = ${BN_BACKUPDIR}/postgres
|
||||||
compress = yes
|
compress = yes
|
||||||
format = plain
|
format = plain
|
||||||
EOF
|
EOF
|
||||||
@ -29,141 +29,141 @@ finish_pgsql() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
teardown_pgsql() {
|
teardown_pgsql() {
|
||||||
rm -rf /var/backups/postgres
|
cleanup_backups local
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "plain: exports all databases, with compression" {
|
@test "plain: exports all databases, with compression" {
|
||||||
setconfig backup.d/test.pgsql databases all
|
setconfig backup.d/test.pgsql databases all
|
||||||
setconfig backup.d/test.pgsql compress yes
|
setconfig backup.d/test.pgsql compress yes
|
||||||
setconfig backup.d/test.pgsql format plain
|
setconfig backup.d/test.pgsql format plain
|
||||||
run backupninja -f "${BATS_TMPDIR}/backupninja.conf" --now --run "${BATS_TMPDIR}/backup.d/test.pgsql"
|
runaction test.pgsql
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
gzip -tq /var/backups/postgres/bntest0-all.sql.gz
|
gzip -tq "${BN_BACKUPDIR}/postgres/bntest0-all.sql.gz"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "plain: exports all databases, without compression" {
|
@test "plain: exports all databases, without compression" {
|
||||||
setconfig backup.d/test.pgsql databases all
|
setconfig backup.d/test.pgsql databases all
|
||||||
setconfig backup.d/test.pgsql compress no
|
setconfig backup.d/test.pgsql compress no
|
||||||
setconfig backup.d/test.pgsql format plain
|
setconfig backup.d/test.pgsql format plain
|
||||||
run backupninja -f "${BATS_TMPDIR}/backupninja.conf" --now --run "${BATS_TMPDIR}/backup.d/test.pgsql"
|
runaction test.pgsql
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[ -s /var/backups/postgres/bntest0-all.sql ]
|
[ -s "${BN_BACKUPDIR}/postgres/bntest0-all.sql" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "plain: exports specific database, with compression" {
|
@test "plain: exports specific database, with compression" {
|
||||||
setconfig backup.d/test.pgsql databases bntest_v11vJj
|
setconfig backup.d/test.pgsql databases bntest_v11vJj
|
||||||
setconfig backup.d/test.pgsql compress yes
|
setconfig backup.d/test.pgsql compress yes
|
||||||
setconfig backup.d/test.pgsql format plain
|
setconfig backup.d/test.pgsql format plain
|
||||||
run backupninja -f "${BATS_TMPDIR}/backupninja.conf" --now --run "${BATS_TMPDIR}/backup.d/test.pgsql"
|
runaction test.pgsql
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
gzip -tq /var/backups/postgres/bntest_v11vJj.sql.gz
|
gzip -tq "${BN_BACKUPDIR}/postgres/bntest_v11vJj.sql.gz"
|
||||||
[ "$(zgrep -c -e '^COPY' /var/backups/postgres/bntest_v11vJj.sql.gz)" -eq 68 ]
|
[ "$(zgrep -c -e '^COPY' ${BN_BACKUPDIR}/postgres/bntest_v11vJj.sql.gz)" -eq 68 ]
|
||||||
[ ! -e /var/backups/postgres/bntest_p8Cz8k.sql.gz ]
|
[ ! -e "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.sql.gz" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "plain: exports specific database, without compression" {
|
@test "plain: exports specific database, without compression" {
|
||||||
setconfig backup.d/test.pgsql databases bntest_v11vJj
|
setconfig backup.d/test.pgsql databases bntest_v11vJj
|
||||||
setconfig backup.d/test.pgsql compress no
|
setconfig backup.d/test.pgsql compress no
|
||||||
setconfig backup.d/test.pgsql format plain
|
setconfig backup.d/test.pgsql format plain
|
||||||
run backupninja -f "${BATS_TMPDIR}/backupninja.conf" --now --run "${BATS_TMPDIR}/backup.d/test.pgsql"
|
runaction test.pgsql
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[ -s /var/backups/postgres/bntest_v11vJj.sql ]
|
[ -s "${BN_BACKUPDIR}/postgres/bntest_v11vJj.sql" ]
|
||||||
[ "$(grep -c -e '^COPY' /var/backups/postgres/bntest_v11vJj.sql)" -eq 68 ]
|
[ "$(grep -c -e '^COPY' ${BN_BACKUPDIR}/postgres/bntest_v11vJj.sql)" -eq 68 ]
|
||||||
[ ! -e /var/backups/postgres/bntest_p8Cz8k.sql ]
|
[ ! -e "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.sql" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "tar: exports all databases, with compression" {
|
@test "tar: exports all databases, with compression" {
|
||||||
setconfig backup.d/test.pgsql databases all
|
setconfig backup.d/test.pgsql databases all
|
||||||
setconfig backup.d/test.pgsql compress yes
|
setconfig backup.d/test.pgsql compress yes
|
||||||
setconfig backup.d/test.pgsql format tar
|
setconfig backup.d/test.pgsql format tar
|
||||||
run backupninja -f "${BATS_TMPDIR}/backupninja.conf" --now --run "${BATS_TMPDIR}/backup.d/test.pgsql"
|
runaction test.pgsql
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
gzip -tq /var/backups/postgres/bntest_p8Cz8k.pg_dump.gz
|
gzip -tq "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump.gz"
|
||||||
gzip -tq /var/backups/postgres/bntest_v11vJj.pg_dump.gz
|
gzip -tq "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump.gz"
|
||||||
gzip -tq /var/backups/postgres/globals.sql.gz
|
gzip -tq "${BN_BACKUPDIR}/postgres/globals.sql.gz"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "tar: exports all databases, without compression" {
|
@test "tar: exports all databases, without compression" {
|
||||||
setconfig backup.d/test.pgsql databases all
|
setconfig backup.d/test.pgsql databases all
|
||||||
setconfig backup.d/test.pgsql compress no
|
setconfig backup.d/test.pgsql compress no
|
||||||
setconfig backup.d/test.pgsql format tar
|
setconfig backup.d/test.pgsql format tar
|
||||||
run backupninja -f "${BATS_TMPDIR}/backupninja.conf" --now --run "${BATS_TMPDIR}/backup.d/test.pgsql"
|
runaction test.pgsql
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[ -s /var/backups/postgres/bntest_p8Cz8k.pg_dump ]
|
[ -s "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump" ]
|
||||||
[ -s /var/backups/postgres/bntest_v11vJj.pg_dump ]
|
[ -s "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump" ]
|
||||||
file /var/backups/postgres/bntest_p8Cz8k.pg_dump | grep "POSIX tar archive"
|
file ${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump | grep "POSIX tar archive"
|
||||||
file /var/backups/postgres/bntest_v11vJj.pg_dump | grep "POSIX tar archive"
|
file ${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump | grep "POSIX tar archive"
|
||||||
[ -s /var/backups/postgres/globals.sql ]
|
[ -s "${BN_BACKUPDIR}/postgres/globals.sql" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "tar: exports specific database, with compression" {
|
@test "tar: exports specific database, with compression" {
|
||||||
setconfig backup.d/test.pgsql databases bntest_v11vJj
|
setconfig backup.d/test.pgsql databases bntest_v11vJj
|
||||||
setconfig backup.d/test.pgsql compress yes
|
setconfig backup.d/test.pgsql compress yes
|
||||||
setconfig backup.d/test.pgsql format tar
|
setconfig backup.d/test.pgsql format tar
|
||||||
run backupninja -f "${BATS_TMPDIR}/backupninja.conf" --now --run "${BATS_TMPDIR}/backup.d/test.pgsql"
|
runaction test.pgsql
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
gzip -tq /var/backups/postgres/bntest_v11vJj.pg_dump.gz
|
gzip -tq "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump.gz"
|
||||||
[ ! -e /var/backups/postgres/bntest_p8Cz8k.pg_dump.gz ]
|
[ ! -e "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump.gz" ]
|
||||||
[ ! -e /var/backups/postgres/globals.sql.gz ]
|
[ ! -e "${BN_BACKUPDIR}/postgres/globals.sql.gz" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "tar: exports specific database, without compression" {
|
@test "tar: exports specific database, without compression" {
|
||||||
setconfig backup.d/test.pgsql databases bntest_v11vJj
|
setconfig backup.d/test.pgsql databases bntest_v11vJj
|
||||||
setconfig backup.d/test.pgsql compress no
|
setconfig backup.d/test.pgsql compress no
|
||||||
setconfig backup.d/test.pgsql format tar
|
setconfig backup.d/test.pgsql format tar
|
||||||
run backupninja -f "${BATS_TMPDIR}/backupninja.conf" --now --run "${BATS_TMPDIR}/backup.d/test.pgsql"
|
runaction test.pgsql
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[ -s /var/backups/postgres/bntest_v11vJj.pg_dump ]
|
[ -s "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump" ]
|
||||||
file /var/backups/postgres/bntest_v11vJj.pg_dump | grep -q "POSIX tar archive"
|
file ${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump | grep -q "POSIX tar archive"
|
||||||
[ ! -e /var/backups/postgres/bntest_p8Cz8k.pg_dump ]
|
[ ! -e "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump" ]
|
||||||
[ ! -e /var/backups/postgres/globals.sql ]
|
[ ! -e "${BN_BACKUPDIR}/postgres/globals.sql" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "custom: exports all databases, with compression" {
|
@test "custom: exports all databases, with compression" {
|
||||||
setconfig backup.d/test.pgsql databases all
|
setconfig backup.d/test.pgsql databases all
|
||||||
setconfig backup.d/test.pgsql compress yes
|
setconfig backup.d/test.pgsql compress yes
|
||||||
setconfig backup.d/test.pgsql format custom
|
setconfig backup.d/test.pgsql format custom
|
||||||
run backupninja -f "${BATS_TMPDIR}/backupninja.conf" --now --run "${BATS_TMPDIR}/backup.d/test.pgsql"
|
runaction test.pgsql
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
gzip -tq /var/backups/postgres/bntest_p8Cz8k.pg_dump.gz
|
gzip -tq "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump.gz"
|
||||||
gzip -tq /var/backups/postgres/bntest_v11vJj.pg_dump.gz
|
gzip -tq "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump.gz"
|
||||||
gzip -tq /var/backups/postgres/globals.sql.gz
|
gzip -tq "${BN_BACKUPDIR}/postgres/globals.sql.gz"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "custom: exports all databases, without compression" {
|
@test "custom: exports all databases, without compression" {
|
||||||
setconfig backup.d/test.pgsql databases all
|
setconfig backup.d/test.pgsql databases all
|
||||||
setconfig backup.d/test.pgsql compress no
|
setconfig backup.d/test.pgsql compress no
|
||||||
setconfig backup.d/test.pgsql format custom
|
setconfig backup.d/test.pgsql format custom
|
||||||
run backupninja -f "${BATS_TMPDIR}/backupninja.conf" --now --run "${BATS_TMPDIR}/backup.d/test.pgsql"
|
runaction test.pgsql
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[ -s /var/backups/postgres/bntest_p8Cz8k.pg_dump ]
|
[ -s "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump" ]
|
||||||
[ -s /var/backups/postgres/bntest_v11vJj.pg_dump ]
|
[ -s "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump" ]
|
||||||
file /var/backups/postgres/bntest_p8Cz8k.pg_dump | grep -q "PostgreSQL custom database dump"
|
file "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump" | grep -q "PostgreSQL custom database dump"
|
||||||
file /var/backups/postgres/bntest_v11vJj.pg_dump | grep -q "PostgreSQL custom database dump"
|
file "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump" | grep -q "PostgreSQL custom database dump"
|
||||||
[ -s /var/backups/postgres/globals.sql ]
|
[ -s "${BN_BACKUPDIR}/postgres/globals.sql" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "custom: exports specific database, with compression" {
|
@test "custom: exports specific database, with compression" {
|
||||||
setconfig backup.d/test.pgsql databases bntest_v11vJj
|
setconfig backup.d/test.pgsql databases bntest_v11vJj
|
||||||
setconfig backup.d/test.pgsql compress yes
|
setconfig backup.d/test.pgsql compress yes
|
||||||
setconfig backup.d/test.pgsql format custom
|
setconfig backup.d/test.pgsql format custom
|
||||||
run backupninja -f "${BATS_TMPDIR}/backupninja.conf" --now --run "${BATS_TMPDIR}/backup.d/test.pgsql"
|
runaction test.pgsql
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
gzip -tq /var/backups/postgres/bntest_v11vJj.pg_dump.gz
|
gzip -tq "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump.gz"
|
||||||
[ ! -e /var/backups/postgres/bntest_p8Cz8k.pg_dump.gz ]
|
[ ! -e "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump.gz" ]
|
||||||
[ ! -e /var/backups/postgres/globals.sql.gz ]
|
[ ! -e "${BN_BACKUPDIR}/postgres/globals.sql.gz" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "custom: exports specific database, without compression" {
|
@test "custom: exports specific database, without compression" {
|
||||||
setconfig backup.d/test.pgsql databases bntest_v11vJj
|
setconfig backup.d/test.pgsql databases bntest_v11vJj
|
||||||
setconfig backup.d/test.pgsql compress no
|
setconfig backup.d/test.pgsql compress no
|
||||||
setconfig backup.d/test.pgsql format custom
|
setconfig backup.d/test.pgsql format custom
|
||||||
run backupninja -f "${BATS_TMPDIR}/backupninja.conf" --now --run "${BATS_TMPDIR}/backup.d/test.pgsql"
|
runaction test.pgsql
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[ -s /var/backups/postgres/bntest_v11vJj.pg_dump ]
|
[ -s "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump" ]
|
||||||
file /var/backups/postgres/bntest_v11vJj.pg_dump | grep -q "PostgreSQL custom database dump"
|
file "${BN_BACKUPDIR}/postgres/bntest_v11vJj.pg_dump" | grep -q "PostgreSQL custom database dump"
|
||||||
[ ! -e /var/backups/postgres/bntest_p8Cz8k.pg_dump ]
|
[ ! -e "${BN_BACKUPDIR}/postgres/bntest_p8Cz8k.pg_dump" ]
|
||||||
[ ! -e /var/backups/postgres/globals.sql ]
|
[ ! -e "${BN_BACKUPDIR}/postgres/globals.sql" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user