You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-06-14 23:44:58 +02:00
The external storage interfaces (Storage, StorageFileRead, etc.) have been stable for a while, but internally they were calling the posix driver functions directly. Create driver interfaces for storage, fileRead, and fileWrite and remove all references to the posix driver outside storage/driver/posix (with the exception of a direct call to pathRemove() in Perl LibC). Posix is still the only available driver so more adjustment may be needed, but this should represent the bulk of the changes.
64 lines
3.0 KiB
C
64 lines
3.0 KiB
C
/***********************************************************************************************************************************
|
|
Test Command Control
|
|
***********************************************************************************************************************************/
|
|
#include "common/harnessConfig.h"
|
|
#include "storage/driver/posix/storage.h"
|
|
|
|
/***********************************************************************************************************************************
|
|
Test Run
|
|
***********************************************************************************************************************************/
|
|
void
|
|
testRun(void)
|
|
{
|
|
FUNCTION_HARNESS_VOID();
|
|
|
|
// Create default storage object for testing
|
|
Storage *storageTest = storageDriverPosixInterface(
|
|
storageDriverPosixNew(strNew(testPath()), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, true, NULL));
|
|
|
|
// *****************************************************************************************************************************
|
|
if (testBegin("lockStopFileName()"))
|
|
{
|
|
// Load configuration so lock path is set
|
|
StringList *argList = strLstNew();
|
|
strLstAddZ(argList, "pgbackrest");
|
|
strLstAddZ(argList, "--stanza=db");
|
|
strLstAddZ(argList, "--lock-path=/path/to/lock");
|
|
strLstAddZ(argList, "archive-get");
|
|
harnessCfgLoad(strLstSize(argList), strLstPtr(argList));
|
|
|
|
TEST_RESULT_STR(strPtr(lockStopFileName(NULL)), "/path/to/lock/all.stop", "stop file for all stanzas");
|
|
TEST_RESULT_STR(strPtr(lockStopFileName(strNew("db"))), "/path/to/lock/db.stop", "stop file for on stanza");
|
|
}
|
|
|
|
// *****************************************************************************************************************************
|
|
if (testBegin("lockStopTest()"))
|
|
{
|
|
StringList *argList = strLstNew();
|
|
strLstAddZ(argList, "pgbackrest");
|
|
strLstAdd(argList, strNewFmt("--lock-path=%s", testPath()));
|
|
strLstAddZ(argList, "start");
|
|
harnessCfgLoad(strLstSize(argList), strLstPtr(argList));
|
|
|
|
TEST_RESULT_VOID(lockStopTest(), "no stop files without stanza");
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
argList = strLstNew();
|
|
strLstAddZ(argList, "pgbackrest");
|
|
strLstAddZ(argList, "--stanza=db");
|
|
strLstAdd(argList, strNewFmt("--lock-path=%s", testPath()));
|
|
strLstAddZ(argList, "start");
|
|
harnessCfgLoad(strLstSize(argList), strLstPtr(argList));
|
|
|
|
TEST_RESULT_VOID(lockStopTest(), "no stop files with stanza");
|
|
|
|
storagePutNP(storageNewWriteNP(storageTest, strNew("all.stop")), NULL);
|
|
TEST_ERROR(lockStopTest(), StopError, "stop file exists for all stanzas");
|
|
|
|
storagePutNP(storageNewWriteNP(storageTest, strNew("db.stop")), NULL);
|
|
TEST_ERROR(lockStopTest(), StopError, "stop file exists for stanza db");
|
|
}
|
|
|
|
FUNCTION_HARNESS_RESULT_VOID();
|
|
}
|