diff --git a/doc/xml/release.xml b/doc/xml/release.xml index 448b5333c..12091e3d5 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -53,7 +53,7 @@ -

Storage refactoring. Posix file functions now differentiate between open and missing errors. Don't use negations in objects below Storage. Rename posix driver files/functions for consistency. Full abstraction of storage driver interface. Merge protocol storage helper into storage helper.

+

Storage refactoring. Posix file functions now differentiate between open and missing errors. Don't use negations in objects below Storage. Rename posix driver files/functions for consistency. Full abstraction of storage driver interface. Merge protocol storage helper into storage helper. Add CIFS driver to storage helper for read-only repositories.

diff --git a/src/storage/helper.c b/src/storage/helper.c index f934acc45..ce95e24ad 100644 --- a/src/storage/helper.c +++ b/src/storage/helper.c @@ -158,6 +158,37 @@ storageRepoPathExpression(const String *expression, const String *path) FUNCTION_TEST_RESULT(STRING, result); } +/*********************************************************************************************************************************** +Get the repo storage +***********************************************************************************************************************************/ +static Storage * +storageRepoGet(const String *type, bool write) +{ + FUNCTION_TEST_BEGIN(); + FUNCTION_TEST_PARAM(STRING, type); + FUNCTION_TEST_PARAM(BOOL, write); + + FUNCTION_TEST_ASSERT(type != NULL); + FUNCTION_TEST_ASSERT(write == false); // ??? Need to create cifs driver before storage can be writable + FUNCTION_TEST_END(); + + Storage *result = NULL; + + // For now treat posix and cifs drivers as if they are the same. This won't be true once the repository storage becomes + // writable but for now it's OK. The assertion above should pop if we try to create writable repo storage. + if (strEqZ(type, STORAGE_TYPE_POSIX) || strEqZ(type, STORAGE_TYPE_CIFS)) + { + result = storageDriverPosixInterface( + storageDriverPosixNew( + cfgOptionStr(cfgOptRepoPath), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, write, + storageRepoPathExpression)); + } + else + THROW_FMT(AssertError, "invalid storage type '%s'", strPtr(type)); + + FUNCTION_TEST_RESULT(STORAGE, result); +} + /*********************************************************************************************************************************** Get a read-only repository storage object ***********************************************************************************************************************************/ @@ -174,11 +205,7 @@ storageRepo(void) MEM_CONTEXT_BEGIN(storageHelper.memContext) { storageHelper.walRegExp = regExpNew(strNew("^[0-F]{24}")); - - storageHelper.storageRepo = storageDriverPosixInterface( - storageDriverPosixNew( - cfgOptionStr(cfgOptRepoPath), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, false, - storageRepoPathExpression)); + storageHelper.storageRepo = storageRepoGet(cfgOptionStr(cfgOptRepoType), false); } MEM_CONTEXT_END(); } diff --git a/test/expect/mock-archive-001.log b/test/expect/mock-archive-001.log index a30baf7a5..ffc3bf5d9 100644 --- a/test/expect/mock-archive-001.log +++ b/test/expect/mock-archive-001.log @@ -282,9 +282,9 @@ P00 INFO: archive-push command begin [BACKREST-VERSION]: [[TEST_PATH]/db-maste P00 ERROR: [045]: WAL segment 000000010000000100000002 already exists in the archive P00 INFO: archive-push command end: aborted with exception [045] -> [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-get --archive-async --archive-timeout=5 000000010000000100000002 [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG +> [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-get --archive-async --repo-type=cifs --archive-timeout=5 000000010000000100000002 [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG ------------------------------------------------------------------------------------------------------------------------------------ -P00 INFO: archive-get command begin [BACKREST-VERSION]: [000000010000000100000002, [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG] --archive-async --archive-timeout=5 --no-compress --compress-level=3 --config=[TEST_PATH]/db-master/pgbackrest.conf --db-timeout=45 --lock-path=[TEST_PATH]/db-master/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --log-subprocess --no-log-timestamp --pg1-path=[TEST_PATH]/db-master/db/base --protocol-timeout=60 --repo1-path=[TEST_PATH]/db-master/repo --spool-path=[TEST_PATH]/db-master/spool --stanza=db +P00 INFO: archive-get command begin [BACKREST-VERSION]: [000000010000000100000002, [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG] --archive-async --archive-timeout=5 --no-compress --compress-level=3 --config=[TEST_PATH]/db-master/pgbackrest.conf --db-timeout=45 --lock-path=[TEST_PATH]/db-master/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --log-subprocess --no-log-timestamp --pg1-path=[TEST_PATH]/db-master/db/base --protocol-timeout=60 --repo1-path=[TEST_PATH]/db-master/repo --repo1-type=cifs --spool-path=[TEST_PATH]/db-master/spool --stanza=db P00 INFO: found 000000010000000100000002 in the archive P00 INFO: archive-get command end: completed successfully diff --git a/test/expect/mock-archive-002.log b/test/expect/mock-archive-002.log index 2e81a18f6..a6239ebb6 100644 --- a/test/expect/mock-archive-002.log +++ b/test/expect/mock-archive-002.log @@ -273,9 +273,9 @@ P00 INFO: archive-push command begin [BACKREST-VERSION]: [[TEST_PATH]/db-maste P00 ERROR: [045]: WAL segment 000000010000000100000002 already exists in the archive P00 INFO: archive-push command end: aborted with exception [045] -> [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-get --cmd-ssh=/usr/bin/ssh --archive-async --archive-timeout=5 000000010000000100000002 [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG +> [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --stanza=db archive-get --cmd-ssh=/usr/bin/ssh --archive-async --repo-type=cifs --archive-timeout=5 000000010000000100000002 [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG ------------------------------------------------------------------------------------------------------------------------------------ -P00 INFO: archive-get command begin [BACKREST-VERSION]: [000000010000000100000002, [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG] --archive-async --archive-timeout=5 --cmd-ssh=/usr/bin/ssh --no-compress --compress-level=3 --compress-level-network=1 --config=[TEST_PATH]/db-master/pgbackrest.conf --db-timeout=45 --lock-path=[TEST_PATH]/db-master/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --log-subprocess --no-log-timestamp --pg1-path=[TEST_PATH]/db-master/db/base --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-master/spool --stanza=db +P00 INFO: archive-get command begin [BACKREST-VERSION]: [000000010000000100000002, [TEST_PATH]/db-master/db/base/pg_xlog/RECOVERYXLOG] --archive-async --archive-timeout=5 --cmd-ssh=/usr/bin/ssh --no-compress --compress-level=3 --compress-level-network=1 --config=[TEST_PATH]/db-master/pgbackrest.conf --db-timeout=45 --lock-path=[TEST_PATH]/db-master/lock --log-level-console=detail --log-level-file=trace --log-level-stderr=off --log-path=[TEST_PATH]/db-master/log --log-subprocess --no-log-timestamp --pg1-path=[TEST_PATH]/db-master/db/base --protocol-timeout=60 --repo1-host=backup --repo1-host-cmd=[BACKREST-BIN] --repo1-host-config=[TEST_PATH]/backup/pgbackrest.conf --repo1-host-user=[USER-1] --repo1-type=cifs --spool-path=[TEST_PATH]/db-master/spool --stanza=db P00 INFO: found 000000010000000100000002 in the archive P00 INFO: archive-get command end: completed successfully diff --git a/test/lib/pgBackRestTest/Module/Mock/MockArchiveTest.pm b/test/lib/pgBackRestTest/Module/Mock/MockArchiveTest.pm index 49c10a3a3..a2d559a21 100644 --- a/test/lib/pgBackRestTest/Module/Mock/MockArchiveTest.pm +++ b/test/lib/pgBackRestTest/Module/Mock/MockArchiveTest.pm @@ -355,8 +355,8 @@ sub run &log(INFO, " get second WAL (${strSourceFile})"); $oHostDbMaster->executeSimple( - $strCommandGet . ($bRemote ? ' --cmd-ssh=/usr/bin/ssh' : '') . - " --archive-async --archive-timeout=5 ${strSourceFile} ${strWalPath}/RECOVERYXLOG", + $strCommandGet . ($bRemote ? ' --cmd-ssh=/usr/bin/ssh' : '') . " --archive-async" . (!$bS3 ? " --repo-type=cifs" : '') . + " --archive-timeout=5 ${strSourceFile} ${strWalPath}/RECOVERYXLOG", {oLogTest => $self->expect()}); # Check that the destination file exists diff --git a/test/src/module/storage/helperTest.c b/test/src/module/storage/helperTest.c index 5f81c1b0d..81495cb11 100644 --- a/test/src/module/storage/helperTest.c +++ b/test/src/module/storage/helperTest.c @@ -39,10 +39,8 @@ testRun(void) } // ***************************************************************************************************************************** - if (testBegin("storageRepo()")) + if (testBegin("storageRepoGet() and storageRepo()")) { - const Storage *storage = NULL; - // Load configuration to set repo-path and stanza StringList *argList = strLstNew(); strLstAddZ(argList, "pgbackrest"); @@ -51,6 +49,12 @@ testRun(void) strLstAddZ(argList, "archive-get"); harnessCfgLoad(strLstSize(argList), strLstPtr(argList)); + TEST_RESULT_VOID(storageRepoGet(strNew(STORAGE_TYPE_CIFS), false), "get cifs repo storage"); + TEST_ERROR(storageRepoGet(strNew(BOGUS_STR), false), AssertError, "invalid storage type 'BOGUS'"); + + // ------------------------------------------------------------------------------------------------------------------------- + const Storage *storage = NULL; + TEST_RESULT_PTR(storageHelper.storageRepo, NULL, "repo storage not cached"); TEST_ASSIGN(storage, storageRepo(), "new storage"); TEST_RESULT_PTR(storageHelper.storageRepo, storage, "repo storage cached");