You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-06-16 23:47:38 +02:00
Migrate control functions to detect stop files to C from Perl.
Basic functions to detect the presence of stanza or all stop files and error when they are present. The functionality to detect stop files without error was not migrated. This functionality is only used by stanza-delete and will be migrated with that command.
This commit is contained in:
61
test/src/module/command/controlTest.c
Normal file
61
test/src/module/command/controlTest.c
Normal file
@ -0,0 +1,61 @@
|
||||
/***********************************************************************************************************************************
|
||||
Test Command Control
|
||||
***********************************************************************************************************************************/
|
||||
#include "common/harnessConfig.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Test Run
|
||||
***********************************************************************************************************************************/
|
||||
void
|
||||
testRun(void)
|
||||
{
|
||||
FUNCTION_HARNESS_VOID();
|
||||
|
||||
// Create default storage object for testing
|
||||
Storage *storageTest = storageNewP(strNew(testPath()), .write = true);
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
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();
|
||||
}
|
Reference in New Issue
Block a user