1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-15 01:04:37 +02:00

Simplify test matrix for real/all tests.

Test matrices were previously simplified for the mock/* tests (e.g. d4410611, d489eb87) but not for real/all since the rules for which tests would run with which options was extremely complex. This only got more complex when new compression formats were added.

Because the loop-generated matrix was so large, mosts tests were skipped for most option combinations following arcane logic which was nearly impossible to decipher even when reading the code, and completely impossible from the test.pl interface. As a consequence, important tests got excluded. For example, backup from standby was excluded for most versions of PostgreSQL because it was only run once per distro, against the latest version to be included in that distro.

Simplify the tests by having a single run per PostgreSQL version and vary test parameters according to the capabilities of each version and the underlying distro. So, ZST testing is based on whether the distro supports ZST. Every test is run for each set of parameters based on the capabilities of the PostgreSQL version, e.g. backup from standby is not attempted on versions that don't support it.

Note that since more tests are running the overall time to run the mock/all tests has increased by about 20-25%. Some time may be saved my removing tests that are adequately covered by unit tests but that should the subject of another commit. Another option would be to limit some non version-specific tests to a single, well defined version of PostgreSQL, .e.g the version that is run by expect tests, currently 9.6.

The motivation for this refactor is that new storage drivers are coming and the loop-generated test matrix simply was not up to the task of adding them.

The following is an example of the new test log (note longer runtime of each test):

module=real, test=all, run=1, pg-version=10 (106.91s)
module=real, test=all, run=1, pg-version=9.5 (151.09s)
module=real, test=all, run=1, pg-version=9.2 (123.11s)
module=real, test=all, run=1, pg-version=9.1 (129s)

vs. the old test log (sub-second tests were skipped entirely):

module=real, test=all, run=2, pg-version=10 (0.31s)
module=real, test=all, run=3, pg-version=10 (0.26s)
module=real, test=all, run=4, pg-version=10 (60.39s)
module=real, test=all, run=1, pg-version=10 (69.12s)
module=real, test=all, run=6, pg-version=10 (34s)
module=real, test=all, run=5, pg-version=10 (42.75s)
module=real, test=all, run=2, pg-version=9.5 (0.21s)
module=real, test=all, run=3, pg-version=9.5 (0.21s)
module=real, test=all, run=4, pg-version=9.5 (0.21s)
module=real, test=all, run=5, pg-version=9.5 (0.26s)
module=real, test=all, run=6, pg-version=9.5 (0.21s)
module=real, test=all, run=1, pg-version=9.2 (72.78s)
module=real, test=all, run=2, pg-version=9.2 (0.26s)
module=real, test=all, run=3, pg-version=9.2 (0.31s)
module=real, test=all, run=4, pg-version=9.2 (0.21s)
module=real, test=all, run=5, pg-version=9.2 (0.21s)
module=real, test=all, run=6, pg-version=9.2 (0.21s)
module=real, test=all, run=1, pg-version=9.5 (88.41s)
module=real, test=all, run=2, pg-version=9.1 (0.21s)
module=real, test=all, run=3, pg-version=9.1 (0.26s)
module=real, test=all, run=4, pg-version=9.1 (0.21s)
module=real, test=all, run=5, pg-version=9.1 (0.31s)
module=real, test=all, run=6, pg-version=9.1 (0.26s)
module=real, test=all, run=1, pg-version=9.1 (72.4s)
This commit is contained in:
David Steele
2020-06-23 13:44:29 -04:00
parent d560c1bf19
commit a3e5e66f05
3 changed files with 886 additions and 495 deletions

View File

@ -727,7 +727,7 @@ integration:
test:
# ----------------------------------------------------------------------------------------------------------------------------
- name: all
total: 6
total: 1
# **********************************************************************************************************************************
# Performance tests

View File

@ -1,30 +1,38 @@
run 001 - bkp 0, sby 0, dst db-primary, cmp none, storage posix, enc 0
======================================================================
run 001 - bkp 1, sby 1, dst backup, cmp none, storage posix, enc 0
==================================================================
stanza-create db - main create stanza info files (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf --stanza=db stanza-create
stanza-create db - main create stanza info files (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --stanza=db stanza-create
------------------------------------------------------------------------------------------------------------------------------------
check db - fail on missing archive.info file (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf --archive-timeout=0.1 --stanza=db check
------------------------------------------------------------------------------------------------------------------------------------
full backup - fail on archive_mode=off (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf --type=full --stanza=db backup
full backup - fail on archive_mode=off (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --type=full --stanza=db backup
------------------------------------------------------------------------------------------------------------------------------------
check db - fail on archive_mode=off (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf --archive-timeout=0.1 --stanza=db check
------------------------------------------------------------------------------------------------------------------------------------
full backup - fail on invalid archive_command (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf --type=full --stanza=db backup
check db - fail on archive_mode=off (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --archive-timeout=0.1 --reset-pg2-host --reset-pg2-path --stanza=db check
------------------------------------------------------------------------------------------------------------------------------------
full backup - fail on invalid archive_command (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --type=full --stanza=db backup
------------------------------------------------------------------------------------------------------------------------------------
check db - fail on invalid archive_command (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf --archive-timeout=0.1 --stanza=db check
------------------------------------------------------------------------------------------------------------------------------------
check db - fail on invalid archive_command (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --archive-timeout=0.1 --reset-pg2-host --reset-pg2-path --stanza=db check
------------------------------------------------------------------------------------------------------------------------------------
check db - fail on archive timeout when archive-check=n (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf --archive-timeout=0.1 --no-archive-check --stanza=db check
------------------------------------------------------------------------------------------------------------------------------------
@ -33,44 +41,64 @@ check db - verify success (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf --archive-timeout=5 --stanza=db check
------------------------------------------------------------------------------------------------------------------------------------
check db - verify success (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --archive-timeout=5 --reset-pg2-host --reset-pg2-path --stanza=db check
------------------------------------------------------------------------------------------------------------------------------------
check db - fail on archive mismatch after upgrade (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf --archive-timeout=0.1 --stanza=db check
------------------------------------------------------------------------------------------------------------------------------------
check db - fail on archive mismatch after upgrade (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --archive-timeout=0.1 --reset-pg2-host --reset-pg2-path --stanza=db check
------------------------------------------------------------------------------------------------------------------------------------
check db - fail on archive timeout (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf --archive-timeout=0.1 --stanza=db check
------------------------------------------------------------------------------------------------------------------------------------
check db - fail on archive timeout (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --archive-timeout=0.1 --reset-pg2-host --reset-pg2-path --stanza=db check
------------------------------------------------------------------------------------------------------------------------------------
check db - fail on backup info mismatch (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf --archive-timeout=5 --stanza=db check
------------------------------------------------------------------------------------------------------------------------------------
check db - fail on backup info mismatch (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --archive-timeout=5 --reset-pg2-host --reset-pg2-path --stanza=db check
------------------------------------------------------------------------------------------------------------------------------------
check db - verify success after backup (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf --archive-timeout=5 --stanza=db check
------------------------------------------------------------------------------------------------------------------------------------
stanza-create db - fail on backup info file missing from non-empty dir (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf --stanza=db stanza-create
check db - verify success after backup (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --archive-timeout=5 --reset-pg2-host --reset-pg2-path --stanza=db check
------------------------------------------------------------------------------------------------------------------------------------
stanza-create db - fail on database mismatch with directory (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf --stanza=db --pg1-path=[TEST_PATH]/db-primary/db/testbase/ stanza-create
stanza-create db - fail on backup info file missing from non-empty dir (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --stanza=db stanza-create
------------------------------------------------------------------------------------------------------------------------------------
stanza-create db - successfully create stanza files to be upgraded (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf --stanza=db --pg1-path=[TEST_PATH]/db-primary/db/testbase/ --no-online --force stanza-create
stanza-create db - fail on database mismatch with directory (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --stanza=db --pg1-path=[TEST_PATH]/db-primary/db/testbase/ stanza-create
------------------------------------------------------------------------------------------------------------------------------------
stanza-upgrade db - upgrade stanza files online (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf --stanza=db stanza-upgrade
stanza-create db - successfully create stanza files to be upgraded (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --stanza=db --pg1-path=[TEST_PATH]/db-primary/db/testbase/ --no-online stanza-create
------------------------------------------------------------------------------------------------------------------------------------
full backup - fail on backup lock exists (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf --type=full --stanza=db backup
stanza-upgrade db - upgrade stanza files online (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --stanza=db stanza-upgrade
------------------------------------------------------------------------------------------------------------------------------------
full backup - update during backup (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf --buffer-size=[BUFFER-SIZE] --type=full --stanza=db backup
full backup - fail on backup lock exists (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --type=full --stanza=db backup
------------------------------------------------------------------------------------------------------------------------------------
full backup - update during backup (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --buffer-size=[BUFFER-SIZE] --type=full --stanza=db backup
------------------------------------------------------------------------------------------------------------------------------------
+ supplemental file: [TEST_PATH]/db-primary/pgbackrest.conf
@ -83,6 +111,7 @@ pg1-socket-path=[TEST_PATH]/db-primary/db
[global]
buffer-size=[BUFFER-SIZE]
compress-level=3
compress-level-network=1
compress-type=none
db-timeout=45
lock-path=[TEST_PATH]/db-primary/lock
@ -93,15 +122,97 @@ log-path=[TEST_PATH]/db-primary/log
log-subprocess=[LOG-SUBPROCESS]
log-timestamp=n
protocol-timeout=60
repo1-path=[TEST_PATH]/db-primary/repo
repo1-host=backup
repo1-host-cmd=[BACKREST-BIN]
repo1-host-config=[TEST_PATH]/backup/pgbackrest.conf
repo1-host-user=[USER-1]
spool-path=[TEST_PATH]/db-primary/spool
+ supplemental file: [TEST_PATH]/db-standby/pgbackrest.conf
-----------------------------------------------------------
[db]
pg1-path=[TEST_PATH]/db-standby/db/base
pg1-port=6544
pg1-socket-path=[TEST_PATH]/db-standby/db
[global]
buffer-size=[BUFFER-SIZE]
compress-level=3
compress-level-network=1
compress-type=none
db-timeout=45
lock-path=[TEST_PATH]/db-standby/lock
log-level-console=detail
log-level-file=[LOG-LEVEL-FILE]
log-level-stderr=off
log-path=[TEST_PATH]/db-standby/log
log-subprocess=[LOG-SUBPROCESS]
log-timestamp=n
protocol-timeout=60
repo1-host=backup
repo1-host-cmd=[BACKREST-BIN]
repo1-host-config=[TEST_PATH]/backup/pgbackrest.conf
repo1-host-user=[USER-1]
spool-path=[TEST_PATH]/db-standby/spool
+ supplemental file: [TEST_PATH]/backup/pgbackrest.conf
-------------------------------------------------------
[db]
pg1-host=db-primary
pg1-host-cmd=[BACKREST-BIN]
pg1-host-config=[TEST_PATH]/db-primary/pgbackrest.conf
pg1-host-user=[USER-1]
pg1-path=[TEST_PATH]/db-primary/db/base
pg1-port=6543
pg2-host=bogus
pg2-host-cmd=[BACKREST-BIN]
pg2-host-config=[TEST_PATH]/db-standby/pgbackrest.conf
pg2-host-user=[USER-1]
pg2-path=[TEST_PATH]/db-standby/db/base
pg8-host=db-standby
pg8-host-cmd=[BACKREST-BIN]
pg8-host-config=[TEST_PATH]/db-standby/pgbackrest.conf
pg8-host-user=[USER-1]
pg8-path=[TEST_PATH]/db-standby/db/base
pg8-port=6544
[global]
buffer-size=[BUFFER-SIZE]
compress-level=3
compress-level-network=1
compress-type=none
db-timeout=45
lock-path=[TEST_PATH]/backup/lock
log-level-console=detail
log-level-file=[LOG-LEVEL-FILE]
log-level-stderr=off
log-path=[TEST_PATH]/backup/log
log-subprocess=[LOG-SUBPROCESS]
log-timestamp=n
protocol-timeout=60
repo1-path=[TEST_PATH]/backup/repo
[global:backup]
archive-copy=y
start-fast=y
diff backup - backup for adhoc expire (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf --type=diff --stanza=db backup
restore, type 'standby', remap - restore backup on replica (db-standby host)
> [CONTAINER-EXEC] db-standby [BACKREST-BIN] --config=[TEST_PATH]/db-standby/pgbackrest.conf --recovery-option="primary_conninfo=host=db-primary port=6543 user=replicator" --type=standby --link-map="pg_xlog=[TEST_PATH]/db-standby/db/pg_xlog" --link-all --stanza=db restore
------------------------------------------------------------------------------------------------------------------------------------
+ supplemental file: [TEST_PATH]/db-standby/db/base/recovery.conf
-----------------------------------------------------------------
# Recovery settings generated by pgBackRest restore on [TIMESTAMP]
primary_conninfo = 'host=db-primary port=6543 user=replicator'
restore_command = '[BACKREST-BIN] --config=[TEST_PATH]/db-standby/pgbackrest.conf --stanza=db archive-get %f "%p"'
standby_mode = 'on'
full backup - backup from standby, failure to access at least one standby (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --pg8-host=bogus --backup-standby --type=full --stanza=db backup
------------------------------------------------------------------------------------------------------------------------------------
full backup - backup from standby (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --repo1-retention-full=1 --backup-standby --type=full --stanza=db backup
------------------------------------------------------------------------------------------------------------------------------------
+ supplemental file: [TEST_PATH]/db-primary/pgbackrest.conf
@ -112,9 +223,9 @@ pg1-port=6543
pg1-socket-path=[TEST_PATH]/db-primary/db
[global]
archive-async=y
buffer-size=[BUFFER-SIZE]
compress-level=3
compress-level-network=1
compress-type=none
db-timeout=45
lock-path=[TEST_PATH]/db-primary/lock
@ -125,9 +236,185 @@ log-path=[TEST_PATH]/db-primary/log
log-subprocess=[LOG-SUBPROCESS]
log-timestamp=n
protocol-timeout=60
repo1-path=[TEST_PATH]/db-primary/repo
repo1-host=backup
repo1-host-cmd=[BACKREST-BIN]
repo1-host-config=[TEST_PATH]/backup/pgbackrest.conf
repo1-host-user=[USER-1]
spool-path=[TEST_PATH]/db-primary/spool
+ supplemental file: [TEST_PATH]/db-standby/pgbackrest.conf
-----------------------------------------------------------
[db]
pg1-path=[TEST_PATH]/db-standby/db/base
pg1-port=6544
pg1-socket-path=[TEST_PATH]/db-standby/db
[db:restore]
[global]
buffer-size=[BUFFER-SIZE]
compress-level=3
compress-level-network=1
compress-type=none
db-timeout=45
lock-path=[TEST_PATH]/db-standby/lock
log-level-console=detail
log-level-file=[LOG-LEVEL-FILE]
log-level-stderr=off
log-path=[TEST_PATH]/db-standby/log
log-subprocess=[LOG-SUBPROCESS]
log-timestamp=n
protocol-timeout=60
repo1-host=backup
repo1-host-cmd=[BACKREST-BIN]
repo1-host-config=[TEST_PATH]/backup/pgbackrest.conf
repo1-host-user=[USER-1]
spool-path=[TEST_PATH]/db-standby/spool
+ supplemental file: [TEST_PATH]/backup/pgbackrest.conf
-------------------------------------------------------
[db]
pg1-host=db-primary
pg1-host-cmd=[BACKREST-BIN]
pg1-host-config=[TEST_PATH]/db-primary/pgbackrest.conf
pg1-host-user=[USER-1]
pg1-path=[TEST_PATH]/db-primary/db/base
pg1-port=6543
pg2-host=bogus
pg2-host-cmd=[BACKREST-BIN]
pg2-host-config=[TEST_PATH]/db-standby/pgbackrest.conf
pg2-host-user=[USER-1]
pg2-path=[TEST_PATH]/db-standby/db/base
pg8-host=db-standby
pg8-host-cmd=[BACKREST-BIN]
pg8-host-config=[TEST_PATH]/db-standby/pgbackrest.conf
pg8-host-user=[USER-1]
pg8-path=[TEST_PATH]/db-standby/db/base
pg8-port=6544
[global]
archive-async=y
buffer-size=[BUFFER-SIZE]
compress-level=3
compress-level-network=1
compress-type=none
db-timeout=45
lock-path=[TEST_PATH]/backup/lock
log-level-console=detail
log-level-file=[LOG-LEVEL-FILE]
log-level-stderr=off
log-path=[TEST_PATH]/backup/log
log-subprocess=[LOG-SUBPROCESS]
log-timestamp=n
protocol-timeout=60
repo1-path=[TEST_PATH]/backup/repo
[global:backup]
archive-copy=y
start-fast=y
check db - verify check command on standby (db-standby host)
> [CONTAINER-EXEC] db-standby [BACKREST-BIN] --config=[TEST_PATH]/db-standby/pgbackrest.conf --reset-pg2-host --reset-pg2-path --stanza=db check
------------------------------------------------------------------------------------------------------------------------------------
diff backup - backup for adhoc expire (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --type=diff --stanza=db backup
------------------------------------------------------------------------------------------------------------------------------------
+ supplemental file: [TEST_PATH]/db-primary/pgbackrest.conf
-----------------------------------------------------------
[db]
pg1-path=[TEST_PATH]/db-primary/db/base
pg1-port=6543
pg1-socket-path=[TEST_PATH]/db-primary/db
[global]
buffer-size=[BUFFER-SIZE]
compress-level=3
compress-level-network=1
compress-type=none
db-timeout=45
lock-path=[TEST_PATH]/db-primary/lock
log-level-console=detail
log-level-file=[LOG-LEVEL-FILE]
log-level-stderr=off
log-path=[TEST_PATH]/db-primary/log
log-subprocess=[LOG-SUBPROCESS]
log-timestamp=n
protocol-timeout=60
repo1-host=backup
repo1-host-cmd=[BACKREST-BIN]
repo1-host-config=[TEST_PATH]/backup/pgbackrest.conf
repo1-host-user=[USER-1]
spool-path=[TEST_PATH]/db-primary/spool
+ supplemental file: [TEST_PATH]/db-standby/pgbackrest.conf
-----------------------------------------------------------
[db]
pg1-path=[TEST_PATH]/db-standby/db/base
pg1-port=6544
pg1-socket-path=[TEST_PATH]/db-standby/db
[db:restore]
[global]
buffer-size=[BUFFER-SIZE]
compress-level=3
compress-level-network=1
compress-type=none
db-timeout=45
lock-path=[TEST_PATH]/db-standby/lock
log-level-console=detail
log-level-file=[LOG-LEVEL-FILE]
log-level-stderr=off
log-path=[TEST_PATH]/db-standby/log
log-subprocess=[LOG-SUBPROCESS]
log-timestamp=n
protocol-timeout=60
repo1-host=backup
repo1-host-cmd=[BACKREST-BIN]
repo1-host-config=[TEST_PATH]/backup/pgbackrest.conf
repo1-host-user=[USER-1]
spool-path=[TEST_PATH]/db-standby/spool
+ supplemental file: [TEST_PATH]/backup/pgbackrest.conf
-------------------------------------------------------
[db]
pg1-host=db-primary
pg1-host-cmd=[BACKREST-BIN]
pg1-host-config=[TEST_PATH]/db-primary/pgbackrest.conf
pg1-host-user=[USER-1]
pg1-path=[TEST_PATH]/db-primary/db/base
pg1-port=6543
pg2-host=bogus
pg2-host-cmd=[BACKREST-BIN]
pg2-host-config=[TEST_PATH]/db-standby/pgbackrest.conf
pg2-host-user=[USER-1]
pg2-path=[TEST_PATH]/db-standby/db/base
pg8-host=db-standby
pg8-host-cmd=[BACKREST-BIN]
pg8-host-config=[TEST_PATH]/db-standby/pgbackrest.conf
pg8-host-user=[USER-1]
pg8-path=[TEST_PATH]/db-standby/db/base
pg8-port=6544
[global]
archive-async=y
buffer-size=[BUFFER-SIZE]
compress-level=3
compress-level-network=1
compress-type=none
db-timeout=45
lock-path=[TEST_PATH]/backup/lock
log-level-console=detail
log-level-file=[LOG-LEVEL-FILE]
log-level-stderr=off
log-path=[TEST_PATH]/backup/log
log-subprocess=[LOG-SUBPROCESS]
log-timestamp=n
protocol-timeout=60
repo1-path=[TEST_PATH]/backup/repo
[global:backup]
archive-copy=y
start-fast=y
@ -136,24 +423,24 @@ stop all stanzas (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf stop
------------------------------------------------------------------------------------------------------------------------------------
incr backup - attempt backup when stopped (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf --stanza=db backup
incr backup - attempt backup when stopped (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --stanza=db backup
------------------------------------------------------------------------------------------------------------------------------------
start all stanzas (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf start
------------------------------------------------------------------------------------------------------------------------------------
incr backup - fail on archive_mode=always (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf --stanza=db backup
incr backup - fail on archive_mode=always (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --stanza=db backup
------------------------------------------------------------------------------------------------------------------------------------
expire --set=[BACKUP-DIFF-1] (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf --set=[BACKUP-DIFF-1] --stanza=db expire
expire --set=[BACKUP-DIFF-1] (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --set=[BACKUP-DIFF-1] --stanza=db expire
------------------------------------------------------------------------------------------------------------------------------------
incr backup - update during backup (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf --stop-auto --buffer-size=[BUFFER-SIZE] --delta --stanza=db backup
incr backup - update during backup (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --stop-auto --buffer-size=[BUFFER-SIZE] --delta --stanza=db backup
------------------------------------------------------------------------------------------------------------------------------------
+ supplemental file: [TEST_PATH]/db-primary/pgbackrest.conf
@ -164,9 +451,9 @@ pg1-port=6543
pg1-socket-path=[TEST_PATH]/db-primary/db
[global]
archive-async=y
buffer-size=[BUFFER-SIZE]
compress-level=3
compress-level-network=1
compress-type=none
db-timeout=45
lock-path=[TEST_PATH]/db-primary/lock
@ -177,15 +464,85 @@ log-path=[TEST_PATH]/db-primary/log
log-subprocess=[LOG-SUBPROCESS]
log-timestamp=n
protocol-timeout=60
repo1-path=[TEST_PATH]/db-primary/repo
repo1-host=backup
repo1-host-cmd=[BACKREST-BIN]
repo1-host-config=[TEST_PATH]/backup/pgbackrest.conf
repo1-host-user=[USER-1]
spool-path=[TEST_PATH]/db-primary/spool
+ supplemental file: [TEST_PATH]/db-standby/pgbackrest.conf
-----------------------------------------------------------
[db]
pg1-path=[TEST_PATH]/db-standby/db/base
pg1-port=6544
pg1-socket-path=[TEST_PATH]/db-standby/db
[db:restore]
[global]
buffer-size=[BUFFER-SIZE]
compress-level=3
compress-level-network=1
compress-type=none
db-timeout=45
lock-path=[TEST_PATH]/db-standby/lock
log-level-console=detail
log-level-file=[LOG-LEVEL-FILE]
log-level-stderr=off
log-path=[TEST_PATH]/db-standby/log
log-subprocess=[LOG-SUBPROCESS]
log-timestamp=n
protocol-timeout=60
repo1-host=backup
repo1-host-cmd=[BACKREST-BIN]
repo1-host-config=[TEST_PATH]/backup/pgbackrest.conf
repo1-host-user=[USER-1]
spool-path=[TEST_PATH]/db-standby/spool
+ supplemental file: [TEST_PATH]/backup/pgbackrest.conf
-------------------------------------------------------
[db]
pg1-host=db-primary
pg1-host-cmd=[BACKREST-BIN]
pg1-host-config=[TEST_PATH]/db-primary/pgbackrest.conf
pg1-host-user=[USER-1]
pg1-path=[TEST_PATH]/db-primary/db/base
pg1-port=6543
pg2-host=bogus
pg2-host-cmd=[BACKREST-BIN]
pg2-host-config=[TEST_PATH]/db-standby/pgbackrest.conf
pg2-host-user=[USER-1]
pg2-path=[TEST_PATH]/db-standby/db/base
pg8-host=db-standby
pg8-host-cmd=[BACKREST-BIN]
pg8-host-config=[TEST_PATH]/db-standby/pgbackrest.conf
pg8-host-user=[USER-1]
pg8-path=[TEST_PATH]/db-standby/db/base
pg8-port=6544
[global]
archive-async=y
buffer-size=[BUFFER-SIZE]
compress-level=3
compress-level-network=1
compress-type=none
db-timeout=45
lock-path=[TEST_PATH]/backup/lock
log-level-console=detail
log-level-file=[LOG-LEVEL-FILE]
log-level-stderr=off
log-path=[TEST_PATH]/backup/log
log-subprocess=[LOG-SUBPROCESS]
log-timestamp=n
protocol-timeout=60
repo1-path=[TEST_PATH]/backup/repo
[global:backup]
archive-copy=y
start-fast=y
check db - check command with tablespace (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf --archive-timeout=5 --stanza=db check
check db - check command with tablespace (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --archive-timeout=5 --reset-pg2-host --reset-pg2-path --stanza=db check
------------------------------------------------------------------------------------------------------------------------------------
restore, type 'default', expect exit 38 - pg running (db-primary host)
@ -283,12 +640,12 @@ restore_command = '[BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.con
standby_mode = 'on'
recovery_target_timeline = '4'
incr backup - fail on --no-online (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf --no-online --stanza=db backup
incr backup - fail on --no-online (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --no-online --reset-pg2-host --reset-pg2-path --stanza=db backup
------------------------------------------------------------------------------------------------------------------------------------
incr backup - succeed on --no-online with --force (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf --no-online --force --stanza=db backup
incr backup - succeed on --no-online with --force (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --no-online --force --reset-pg2-host --reset-pg2-path --stanza=db backup
------------------------------------------------------------------------------------------------------------------------------------
+ supplemental file: [TEST_PATH]/db-primary/pgbackrest.conf
@ -299,9 +656,9 @@ pg1-port=6543
pg1-socket-path=[TEST_PATH]/db-primary/db
[global]
archive-async=y
buffer-size=[BUFFER-SIZE]
compress-level=3
compress-level-network=1
compress-type=none
db-timeout=45
lock-path=[TEST_PATH]/db-primary/lock
@ -312,9 +669,99 @@ log-path=[TEST_PATH]/db-primary/log
log-subprocess=[LOG-SUBPROCESS]
log-timestamp=n
protocol-timeout=60
repo1-path=[TEST_PATH]/db-primary/repo
repo1-host=backup
repo1-host-cmd=[BACKREST-BIN]
repo1-host-config=[TEST_PATH]/backup/pgbackrest.conf
repo1-host-user=[USER-1]
spool-path=[TEST_PATH]/db-primary/spool
+ supplemental file: [TEST_PATH]/db-standby/pgbackrest.conf
-----------------------------------------------------------
[db]
pg1-path=[TEST_PATH]/db-standby/db/base
pg1-port=6544
pg1-socket-path=[TEST_PATH]/db-standby/db
[db:restore]
[global]
buffer-size=[BUFFER-SIZE]
compress-level=3
compress-level-network=1
compress-type=none
db-timeout=45
lock-path=[TEST_PATH]/db-standby/lock
log-level-console=detail
log-level-file=[LOG-LEVEL-FILE]
log-level-stderr=off
log-path=[TEST_PATH]/db-standby/log
log-subprocess=[LOG-SUBPROCESS]
log-timestamp=n
protocol-timeout=60
repo1-host=backup
repo1-host-cmd=[BACKREST-BIN]
repo1-host-config=[TEST_PATH]/backup/pgbackrest.conf
repo1-host-user=[USER-1]
spool-path=[TEST_PATH]/db-standby/spool
+ supplemental file: [TEST_PATH]/backup/pgbackrest.conf
-------------------------------------------------------
[db]
pg1-host=db-primary
pg1-host-cmd=[BACKREST-BIN]
pg1-host-config=[TEST_PATH]/db-primary/pgbackrest.conf
pg1-host-user=[USER-1]
pg1-path=[TEST_PATH]/db-primary/db/base
pg1-port=6543
pg2-host=bogus
pg2-host-cmd=[BACKREST-BIN]
pg2-host-config=[TEST_PATH]/db-standby/pgbackrest.conf
pg2-host-user=[USER-1]
pg2-path=[TEST_PATH]/db-standby/db/base
pg8-host=db-standby
pg8-host-cmd=[BACKREST-BIN]
pg8-host-config=[TEST_PATH]/db-standby/pgbackrest.conf
pg8-host-user=[USER-1]
pg8-path=[TEST_PATH]/db-standby/db/base
pg8-port=6544
[global]
archive-async=y
buffer-size=[BUFFER-SIZE]
compress-level=3
compress-level-network=1
compress-type=none
db-timeout=45
lock-path=[TEST_PATH]/backup/lock
log-level-console=detail
log-level-file=[LOG-LEVEL-FILE]
log-level-stderr=off
log-path=[TEST_PATH]/backup/log
log-subprocess=[LOG-SUBPROCESS]
log-timestamp=n
protocol-timeout=60
repo1-path=[TEST_PATH]/backup/repo
[global:backup]
archive-copy=y
start-fast=y
stop all stanzas (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf stop
------------------------------------------------------------------------------------------------------------------------------------
stop db stanza (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --stanza=db stop
------------------------------------------------------------------------------------------------------------------------------------
stanza-delete db - delete stanza with --force when pgbackrest on pg host not accessible (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf --stanza=db --force stanza-delete
------------------------------------------------------------------------------------------------------------------------------------
start all stanzas (db-primary host)
> [CONTAINER-EXEC] db-primary [BACKREST-BIN] --config=[TEST_PATH]/db-primary/pgbackrest.conf start
------------------------------------------------------------------------------------------------------------------------------------
start all stanzas (backup host)
> [CONTAINER-EXEC] backup [BACKREST-BIN] --config=[TEST_PATH]/backup/pgbackrest.conf start
------------------------------------------------------------------------------------------------------------------------------------

View File

@ -50,63 +50,40 @@ sub run
{
my $self = shift;
# Should the test use lz4 compression?
my $bLz4Compress = true;
foreach my $rhRun
(
{pg => PG_VERSION_83, repoDest => HOST_DB_PRIMARY, storage => POSIX, encrypt => false, compress => NONE},
{pg => PG_VERSION_84, repoDest => HOST_BACKUP, storage => S3, encrypt => true, compress => GZ},
{pg => PG_VERSION_90, repoDest => HOST_DB_PRIMARY, storage => POSIX, encrypt => true, compress => BZ2},
{pg => PG_VERSION_91, repoDest => HOST_DB_STANDBY, storage => S3, encrypt => false, compress => NONE},
{pg => PG_VERSION_92, repoDest => HOST_DB_STANDBY, storage => POSIX, encrypt => true, compress => NONE},
{pg => PG_VERSION_93, repoDest => HOST_BACKUP, storage => S3, encrypt => false, compress => GZ},
{pg => PG_VERSION_94, repoDest => HOST_DB_STANDBY, storage => POSIX, encrypt => true, compress => LZ4},
{pg => PG_VERSION_95, repoDest => HOST_BACKUP, storage => S3, encrypt => false, compress => BZ2},
{pg => PG_VERSION_96, repoDest => HOST_BACKUP, storage => POSIX, encrypt => false, compress => NONE},
{pg => PG_VERSION_10, repoDest => HOST_DB_STANDBY, storage => S3, encrypt => true, compress => GZ},
{pg => PG_VERSION_11, repoDest => HOST_BACKUP, storage => POSIX, encrypt => false, compress => ZST},
{pg => PG_VERSION_12, repoDest => HOST_DB_STANDBY, storage => S3, encrypt => true, compress => LZ4},
{pg => PG_VERSION_13, repoDest => HOST_BACKUP, storage => POSIX, encrypt => false, compress => ZST},
)
{
# Only run tests for this pg version
next if ($rhRun->{pg} ne $self->pgVersion());
foreach my $strStorage (POSIX, S3)
{
foreach my $bHostBackup ($strStorage eq S3 ? (true) : (false, true))
{
# Standby should only be tested for pg versions that support it
foreach my $bHostStandby ($strStorage eq S3 ? (false) : (false, true))
{
# Primary and standby backup destinations only need to be tested on one db version since it is not version specific
foreach my $strBackupDestination (
$strStorage eq S3 || $bHostBackup ? (HOST_BACKUP) : $bHostStandby ? (HOST_DB_PRIMARY, HOST_DB_STANDBY) : (HOST_DB_PRIMARY))
{
my $strCompressType =
$bHostBackup && !$bHostStandby ?
(vmWithLz4($self->vm()) && $bLz4Compress ? LZ4 : vmWithZst($self->vm()) ?
ZST : ($strStorage eq S3 ? BZ2 : GZ)) : NONE;
my $bRepoEncrypt = ($strCompressType ne NONE && $strStorage eq POSIX) ? true : false;
# If compression was used then switch it for the next test that uses compression
if ($strCompressType ne NONE)
{
$bLz4Compress = !$bLz4Compress;
}
# Get run parameters
my $bHostBackup = $rhRun->{repoDest} eq HOST_BACKUP ? true : false;
my $bHostStandby = $self->pgVersion() >= PG_VERSION_HOT_STANDBY ? true : false;
my $strBackupDestination = $rhRun->{repoDest};
my $strStorage = $rhRun->{storage};
my $bRepoEncrypt = $rhRun->{encrypt};
my $strCompressType = $rhRun->{compress};
# Increment the run, log, and decide whether this unit test should be run
my $hyVm = vmGet();
my $strDbVersionMostRecent = ${$hyVm->{$self->vm()}{&VM_DB_TEST}}[-1];
next if (!$self->begin(
"bkp ${bHostBackup}, sby ${bHostStandby}, dst ${strBackupDestination}, cmp ${strCompressType}" .
", storage ${strStorage}, enc ${bRepoEncrypt}",
# Use the most recent db version on the expect vm for expect testing
$self->vm() eq VM_EXPECT && $self->pgVersion() eq $strDbVersionMostRecent));
# Skip when s3 and host backup tests when there is more than one version of pg being tested and this is not the last one
if (($strStorage eq S3 || $bHostBackup) &&
(@{$hyVm->{$self->vm()}{&VM_DB_TEST}} > 1 && $strDbVersionMostRecent ne $self->pgVersion()))
{
&log(INFO, "skipped - this test is run this OS using PG ${strDbVersionMostRecent}");
next;
}
# Skip hot standby tests if the system does not support hot standby
if ($bHostStandby && $self->pgVersion() < PG_VERSION_HOT_STANDBY)
{
&log(INFO, 'skipped - this version of PostgreSQL does not support hot standby');
next;
}
# Skip backup destinations other than backup host when standby except for one arbitrary db version
if ($bHostStandby && $strBackupDestination ne HOST_BACKUP && $self->pgVersion() ne PG_VERSION_96)
{
&log(INFO, 'skipped - standby with backup destination other than backup host is tested on PG ' . PG_VERSION_96);
next;
}
$self->vm() eq VM_EXPECT && $self->pgVersion() eq PG_VERSION_96));
# Create hosts, file object, and config
my ($oHostDbPrimary, $oHostDbStandby, $oHostBackup) = $self->setup(
@ -115,10 +92,9 @@ sub run
strCompressType => $strCompressType, bArchiveAsync => false, strStorage => $strStorage,
bRepoEncrypt => $bRepoEncrypt});
# Only perform extra tests on certain runs to save time
my $bTestLocal = $self->runCurrent() == 1;
my $bTestExtra =
$bTestLocal || $self->runCurrent() == 4 || ($self->runCurrent() == 6 && $self->pgVersion() eq PG_VERSION_96);
# Some commands will fail because of the bogus host created when a standby is present. These options reset the bogus host
# so it won't interfere with commands that won't tolerate a connection failure.
my $strBogusReset = $oHostBackup->bogusHost() ? ' --reset-pg2-host --reset-pg2-path' : '';
# If S3 set process max to 2. This seems like the best place for parallel testing since it will help speed S3 processing
# without slowing down the other tests too much.
@ -156,16 +132,11 @@ sub run
my $strTimelineMessage = 'timeline';
# Create two new databases
if ($bTestLocal)
{
$oHostDbPrimary->sqlExecute('create database test1', {bAutoCommit => true});
$oHostDbPrimary->sqlExecute('create database test2', {bAutoCommit => true});
}
# Test check command and stanza create
#---------------------------------------------------------------------------------------------------------------------------
if ($bTestExtra)
{
# In this section the same comment can be used multiple times so make it a variable that can be set once and reused
my $strComment = undef;
@ -199,10 +170,12 @@ sub run
$oHostBackup->backup(CFGOPTVAL_BACKUP_TYPE_FULL, $strComment, {iExpectedExitStatus => ERROR_ARCHIVE_DISABLED});
$oHostDbPrimary->check($strComment, {iTimeout => 0.1, iExpectedExitStatus => ERROR_ARCHIVE_DISABLED});
# If running the remote tests then also need to run check locally
# Also run check on the backup host when present
if ($bHostBackup)
{
$oHostBackup->check($strComment, {iTimeout => 0.1, iExpectedExitStatus => ERROR_ARCHIVE_DISABLED});
$oHostBackup->check(
$strComment,
{iTimeout => 0.1, iExpectedExitStatus => ERROR_ARCHIVE_DISABLED, strOptionalParam => $strBogusReset});
}
# Check ERROR_ARCHIVE_COMMAND_INVALID error
@ -212,10 +185,12 @@ sub run
$oHostBackup->backup(CFGOPTVAL_BACKUP_TYPE_FULL, $strComment, {iExpectedExitStatus => ERROR_ARCHIVE_COMMAND_INVALID});
$oHostDbPrimary->check($strComment, {iTimeout => 0.1, iExpectedExitStatus => ERROR_ARCHIVE_COMMAND_INVALID});
# If running the remote tests then also need to run check locally
# Also run check on the backup host when present
if ($bHostBackup)
{
$oHostBackup->check($strComment, {iTimeout => 0.1, iExpectedExitStatus => ERROR_ARCHIVE_COMMAND_INVALID});
$oHostBackup->check(
$strComment,
{iTimeout => 0.1, iExpectedExitStatus => ERROR_ARCHIVE_COMMAND_INVALID, strOptionalParam => $strBogusReset});
}
# When archive-check=n then ERROR_ARCHIVE_TIMEOUT will be raised instead of ERROR_ARCHIVE_COMMAND_INVALID
@ -234,10 +209,10 @@ sub run
$oHostDbPrimary->clusterStart();
$oHostDbPrimary->check($strComment, {iTimeout => 5});
# If running the remote tests then also need to run check locally
# Also run check on the backup host when present
if ($bHostBackup)
{
$oHostBackup->check($strComment, {iTimeout => 5});
$oHostBackup->check($strComment, {iTimeout => 5, strOptionalParam => $strBogusReset});
}
# Check archive mismatch due to upgrade error
@ -251,10 +226,11 @@ sub run
$oHostDbPrimary->check($strComment, {iTimeout => 0.1, iExpectedExitStatus => ERROR_FILE_INVALID});
# If running the remote tests then also need to run check locally
# Also run check on the backup host when present
if ($bHostBackup)
{
$oHostBackup->check($strComment, {iTimeout => 0.1, iExpectedExitStatus => ERROR_FILE_INVALID});
$oHostBackup->check(
$strComment, {iTimeout => 0.1, iExpectedExitStatus => ERROR_FILE_INVALID, strOptionalParam => $strBogusReset});
}
# Restore the file to its original condition
@ -266,10 +242,12 @@ sub run
$oHostDbPrimary->clusterRestart({bIgnoreLogError => true, bArchiveInvalid => true});
$oHostDbPrimary->check($strComment, {iTimeout => 0.1, iExpectedExitStatus => ERROR_ARCHIVE_TIMEOUT});
# If running the remote tests then also need to run check locally
# Also run check on the backup host when present
if ($bHostBackup)
{
$oHostBackup->check($strComment, {iTimeout => 0.1, iExpectedExitStatus => ERROR_ARCHIVE_TIMEOUT});
$oHostBackup->check(
$strComment,
{iTimeout => 0.1, iExpectedExitStatus => ERROR_ARCHIVE_TIMEOUT, strOptionalParam => $strBogusReset});
}
# Restart the cluster ignoring any errors in the postgresql log
@ -290,10 +268,11 @@ sub run
# Run the test
$oHostDbPrimary->check($strComment, {iTimeout => 5, iExpectedExitStatus => ERROR_FILE_INVALID});
# If running the remote tests then also need to run check locally
# Also run check on the backup host when present
if ($bHostBackup)
{
$oHostBackup->check($strComment, {iTimeout => 5, iExpectedExitStatus => ERROR_FILE_INVALID});
$oHostBackup->check(
$strComment, {iTimeout => 5, iExpectedExitStatus => ERROR_FILE_INVALID, strOptionalParam => $strBogusReset});
}
# Restore the file to its original condition
@ -316,10 +295,10 @@ sub run
$oHostDbPrimary->check($strComment, {iTimeout => 5});
# If running the remote tests then also need to run check locally
# Also run check on the backup host when present
if ($bHostBackup)
{
$oHostBackup->check($strComment, {iTimeout => 5});
$oHostBackup->check($strComment, {iTimeout => 5, strOptionalParam => $strBogusReset});
}
# Restart the cluster ignoring any errors in the postgresql log
@ -327,6 +306,11 @@ sub run
# Stanza Create
#-----------------------------------------------------------------------------------------------------------------------
# Determine which pg index is the primary. When backing up to the standby the primary and standby indexes are switched
# to provide coverage for cases where the primary is not first and because the local pg instance is always intended to
# be index 1.
my $strPrimaryIdx = $strBackupDestination eq HOST_DB_STANDBY ? '8' : '1';
# With data existing in the archive and backup directory, move info files and confirm failure
forceStorageMove(storageRepo(), $strArchiveInfoFile, $strArchiveInfoOldFile, {bRecurse => false});
forceStorageMove(storageRepo(), $strArchiveInfoCopyFile, $strArchiveInfoCopyOldFile, {bRecurse => false});
@ -345,7 +329,7 @@ sub run
# Run stanza-create online to confirm proper handling of configValidation error against new pg-path
$oHostBackup->stanzaCreate('fail on database mismatch with directory',
{strOptionalParam => ' --pg1-path=' . $oHostDbPrimary->dbPath() . '/testbase/',
{strOptionalParam => " --pg${strPrimaryIdx}-path=" . $oHostDbPrimary->dbPath() . '/testbase/',
iExpectedExitStatus => ERROR_DB_MISMATCH});
# Remove the directories to be able to create the stanza
@ -354,9 +338,23 @@ sub run
# Stanza Upgrade - tests configValidate code - all other tests in synthetic integration tests
#-----------------------------------------------------------------------------------------------------------------------
# Change the database version by copying a new pg_control file to a new pg-path to use for db mismatch test
if ($strBackupDestination eq HOST_DB_STANDBY)
{
storageTest()->pathCreate(
$oHostDbStandby->dbPath() . '/testbase/' . DB_PATH_GLOBAL,
{strMode => '0700', bIgnoreExists => true, bCreateParent => true});
$self->controlGenerate(
$oHostDbStandby->dbPath() . '/testbase', $self->pgVersion() eq PG_VERSION_94 ? PG_VERSION_95 : PG_VERSION_94);
}
# Run stanza-create offline to create files needing to be upgraded (using new pg-path)
$oHostBackup->stanzaCreate('successfully create stanza files to be upgraded',
{strOptionalParam => ' --pg1-path=' . $oHostDbPrimary->dbPath() . '/testbase/ --no-online --force'});
$oHostBackup->stanzaCreate(
'successfully create stanza files to be upgraded',
{strOptionalParam =>
" --pg1-path=" .
($strBackupDestination eq HOST_DB_STANDBY ? $oHostDbStandby->dbPath() : $oHostDbPrimary->dbPath()) .
'/testbase/ --no-online'});
my $oArchiveInfo = new pgBackRestTest::Env::ArchiveInfo($oHostBackup->repoArchivePath());
my $oBackupInfo = new pgBackRestTest::Env::BackupInfo($oHostBackup->repoBackupPath());
@ -386,7 +384,6 @@ sub run
$self->pgVersion())}, true, 'archive upgrade online corrects db');
$self->testResult(sub {$oBackupInfo->test(INFO_BACKUP_SECTION_DB, INFO_BACKUP_KEY_DB_VERSION, undef,
$self->pgVersion())}, true, 'backup upgrade online corrects db');
}
# Full backup
#---------------------------------------------------------------------------------------------------------------------------
@ -395,8 +392,6 @@ sub run
$oHostDbPrimary->sqlWalRotate();
$oHostDbPrimary->sqlExecute("insert into test values ('$strDefaultMessage')");
if ($bTestLocal)
{
# Acquire the backup advisory lock so it looks like a backup is running
if (!$oHostDbPrimary->sqlSelectOne('select pg_try_advisory_lock(' . DB_BACKUP_ADVISORY_LOCK . ')'))
{
@ -411,7 +406,6 @@ sub run
{
confess 'unable to release advisory lock';
}
}
$oHostDbPrimary->sqlExecute("update test set message = '$strFullMessage'");
@ -427,7 +421,7 @@ sub run
# Kick out a bunch of archive logs to exercise async archiving. Only do this when compressed and remote to slow it
# down enough to make it evident that the async process is working.
if ($bTestExtra && $strCompressType ne NONE && $strBackupDestination eq HOST_BACKUP)
if ($strCompressType ne NONE && $strBackupDestination eq HOST_BACKUP)
{
&log(INFO, ' multiple wal switches to exercise async archiving');
$oHostDbPrimary->sqlExecute("create table wal_activity (id int)");
@ -526,10 +520,7 @@ sub run
# executeTest("sudo rmdir ${strDir}");
# Confirm the check command runs without error on a standby (when a bogus host is not configured)
if (!$oHostDbStandby->bogusHost())
{
$oHostDbStandby->check('verify check command on standby');
}
$oHostDbStandby->check('verify check command on standby', {strOptionalParam => $strBogusReset});
# Shutdown the standby before creating tablespaces (this will error since paths are different)
$oHostDbStandby->clusterStop({bIgnoreLogError => true});
@ -541,7 +532,7 @@ sub run
#---------------------------------------------------------------------------------------------------------------------------
# Restart the cluster to check for any errors before continuing since the stop tests will definitely create errors and
# the logs will to be deleted to avoid causing issues further down the line.
if ($bTestExtra && $strStorage eq POSIX)
if ($strStorage eq POSIX)
{
$oHostDbPrimary->clusterRestart();
@ -571,7 +562,7 @@ sub run
# Incr backup - fail on archive_mode=always when version >= 9.5
#---------------------------------------------------------------------------------------------------------------------------
if ($bTestLocal && $oHostDbPrimary->pgVersion() >= PG_VERSION_95)
if ($oHostDbPrimary->pgVersion() >= PG_VERSION_95)
{
# Set archive_mode=always
$oHostDbPrimary->clusterRestart({bArchiveAlways => true});
@ -614,18 +605,15 @@ sub run
'insert into test3_exists values (1);',
{strDb => 'test3', bAutoCommit => true});
if ($bTestLocal)
{
# Create a table in test1 to check - test1 will not be restored
$oHostDbPrimary->sqlExecute(
'create table test1_zeroed (id int);' .
'insert into test1_zeroed values (1);',
{strDb => 'test1', bAutoCommit => true});
}
# Start a backup so the next backup has to restart it. This test is not required for PostgreSQL >= 9.6 since backups
# are run in non-exclusive mode.
if ($bTestLocal && $oHostDbPrimary->pgVersion() >= PG_VERSION_93 && $oHostDbPrimary->pgVersion() < PG_VERSION_96)
if ($oHostDbPrimary->pgVersion() >= PG_VERSION_93 && $oHostDbPrimary->pgVersion() < PG_VERSION_96)
{
$oHostDbPrimary->sqlSelectOne("select pg_start_backup('test backup that will cause an error', true)");
@ -655,31 +643,23 @@ sub run
my $strIncrBackup = $oHostBackup->backup(
CFGOPTVAL_BACKUP_TYPE_INCR, 'update during backup', {strOptionalParam => '--stop-auto --buffer-size=32768 --delta'});
# Ensure the check command runs properly with a tablespace unless there is a bogus host
if (!$oHostBackup->bogusHost())
{
$oHostBackup->check( 'check command with tablespace', {iTimeout => 5});
}
# Ensure the check command runs properly with a tablespace
$oHostBackup->check( 'check command with tablespace', {iTimeout => 5, strOptionalParam => $strBogusReset});
# Setup the xid target
#---------------------------------------------------------------------------------------------------------------------------
my $strXidTarget = undef;
if ($bTestLocal)
{
$oHostDbPrimary->sqlExecute("update test set message = '$strXidMessage'", {bCommit => false});
$oHostDbPrimary->sqlWalRotate();
$strXidTarget = $oHostDbPrimary->sqlSelectOne("select txid_current()");
$oHostDbPrimary->sqlCommit();
&log(INFO, " xid target is ${strXidTarget}");
}
# Setup the name target
#---------------------------------------------------------------------------------------------------------------------------
my $strNameTarget = 'backrest';
if ($bTestLocal)
{
$oHostDbPrimary->sqlExecute("update test set message = '$strNameMessage'", {bCommit => true});
$oHostDbPrimary->sqlWalRotate();
@ -689,17 +669,13 @@ sub run
}
&log(INFO, " name target is ${strNameTarget}");
}
# Create a table and data in database test2
#---------------------------------------------------------------------------------------------------------------------------
# Initialize variables for SHA1 and path of the pg_filenode.map for the database that will not be restored
my $strDb1TablePath;
my $strDb1TableSha1;
if ($bTestLocal)
{
$oHostDbPrimary->sqlExecute(
'create table test (id int);' .
'insert into test values (1);' .
@ -714,23 +690,16 @@ sub run
$oHostDbPrimary->sqlSelectOne("select oid from pg_database where datname='test1'") . "/" .
$oHostDbPrimary->sqlSelectOne("select relfilenode from pg_class where relname='test1_zeroed'", {strDb => 'test1'});
$strDb1TableSha1 = storageTest()->hashSize($strDb1TablePath);
}
# Restore (type = default)
#---------------------------------------------------------------------------------------------------------------------------
if ($bTestLocal)
{
# Expect failure because pg (appears to be) running
$oHostDbPrimary->restore('pg running', 'latest', {iExpectedExitStatus => ERROR_PG_RUNNING});
}
$oHostDbPrimary->clusterStop();
if ($bTestLocal)
{
# Expect failure because db path is not empty
$oHostDbPrimary->restore('path not empty', 'latest', {iExpectedExitStatus => ERROR_PATH_NOT_EMPTY});
}
# Drop and recreate db path
testPathRemove($oHostDbPrimary->dbBasePath());
@ -742,12 +711,9 @@ sub run
# Now the restore should work
$oHostDbPrimary->restore(
undef, 'latest',
{strOptionalParam => ($bTestLocal ? ' --db-include=test2 --db-include=test3' : '') . ' --buffer-size=16384'});
undef, 'latest', {strOptionalParam => ' --db-include=test2 --db-include=test3 --buffer-size=16384'});
# Test that the first database has not been restored since --db-include did not include test1
if ($bTestLocal)
{
my ($strSHA1, $lSize) = storageTest()->hashSize($strDb1TablePath);
# Create a zeroed sparse file in the test directory that is the same size as the filenode.map. We need to use the
@ -769,20 +735,16 @@ sub run
my ($strSHA1Test, $lSizeTest) = storageTest()->hashSize($strTestTable);
$self->testResult(sub {($strSHA1Test eq $strSHA1) && ($lSizeTest == $lSize) && ($strSHA1 ne $strDb1TableSha1)},
true, 'database test1 not restored');
}
$oHostDbPrimary->clusterStart();
$oHostDbPrimary->sqlSelectOneTest('select message from test', $bTestLocal ? $strNameMessage : $strIncrMessage);
$oHostDbPrimary->sqlSelectOneTest('select message from test', $strNameMessage);
# Once the cluster is back online, make sure the database & table in the tablespace exists properly
if ($bTestLocal)
{
$oHostDbPrimary->sqlSelectOneTest('select id from test_ts1', 2, {strDb => 'test2'});
$oHostDbPrimary->sqlDisconnect({strDb => 'test2'});
$oHostDbPrimary->sqlSelectOneTest('select id from test3_exists', 1, {strDb => 'test3'});
$oHostDbPrimary->sqlDisconnect({strDb => 'test3'});
}
# The tablespace path should exist and have files in it
my $strTablespacePath = $oHostDbPrimary->tablespacePath(1);
@ -826,10 +788,7 @@ sub run
$oHostDbPrimary->sqlExecute('drop table test_exists');
# Now it should be OK to drop database test2 and test3
if ($bTestLocal)
{
$oHostDbPrimary->sqlExecute('drop database test2', {bAutoCommit => true});
}
# The test table lives in ts1 so it needs to be moved or dropped
if ($oHostDbPrimary->pgVersion() >= PG_VERSION_90)
@ -848,7 +807,7 @@ sub run
# Restore (restore type = immediate, inclusive)
#---------------------------------------------------------------------------------------------------------------------------
if (($bTestLocal || $bHostStandby) && $oHostDbPrimary->pgVersion() >= PG_VERSION_94)
if ($oHostDbPrimary->pgVersion() >= PG_VERSION_94)
{
&log(INFO, ' testing recovery type = ' . CFGOPTVAL_RESTORE_TYPE_IMMEDIATE);
@ -866,8 +825,6 @@ sub run
#---------------------------------------------------------------------------------------------------------------------------
my $strRecoveryFile = undef;
if ($bTestLocal)
{
&log(INFO, ' testing recovery type = ' . CFGOPTVAL_RESTORE_TYPE_XID);
$oHostDbPrimary->clusterStop();
@ -892,12 +849,9 @@ sub run
$oHostDbPrimary->sqlSelectOneTest('select message from test', $strXidMessage);
$oHostDbPrimary->sqlExecute("update test set message = '$strTimelineMessage'");
}
# Restore (restore type = preserve, inclusive)
#---------------------------------------------------------------------------------------------------------------------------
if ($bTestLocal)
{
&log(INFO, ' testing recovery type = ' . CFGOPTVAL_RESTORE_TYPE_PRESERVE);
$oHostDbPrimary->clusterStop();
@ -921,7 +875,6 @@ sub run
$oHostDbPrimary->sqlSelectOneTest('select message from test', $strXidMessage);
$oHostDbPrimary->sqlExecute("update test set message = '$strTimelineMessage'");
}
# Restore (restore type = time, inclusive, automatically select backup) - there is no exclusive time test because I can't
# find a way to find the exact commit time of a transaction.
@ -942,8 +895,6 @@ sub run
# Restore (restore type = xid, exclusive)
#---------------------------------------------------------------------------------------------------------------------------
if ($bTestLocal)
{
&log(INFO, ' testing recovery type = ' . CFGOPTVAL_RESTORE_TYPE_XID);
$oHostDbPrimary->clusterStop();
@ -956,11 +907,10 @@ sub run
$oHostDbPrimary->clusterStart();
$oHostDbPrimary->sqlSelectOneTest('select message from test', $strIncrMessage);
}
# Restore (restore type = name)
#---------------------------------------------------------------------------------------------------------------------------
if ($bTestLocal && $oHostDbPrimary->pgVersion() >= PG_VERSION_91)
if ($oHostDbPrimary->pgVersion() >= PG_VERSION_91)
{
&log(INFO, ' testing recovery type = ' . CFGOPTVAL_RESTORE_TYPE_NAME);
@ -978,7 +928,7 @@ sub run
# Restore (restore type = default, timeline = created by type = xid, inclusive recovery)
#---------------------------------------------------------------------------------------------------------------------------
if ($bTestLocal && $oHostDbPrimary->pgVersion() >= PG_VERSION_84)
if ($oHostDbPrimary->pgVersion() >= PG_VERSION_84)
{
&log(INFO, ' testing recovery type = ' . CFGOPTVAL_RESTORE_TYPE_DEFAULT);
@ -1004,27 +954,25 @@ sub run
# Test no-online backups
#---------------------------------------------------------------------------------------------------------------------------
if ($bTestExtra & $strStorage eq POSIX)
{
# Create a postmaster.pid file so it appears that the server is running
storageTest()->put($oHostDbPrimary->dbBasePath() . '/postmaster.pid', '99999');
storageTest()->put(
($strBackupDestination eq HOST_DB_STANDBY ? $oHostDbStandby->dbBasePath() : $oHostDbPrimary->dbBasePath()) .
'/postmaster.pid', '99999');
# Incr backup - make sure a --no-online backup fails
#-----------------------------------------------------------------------------------------------------------------------
$oHostBackup->backup(
CFGOPTVAL_BACKUP_TYPE_INCR, 'fail on --no-online',
{iExpectedExitStatus => ERROR_PG_RUNNING, strOptionalParam => '--no-online'});
{iExpectedExitStatus => ERROR_PG_RUNNING, strOptionalParam => '--no-online' . $strBogusReset});
# Incr backup - allow --no-online backup to succeed with --force
#-----------------------------------------------------------------------------------------------------------------------
$oHostBackup->backup(
CFGOPTVAL_BACKUP_TYPE_INCR, 'succeed on --no-online with --force', {strOptionalParam => '--no-online --force'});
}
CFGOPTVAL_BACKUP_TYPE_INCR, 'succeed on --no-online with --force',
{strOptionalParam => '--no-online --force' . $strBogusReset});
# Stanza-delete --force without access to pgbackrest on database host
#---------------------------------------------------------------------------------------------------------------------------
if ($bTestExtra && $strStorage eq POSIX && $bHostBackup)
{
# With stanza-delete --force, allow stanza to be deleted regardless of accessibility of database host
if ($bHostBackup)
{
@ -1036,10 +984,6 @@ sub run
$oHostBackup->start();
}
}
}
}
}
}
}
1;