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

Add defines for many test*() getter functions.

A define was already added for TEST_PATH but it was not widely used. Replace all occurrences of testPath() with TEST_PATH in the tests.

Replace testUser() with TEST_USER, testGroup() with TEST_GROUP, testRepoPath() with HRN_PATH_REPO, testDataPath() with HRN_PATH, testProjectExe() with TEST_PROJECT_EXE, and testScale() with TEST_SCALE.

Replace {[path]}, {[user]}, {[group]}, etc. with defines and remove hrnReplaceKey(). This is better than having two ways to deal with replacements.

In some cases the original test*() getters were kept because they are used by the harness, which does not have access to the new defines. Move them to harnessTest.intern.h to indicate that the tests should no longer use them.
This commit is contained in:
David Steele
2021-05-22 09:30:54 -04:00
parent aed3d468a1
commit b270253a69
47 changed files with 1079 additions and 1214 deletions

View File

@ -31,9 +31,11 @@ use pgBackRestTest::Common::VmTest;
use constant TEST_USER => getpwuid($UID) . '';
push @EXPORT, qw(TEST_USER);
use constant TEST_USER_ID => $UID;
push @EXPORT, qw(TEST_USER_ID);
use constant TEST_GROUP => getgrgid((getpwnam(TEST_USER))[3]) . '';
push @EXPORT, qw(TEST_GROUP);
use constant TEST_GROUP_ID => getgrnam(TEST_GROUP) . '';
push @EXPORT, qw(TEST_GROUP_ID);
####################################################################################################################################
# Cert file constants

View File

@ -620,10 +620,14 @@ sub run
$strTestC =~ s/\{\[C\_TEST\_CONTAINER\]\}/$strContainer/g;
$strTestC =~ s/\{\[C\_TEST\_PROJECT\_EXE\]\}/$strProjectExePath/g;
$strTestC =~ s/\{\[C\_TEST\_PATH\]\}/$strTestPathC/g;
$strTestC =~ s/\{\[C\_TEST\_USER\]\}/${\TEST_USER}/g;
$strTestC =~ s/\{\[C\_TEST\_USER\_ID\]\}/${\TEST_USER_ID}/g;
$strTestC =~ s/\{\[C\_TEST\_GROUP\]\}/${\TEST_GROUP}/g;
$strTestC =~ s/\{\[C\_TEST\_GROUP\_ID\]\}/${\TEST_GROUP_ID}/g;
$strTestC =~ s/\{\[C\_TEST\_PGB\_PATH\]\}/$strRepoCopyPath/g;
$strTestC =~ s/\{\[C\_TEST\_DATA_PATH\]\}/$self->{strDataPath}/g;
$strTestC =~ s/\{\[C\_HRN\_PATH\]\}/$self->{strDataPath}/g;
$strTestC =~ s/\{\[C\_TEST\_IDX\]\}/$self->{iVmIdx}/g;
$strTestC =~ s/\{\[C\_TEST\_REPO_PATH\]\}/$self->{strBackRestBase}/g;
$strTestC =~ s/\{\[C\_HRN\_PATH\_REPO\]\}/$self->{strBackRestBase}/g;
$strTestC =~ s/\{\[C\_TEST\_SCALE\]\}/$self->{iScale}/g;
my $strLogTimestampC = $self->{bLogTimestamp} ? 'true' : 'false';

View File

@ -78,11 +78,11 @@ harnessCfgLoadRole(ConfigCommand commandId, ConfigCommandRole commandRoleId, con
// Set log path if valid
if (cfgParseOptionValid(commandId, commandRoleId, cfgOptLogPath))
strLstInsert(argList, 0, strNewFmt("--" CFGOPT_LOG_PATH "=%s", testDataPath()));
strLstInsert(argList, 0, strNewFmt("--" CFGOPT_LOG_PATH "=%s", hrnPath()));
// Set lock path if valid
if (cfgParseOptionValid(commandId, commandRoleId, cfgOptLockPath))
strLstInsert(argList, 0, strNewFmt("--" CFGOPT_LOCK_PATH "=%s/lock", testDataPath()));
strLstInsert(argList, 0, strNewFmt("--" CFGOPT_LOCK_PATH "=%s/lock", hrnPath()));
// Insert the command so it does not interfere with parameters
strLstInsert(argList, 0, cfgCommandRoleNameParam(commandId, commandRoleId, COLON_STR));

View File

@ -72,7 +72,7 @@ harnessLogInit(void)
logInit(logLevelTestDefault, logLevelOff, logLevelInfo, false, logProcessId, 99, false);
logFileBanner = true;
snprintf(logFile, sizeof(logFile), "%s/expect.log", testDataPath());
snprintf(logFile, sizeof(logFile), "%s/expect.log", hrnPath());
logFdFile = harnessLogOpen(logFile, O_WRONLY | O_CREAT | O_TRUNC, 0640);
logAnySet();
@ -402,8 +402,6 @@ harnessLogResult(const char *expected)
harnessLogLoad(logFile);
hrnLogReplace();
expected = hrnReplaceKey(expected);
if (strcmp(harnessLogBuffer, expected) != 0)
{
THROW_FMT(

View File

@ -254,8 +254,8 @@ void hrnServerRun(IoRead *read, HrnServerProtocol protocol, HrnServerRunParam pa
// Else use a certificate from the test path -- tests will need to disable verify
else
{
param.certificate = strNewFmt("%s/" HRN_SERVER_CERT_PREFIX ".crt", testRepoPath());
param.key = strNewFmt("%s/" HRN_SERVER_CERT_PREFIX ".key", testRepoPath());
param.certificate = strNewFmt("%s/" HRN_SERVER_CERT_PREFIX ".crt", hrnPathRepo());
param.key = strNewFmt("%s/" HRN_SERVER_CERT_PREFIX ".key", hrnPathRepo());
}
}

View File

@ -4,8 +4,6 @@ C Test Harness
#include "build.auto.h"
#include <fcntl.h>
#include <grp.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -37,16 +35,10 @@ static const char *testProjectExeData = NULL;
static bool testContainerData = false;
static unsigned int testIdxData = 0;
static bool testTiming = true;
static uint64_t testScaleData = 1;
static const char *testPathData = NULL;
static const char *testDataPathData = NULL;
static const char *testRepoPathData = NULL;
static char testUserIdData[32];
static char testUserData[64];
static char testGroupIdData[32];
static char testGroupData[64];
static struct HarnessTestLocal
{
uint64_t logLastBeginTime; // Store the begin time of the last log for deltas
@ -73,8 +65,8 @@ Initialize harness
***********************************************************************************************************************************/
void
hrnInit(
const char *testExe, const char *testProjectExe, bool testContainer, unsigned int testIdx, bool timing, uint64_t testScale,
const char *testPath, const char *testDataPath, const char *testRepoPath)
const char *testExe, const char *testProjectExe, bool testContainer, unsigned int testIdx, bool timing, const char *testPath,
const char *testDataPath, const char *testRepoPath)
{
FUNCTION_HARNESS_VOID();
@ -84,41 +76,10 @@ hrnInit(
testContainerData = testContainer;
testIdxData = testIdx;
testTiming = timing;
testScaleData = testScale;
testPathData = testPath;
testDataPathData = testDataPath;
testRepoPathData = testRepoPath;
// Set test user id
snprintf(testUserIdData, sizeof(testUserIdData), "%u", getuid());
// Set test user
const char *testUserTemp = getpwuid(getuid())->pw_name;
if (strlen(testUserTemp) > sizeof(testUserData) - 1)
{
fprintf(stderr, "ERROR: test user name must be less than %zu characters", sizeof(testUserData) - 1);
fflush(stderr);
exit(255);
}
strcpy(testUserData, testUserTemp);
// Set test group id
snprintf(testGroupIdData, sizeof(testGroupIdData), "%u", getgid());
// Set test group
const char *testGroupTemp = getgrgid(getgid())->gr_name;
if (strlen(testGroupTemp) > sizeof(testGroupData) - 1)
{
fprintf(stderr, "ERROR: test group name must be less than %zu characters", sizeof(testGroupData) - 1);
fflush(stderr);
exit(255);
}
strcpy(testGroupData, testGroupTemp);
FUNCTION_HARNESS_RETURN_VOID();
}
@ -185,11 +146,11 @@ testBegin(const char *name)
// Clear out the data directory so the next test starts clean
snprintf(
buffer, sizeof(buffer), "%schmod -R 700 %s/" "* > /dev/null 2>&1;%srm -rf %s/" "*", testContainer() ? "sudo " : "",
testDataPath(), testContainer() ? "sudo " : "", testDataPath());
hrnPath(), testContainer() ? "sudo " : "", hrnPath());
if (system(buffer) != 0)
{
fprintf(stderr, "ERROR: unable to clear data path '%s'\n", testDataPath());
fprintf(stderr, "ERROR: unable to clear data path '%s'\n", hrnPath());
fflush(stderr);
exit(255);
}
@ -247,72 +208,6 @@ hrnComplete(void)
FUNCTION_HARNESS_RETURN_VOID();
}
/***********************************************************************************************************************************
Replace a substring with another string
***********************************************************************************************************************************/
static void
hrnReplaceStr(char *string, size_t bufferSize, const char *substring, const char *replace)
{
FUNCTION_HARNESS_BEGIN();
FUNCTION_HARNESS_PARAM(STRINGZ, string);
FUNCTION_HARNESS_PARAM(SIZE, bufferSize);
FUNCTION_HARNESS_PARAM(STRINGZ, substring);
FUNCTION_HARNESS_PARAM(STRINGZ, replace);
FUNCTION_HARNESS_END();
ASSERT(string != NULL);
ASSERT(substring != NULL);
// Find substring
char *begin = strstr(string, substring);
while (begin != NULL)
{
// Find end of substring and calculate replace size difference
char *end = begin + strlen(substring);
int diff = (int)strlen(replace) - (int)strlen(substring);
// Make sure we won't overflow the buffer
CHECK((size_t)((int)strlen(string) + diff) < bufferSize - 1);
// Move data from end of string enough to make room for the replacement and copy replacement
memmove(end + diff, end, strlen(end) + 1);
memcpy(begin, replace, strlen(replace));
// Find next substring
begin = strstr(begin + strlen(replace), substring);
}
FUNCTION_HARNESS_RETURN_VOID();
}
/**********************************************************************************************************************************/
char harnessReplaceKeyBuffer[256 * 1024];
const char *
hrnReplaceKey(const char *string)
{
FUNCTION_HARNESS_BEGIN();
FUNCTION_HARNESS_PARAM(STRINGZ, string);
FUNCTION_HARNESS_END();
ASSERT(string != NULL);
// Make sure we won't overflow the buffer
ASSERT(strlen(string) < sizeof(harnessReplaceKeyBuffer) - 1);
strcpy(harnessReplaceKeyBuffer, string);
hrnReplaceStr(harnessReplaceKeyBuffer, sizeof(harnessReplaceKeyBuffer), "{[path]}", testPath());
hrnReplaceStr(harnessReplaceKeyBuffer, sizeof(harnessReplaceKeyBuffer), "{[path-data]}", testDataPath());
hrnReplaceStr(harnessReplaceKeyBuffer, sizeof(harnessReplaceKeyBuffer), "{[user-id]}", testUserIdData);
hrnReplaceStr(harnessReplaceKeyBuffer, sizeof(harnessReplaceKeyBuffer), "{[user]}", testUser());
hrnReplaceStr(harnessReplaceKeyBuffer, sizeof(harnessReplaceKeyBuffer), "{[group-id]}", testGroupIdData);
hrnReplaceStr(harnessReplaceKeyBuffer, sizeof(harnessReplaceKeyBuffer), "{[group]}", testGroup());
hrnReplaceStr(harnessReplaceKeyBuffer, sizeof(harnessReplaceKeyBuffer), "{[project-exe]}", testProjectExe());
FUNCTION_HARNESS_RETURN(STRINGZ, harnessReplaceKeyBuffer);
}
/**********************************************************************************************************************************/
void
hrnFileRead(const char *fileName, unsigned char *buffer, size_t bufferSize)
@ -378,17 +273,17 @@ hrnDiff(const char *expected, const char *actual)
// Write expected file
char expectedFile[1024];
snprintf(expectedFile, sizeof(expectedFile), "%s/diff.expected", testDataPath());
snprintf(expectedFile, sizeof(expectedFile), "%s/diff.expected", hrnPath());
hrnFileWrite(expectedFile, (unsigned char *)expected, strlen(expected));
// Write actual file
char actualFile[1024];
snprintf(actualFile, sizeof(actualFile), "%s/diff.actual", testDataPath());
snprintf(actualFile, sizeof(actualFile), "%s/diff.actual", hrnPath());
hrnFileWrite(actualFile, (unsigned char *)actual, strlen(actual));
// Perform diff
char command[2560];
snprintf(command, sizeof(command), "diff -u %s %s > %s/diff.result", expectedFile, actualFile, testDataPath());
snprintf(command, sizeof(command), "diff -u %s %s > %s/diff.result", expectedFile, actualFile, hrnPath());
if (system(command) == 2)
{
@ -399,7 +294,7 @@ hrnDiff(const char *expected, const char *actual)
// Read result
char resultFile[1024];
snprintf(resultFile, sizeof(resultFile), "%s/diff.result", testDataPath());
snprintf(resultFile, sizeof(resultFile), "%s/diff.result", hrnPath());
hrnFileRead(resultFile, (unsigned char *)harnessDiffBuffer, sizeof(harnessDiffBuffer));
// Remove last linefeed from diff output
@ -780,14 +675,6 @@ testIdx(void)
FUNCTION_HARNESS_RETURN(UINT, testIdxData);
}
/**********************************************************************************************************************************/
uint64_t
testScale(void)
{
FUNCTION_HARNESS_VOID();
FUNCTION_HARNESS_RETURN(UINT64, testScaleData);
}
/**********************************************************************************************************************************/
const char *
testPath(void)
@ -798,7 +685,7 @@ testPath(void)
/**********************************************************************************************************************************/
const char *
testDataPath(void)
hrnPath(void)
{
FUNCTION_HARNESS_VOID();
FUNCTION_HARNESS_RETURN(STRINGZ, testDataPathData);
@ -806,26 +693,12 @@ testDataPath(void)
/**********************************************************************************************************************************/
const char *
testRepoPath(void)
hrnPathRepo(void)
{
FUNCTION_HARNESS_VOID();
FUNCTION_HARNESS_RETURN(STRINGZ, testRepoPathData);
}
/**********************************************************************************************************************************/
const char *
testUser(void)
{
return testUserData;
}
/**********************************************************************************************************************************/
const char *
testGroup(void)
{
return testGroupData;
}
/**********************************************************************************************************************************/
uint64_t
testTimeMSec(void)

View File

@ -28,19 +28,6 @@ void hrnFileRead(const char *fileName, unsigned char *buffer, size_t bufferSize)
// Write a buffer to a file
void hrnFileWrite(const char *fileName, const unsigned char *buffer, size_t bufferSize);
// Replace common test values in a string and return a buffer with the replacements.
//
// Note that the returned buffer will be overwritten with each call. Values that can be replaced are:
//
// {[path]} - the current test path
// {[path-data]} - the current test data path
// {[user-id]} - the current test user id
// {[user]} - the current test user
// {[group-id]} - the current test group id
// {[group]} - the current test group
// {[project-exe]} - the project exe
const char *hrnReplaceKey(const char *string);
// Diff two strings using command-line diff tool
const char *hrnDiff(const char *actual, const char *expected);
@ -56,34 +43,13 @@ uint64_t testTimeMSecBegin(void);
// The path and name of the test executable
const char *testExe(void);
// Path where test data is written
const char *testPath(void);
// Path to a copy of the repository
const char *testRepoPath(void);
// Test OS user
const char *testUser(void);
// Test OS group
const char *testGroup(void);
// Is this test running in a container?
bool testContainer(void);
// Location of the data path were the harness can write data that won't be visible to the test
const char *testDataPath(void);
// Get the 0-based index of the test. Useful for modifying resources like port numbers to avoid conflicts when running tests in
// parallel.
unsigned int testIdx(void);
// Location of the project exe
const char *testProjectExe(void);
// For scaling performance tests
uint64_t testScale(void);
/***********************************************************************************************************************************
Test that an expected error is actually thrown and error when it isn't
***********************************************************************************************************************************/
@ -106,7 +72,7 @@ Test that an expected error is actually thrown and error when it isn't
{ \
TEST_ERROR_catch = true; \
\
if (strcmp(errorMessage(), hrnReplaceKey(errorMessageExpected)) != 0 || errorType() != &errorTypeExpected) \
if (strcmp(errorMessage(), errorMessageExpected) != 0 || errorType() != &errorTypeExpected) \
THROW_FMT( \
TestError, "EXPECTED %s: %s\n\n BUT GOT %s: %s\n\nTHROWN AT:\n%s", errorTypeName(&errorTypeExpected), \
errorMessageExpected, errorName(), errorMessage(), errorStackTrace()); \
@ -241,9 +207,9 @@ Macros to compare results of common data types
#define TEST_RESULT_STR_Z(statement, resultExpected, ...) \
TEST_RESULT_Z(strZNull(statement), resultExpected, __VA_ARGS__)
#define TEST_RESULT_STR_KEYRPL(statement, resultExpected, ...) \
TEST_RESULT_Z(strZNull(statement), hrnReplaceKey(strZ(resultExpected)), __VA_ARGS__)
TEST_RESULT_Z(strZNull(statement), strZ(resultExpected), __VA_ARGS__)
#define TEST_RESULT_STR_Z_KEYRPL(statement, resultExpected, ...) \
TEST_RESULT_Z(strZNull(statement), hrnReplaceKey(resultExpected), __VA_ARGS__)
TEST_RESULT_Z(strZNull(statement), resultExpected, __VA_ARGS__)
#define TEST_RESULT_Z_STR(statement, resultExpected, ...) \
TEST_RESULT_Z(statement, strZNull(resultExpected), __VA_ARGS__)
@ -290,13 +256,13 @@ Test system calls
#define TEST_SYSTEM(command) \
do \
{ \
int TEST_SYSTEM_FMT_result = system(hrnReplaceKey(command)); \
int TEST_SYSTEM_FMT_result = system(command); \
\
if (TEST_SYSTEM_FMT_result != 0) \
{ \
THROW_FMT( \
AssertError, "SYSTEM COMMAND: %s\n\nFAILED WITH CODE %d\n\nTHROWN AT:\n%s", hrnReplaceKey(command), \
TEST_SYSTEM_FMT_result, errorStackTrace()); \
AssertError, "SYSTEM COMMAND: %s\n\nFAILED WITH CODE %d\n\nTHROWN AT:\n%s", command, TEST_SYSTEM_FMT_result, \
errorStackTrace()); \
} \
} while (0)

View File

@ -21,12 +21,27 @@ typedef enum
harnessTestResultOperationNe,
} HarnessTestResultOperation;
/***********************************************************************************************************************************
Getters/Setters
***********************************************************************************************************************************/
// Location of the data path were the harness can write data that won't be visible to the test
const char *hrnPath(void);
// Path to the source repository
const char *hrnPathRepo(void);
// Path where test data is written
const char *testPath(void);
// Location of the project exe
const char *testProjectExe(void);
/***********************************************************************************************************************************
Functions
***********************************************************************************************************************************/
void hrnInit(
const char *testExe, const char *testProjectExe, bool testContainer, unsigned int testIdx, bool timing, uint64_t testScale,
const char *testPath, const char *testDataPath, const char *testRepoPath);
const char *testExe, const char *testProjectExe, bool testContainer, unsigned int testIdx, bool timing, const char *testPath,
const char *testDataPath, const char *testRepoPath);
void hrnAdd(int run, bool selected);
void hrnComplete(void);

View File

@ -19,13 +19,13 @@ testRun(void)
FUNCTION_HARNESS_VOID();
// Create default storage object for testing
Storage *storageTest = storagePosixNewP(strNewZ(testPath()), .write = true);
Storage *storageTest = storagePosixNewP(TEST_PATH_STR, .write = true);
// *****************************************************************************************************************************
if (testBegin("archiveAsyncErrorClear() and archiveAsyncStatus()"))
{
StringList *argList = strLstNew();
strLstAdd(argList, strNewFmt("--spool-path=%s", testPath()));
strLstAddZ(argList, "--spool-path=" TEST_PATH);
strLstAddZ(argList, "--archive-async");
strLstAddZ(argList, "--archive-timeout=1");
strLstAddZ(argList, "--stanza=db");
@ -38,9 +38,9 @@ testRun(void)
TEST_RESULT_BOOL(archiveAsyncStatus(archiveModeGet, segment, false, true), false, "directory and status file not present");
// -------------------------------------------------------------------------------------------------------------------------
mkdir(strZ(strNewFmt("%s/archive", testPath())), 0750);
mkdir(strZ(strNewFmt("%s/archive/db", testPath())), 0750);
mkdir(strZ(strNewFmt("%s/archive/db/out", testPath())), 0750);
mkdir(TEST_PATH "/archive", 0750);
mkdir(TEST_PATH "/archive/db", 0750);
mkdir(TEST_PATH "/archive/db/out", 0750);
TEST_RESULT_BOOL(archiveAsyncStatus(archiveModePush, segment, false, true), false, "status file not present");
@ -134,7 +134,7 @@ testRun(void)
if (testBegin("archiveAsyncStatusErrorWrite() and archiveAsyncStatusOkWrite()"))
{
StringList *argList = strLstNew();
strLstAdd(argList, strNewFmt("--spool-path=%s", testPath()));
strLstAddZ(argList, "--spool-path=" TEST_PATH);
strLstAddZ(argList, "--stanza=db");
hrnCfgArgRawZ(argList, cfgOptPgPath, "/path/to/pg");
strLstAddZ(argList, "--" CFGOPT_ARCHIVE_ASYNC);
@ -219,7 +219,7 @@ testRun(void)
THROW_ON_SYS_ERROR(chdir("/") != 0, PathMissingError, "unable to chdir()");
TEST_ERROR(
walPath(STRDEF("relative/path"), pgPathLink, STRDEF("test")), OptionInvalidValueError,
"PostgreSQL working directory '/' is not the same as option pg1-path '{[path]}/pg-link'\n"
"PostgreSQL working directory '/' is not the same as option pg1-path '" TEST_PATH "/pg-link'\n"
"HINT: is the PostgreSQL data_directory configured the same as the pg1-path option?");
TEST_ERROR(
@ -236,7 +236,7 @@ testRun(void)
StringList *argList = strLstNew();
strLstAddZ(argList, "--stanza=db");
hrnCfgArgRawZ(argList, cfgOptPgPath, "/path/to/pg");
strLstAdd(argList, strNewFmt("--repo-path=%s", testPath()));
strLstAddZ(argList, "--repo-path=" TEST_PATH);
strLstAddZ(argList, "archive-get");
harnessCfgLoad(cfgCmdArchiveGet, argList);

View File

@ -24,7 +24,7 @@ testRun(void)
{
FUNCTION_HARNESS_VOID();
Storage *storageTest = storagePosixNewP(strNewZ(testPath()), .write = true);
Storage *storageTest = storagePosixNewP(TEST_PATH_STR, .write = true);
// *****************************************************************************************************************************
if (testBegin("queueNeed()"))
@ -33,15 +33,15 @@ testRun(void)
strLstAddZ(argList, "--stanza=test1");
strLstAddZ(argList, "--archive-async");
hrnCfgArgRawZ(argList, cfgOptPgPath, "/unused");
strLstAdd(argList, strNewFmt("--spool-path=%s/spool", testPath()));
strLstAddZ(argList, "--spool-path=" TEST_PATH "/spool");
harnessCfgLoad(cfgCmdArchiveGet, argList);
size_t queueSize = 16 * 1024 * 1024;
size_t walSegmentSize = 16 * 1024 * 1024;
TEST_ERROR_FMT(
TEST_ERROR(
queueNeed(STRDEF("000000010000000100000001"), false, queueSize, walSegmentSize, PG_VERSION_92),
PathMissingError, "unable to list file info for missing path '%s/spool/archive/test1/in'", testPath());
PathMissingError, "unable to list file info for missing path '" TEST_PATH "/spool/archive/test1/in'");
// -------------------------------------------------------------------------------------------------------------------------
storagePathCreateP(storageSpoolWrite(), STRDEF(STORAGE_SPOOL_ARCHIVE_IN));
@ -574,7 +574,7 @@ testRun(void)
hrnCfgArgRawZ(argBaseList, cfgOptRepoPath, TEST_PATH_REPO);
hrnCfgArgRawZ(argBaseList, cfgOptStanza, "test1");
hrnCfgArgRawZ(argBaseList, cfgOptArchiveTimeout, "1");
hrnCfgArgRawFmt(argBaseList, cfgOptLockPath, "%s/lock", testDataPath());
hrnCfgArgRawZ(argBaseList, cfgOptLockPath, HRN_PATH "/lock");
strLstAddZ(argBaseList, CFGCMD_ARCHIVE_GET);
// -------------------------------------------------------------------------------------------------------------------------
@ -604,7 +604,7 @@ testRun(void)
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL,
hrnPgControlToBuffer((PgControl){.version = PG_VERSION_10, .systemId = 0xFACEFACEFACEFACE}));
storagePathCreateP(storageTest, strNewFmt("%s/pg/pg_wal", testPath()));
storagePathCreateP(storageTest, STRDEF(TEST_PATH "/pg/pg_wal"));
strLstAddZ(argList, TEST_PATH_PG "/pg_wal/RECOVERYXLOG");
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));

View File

@ -23,7 +23,7 @@ testRun(void)
FUNCTION_HARNESS_VOID();
// Create default storage object for testing
Storage *storageTest = storagePosixNewP(strNewZ(testPath()), .write = true);
Storage *storageTest = storagePosixNewP(TEST_PATH_STR, .write = true);
// Start a protocol server to test the protocol directly
Buffer *serverWrite = bufNew(8192);
@ -40,8 +40,8 @@ testRun(void)
{
StringList *argList = strLstNew();
strLstAddZ(argList, "--stanza=db");
strLstAdd(argList, strNewFmt("--pg1-path=%s/db", testPath()));
strLstAdd(argList, strNewFmt("--spool-path=%s/spool", testPath()));
strLstAddZ(argList, "--pg1-path=" TEST_PATH "/db");
strLstAddZ(argList, "--spool-path=" TEST_PATH "/spool");
strLstAddZ(argList, "--" CFGOPT_ARCHIVE_ASYNC);
harnessCfgLoadRole(cfgCmdArchivePush, cfgCmdRoleAsync, argList);
@ -69,7 +69,7 @@ testRun(void)
storagePutP(storageNewWriteP(storagePgWrite(), STRDEF("pg_wal/archive_status/000000010000000100000006.ready")), NULL);
TEST_RESULT_STRLST_Z(
archivePushProcessList(strNewFmt("%s/db/pg_wal", testPath())),
archivePushProcessList(STRDEF(TEST_PATH "/db/pg_wal")),
"000000010000000100000002\n000000010000000100000005\n000000010000000100000006\n", "ready list");
TEST_RESULT_STRLST_Z(
@ -95,7 +95,7 @@ testRun(void)
// Queue max is high enough that no WAL will be dropped
TEST_RESULT_BOOL(
archivePushDrop(STRDEF("pg_wal"), archivePushProcessList(strNewFmt("%s/db/pg_wal", testPath()))), false,
archivePushDrop(STRDEF("pg_wal"), archivePushProcessList(STRDEF(TEST_PATH "/db/pg_wal"))), false,
"wal is not dropped");
// Now set queue max low enough that WAL will be dropped
@ -104,7 +104,7 @@ testRun(void)
harnessCfgLoadRole(cfgCmdArchivePush, cfgCmdRoleAsync, argListDrop);
TEST_RESULT_BOOL(
archivePushDrop(STRDEF("pg_wal"), archivePushProcessList(strNewFmt("%s/db/pg_wal", testPath()))), true,
archivePushDrop(STRDEF("pg_wal"), archivePushProcessList(STRDEF(TEST_PATH "/db/pg_wal"))), true,
"wal is dropped");
}
@ -113,8 +113,8 @@ testRun(void)
{
StringList *argList = strLstNew();
strLstAddZ(argList, "--stanza=test");
strLstAdd(argList, strNewFmt("--pg1-path=%s/pg", testPath()));
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAddZ(argList, "--pg1-path=" TEST_PATH "/pg");
strLstAddZ(argList, "--repo1-path=" TEST_PATH "/repo");
harnessCfgLoad(cfgCmdArchivePush, argList);
// Check mismatched pg_control and archive.info
@ -184,8 +184,8 @@ testRun(void)
argList = strLstNew();
strLstAddZ(argList, "--stanza=test");
strLstAdd(argList, strNewFmt("--repo2-path=%s/repo2", testPath()));
strLstAdd(argList, strNewFmt("--repo4-path=%s/repo4", testPath()));
strLstAddZ(argList, "--repo2-path=" TEST_PATH "/repo2");
strLstAddZ(argList, "--repo4-path=" TEST_PATH "/repo4");
harnessCfgLoad(cfgCmdArchivePush, argList);
// repo2 has correct info
@ -290,8 +290,8 @@ testRun(void)
// Create pg_control and archive.info
// -------------------------------------------------------------------------------------------------------------------------
strLstAdd(argList, strNewFmt("--pg1-path=%s/pg", testPath()));
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAddZ(argList, "--pg1-path=" TEST_PATH "/pg");
strLstAddZ(argList, "--repo1-path=" TEST_PATH "/repo");
argListTemp = strLstDup(argList);
strLstAddZ(argListTemp, "pg_wal/000000010000000100000001");
@ -323,7 +323,7 @@ testRun(void)
TEST_ERROR(
cmdArchivePush(), ArchiveMismatchError,
"WAL file '{[path]}/pg/pg_wal/000000010000000100000001' version 10, system-id 18072658121562454734 do not match"
"WAL file '" TEST_PATH "/pg/pg_wal/000000010000000100000001' version 10, system-id 18072658121562454734 do not match"
" stanza version 11, system-id 18072658121562454734");
memset(bufPtr(walBuffer1), 0, bufSize(walBuffer1));
@ -334,7 +334,7 @@ testRun(void)
TEST_ERROR(
cmdArchivePush(), ArchiveMismatchError,
"WAL file '{[path]}/pg/pg_wal/000000010000000100000001' version 11, system-id 17055110554209741999 do not match"
"WAL file '" TEST_PATH "/pg/pg_wal/000000010000000100000001' version 11, system-id 17055110554209741999 do not match"
" stanza version 11, system-id 18072658121562454734");
// -------------------------------------------------------------------------------------------------------------------------
@ -405,8 +405,8 @@ testRun(void)
argListTemp = strLstNew();
strLstAddZ(argListTemp, "--" CFGOPT_STANZA "=test");
hrnCfgArgRawFmt(argListTemp, cfgOptRepoPath, "%s/repo", testPath());
strLstAdd(argListTemp, strNewFmt("%s/pg/pg_wal/000000010000000100000002", testPath()));
hrnCfgArgRawZ(argListTemp, cfgOptRepoPath, TEST_PATH "/repo");
strLstAddZ(argListTemp, TEST_PATH "/pg/pg_wal/000000010000000100000002");
harnessCfgLoad(cfgCmdArchivePush, argListTemp);
TEST_RESULT_VOID(
@ -476,7 +476,7 @@ testRun(void)
// Check protocol function directly
// -------------------------------------------------------------------------------------------------------------------------
VariantList *paramList = varLstNew();
varLstAdd(paramList, varNewStr(strNewFmt("%s/pg/pg_wal/000000010000000100000002", testPath())));
varLstAdd(paramList, varNewStrZ(TEST_PATH "/pg/pg_wal/000000010000000100000002"));
varLstAdd(paramList, varNewBool(true));
varLstAdd(paramList, varNewUInt64(PG_VERSION_11));
varLstAdd(paramList, varNewUInt64(0xFACEFACEFACEFACE));
@ -537,11 +537,11 @@ testRun(void)
// Push encrypted WAL segment
argListTemp = strLstNew();
hrnCfgArgRawZ(argListTemp, cfgOptStanza, "test");
hrnCfgArgKeyRawFmt(argListTemp, cfgOptPgPath, 1, "%s/pg", testPath());
hrnCfgArgKeyRawFmt(argListTemp, cfgOptRepoPath, 2, "%s/repo2", testPath());
hrnCfgArgKeyRawZ(argListTemp, cfgOptPgPath, 1, TEST_PATH "/pg");
hrnCfgArgKeyRawZ(argListTemp, cfgOptRepoPath, 2, TEST_PATH "/repo2");
hrnCfgArgKeyRawStrId(argListTemp, cfgOptRepoCipherType, 2, cipherTypeAes256Cbc);
hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 2, "badpassphrase");
hrnCfgArgKeyRawFmt(argListTemp, cfgOptRepoPath, 3, "%s/repo3", testPath());
hrnCfgArgKeyRawZ(argListTemp, cfgOptRepoPath, 3, TEST_PATH "/repo3");
hrnCfgArgRawNegate(argListTemp, cfgOptCompress);
strLstAddZ(argListTemp, "pg_wal/000000010000000100000002");
harnessCfgLoad(cfgCmdArchivePush, argListTemp);
@ -577,7 +577,7 @@ testRun(void)
strZ(
strNewFmt(
"archive-push command encountered error(s):\n"
"repo2: [FileOpenError] unable to open file '{[path]}/repo2/archive/test/11-1/0000000100000001"
"repo2: [FileOpenError] unable to open file '" TEST_PATH "/repo2/archive/test/11-1/0000000100000001"
"/000000010000000100000002-%s' for write: [13] Permission denied", walBuffer2Sha1)));
TEST_RESULT_BOOL(
@ -628,10 +628,11 @@ testRun(void)
TEST_ERROR(
cmdArchivePush(), CommandError,
"archive-push command encountered error(s):\n"
"repo2: [FileOpenError] unable to load info file '{[path]}/repo2/archive/test/archive.info' or"
" '{[path]}/repo2/archive/test/archive.info.copy':\n"
"FileOpenError: unable to open file '{[path]}/repo2/archive/test/archive.info' for read: [13] Permission denied\n"
"FileOpenError: unable to open file '{[path]}/repo2/archive/test/archive.info.copy' for read: [13] Permission denied\n"
"repo2: [FileOpenError] unable to load info file '" TEST_PATH "/repo2/archive/test/archive.info' or"
" '" TEST_PATH "/repo2/archive/test/archive.info.copy':\n"
"FileOpenError: unable to open file '" TEST_PATH "/repo2/archive/test/archive.info' for read: [13] Permission denied\n"
"FileOpenError: unable to open file '" TEST_PATH "/repo2/archive/test/archive.info.copy' for read:"
" [13] Permission denied\n"
"HINT: archive.info cannot be opened but is required to push/get WAL segments.\n"
"HINT: is archive_command configured correctly in postgresql.conf?\n"
"HINT: has a stanza-create been performed?\n"
@ -651,8 +652,8 @@ testRun(void)
TEST_ERROR(
cmdArchivePush(), CommandError,
"archive-push command encountered error(s):\n"
"repo2: [PathOpenError] unable to list file info for path '{[path]}/repo2/archive/test/11-1/0000000100000001': [13]"
" Permission denied");
"repo2: [PathOpenError] unable to list file info for path '" TEST_PATH "/repo2/archive/test/11-1/0000000100000001':"
" [13] Permission denied");
// Make sure WAL got pushed to repo3
TEST_STORAGE_REMOVE(
@ -697,10 +698,10 @@ testRun(void)
strLstAddZ(argList, "--stanza=test");
strLstAddZ(argList, "--archive-async");
strLstAddZ(argList, "--archive-timeout=1");
strLstAdd(argList, strNewFmt("--lock-path=%s/lock", testPath()));
strLstAdd(argList, strNewFmt("--spool-path=%s/spool", testPath()));
strLstAdd(argList, strNewFmt("--pg1-path=%s/pg", testPath()));
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAddZ(argList, "--lock-path=" TEST_PATH "/lock");
strLstAddZ(argList, "--spool-path=" TEST_PATH " /spool");
strLstAddZ(argList, "--pg1-path=" TEST_PATH "/pg");
strLstAddZ(argList, "--repo1-path=" TEST_PATH "/repo");
strLstAddZ(argList, "archive-push");
strLstAddZ(argList, "pg_wal/bogus");
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
@ -718,9 +719,9 @@ testRun(void)
strLstAddZ(argList, "--stanza=test");
strLstAddZ(argList, "--archive-async");
strLstAddZ(argList, "--no-compress");
strLstAdd(argList, strNewFmt("--spool-path=%s/spool", testPath()));
strLstAdd(argList, strNewFmt("--pg1-path=%s/pg", testPath()));
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAddZ(argList, "--spool-path=" TEST_PATH "/spool");
strLstAddZ(argList, "--pg1-path=" TEST_PATH "/pg");
strLstAddZ(argList, "--repo1-path=" TEST_PATH "/repo");
strLstAddZ(argList, "--log-subprocess");
storagePutP(
@ -739,7 +740,7 @@ testRun(void)
// Write out an error file that will be ignored on the first pass, then the async process will write a new one
// -------------------------------------------------------------------------------------------------------------------------
StringList *argListTemp = strLstDup(argList);
strLstAdd(argListTemp, strNewFmt("%s/pg/pg_xlog/000000010000000100000001", testPath()));
strLstAddZ(argListTemp, TEST_PATH "/pg/pg_xlog/000000010000000100000001");
harnessCfgLoad(cfgCmdArchivePush, argListTemp);
storagePathCreateP(storagePgWrite(), STRDEF("pg_xlog/archive_status"));
@ -755,7 +756,7 @@ testRun(void)
// Acquire a lock so the async process will not be able to run -- this will result in a timeout
// -------------------------------------------------------------------------------------------------------------------------
argListTemp = strLstDup(argList);
strLstAdd(argListTemp, strNewFmt("%s/pg/pg_xlog/000000010000000100000001", testPath()));
strLstAddZ(argListTemp, TEST_PATH "/pg/pg_xlog/000000010000000100000001");
strLstAddZ(argListTemp, "--archive-timeout=1");
harnessCfgLoad(cfgCmdArchivePush, argListTemp);
@ -807,7 +808,7 @@ testRun(void)
// Actually push a WAL file
// -------------------------------------------------------------------------------------------------------------------------
argListTemp = strLstDup(argList);
strLstAdd(argListTemp, strNewFmt("%s/pg/pg_xlog/000000010000000100000001", testPath()));
strLstAddZ(argListTemp, TEST_PATH "/pg/pg_xlog/000000010000000100000001");
harnessCfgLoad(cfgCmdArchivePush, argListTemp);
storagePutP(storageNewWriteP(storagePgWrite(), STRDEF("pg_xlog/archive_status/000000010000000100000001.ready")), NULL);
@ -833,10 +834,10 @@ testRun(void)
argList = strLstNew();
strLstAddZ(argList, "--stanza=test");
hrnCfgArgRawZ(argList, cfgOptCompressType, "none");
strLstAdd(argList, strNewFmt("--spool-path=%s/spool", testPath()));
strLstAddZ(argList, "--spool-path=" TEST_PATH "/spool");
strLstAddZ(argList, "--" CFGOPT_ARCHIVE_ASYNC);
strLstAdd(argList, strNewFmt("--pg1-path=%s/pg", testPath()));
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAddZ(argList, "--pg1-path=" TEST_PATH "/pg");
strLstAddZ(argList, "--repo1-path=" TEST_PATH "/repo");
strLstAddZ(argList, "--log-subprocess");
harnessCfgLoadRole(cfgCmdArchivePush, cfgCmdRoleAsync, argList);
@ -851,7 +852,7 @@ testRun(void)
storagePathRemoveP(storagePgWrite(), STRDEF("pg_xlog/archive_status"), .recurse = true);
storagePathCreateP(storagePgWrite(), STRDEF("pg_xlog/archive_status"));
strLstAdd(argList, strNewFmt("%s/pg/pg_xlog", testPath()));
strLstAddZ(argList, TEST_PATH "/pg/pg_xlog");
harnessCfgLoadRole(cfgCmdArchivePush, cfgCmdRoleAsync, argList);
TEST_ERROR(cmdArchivePushAsync(), AssertError, "no WAL files to process");
@ -868,7 +869,7 @@ testRun(void)
TEST_TITLE("add repo, push already pushed WAL and new WAL");
// Add repo3
hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 3, "%s/repo3", testPath());
hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 3, TEST_PATH "/repo3");
harnessCfgLoadRole(cfgCmdArchivePush, cfgCmdRoleAsync, argList);
storagePutP(
@ -892,16 +893,14 @@ testRun(void)
storagePutP(storageNewWriteP(storagePgWrite(), STRDEF("pg_xlog/archive_status/000000010000000100000002.ready")), NULL);
TEST_RESULT_VOID(cmdArchivePushAsync(), "push WAL segments");
harnessLogResult(
strZ(
strNewFmt(
"P00 INFO: push 2 WAL file(s) to archive: 000000010000000100000001...000000010000000100000002\n"
"P01 WARN: WAL file '000000010000000100000001' already exists in the repo1 archive with the same checksum\n"
" HINT: this is valid in some recovery scenarios but may also indicate a problem.\n"
"P01 DETAIL: pushed WAL file '000000010000000100000001' to the archive\n"
"P01 WARN: could not push WAL file '000000010000000100000002' to the archive (will be retried): "
"[55] raised from local-1 protocol: " STORAGE_ERROR_READ_MISSING,
strZ(strNewFmt("%s/pg/pg_xlog/000000010000000100000002", testPath())))));
TEST_RESULT_LOG_FMT(
"P00 INFO: push 2 WAL file(s) to archive: 000000010000000100000001...000000010000000100000002\n"
"P01 WARN: WAL file '000000010000000100000001' already exists in the repo1 archive with the same checksum\n"
" HINT: this is valid in some recovery scenarios but may also indicate a problem.\n"
"P01 DETAIL: pushed WAL file '000000010000000100000001' to the archive\n"
"P01 WARN: could not push WAL file '000000010000000100000002' to the archive (will be retried): "
"[55] raised from local-1 protocol: " STORAGE_ERROR_READ_MISSING,
TEST_PATH "/pg/pg_xlog/000000010000000100000002");
TEST_RESULT_BOOL(
storageExistsP(

View File

@ -106,11 +106,11 @@ testBackupValidateCallback(void *callbackData, const StorageInfo *info)
if (info->mode != 0640)
THROW_FMT(AssertError, "'%s' mode is not 0640", strZ(manifestName));
if (!strEqZ(info->user, testUser()))
THROW_FMT(AssertError, "'%s' user should be '%s'", strZ(manifestName), testUser());
if (!strEq(info->user, TEST_USER_STR))
THROW_FMT(AssertError, "'%s' user should be '" TEST_USER "'", strZ(manifestName));
if (!strEqZ(info->group, testGroup()))
THROW_FMT(AssertError, "'%s' group should be '%s'", strZ(manifestName), testGroup());
if (!strEq(info->group, TEST_GROUP_STR))
THROW_FMT(AssertError, "'%s' group should be '" TEST_GROUP "'", strZ(manifestName));
break;
}
@ -132,11 +132,11 @@ testBackupValidateCallback(void *callbackData, const StorageInfo *info)
if (info->mode != 0750)
THROW_FMT(AssertError, "'%s' mode is not 00750", strZ(info->name));
if (!strEqZ(info->user, testUser()))
THROW_FMT(AssertError, "'%s' user should be '%s'", strZ(info->name), testUser());
if (!strEq(info->user, TEST_USER_STR))
THROW_FMT(AssertError, "'%s' user should be '" TEST_USER "'", strZ(info->name));
if (!strEqZ(info->group, testGroup()))
THROW_FMT(AssertError, "'%s' group should be '%s'", strZ(info->name), testGroup());
if (!strEq(info->group, TEST_GROUP_STR))
THROW_FMT(AssertError, "'%s' group should be '" TEST_GROUP "'", strZ(info->name));
break;
}
@ -248,8 +248,8 @@ typedef struct TestBackupPqScriptParam
static void
testBackupPqScript(unsigned int pgVersion, time_t backupTimeStart, TestBackupPqScriptParam param)
{
const char *pg1Path = strZ(strNewFmt("%s/pg1", testPath()));
const char *pg2Path = strZ(strNewFmt("%s/pg2", testPath()));
const char *pg1Path = TEST_PATH "/pg1";
const char *pg2Path = TEST_PATH "/pg2";
// If no timeline specified then use timeline 1
param.timeline = param.timeline == 0 ? 1 : param.timeline;
@ -449,7 +449,7 @@ testRun(void)
// The tests expect the timezone to be UTC
setenv("TZ", "UTC", true);
Storage *storageTest = storagePosixNewP(strNewZ(testPath()), .write = true);
Storage *storageTest = storagePosixNewP(TEST_PATH_STR, .write = true);
const String *pgFile = STRDEF("testfile");
const String *missingFile = STRDEF("missing");
@ -471,8 +471,8 @@ testRun(void)
// Load Parameters
StringList *argList = strLstNew();
strLstAddZ(argList, "--stanza=test1");
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAdd(argList, strNewFmt("--pg1-path=%s/pg", testPath()));
strLstAddZ(argList, "--repo1-path=" TEST_PATH "/repo");
strLstAddZ(argList, "--pg1-path=" TEST_PATH "/pg");
strLstAddZ(argList, "--repo1-retention-full=1");
harnessCfgLoad(cfgCmdBackup, argList);
@ -492,11 +492,11 @@ testRun(void)
// Pg file missing - ignoreMissing=false
// -------------------------------------------------------------------------------------------------------------------------
TEST_ERROR_FMT(
TEST_ERROR(
backupFile(
missingFile, false, 0, true, NULL, false, 0, missingFile, false, compressTypeNone, 1, backupLabel, false,
cipherTypeNone, NULL),
FileMissingError, "unable to open missing file '%s/pg/missing' for read", testPath());
FileMissingError, "unable to open missing file '" TEST_PATH "/pg/missing' for read");
// Create a pg file to backup
storagePutP(storageNewWriteP(storagePgWrite(), pgFile), BUFSTRDEF("atestfile"));
@ -743,8 +743,8 @@ testRun(void)
// Load Parameters
StringList *argList = strLstNew();
strLstAddZ(argList, "--stanza=test1");
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAdd(argList, strNewFmt("--pg1-path=%s/pg", testPath()));
strLstAddZ(argList, "--repo1-path=" TEST_PATH "/repo");
strLstAddZ(argList, "--pg1-path=" TEST_PATH "/pg");
strLstAddZ(argList, "--repo1-retention-full=1");
strLstAddZ(argList, "--repo1-cipher-type=aes-256-cbc");
setenv("PGBACKREST_REPO1_CIPHER_PASS", "12345678", true);
@ -829,8 +829,8 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("backupLabelCreate()"))
{
const String *pg1Path = strNewFmt("%s/pg1", testPath());
const String *repoPath = strNewFmt("%s/repo", testPath());
const String *pg1Path = STRDEF(TEST_PATH "/pg1");
const String *repoPath = STRDEF(TEST_PATH "/repo");
StringList *argList = strLstNew();
strLstAddZ(argList, "--" CFGOPT_STANZA "=test1");
@ -903,8 +903,8 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("backupInit()"))
{
const String *pg1Path = strNewFmt("%s/pg1", testPath());
const String *repoPath = strNewFmt("%s/repo", testPath());
const String *pg1Path = STRDEF(TEST_PATH "/pg1");
const String *repoPath = STRDEF(TEST_PATH "/repo");
// Set log level to detail
harnessLogLevelSet(logLevelDetail);
@ -1107,8 +1107,8 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("backupTime()"))
{
const String *pg1Path = strNewFmt("%s/pg1", testPath());
const String *repoPath = strNewFmt("%s/repo", testPath());
const String *pg1Path = STRDEF(TEST_PATH "/pg1");
const String *repoPath = STRDEF(TEST_PATH "/repo");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("sleep retries and stall error");
@ -1156,7 +1156,7 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("backupResumeFind()"))
{
const String *repoPath = strNewFmt("%s/repo", testPath());
const String *repoPath = STRDEF(TEST_PATH "/repo");
StringList *argList = strLstNew();
strLstAddZ(argList, "--" CFGOPT_STANZA "=test1");
@ -1345,8 +1345,8 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("cmdBackup() offline"))
{
const String *pg1Path = strNewFmt("%s/pg1", testPath());
const String *repoPath = strNewFmt("%s/repo", testPath());
const String *pg1Path = STRDEF(TEST_PATH "/pg1");
const String *repoPath = STRDEF(TEST_PATH "/repo");
// Set log level to detail
harnessLogLevelSet(logLevelDetail);
@ -1413,8 +1413,9 @@ testRun(void)
"P00 WARN: no prior backup exists, incr backup has been changed to full\n"
"P00 WARN: --no-online passed and postmaster.pid exists but --force was passed so backup will continue though it"
" looks like " PG_NAME " is running and the backup will probably not be consistent\n"
"P01 INFO: backup file {[path]}/pg1/global/pg_control (8KB, 99%%) checksum %s\n"
"P01 INFO: backup file {[path]}/pg1/postgresql.conf (11B, 100%%) checksum e3db315c260e79211b7b52587123b7aa060f30ab\n"
"P01 INFO: backup file " TEST_PATH "/pg1/global/pg_control (8KB, 99%%) checksum %s\n"
"P01 INFO: backup file " TEST_PATH "/pg1/postgresql.conf (11B, 100%%) checksum"
" e3db315c260e79211b7b52587123b7aa060f30ab\n"
"P00 INFO: full backup size = 8KB\n"
"P00 INFO: new backup label = [FULL-1]",
TEST_64BIT() ?
@ -1467,7 +1468,7 @@ testRun(void)
"P00 INFO: last backup label = [FULL-1], version = " PROJECT_VERSION "\n"
"P00 WARN: incr backup cannot alter 'checksum-page' option to 'true', reset to 'false' from [FULL-1]\n"
"P00 WARN: backup '[DIFF-1]' cannot be resumed: new backup type 'incr' does not match resumable backup type 'diff'\n"
"P01 INFO: backup file {[path]}/pg1/PG_VERSION (3B, 100%) checksum c8663c2525f44b6d9c687fbceb4aafc63ed8b451\n"
"P01 INFO: backup file " TEST_PATH "/pg1/PG_VERSION (3B, 100%) checksum c8663c2525f44b6d9c687fbceb4aafc63ed8b451\n"
"P00 DETAIL: reference pg_data/global/pg_control to [FULL-1]\n"
"P00 DETAIL: reference pg_data/postgresql.conf to [FULL-1]\n"
"P00 INFO: incr backup size = 3B\n"
@ -1493,7 +1494,7 @@ testRun(void)
TEST_RESULT_LOG(
"P00 INFO: last backup label = [FULL-1], version = " PROJECT_VERSION "\n"
"P01 INFO: backup file {[path]}/pg1/PG_VERSION (3B, 100%) checksum 6f1894088c578e4f0b9888e8e8a997d93cbbc0c5\n"
"P01 INFO: backup file " TEST_PATH "/pg1/PG_VERSION (3B, 100%) checksum 6f1894088c578e4f0b9888e8e8a997d93cbbc0c5\n"
"P00 DETAIL: reference pg_data/global/pg_control to [FULL-1]\n"
"P00 DETAIL: reference pg_data/postgresql.conf to [FULL-1]\n"
"P00 INFO: diff backup size = 3B\n"
@ -1505,7 +1506,7 @@ testRun(void)
// Create stanza on a second repo
argList = strLstNew();
hrnCfgArgRawZ(argList, cfgOptStanza, "test1");
hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 2, "%s/repo2", testPath());
hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 2, TEST_PATH "/repo2");
hrnCfgArgKeyRawStrId(argList, cfgOptRepoCipherType, 2, cipherTypeAes256Cbc);
hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 2, TEST_CIPHER_PASS);
hrnCfgArgRaw(argList, cfgOptPgPath, pg1Path);
@ -1545,7 +1546,7 @@ testRun(void)
"P00 INFO: repo option not specified, defaulting to repo1\n"
"P00 INFO: last backup label = [FULL-1], version = " PROJECT_VERSION "\n"
"P00 WARN: diff backup cannot alter compress-type option to 'gz', reset to value in [FULL-1]\n"
"P01 INFO: backup file {[path]}/pg1/PG_VERSION (3B, 100%) checksum 6f1894088c578e4f0b9888e8e8a997d93cbbc0c5\n"
"P01 INFO: backup file " TEST_PATH "/pg1/PG_VERSION (3B, 100%) checksum 6f1894088c578e4f0b9888e8e8a997d93cbbc0c5\n"
"P00 INFO: diff backup size = 3B\n"
"P00 INFO: new backup label = [DIFF-3]");
@ -1563,7 +1564,7 @@ testRun(void)
TEST_RESULT_VOID(cmdBackup(), "backup");
TEST_RESULT_LOG(
"P00 INFO: last backup label = [FULL-2], version = " PROJECT_VERSION "\n"
"P01 INFO: backup file {[path]}/pg1/PG_VERSION (3B, 100%) checksum c8663c2525f44b6d9c687fbceb4aafc63ed8b451\n"
"P01 INFO: backup file " TEST_PATH "/pg1/PG_VERSION (3B, 100%) checksum c8663c2525f44b6d9c687fbceb4aafc63ed8b451\n"
"P00 INFO: diff backup size = 3B\n"
"P00 INFO: new backup label = [DIFF-4]");
TEST_RESULT_UINT(
@ -1578,9 +1579,9 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("cmdBackup() online"))
{
const String *pg1Path = strNewFmt("%s/pg1", testPath());
const String *repoPath = strNewFmt("%s/repo", testPath());
const String *pg2Path = strNewFmt("%s/pg2", testPath());
const String *pg1Path = STRDEF(TEST_PATH "/pg1");
const String *repoPath = STRDEF(TEST_PATH "/repo");
const String *pg2Path = STRDEF(TEST_PATH "/pg2");
// Set log level to detail
harnessLogLevelSet(logLevelDetail);
@ -1678,9 +1679,9 @@ testRun(void)
"P00 INFO: execute exclusive pg_start_backup(): backup begins after the next regular checkpoint completes\n"
"P00 INFO: backup start archive = 0000000105D944C000000000, lsn = 5d944c0/0\n"
"P00 WARN: resumable backup 20191002-070640F of same type exists -- remove invalid files and resume\n"
"P01 INFO: backup file {[path]}/pg1/global/pg_control (8KB, [PCT]) checksum [SHA1]\n"
"P01 INFO: backup file {[path]}/pg1/postgresql.conf (11B, [PCT]) checksum [SHA1]\n"
"P01 DETAIL: checksum resumed file {[path]}/pg1/PG_VERSION (3B, [PCT]) checksum [SHA1]\n"
"P01 INFO: backup file " TEST_PATH "/pg1/global/pg_control (8KB, [PCT]) checksum [SHA1]\n"
"P01 INFO: backup file " TEST_PATH "/pg1/postgresql.conf (11B, [PCT]) checksum [SHA1]\n"
"P01 DETAIL: checksum resumed file " TEST_PATH "/pg1/PG_VERSION (3B, [PCT]) checksum [SHA1]\n"
"P00 INFO: full backup size = [SIZE]\n"
"P00 INFO: execute exclusive pg_stop_backup() and wait for all WAL segments to archive\n"
"P00 INFO: backup stop archive = 0000000105D944C000000000, lsn = 5d944c0/800000\n"
@ -1697,7 +1698,7 @@ testRun(void)
"pg_data/postgresql.conf {file, s=11}\n"
"--------\n"
"[backup:target]\n"
"pg_data={\"path\":\"{[path]}/pg1\",\"type\":\"path\"}\n"
"pg_data={\"path\":\"" TEST_PATH "/pg1\",\"type\":\"path\"}\n"
"\n"
"[target:file]\n"
"pg_data/PG_VERSION={\"checksum\":\"06d06bb31b570b94d7b4325f511f853dbe771c21\",\"size\":3"
@ -1830,28 +1831,29 @@ testRun(void)
"P00 INFO: execute exclusive pg_start_backup(): backup begins after the next regular checkpoint completes\n"
"P00 INFO: backup start archive = 0000000105D95D3000000000, lsn = 5d95d30/0\n"
"P00 WARN: resumable backup 20191003-105320F of same type exists -- remove invalid files and resume\n"
"P00 DETAIL: remove path '{[path]}/repo/backup/test1/20191003-105320F/pg_data/bogus_path' from resumed backup\n"
"P00 DETAIL: remove file '{[path]}/repo/backup/test1/20191003-105320F/pg_data/global/bogus' from resumed backup"
" (mismatched compression type)\n"
"P00 DETAIL: remove file '{[path]}/repo/backup/test1/20191003-105320F/pg_data/global/bogus.gz' from resumed backup"
" (missing in manifest)\n"
"P00 DETAIL: remove file '{[path]}/repo/backup/test1/20191003-105320F/pg_data/global/pg_control.gz' from resumed"
" backup (no checksum in resumed manifest)\n"
"P00 DETAIL: remove file '{[path]}/repo/backup/test1/20191003-105320F/pg_data/not-in-resume.gz' from resumed backup"
" (missing in resumed manifest)\n"
"P00 DETAIL: remove file '{[path]}/repo/backup/test1/20191003-105320F/pg_data/size-mismatch.gz' from resumed backup"
" (mismatched size)\n"
"P00 DETAIL: remove file '{[path]}/repo/backup/test1/20191003-105320F/pg_data/time-mismatch.gz' from resumed backup"
" (mismatched timestamp)\n"
"P00 DETAIL: remove file '{[path]}/repo/backup/test1/20191003-105320F/pg_data/zero-size.gz' from resumed backup"
" (zero size)\n"
"P01 INFO: backup file {[path]}/pg1/global/pg_control (8KB, [PCT]) checksum [SHA1]\n"
"P01 INFO: backup file {[path]}/pg1/postgresql.conf (11B, [PCT]) checksum [SHA1]\n"
"P01 INFO: backup file {[path]}/pg1/time-mismatch (4B, [PCT]) checksum [SHA1]\n"
"P01 INFO: backup file {[path]}/pg1/size-mismatch (4B, [PCT]) checksum [SHA1]\n"
"P01 INFO: backup file {[path]}/pg1/not-in-resume (4B, [PCT]) checksum [SHA1]\n"
"P01 INFO: backup file {[path]}/pg1/PG_VERSION (3B, [PCT]) checksum [SHA1]\n"
"P01 INFO: backup file {[path]}/pg1/zero-size (0B, [PCT])\n"
"P00 DETAIL: remove path '" TEST_PATH "/repo/backup/test1/20191003-105320F/pg_data/bogus_path' from resumed"
" backup\n"
"P00 DETAIL: remove file '" TEST_PATH "/repo/backup/test1/20191003-105320F/pg_data/global/bogus' from resumed"
" backup (mismatched compression type)\n"
"P00 DETAIL: remove file '" TEST_PATH "/repo/backup/test1/20191003-105320F/pg_data/global/bogus.gz' from resumed"
" backup (missing in manifest)\n"
"P00 DETAIL: remove file '" TEST_PATH "/repo/backup/test1/20191003-105320F/pg_data/global/pg_control.gz' from"
" resumed backup (no checksum in resumed manifest)\n"
"P00 DETAIL: remove file '" TEST_PATH "/repo/backup/test1/20191003-105320F/pg_data/not-in-resume.gz' from resumed"
" backup (missing in resumed manifest)\n"
"P00 DETAIL: remove file '" TEST_PATH "/repo/backup/test1/20191003-105320F/pg_data/size-mismatch.gz' from resumed"
" backup (mismatched size)\n"
"P00 DETAIL: remove file '" TEST_PATH "/repo/backup/test1/20191003-105320F/pg_data/time-mismatch.gz' from resumed"
" backup (mismatched timestamp)\n"
"P00 DETAIL: remove file '" TEST_PATH "/repo/backup/test1/20191003-105320F/pg_data/zero-size.gz' from resumed"
" backup (zero size)\n"
"P01 INFO: backup file " TEST_PATH "/pg1/global/pg_control (8KB, [PCT]) checksum [SHA1]\n"
"P01 INFO: backup file " TEST_PATH "/pg1/postgresql.conf (11B, [PCT]) checksum [SHA1]\n"
"P01 INFO: backup file " TEST_PATH "/pg1/time-mismatch (4B, [PCT]) checksum [SHA1]\n"
"P01 INFO: backup file " TEST_PATH "/pg1/size-mismatch (4B, [PCT]) checksum [SHA1]\n"
"P01 INFO: backup file " TEST_PATH "/pg1/not-in-resume (4B, [PCT]) checksum [SHA1]\n"
"P01 INFO: backup file " TEST_PATH "/pg1/PG_VERSION (3B, [PCT]) checksum [SHA1]\n"
"P01 INFO: backup file " TEST_PATH "/pg1/zero-size (0B, [PCT])\n"
"P00 INFO: full backup size = [SIZE]\n"
"P00 INFO: execute exclusive pg_stop_backup() and wait for all WAL segments to archive\n"
"P00 INFO: backup stop archive = 0000000105D95D3000000000, lsn = 5d95d30/800000\n"
@ -1875,7 +1877,7 @@ testRun(void)
"pg_data/zero-size.gz {file, s=0}\n"
"--------\n"
"[backup:target]\n"
"pg_data={\"path\":\"{[path]}/pg1\",\"type\":\"path\"}\n"
"pg_data={\"path\":\"" TEST_PATH "/pg1\",\"type\":\"path\"}\n"
"\n"
"[target:file]\n"
"pg_data/PG_VERSION={\"checksum\":\"06d06bb31b570b94d7b4325f511f853dbe771c21\",\"size\":3"
@ -2000,21 +2002,21 @@ testRun(void)
"P00 WARN: file 'time-mismatch2' has timestamp in the future, enabling delta checksum\n"
"P00 WARN: resumable backup 20191003-105320F_20191004-144000D of same type exists"
" -- remove invalid files and resume\n"
"P00 DETAIL: remove file '{[path]}/repo/backup/test1/20191003-105320F_20191004-144000D/pg_data/PG_VERSION.gz'"
"P00 DETAIL: remove file '" TEST_PATH "/repo/backup/test1/20191003-105320F_20191004-144000D/pg_data/PG_VERSION.gz'"
" from resumed backup (reference in manifest)\n"
"P00 WARN: remove special file '{[path]}/repo/backup/test1/20191003-105320F_20191004-144000D/pg_data/pipe'"
"P00 WARN: remove special file '" TEST_PATH "/repo/backup/test1/20191003-105320F_20191004-144000D/pg_data/pipe'"
" from resumed backup\n"
"P00 DETAIL: remove file '{[path]}/repo/backup/test1/20191003-105320F_20191004-144000D/pg_data/resume-ref.gz'"
"P00 DETAIL: remove file '" TEST_PATH "/repo/backup/test1/20191003-105320F_20191004-144000D/pg_data/resume-ref.gz'"
" from resumed backup (reference in resumed manifest)\n"
"P01 DETAIL: match file from prior backup {[path]}/pg1/global/pg_control (8KB, [PCT]) checksum [SHA1]\n"
"P01 DETAIL: match file from prior backup {[path]}/pg1/postgresql.conf (11B, [PCT]) checksum [SHA1]\n"
"P01 DETAIL: match file from prior backup " TEST_PATH "/pg1/global/pg_control (8KB, [PCT]) checksum [SHA1]\n"
"P01 DETAIL: match file from prior backup " TEST_PATH "/pg1/postgresql.conf (11B, [PCT]) checksum [SHA1]\n"
"P00 WARN: resumed backup file pg_data/time-mismatch2 does not have expected checksum"
" 984816fd329622876e14907634264e6f332e9fb3. The file will be recopied and backup will continue but this may be"
" an issue unless the resumed backup path in the repository is known to be corrupted.\n"
" NOTE: this does not indicate a problem with the PostgreSQL page checksums.\n"
"P01 INFO: backup file {[path]}/pg1/time-mismatch2 (4B, [PCT]) checksum [SHA1]\n"
"P01 DETAIL: match file from prior backup {[path]}/pg1/PG_VERSION (3B, [PCT]) checksum [SHA1]\n"
"P01 INFO: backup file {[path]}/pg1/resume-ref (0B, [PCT])\n"
"P01 INFO: backup file " TEST_PATH "/pg1/time-mismatch2 (4B, [PCT]) checksum [SHA1]\n"
"P01 DETAIL: match file from prior backup " TEST_PATH "/pg1/PG_VERSION (3B, [PCT]) checksum [SHA1]\n"
"P01 INFO: backup file " TEST_PATH "/pg1/resume-ref (0B, [PCT])\n"
"P00 DETAIL: hardlink pg_data/PG_VERSION to 20191003-105320F\n"
"P00 DETAIL: hardlink pg_data/global/pg_control to 20191003-105320F\n"
"P00 DETAIL: hardlink pg_data/postgresql.conf to 20191003-105320F\n"
@ -2038,7 +2040,7 @@ testRun(void)
"pg_data/time-mismatch2.gz {file, s=4}\n"
"--------\n"
"[backup:target]\n"
"pg_data={\"path\":\"{[path]}/pg1\",\"type\":\"path\"}\n"
"pg_data={\"path\":\"" TEST_PATH "/pg1\",\"type\":\"path\"}\n"
"\n"
"[target:file]\n"
"pg_data/PG_VERSION={\"checksum\":\"06d06bb31b570b94d7b4325f511f853dbe771c21\",\"reference\":\"20191003-105320F\""
@ -2173,7 +2175,7 @@ testRun(void)
"pg_data/postgresql.conf {file, s=11}\n"
"--------\n"
"[backup:target]\n"
"pg_data={\"path\":\"{[path]}/pg1\",\"type\":\"path\"}\n"
"pg_data={\"path\":\"" TEST_PATH "/pg1\",\"type\":\"path\"}\n"
"\n"
"[target:file]\n"
"pg_data/PG_VERSION={\"checksum\":\"f5b7e6d36dc0113f61b36c700817d42b96f7b037\",\"size\":3"
@ -2327,17 +2329,18 @@ testRun(void)
TEST_RESULT_LOG(
"P00 INFO: execute non-exclusive pg_start_backup(): backup begins after the next regular checkpoint completes\n"
"P00 INFO: backup start archive = 0000000105DB5DE000000000, lsn = 5db5de0/0\n"
"P01 INFO: backup file {[path]}/pg1/base/1/3 (32KB, [PCT]) checksum [SHA1]\n"
"P00 WARN: invalid page checksums found in file {[path]}/pg1/base/1/3 at pages 0, 2-3\n"
"P01 INFO: backup file {[path]}/pg1/base/1/4 (24KB, [PCT]) checksum [SHA1]\n"
"P00 WARN: invalid page checksum found in file {[path]}/pg1/base/1/4 at page 1\n"
"P01 INFO: backup file {[path]}/pg1/base/1/2 (8KB, [PCT]) checksum [SHA1]\n"
"P00 WARN: page misalignment in file {[path]}/pg1/base/1/2: file size 8193 is not divisible by page size 8192\n"
"P01 INFO: backup file {[path]}/pg1/global/pg_control (8KB, [PCT]) checksum [SHA1]\n"
"P01 INFO: backup file {[path]}/pg1/base/1/1 (8KB, [PCT]) checksum [SHA1]\n"
"P01 INFO: backup file {[path]}/pg1/postgresql.conf (11B, [PCT]) checksum [SHA1]\n"
"P01 INFO: backup file {[path]}/pg1/PG_VERSION (2B, [PCT]) checksum [SHA1]\n"
"P01 INFO: backup file {[path]}/pg1/pg_tblspc/32768/PG_11_201809051/1/5 (0B, [PCT])\n"
"P01 INFO: backup file " TEST_PATH "/pg1/base/1/3 (32KB, [PCT]) checksum [SHA1]\n"
"P00 WARN: invalid page checksums found in file " TEST_PATH "/pg1/base/1/3 at pages 0, 2-3\n"
"P01 INFO: backup file " TEST_PATH "/pg1/base/1/4 (24KB, [PCT]) checksum [SHA1]\n"
"P00 WARN: invalid page checksum found in file " TEST_PATH "/pg1/base/1/4 at page 1\n"
"P01 INFO: backup file " TEST_PATH "/pg1/base/1/2 (8KB, [PCT]) checksum [SHA1]\n"
"P00 WARN: page misalignment in file " TEST_PATH "/pg1/base/1/2: file size 8193 is not divisible by page size"
" 8192\n"
"P01 INFO: backup file " TEST_PATH "/pg1/global/pg_control (8KB, [PCT]) checksum [SHA1]\n"
"P01 INFO: backup file " TEST_PATH "/pg1/base/1/1 (8KB, [PCT]) checksum [SHA1]\n"
"P01 INFO: backup file " TEST_PATH "/pg1/postgresql.conf (11B, [PCT]) checksum [SHA1]\n"
"P01 INFO: backup file " TEST_PATH "/pg1/PG_VERSION (2B, [PCT]) checksum [SHA1]\n"
"P01 INFO: backup file " TEST_PATH "/pg1/pg_tblspc/32768/PG_11_201809051/1/5 (0B, [PCT])\n"
"P00 INFO: full backup size = [SIZE]\n"
"P00 INFO: execute non-exclusive pg_stop_backup() and wait for all WAL segments to archive\n"
"P00 INFO: backup stop archive = 0000000105DB5DE000000002, lsn = 5db5de0/280000\n"
@ -2375,7 +2378,7 @@ testRun(void)
"pg_tblspc/32768/PG_11_201809051/1/5.gz {file, s=0}\n"
"--------\n"
"[backup:target]\n"
"pg_data={\"path\":\"{[path]}/pg1\",\"type\":\"path\"}\n"
"pg_data={\"path\":\"" TEST_PATH "/pg1\",\"type\":\"path\"}\n"
"pg_tblspc/32768={\"path\":\"../../pg1-tblspc/32768\",\"tablespace-id\":\"32768\""
",\"tablespace-name\":\"tblspc32768\",\"type\":\"link\"}\n"
"\n"
@ -2492,10 +2495,10 @@ testRun(void)
"P00 INFO: backup start archive = 0000002C05DB8EB000000000, lsn = 5db8eb0/0\n"
"P00 WARN: a timeline switch has occurred since the 20191027-181320F backup, enabling delta checksum\n"
" HINT: this is normal after restoring from backup or promoting a standby.\n"
"P01 DETAIL: match file from prior backup {[path]}/pg1/global/pg_control (8KB, [PCT]) checksum [SHA1]\n"
"P01 DETAIL: match file from prior backup {[path]}/pg1/base/1/1 (8KB, [PCT]) checksum [SHA1]\n"
"P01 DETAIL: match file from prior backup {[path]}/pg1/postgresql.conf (11B, [PCT]) checksum [SHA1]\n"
"P01 DETAIL: match file from prior backup {[path]}/pg1/PG_VERSION (2B, [PCT]) checksum [SHA1]\n"
"P01 DETAIL: match file from prior backup " TEST_PATH "/pg1/global/pg_control (8KB, [PCT]) checksum [SHA1]\n"
"P01 DETAIL: match file from prior backup " TEST_PATH "/pg1/base/1/1 (8KB, [PCT]) checksum [SHA1]\n"
"P01 DETAIL: match file from prior backup " TEST_PATH "/pg1/postgresql.conf (11B, [PCT]) checksum [SHA1]\n"
"P01 DETAIL: match file from prior backup " TEST_PATH "/pg1/PG_VERSION (2B, [PCT]) checksum [SHA1]\n"
"P00 DETAIL: hardlink pg_data/PG_VERSION to 20191027-181320F\n"
"P00 DETAIL: hardlink pg_data/base/1/1 to 20191027-181320F\n"
"P00 DETAIL: hardlink pg_data/global/pg_control to 20191027-181320F\n"
@ -2530,7 +2533,7 @@ testRun(void)
"pg_tblspc/32768/PG_11_201809051/1/5.gz {file, s=0}\n"
"--------\n"
"[backup:target]\n"
"pg_data={\"path\":\"{[path]}/pg1\",\"type\":\"path\"}\n"
"pg_data={\"path\":\"" TEST_PATH "/pg1\",\"type\":\"path\"}\n"
"pg_tblspc/32768={\"path\":\"../../pg1-tblspc/32768\",\"tablespace-id\":\"32768\""
",\"tablespace-name\":\"tblspc32768\",\"type\":\"link\"}\n"
"\n"

View File

@ -25,13 +25,13 @@ testRun(void)
// PQfinish() is strictly checked
harnessPqScriptStrictSet(true);
Storage *storageTest = storagePosixNewP(strNewZ(testPath()), .write = true);
Storage *storageTest = storagePosixNewP(TEST_PATH_STR, .write = true);
const String *pg1 = STRDEF("pg1");
String *pg1Path = strNewFmt("%s/%s", testPath(), strZ(pg1));
String *pg1Path = strNewFmt(TEST_PATH "/%s", strZ(pg1));
String *pg1PathOpt = strNewFmt("--pg1-path=%s", strZ(pg1Path));
const String *pg8 = STRDEF("pg8");
String *pg8Path = strNewFmt("%s/%s", testPath(), strZ(pg8));
String *pg8Path = strNewFmt(TEST_PATH "/%s", strZ(pg8));
String *pg8PathOpt = strNewFmt("--pg8-path=%s", strZ(pg8Path));
const String *stanza = STRDEF("test1");
String *stanzaOpt = strNewFmt("--stanza=%s", strZ(stanza));
@ -44,7 +44,7 @@ testRun(void)
argList = strLstNew();
strLstAdd(argList, stanzaOpt);
strLstAdd(argList, pg1PathOpt);
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAddZ(argList, "--repo1-path=" TEST_PATH "/repo");
strLstAddZ(argList, "--archive-timeout=.5");
harnessCfgLoad(cfgCmdCheck, argList);
@ -80,7 +80,7 @@ testRun(void)
strLstAdd(argList, pg1PathOpt);
strLstAddZ(argList, "--pg8-path=/path/to/standby2");
strLstAddZ(argList, "--pg8-port=5433");
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAddZ(argList, "--repo1-path=" TEST_PATH "/repo");
strLstAddZ(argList, "--repo2-host=repo.domain.com");
strLstAddZ(argList, "--archive-timeout=.5");
harnessCfgLoad(cfgCmdCheck, argList);
@ -123,7 +123,7 @@ testRun(void)
argList = strLstNew();
strLstAdd(argList, stanzaOpt);
strLstAdd(argList, pg1PathOpt);
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAddZ(argList, "--repo1-path=" TEST_PATH "/repo");
strLstAddZ(argList, "--archive-timeout=.5");
strLstAddZ(argList, "--backup-standby");
harnessCfgLoad(cfgCmdCheck, argList);
@ -153,7 +153,7 @@ testRun(void)
argList = strLstNew();
strLstAdd(argList, stanzaOpt);
strLstAdd(argList, pg1PathOpt);
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAddZ(argList, "--repo1-path=" TEST_PATH "/repo");
strLstAddZ(argList, "--archive-timeout=.5");
strLstAdd(argList, pg8PathOpt);
strLstAddZ(argList, "--pg8-port=5433");
@ -162,7 +162,7 @@ testRun(void)
// Standby database path doesn't match pg_control
harnessPqScriptSet((HarnessPq [])
{
HRNPQ_MACRO_OPEN_GE_92(1, "dbname='postgres' port=5432", PG_VERSION_92, testPath(), true, NULL, NULL),
HRNPQ_MACRO_OPEN_GE_92(1, "dbname='postgres' port=5432", PG_VERSION_92, TEST_PATH, true, NULL, NULL),
HRNPQ_MACRO_OPEN_GE_92(8, "dbname='postgres' port=5433", PG_VERSION_92, strZ(pg8Path), false, NULL, NULL),
HRNPQ_MACRO_CLOSE(8),
@ -175,7 +175,7 @@ testRun(void)
cmdCheck(), DbMismatchError, "version '%s' and path '%s' queried from cluster do not match version '%s' and '%s'"
" read from '%s/" PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL "'\n"
"HINT: the pg1-path and pg1-port settings likely reference different clusters.",
strZ(pgVersionToStr(PG_VERSION_92)), testPath(), strZ(pgVersionToStr(PG_VERSION_92)), strZ(pg1Path), strZ(pg1Path));
strZ(pgVersionToStr(PG_VERSION_92)), TEST_PATH, strZ(pgVersionToStr(PG_VERSION_92)), strZ(pg1Path), strZ(pg1Path));
// Standby
// -------------------------------------------------------------------------------------------------------------------------
@ -231,7 +231,7 @@ testRun(void)
// Multi-repo - add a second repo (repo2)
StringList *argListRepo2 = strLstDup(argList);
strLstAdd(argListRepo2, strNewFmt("--repo2-path=%s/repo2", testPath()));
strLstAddZ(argListRepo2, "--repo2-path=" TEST_PATH "/repo2");
harnessCfgLoad(cfgCmdCheck, argListRepo2);
harnessPqScriptSet((HarnessPq [])
@ -255,8 +255,8 @@ testRun(void)
"HINT: is archive_command configured correctly in postgresql.conf?\n"
"HINT: has a stanza-create been performed?\n"
"HINT: use --no-archive-check to disable archive checks during backup if you have an alternate archiving scheme.",
testPath(), testPath(), strZ(strNewFmt("%s/repo2/archive/test1/archive.info", testPath())),
strZ(strNewFmt("%s/repo2/archive/test1/archive.info.copy", testPath())));
TEST_PATH, TEST_PATH, strZ(strNewFmt("%s/repo2/archive/test1/archive.info", TEST_PATH)),
strZ(strNewFmt("%s/repo2/archive/test1/archive.info.copy", TEST_PATH)));
harnessLogResult("P00 INFO: check repo1 (standby)\nP00 INFO: check repo2 (standby)");
// Single primary
@ -265,8 +265,8 @@ testRun(void)
argList = strLstNew();
strLstAdd(argList, stanzaOpt);
strLstAdd(argList, pg1PathOpt);
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAdd(argList, strNewFmt("--repo2-path=%s/repo2", testPath()));
strLstAddZ(argList, "--repo1-path=" TEST_PATH "/repo");
strLstAddZ(argList, "--repo2-path=" TEST_PATH "/repo2");
strLstAddZ(argList, "--archive-timeout=.5");
harnessCfgLoad(cfgCmdCheck, argList);
@ -334,7 +334,7 @@ testRun(void)
"P00 INFO: check repo2 archive for WAL (primary)\n"
"P00 INFO: WAL segment 000000010000000100000001 successfully archived to '%s/repo2/archive/test1/9.2-1/"
"0000000100000001/000000010000000100000001-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' on repo2",
testPath(), testPath())));
TEST_PATH, TEST_PATH)));
// Primary == NULL (for test coverage)
// -------------------------------------------------------------------------------------------------------------------------
@ -351,7 +351,7 @@ testRun(void)
hrnCfgArgKeyRawZ(argList, cfgOptPgHost, 5, "localhost");
hrnCfgArgKeyRawZ(argList, cfgOptPgHostCmd, 5, "pgbackrest-bogus");
strLstAddZ(argList, "--pg5-path=/path/to/pg5");
strLstAdd(argList, strNewFmt("--pg5-host-user=%s", testUser()));
strLstAddZ(argList, "--pg5-host-user=" TEST_USER);
harnessCfgLoad(cfgCmdCheck, argList);
// Placeholder test for manifest
@ -385,7 +385,7 @@ testRun(void)
strLstAdd(argList, pg1PathOpt);
strLstAdd(argList, pg8PathOpt);
strLstAddZ(argList, "--pg8-port=5433");
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAddZ(argList, "--repo1-path=" TEST_PATH "/repo");
harnessCfgLoad(cfgCmdCheck, argList);
DbGetResult db = {0};
@ -437,7 +437,7 @@ testRun(void)
strLstAdd(argList, pg1PathOpt);
strLstAdd(argList, pg8PathOpt);
strLstAddZ(argList, "--pg8-port=5433");
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAddZ(argList, "--repo1-path=" TEST_PATH "/repo");
harnessCfgLoad(cfgCmdStanzaCreate, argList);
TEST_RESULT_VOID(
@ -451,7 +451,7 @@ testRun(void)
argList = strLstNew();
strLstAdd(argList, stanzaOpt);
strLstAdd(argList, pg1PathOpt);
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAddZ(argList, "--repo1-path=" TEST_PATH "/repo");
harnessCfgLoad(cfgCmdCheck, argList);
harnessPqScriptSet((HarnessPq [])
@ -536,8 +536,8 @@ testRun(void)
argList = strLstNew();
strLstAddZ(argList, "--no-online");
strLstAdd(argList, stanzaOpt);
strLstAdd(argList, strNewFmt("--pg1-path=%s/%s", testPath(), strZ(stanza)));
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAdd(argList, strNewFmt("--pg1-path=" TEST_PATH "/%s", strZ(stanza)));
strLstAddZ(argList, "--repo1-path=" TEST_PATH "/repo");
strLstAddZ(argList, "--repo1-cipher-type=aes-256-cbc");
setenv("PGBACKREST_REPO1_CIPHER_PASS", "12345678", true);
harnessCfgLoad(cfgCmdStanzaCreate, argList);

View File

@ -16,7 +16,7 @@ testRun(void)
FUNCTION_HARNESS_VOID();
// Create default storage object for testing
Storage *storageData = storagePosixNewP(strNewZ(testDataPath()), .write = true);
const Storage *const hrnStorage = storagePosixNewP(HRN_PATH_STR, .write = true);
// *****************************************************************************************************************************
if (testBegin("lockStopFileName()"))
@ -27,10 +27,8 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptPgPath, "/path/to/pg");
harnessCfgLoad(cfgCmdArchiveGet, argList);
TEST_RESULT_STR_Z(
lockStopFileName(NULL), hrnReplaceKey("{[path-data]}/lock/all" STOP_FILE_EXT), "stop file for all stanzas");
TEST_RESULT_STR_Z(
lockStopFileName(STRDEF("db")), hrnReplaceKey("{[path-data]}/lock/db" STOP_FILE_EXT), "stop file for on stanza");
TEST_RESULT_STR_Z(lockStopFileName(NULL), HRN_PATH "/lock/all" STOP_FILE_EXT, "stop file for all stanzas");
TEST_RESULT_STR_Z(lockStopFileName(STRDEF("db")), HRN_PATH "/lock/db" STOP_FILE_EXT, "stop file for on stanza");
}
// *****************************************************************************************************************************
@ -43,9 +41,9 @@ testRun(void)
TEST_RESULT_VOID(cmdStart(), " cmdStart - no stanza, no stop files");
harnessLogResult("P00 WARN: stop file does not exist");
TEST_RESULT_VOID(storagePutP(storageNewWriteP(storageData, STRDEF("lock/all" STOP_FILE_EXT)), NULL), "create stop file");
TEST_RESULT_VOID(storagePutP(storageNewWriteP(hrnStorage, STRDEF("lock/all" STOP_FILE_EXT)), NULL), "create stop file");
TEST_RESULT_VOID(cmdStart(), " cmdStart - no stanza, stop file exists");
TEST_RESULT_BOOL(storageExistsP(storageData, STRDEF("lock/all" STOP_FILE_EXT)), false, " stop file removed");
TEST_RESULT_BOOL(storageExistsP(hrnStorage, STRDEF("lock/all" STOP_FILE_EXT)), false, " stop file removed");
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
@ -56,31 +54,31 @@ testRun(void)
TEST_RESULT_VOID(cmdStart(), " cmdStart - stanza, no stop files");
harnessLogResult("P00 WARN: stop file does not exist for stanza db");
storagePutP(storageNewWriteP(storageData, STRDEF("lock/all" STOP_FILE_EXT)), NULL);
storagePutP(storageNewWriteP(hrnStorage, STRDEF("lock/all" STOP_FILE_EXT)), NULL);
TEST_ERROR(lockStopTest(), StopError, "stop file exists for all stanzas");
storagePutP(storageNewWriteP(storageData, STRDEF("lock/db" STOP_FILE_EXT)), NULL);
storagePutP(storageNewWriteP(hrnStorage, STRDEF("lock/db" STOP_FILE_EXT)), NULL);
TEST_ERROR(lockStopTest(), StopError, "stop file exists for stanza db");
TEST_RESULT_VOID(cmdStart(), "cmdStart - stanza, stop file exists");
TEST_RESULT_BOOL(storageExistsP(storageData, STRDEF("lock/db" STOP_FILE_EXT)), false, " stanza stop file removed");
TEST_RESULT_BOOL(storageExistsP(storageData, STRDEF("lock/all" STOP_FILE_EXT)), true, " all stop file not removed");
TEST_RESULT_BOOL(storageExistsP(hrnStorage, STRDEF("lock/db" STOP_FILE_EXT)), false, " stanza stop file removed");
TEST_RESULT_BOOL(storageExistsP(hrnStorage, STRDEF("lock/all" STOP_FILE_EXT)), true, " all stop file not removed");
}
// *****************************************************************************************************************************
if (testBegin("cmdStop()"))
{
String *lockPath = strNewFmt("%s/lock", testDataPath());
const String *lockPath = STRDEF(HRN_PATH "/lock");
StringList *argList = strLstNew();
harnessCfgLoad(cfgCmdStop, argList);
TEST_RESULT_VOID(cmdStop(), "no stanza, create stop file");
StorageInfo info = {0};
TEST_ASSIGN(info, storageInfoP(storageData, lockPath), " get path info");
TEST_ASSIGN(info, storageInfoP(hrnStorage, lockPath), " get path info");
TEST_RESULT_INT(info.mode, 0770, " check path mode");
TEST_RESULT_BOOL(
storageExistsP(storageData, strNewFmt("%s/all" STOP_FILE_EXT, strZ(lockPath))), true, " all stop file created");
TEST_ASSIGN(info, storageInfoP(storageData, strNewFmt("%s/all" STOP_FILE_EXT, strZ(lockPath))), " get file info");
storageExistsP(hrnStorage, strNewFmt("%s/all" STOP_FILE_EXT, strZ(lockPath))), true, " all stop file created");
TEST_ASSIGN(info, storageInfoP(hrnStorage, strNewFmt("%s/all" STOP_FILE_EXT, strZ(lockPath))), " get file info");
TEST_RESULT_INT(info.mode, 0640, " check file mode");
// -------------------------------------------------------------------------------------------------------------------------
@ -88,13 +86,13 @@ testRun(void)
harnessLogResult("P00 WARN: stop file already exists for all stanzas");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_VOID(storageRemoveP(storageData, STRDEF("lockpath/all" STOP_FILE_EXT)), "remove stop file");
TEST_RESULT_VOID(storageRemoveP(hrnStorage, STRDEF("lockpath/all" STOP_FILE_EXT)), "remove stop file");
TEST_RESULT_INT(system(strZ(strNewFmt("chmod 444 %s", strZ(lockPath)))), 0, "change perms");
TEST_ERROR_FMT(
cmdStop(), FileOpenError, "unable to get info for path/file '%s/all.stop': [13] Permission denied", strZ(lockPath));
TEST_RESULT_INT(system(strZ(strNewFmt("chmod 700 %s", strZ(lockPath)))), 0, "change perms");
TEST_RESULT_VOID(
storagePathRemoveP(storageData, lockPath, .recurse = true, .errorOnMissing = true), " remove the lock path");
storagePathRemoveP(hrnStorage, lockPath, .recurse = true, .errorOnMissing = true), " remove the lock path");
// -------------------------------------------------------------------------------------------------------------------------
String *stanzaStopFile = strNewFmt("%s/db" STOP_FILE_EXT, strZ(lockPath));
@ -102,48 +100,48 @@ testRun(void)
harnessCfgLoad(cfgCmdStop, argList);
TEST_RESULT_VOID(cmdStop(), "stanza, create stop file");
TEST_RESULT_BOOL(storageExistsP(storageData, stanzaStopFile), true, " stanza stop file created");
TEST_RESULT_BOOL(storageExistsP(hrnStorage, stanzaStopFile), true, " stanza stop file created");
StringList *lockPathList = NULL;
TEST_ASSIGN(lockPathList, storageListP(storageData, STRDEF("lock"), .errorOnMissing = true), " get file list");
TEST_ASSIGN(lockPathList, storageListP(hrnStorage, STRDEF("lock"), .errorOnMissing = true), " get file list");
TEST_RESULT_INT(strLstSize(lockPathList), 1, " only file in lock path");
TEST_RESULT_STR_Z(strLstGet(lockPathList, 0), "db" STOP_FILE_EXT, " stanza stop exists");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_VOID(cmdStop(), "stanza, stop file already exists");
harnessLogResult("P00 WARN: stop file already exists for stanza db");
TEST_RESULT_VOID(storageRemoveP(storageData, stanzaStopFile), " remove stop file");
TEST_RESULT_VOID(storageRemoveP(hrnStorage, stanzaStopFile), " remove stop file");
// -------------------------------------------------------------------------------------------------------------------------
strLstAddZ(argList, "--force");
harnessCfgLoad(cfgCmdStop, argList);
TEST_RESULT_VOID(cmdStop(), "stanza, create stop file, force");
TEST_RESULT_VOID(storageRemoveP(storageData, stanzaStopFile), " remove stop file");
TEST_RESULT_VOID(storageRemoveP(hrnStorage, stanzaStopFile), " remove stop file");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_VOID(
storagePutP(storageNewWriteP(storageData, strNewFmt("%s/bad" LOCK_FILE_EXT, strZ(lockPath)), .modeFile = 0222), NULL),
storagePutP(storageNewWriteP(hrnStorage, strNewFmt("%s/bad" LOCK_FILE_EXT, strZ(lockPath)), .modeFile = 0222), NULL),
"create a lock file that cannot be opened");
TEST_RESULT_VOID(cmdStop(), " stanza, create stop file but unable to open lock file");
harnessLogResult(strZ(strNewFmt("P00 WARN: unable to open lock file %s/bad" LOCK_FILE_EXT, strZ(lockPath))));
TEST_RESULT_VOID(
storagePathRemoveP(storageData, lockPath, .recurse = true, .errorOnMissing = true), " remove the lock path");
storagePathRemoveP(hrnStorage, lockPath, .recurse = true, .errorOnMissing = true), " remove the lock path");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_VOID(
storagePutP(storageNewWriteP(storageData, strNewFmt("%s/empty" LOCK_FILE_EXT, strZ(lockPath))), NULL),
storagePutP(storageNewWriteP(hrnStorage, strNewFmt("%s/empty" LOCK_FILE_EXT, strZ(lockPath))), NULL),
"create empty lock file");
TEST_RESULT_VOID(cmdStop(), " stanza, create stop file, force - empty lock file");
TEST_RESULT_BOOL(storageExistsP(storageData, stanzaStopFile), true, " stanza stop file created");
TEST_RESULT_BOOL(storageExistsP(hrnStorage, stanzaStopFile), true, " stanza stop file created");
TEST_RESULT_BOOL(
storageExistsP(storageData, strNewFmt("%s/empty" LOCK_FILE_EXT, strZ(lockPath))), false,
storageExistsP(hrnStorage, strNewFmt("%s/empty" LOCK_FILE_EXT, strZ(lockPath))), false,
" no other process lock, lock file was removed");
// empty lock file with another process lock, processId == NULL
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_VOID(storageRemoveP(storageData, stanzaStopFile), "remove stop file");
TEST_RESULT_VOID(storageRemoveP(hrnStorage, stanzaStopFile), "remove stop file");
TEST_RESULT_VOID(
storagePutP(storageNewWriteP(storageData, strNewFmt("%s/empty" LOCK_FILE_EXT, strZ(lockPath))), NULL),
storagePutP(storageNewWriteP(hrnStorage, strNewFmt("%s/empty" LOCK_FILE_EXT, strZ(lockPath))), NULL),
" create empty lock file");
HARNESS_FORK_BEGIN()
@ -185,7 +183,7 @@ testRun(void)
cmdStop(),
" stanza, create stop file, force - empty lock file with another process lock, processId == NULL");
TEST_RESULT_BOOL(
storageExistsP(storageData, strNewFmt("%s/empty" LOCK_FILE_EXT, strZ(lockPath))), false,
storageExistsP(hrnStorage, strNewFmt("%s/empty" LOCK_FILE_EXT, strZ(lockPath))), false,
" lock file was removed");
// Notify the child to release the lock
@ -198,9 +196,9 @@ testRun(void)
// not empty lock file with another process lock, processId size trimmed to 0
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_VOID(storageRemoveP(storageData, stanzaStopFile), "remove stop file");
TEST_RESULT_VOID(storageRemoveP(hrnStorage, stanzaStopFile), "remove stop file");
TEST_RESULT_VOID(
storagePutP(storageNewWriteP(storageData, strNewFmt("%s/empty" LOCK_FILE_EXT, strZ(lockPath))), BUFSTRDEF(" ")),
storagePutP(storageNewWriteP(hrnStorage, strNewFmt("%s/empty" LOCK_FILE_EXT, strZ(lockPath))), BUFSTRDEF(" ")),
" create non-empty lock file");
HARNESS_FORK_BEGIN()
@ -241,7 +239,7 @@ testRun(void)
TEST_RESULT_VOID(
cmdStop(), " stanza, create stop file, force - empty lock file with another process lock, processId size 0");
TEST_RESULT_BOOL(
storageExistsP(storageData, strNewFmt("%s/empty" LOCK_FILE_EXT, strZ(lockPath))), false,
storageExistsP(hrnStorage, strNewFmt("%s/empty" LOCK_FILE_EXT, strZ(lockPath))), false,
" lock file was removed");
// Notify the child to release the lock
@ -254,7 +252,7 @@ testRun(void)
// lock file with another process lock, processId is valid
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_VOID(storageRemoveP(storageData, stanzaStopFile), "remove stop file");
TEST_RESULT_VOID(storageRemoveP(hrnStorage, stanzaStopFile), "remove stop file");
HARNESS_FORK_BEGIN()
{
HARNESS_FORK_CHILD_BEGIN(0, true)
@ -299,9 +297,9 @@ testRun(void)
// lock file with another process lock, processId is invalid
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_VOID(storageRemoveP(storageData, stanzaStopFile), "remove stop file");
TEST_RESULT_VOID(storageRemoveP(hrnStorage, stanzaStopFile), "remove stop file");
TEST_RESULT_VOID(
storagePutP(storageNewWriteP(storageData, strNewFmt("%s/badpid" LOCK_FILE_EXT, strZ(lockPath))), BUFSTRDEF("-32768")),
storagePutP(storageNewWriteP(hrnStorage, strNewFmt("%s/badpid" LOCK_FILE_EXT, strZ(lockPath))), BUFSTRDEF("-32768")),
"create lock file with invalid PID");
HARNESS_FORK_BEGIN()
@ -325,7 +323,7 @@ testRun(void)
ioReadLine(read);
// Remove the file and close the file descriptor
storageRemoveP(storageData, strNewFmt("%s/badpid" LOCK_FILE_EXT, strZ(lockPath)));
storageRemoveP(hrnStorage, strNewFmt("%s/badpid" LOCK_FILE_EXT, strZ(lockPath)));
close(lockFd);
}
HARNESS_FORK_CHILD_END();
@ -343,7 +341,7 @@ testRun(void)
TEST_RESULT_VOID(
cmdStop(), " stanza, create stop file, force - lock file with another process lock, processId is invalid");
harnessLogResult("P00 WARN: unable to send term signal to process -32768");
TEST_RESULT_BOOL(storageExistsP(storageData, stanzaStopFile), true, " stanza stop file not removed");
TEST_RESULT_BOOL(storageExistsP(hrnStorage, stanzaStopFile), true, " stanza stop file not removed");
// Notify the child to release the lock
ioWriteLine(write, bufNew(0));

View File

@ -68,7 +68,7 @@ testRun(void)
{
FUNCTION_HARNESS_VOID();
Storage *storageTest = storagePosixNewP(strNewZ(testPath()), .write = true);
Storage *storageTest = storagePosixNewP(TEST_PATH_STR, .write = true);
const String *backupStanzaPath = STRDEF("repo/backup/db");
String *backupInfoFileName = strNewFmt("%s/backup.info", strZ(backupStanzaPath));
@ -77,7 +77,7 @@ testRun(void)
StringList *argListBase = strLstNew();
strLstAddZ(argListBase, "--stanza=db");
strLstAdd(argListBase, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAddZ(argListBase, "--repo1-path=" TEST_PATH "/repo");
StringList *argListAvoidWarn = strLstDup(argListBase);
strLstAddZ(argListAvoidWarn, "--repo1-retention-full=1"); // avoid warning
@ -854,8 +854,8 @@ testRun(void)
TEST_TITLE("expire via backup command");
// Copy the repo to another repo
TEST_SYSTEM_FMT("mkdir %s/repo2", testPath());
TEST_SYSTEM_FMT("cp -r %s/repo/* %s/repo2/", testPath(), testPath());
TEST_SYSTEM("mkdir " TEST_PATH "/repo2");
TEST_SYSTEM("cp -r " TEST_PATH "/repo/* " TEST_PATH "/repo2/");
// Configure multi-repo and set the repo option to expire the second repo (non-default) files
argList = strLstDup(argListBase);
@ -863,7 +863,7 @@ testRun(void)
strLstAddZ(argList, "--repo1-retention-diff=3");
strLstAddZ(argList, "--repo1-retention-archive=2");
strLstAddZ(argList, "--repo1-retention-archive-type=diff");
hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 2, "%s/repo2", testPath());
hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 2, TEST_PATH "/repo2");
hrnCfgArgKeyRawZ(argList, cfgOptRepoRetentionFull, 2, "2");
hrnCfgArgKeyRawZ(argList, cfgOptRepoRetentionDiff, 2, "3");
hrnCfgArgKeyRawZ(argList, cfgOptRepoRetentionArchive, 2, "2");
@ -871,7 +871,7 @@ testRun(void)
StringList *argList2 = strLstDup(argList);
hrnCfgArgRawZ(argList2, cfgOptRepo, "2");
strLstAdd(argList2, strNewFmt("--pg1-path=%s/pg", testPath()));
strLstAddZ(argList2, "--pg1-path=" TEST_PATH "/pg");
harnessCfgLoad(cfgCmdBackup, argList2);
TEST_RESULT_VOID(cmdExpire(), "via backup command: expire last backup in archive sub path and remove sub path");
@ -914,7 +914,7 @@ testRun(void)
argList = strLstDup(argListAvoidWarn);
strLstAddZ(argList, "--repo1-retention-archive=1");
hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 2, "%s/repo2", testPath());
hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 2, TEST_PATH "/repo2");
hrnCfgArgKeyRawZ(argList, cfgOptRepoRetentionFull, 2, "3");
hrnCfgArgKeyRawZ(argList, cfgOptRepoRetentionDiff, 2, "2");
hrnCfgArgKeyRawZ(argList, cfgOptRepoRetentionArchive, 2, "1");
@ -967,11 +967,11 @@ testRun(void)
" HINT: has a stanza-create been performed?\n"
" HINT: use --no-archive-check to disable archive checks during backup if you have an alternate"
" archiving scheme.",
testPath(), strZ(backupInfoFileName), testPath(), strZ(strNewFmt("%s" INFO_COPY_EXT, strZ(backupInfoFileName))),
testPath(), strZ(backupInfoFileName), testPath(), strZ(strNewFmt("%s" INFO_COPY_EXT, strZ(backupInfoFileName))),
testPath(), strZ(archiveInfoFileNameRepo2), testPath(),
strZ(strNewFmt("%s" INFO_COPY_EXT, strZ(archiveInfoFileNameRepo2))), testPath(), strZ(archiveInfoFileNameRepo2),
testPath(), strZ(strNewFmt("%s" INFO_COPY_EXT, strZ(archiveInfoFileNameRepo2))))));
TEST_PATH, strZ(backupInfoFileName), TEST_PATH, strZ(strNewFmt("%s" INFO_COPY_EXT, strZ(backupInfoFileName))),
TEST_PATH, strZ(backupInfoFileName), TEST_PATH, strZ(strNewFmt("%s" INFO_COPY_EXT, strZ(backupInfoFileName))),
TEST_PATH, strZ(archiveInfoFileNameRepo2), TEST_PATH,
strZ(strNewFmt("%s" INFO_COPY_EXT, strZ(archiveInfoFileNameRepo2))), TEST_PATH, strZ(archiveInfoFileNameRepo2),
TEST_PATH, strZ(strNewFmt("%s" INFO_COPY_EXT, strZ(archiveInfoFileNameRepo2))))));
// Restore saved archive.info file
TEST_RESULT_VOID(
@ -1004,8 +1004,8 @@ testRun(void)
" stop = 000000020000000000000007\n"
"P00 DETAIL: [DRY-RUN] repo2: 10-2 archive retention on backup 20181119-152900F, start = 000000010000000000000003\n"
"P00 DETAIL: [DRY-RUN] repo2: 10-2 no archive to remove",
testPath(), strZ(backupInfoFileName), testPath(), strZ(strNewFmt("%s" INFO_COPY_EXT, strZ(backupInfoFileName))),
testPath(), strZ(backupInfoFileName), testPath(), strZ(strNewFmt("%s" INFO_COPY_EXT, strZ(backupInfoFileName))))));
TEST_PATH, strZ(backupInfoFileName), TEST_PATH, strZ(strNewFmt("%s" INFO_COPY_EXT, strZ(backupInfoFileName))),
TEST_PATH, strZ(backupInfoFileName), TEST_PATH, strZ(strNewFmt("%s" INFO_COPY_EXT, strZ(backupInfoFileName))))));
// Restore saved backup.info files
TEST_RESULT_VOID(
@ -1057,7 +1057,7 @@ testRun(void)
"P00 DETAIL: [DRY-RUN] repo2: 9.4-1 remove archive, start = 000000020000000000000004,"
" stop = 000000020000000000000007\n"
"P00 DETAIL: [DRY-RUN] repo2: 10-2 archive retention on backup 20181119-152900F, start = 000000010000000000000003\n"
"P00 DETAIL: [DRY-RUN] repo2: 10-2 no archive to remove", testPath(), strZ(archiveStanzaPath))));
"P00 DETAIL: [DRY-RUN] repo2: 10-2 no archive to remove", TEST_PATH, strZ(archiveStanzaPath))));
//--------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("expire command - multi-repo, archive and backups removed");
@ -1090,7 +1090,7 @@ testRun(void)
" start = 000000020000000000000009\n"
"P00 DETAIL: repo2: 9.4-1 remove archive, start = 000000020000000000000004, stop = 000000020000000000000007\n"
"P00 DETAIL: repo2: 10-2 archive retention on backup 20181119-152900F, start = 000000010000000000000003\n"
"P00 DETAIL: repo2: 10-2 no archive to remove", testPath(), strZ(archiveStanzaPath))));
"P00 DETAIL: repo2: 10-2 no archive to remove", TEST_PATH, strZ(archiveStanzaPath))));
TEST_ASSIGN(infoBackup, infoBackupLoadFile(storageTest, backupInfoFileName, cipherTypeNone, NULL), "get backup.info");
TEST_RESULT_UINT(infoBackupDataTotal(infoBackup), 2, "backup.info updated on disk");
@ -1150,12 +1150,12 @@ testRun(void)
archiveGenerate(storageTest, archiveStanzaPath, 1, 1, "9.4-1", "0000000100000000");
argList = strLstDup(argListAvoidWarn);
strLstAddZ(argList, "--repo1-retention-archive=1");
strLstAdd(argList, strNewFmt("--pg1-path=%s/pg", testPath()));
strLstAddZ(argList, "--pg1-path=" TEST_PATH "/pg");
harnessCfgLoad(cfgCmdBackup, argList);
TEST_RESULT_VOID(cmdExpire(), "expire remove archive path");
harnessLogResult(
strZ(strNewFmt("P00 INFO: repo1: remove archive path %s/%s/9.4-1", testPath(), strZ(archiveStanzaPath))));
strZ(strNewFmt("P00 INFO: repo1: remove archive path %s/%s/9.4-1", TEST_PATH, strZ(archiveStanzaPath))));
//--------------------------------------------------------------------------------------------------------------------------
storagePutP(storageNewWriteP(storageTest, backupInfoFileName),
@ -1354,7 +1354,7 @@ testRun(void)
// Load Parameters
argList = strLstDup(argListBase);
strLstAddZ(argList, "--repo1-retention-full=2");
strLstAdd(argList, strNewFmt("--pg1-path=%s/pg", testPath()));
strLstAddZ(argList, "--pg1-path=" TEST_PATH "/pg");
harnessCfgLoad(cfgCmdBackup, argList);
storagePutP(
@ -1737,7 +1737,7 @@ testRun(void)
"option-online=false\n"
"\n"
"[backup:target]\n"
"pg_data={\"path\":\"{[path]}/pg\",\"type\":\"path\"}\n"
"pg_data={\"path\":\"" TEST_PATH "/pg\",\"type\":\"path\"}\n"
"\n"
"[db]\n"
"postgres={\"db-id\":12980,\"db-last-system-id\":12979}\n"
@ -1942,7 +1942,7 @@ testRun(void)
"P00 INFO: repo1: remove expired backup 20181119-152800F\n"
"P00 INFO: repo1: remove archive path %s/repo/archive/db/9.4-1\n"
"P00 DETAIL: repo1: 12-2 archive retention on backup 20181119-152850F, start = 000000010000000000000002\n"
"P00 DETAIL: repo1: 12-2 no archive to remove", testPath())));
"P00 DETAIL: repo1: 12-2 no archive to remove", TEST_PATH)));
//--------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("error on expire last full backup on disk");
@ -2026,7 +2026,7 @@ testRun(void)
argList = strLstDup(argListAvoidWarn);
hrnCfgArgRawZ(argList, cfgOptSet, "20181119-152850F_20181119-152252D");
hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 2, "%s/repo2", testPath());
hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 2, TEST_PATH "/repo2");
hrnCfgArgKeyRawZ(argList, cfgOptRepoRetentionFull, 2, "1");
hrnCfgArgKeyRawStrId(argList, cfgOptRepoCipherType, 2, cipherTypeAes256Cbc);
hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 2, TEST_CIPHER_PASS);
@ -2103,7 +2103,7 @@ testRun(void)
"option-online=false\n"
"\n"
"[backup:target]\n"
"pg_data={\"path\":\"{[path]}/pg\",\"type\":\"path\"}\n"
"pg_data={\"path\":\"" TEST_PATH "/pg\",\"type\":\"path\"}\n"
"\n"
"[db]\n"
"postgres={\"db-id\":12980,\"db-last-system-id\":12979}\n"
@ -2136,8 +2136,8 @@ testRun(void)
// Create encrypted repo2 with same data from repo1 and ensure results are reported the same. This will test that the
// manifest can be read on encrypted repos.
String *repo2ArchiveStanzaPath = strNewFmt("%s/repo2/archive/db", testPath());
String *repo2BackupStanzaPath = strNewFmt("%s/repo2/backup/db", testPath());
const String *repo2ArchiveStanzaPath = STRDEF(TEST_PATH "/repo2/archive/db");
const String *repo2BackupStanzaPath = STRDEF(TEST_PATH "/repo2/backup/db");
storagePathCreateP(storageLocalWrite(), repo2ArchiveStanzaPath);
storagePathCreateP(storageLocalWrite(), repo2BackupStanzaPath);

View File

@ -496,7 +496,7 @@ testRun(void)
// Redirect stdout to a file
int stdoutSave = dup(STDOUT_FILENO);
String *stdoutFile = strNewFmt("%s/stdout.help", testPath());
const String *stdoutFile = STRDEF(TEST_PATH "/stdout.help");
THROW_ON_SYS_ERROR(freopen(strZ(stdoutFile), "w", stdout) == NULL, FileWriteError, "unable to reopen stdout");
@ -506,7 +506,7 @@ testRun(void)
// Restore normal stdout
dup2(stdoutSave, STDOUT_FILENO);
Storage *storage = storagePosixNewP(strNewZ(testPath()));
Storage *storage = storagePosixNewP(TEST_PATH_STR);
TEST_RESULT_STR_Z(strNewBuf(storageGetP(storageNewReadP(storage, stdoutFile))), generalHelp, " check text");
}

View File

@ -22,7 +22,7 @@ testRun(void)
setenv("TZ", "UTC", true);
// Create the repo directories
String *repoPath = strNewFmt("%s/repo", testPath());
const String *repoPath = STRDEF(TEST_PATH "/repo");
String *archivePath = strNewFmt("%s/%s", strZ(repoPath), "archive");
String *backupPath = strNewFmt("%s/%s", strZ(repoPath), "backup");
String *archiveStanza1Path = strNewFmt("%s/stanza1", strZ(archivePath));
@ -330,7 +330,7 @@ testRun(void)
StringList *argList2 = strLstDup(argListText);
strLstAddZ(argList2, "--stanza=stanza1");
hrnCfgArgKeyRawFmt(argList2, cfgOptRepoPath, 2, "%s/repo2", testPath());
hrnCfgArgKeyRawZ(argList2, cfgOptRepoPath, 2, TEST_PATH "/repo2");
hrnCfgArgRawZ(argList2, cfgOptRepo, "1");
harnessCfgLoad(cfgCmdInfo, argList2);
@ -349,7 +349,7 @@ testRun(void)
//--------------------------------------------------------------------------------------------------------------------------
argList2 = strLstDup(argListText);
strLstAddZ(argList2, "--stanza=stanza1");
hrnCfgArgKeyRawFmt(argList2, cfgOptRepoPath, 2, "%s/repo2", testPath());
hrnCfgArgKeyRawZ(argList2, cfgOptRepoPath, 2, TEST_PATH "/repo2");
hrnCfgArgRawZ(argList2, cfgOptRepo, "2");
harnessCfgLoad(cfgCmdInfo, argList2);
@ -873,8 +873,8 @@ testRun(void)
"put backup info to file - stanza2, repo1");
// Create encrypted repo2
String *repo2archivePath = strNewFmt("%s/repo2/archive", testPath());
String *repo2backupPath = strNewFmt("%s/repo2/backup", testPath());
const String *repo2archivePath = STRDEF(TEST_PATH "/repo2/archive");
const String *repo2backupPath = STRDEF(TEST_PATH "/repo2/backup");
storagePathCreateP(storageLocalWrite(), strNewFmt("%s/stanza1", strZ(repo2archivePath)));
storagePathCreateP(storageLocalWrite(), strNewFmt("%s/stanza1", strZ(repo2backupPath)));
@ -1077,7 +1077,7 @@ testRun(void)
// Set up the configuration
StringList *argListMultiRepo = strLstNew();
hrnCfgArgRawZ(argListMultiRepo, cfgOptRepoPath, TEST_PATH_REPO);
hrnCfgArgKeyRawFmt(argListMultiRepo, cfgOptRepoPath, 2, "%s/repo2", testPath());
hrnCfgArgKeyRawZ(argListMultiRepo, cfgOptRepoPath, 2, TEST_PATH "/repo2");
hrnCfgArgKeyRawStrId(argListMultiRepo, cfgOptRepoCipherType, 2, cipherTypeAes256Cbc);
hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 2, TEST_CIPHER_PASS);
@ -2357,12 +2357,12 @@ testRun(void)
);
TEST_RESULT_VOID(
storagePutP(storageNewWriteP(storageLocalWrite(), strNewFmt("%s/pgbackrest.conf", testPath())),
BUFSTR(content)), "put pgbackrest.conf file");
storagePutP(storageNewWriteP(storageLocalWrite(), STRDEF(TEST_PATH "/pgbackrest.conf")), BUFSTR(content)),
"put pgbackrest.conf file");
argList2 = strLstDup(argListMultiRepo);
strLstAddZ(argList2, "--repo-cipher-type=aes-256-cbc");
strLstAdd(argList2, strNewFmt("--config=%s/pgbackrest.conf", testPath()));
strLstAddZ(argList2, "--config=" TEST_PATH "/pgbackrest.conf");
harnessCfgLoad(cfgCmdInfo, argList2);
TEST_RESULT_STR(
@ -2489,8 +2489,8 @@ testRun(void)
storagePathCreateP(storageLocalWrite(), archivePath);
storagePathCreateP(storageLocalWrite(), backupPath);
String *archivePath2 = strNewFmt("%s/repo2/%s", testPath(), "archive");
String *backupPath2 = strNewFmt("%s/repo2/%s", testPath(), "backup");
String *archivePath2 = strNewFmt(TEST_PATH "/repo2/%s", "archive");
String *backupPath2 = strNewFmt(TEST_PATH "/repo2/%s", "backup");
storagePathCreateP(storageLocalWrite(), archivePath2);
storagePathCreateP(storageLocalWrite(), backupPath2);
@ -2609,7 +2609,7 @@ testRun(void)
StringList *argList2 = strLstNew();
hrnCfgArgRawZ(argList2, cfgOptRepoPath, TEST_PATH_REPO);
hrnCfgArgRawZ(argList2, cfgOptStanza, "stanza1");
hrnCfgArgKeyRawFmt(argList2, cfgOptRepoPath, 2, "%s/repo2", testPath());
hrnCfgArgKeyRawZ(argList2, cfgOptRepoPath, 2, TEST_PATH "/repo2");
harnessCfgLoad(cfgCmdInfo, argList2);
// Note that although the time on the backup in repo2 > repo1, repo1 current db is not the same because of the version so
@ -2731,7 +2731,7 @@ testRun(void)
// Redirect stdout to a file
int stdoutSave = dup(STDOUT_FILENO);
String *stdoutFile = strNewFmt("%s/stdout.info", testPath());
const String *stdoutFile = STRDEF(TEST_PATH "/stdout.info");
THROW_ON_SYS_ERROR(freopen(strZ(stdoutFile), "w", stdout) == NULL, FileWriteError, "unable to reopen stdout");
@ -2741,7 +2741,7 @@ testRun(void)
// Restore normal stdout
dup2(stdoutSave, STDOUT_FILENO);
Storage *storage = storagePosixNewP(strNewZ(testPath()));
Storage *storage = storagePosixNewP(TEST_PATH_STR);
TEST_RESULT_STR_Z(
strNewBuf(storageGetP(storageNewReadP(storage, stdoutFile))), "No stanzas exist in the repository.\n",
" check text");
@ -2756,26 +2756,26 @@ testRun(void)
TEST_TITLE("repo-level error");
TEST_RESULT_VOID(
storagePathCreateP(
storageLocalWrite(), strNewFmt("%s/repo2", testPath()), .mode = 0200), "repo directory with bad permissions");
storagePathCreateP(storageLocalWrite(), STRDEF(TEST_PATH "/repo2"), .mode = 0200),
"repo directory with bad permissions");
argList = strLstNew();
hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 1, "%s/repo2", testPath());
hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 1, TEST_PATH "/repo2");
harnessCfgLoad(cfgCmdInfo, argList);
TEST_RESULT_STR(
infoRender(), strNewFmt(
TEST_RESULT_STR_Z(
infoRender(),
"stanza: [invalid]\n"
" status: error (other)\n"
" [PathOpenError] unable to list file info for path '%s/repo2/backup': [13] Permission denied\n"
" cipher: none\n", testPath()),
" [PathOpenError] unable to list file info for path '" TEST_PATH "/repo2/backup': [13] Permission denied\n"
" cipher: none\n",
"text - invalid stanza");
hrnCfgArgRawZ(argList, cfgOptOutput, "json");
harnessCfgLoad(cfgCmdInfo, argList);
TEST_RESULT_STR(
infoRender(), strNewFmt(
TEST_RESULT_STR_Z(
infoRender(),
"["
"{"
"\"archive\":[],"
@ -2789,8 +2789,8 @@ testRun(void)
"\"key\":1,"
"\"status\":{"
"\"code\":99,"
"\"message\":\"[PathOpenError] unable to list file info for path '%s/repo2/backup': [13] Permission"
" denied\""
"\"message\":\"[PathOpenError] unable to list file info for path '" TEST_PATH "/repo2/backup':"
" [13] Permission denied\""
"}"
"}"
"],"
@ -2800,33 +2800,34 @@ testRun(void)
"\"message\":\"other\""
"}"
"}"
"]", testPath()),
"]",
"json - invalid stanza");
argList = strLstNew();
hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 1, "%s/repo2", testPath());
hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 1, TEST_PATH "/repo2");
hrnCfgArgRawZ(argList, cfgOptStanza, "stanza1");
harnessCfgLoad(cfgCmdInfo, argList);
TEST_RESULT_STR(
infoRender(), strNewFmt(
TEST_RESULT_STR_Z(
infoRender(),
"stanza: stanza1\n"
" status: error (other)\n"
" [PathOpenError] unable to list file info for path '%s/repo2/backup': [13] Permission denied\n"
" cipher: none\n", testPath()),
" [PathOpenError] unable to list file info for path '" TEST_PATH "/repo2/backup': [13] Permission denied\n"
" cipher: none\n",
"text - stanza requested");
hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 2, "%s/repo", testPath());
hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 2, TEST_PATH "/repo");
harnessCfgLoad(cfgCmdInfo, argList);
TEST_RESULT_STR(
infoRender(), strNewFmt(
TEST_RESULT_STR_Z(
infoRender(),
"stanza: stanza1\n"
" status: mixed\n"
" repo1: error (other)\n"
" [PathOpenError] unable to list file info for path '%s/repo2/backup': [13] Permission denied\n"
" [PathOpenError] unable to list file info for path '" TEST_PATH "/repo2/backup':"
" [13] Permission denied\n"
" repo2: error (missing stanza path)\n"
" cipher: none\n", testPath()),
" cipher: none\n",
"text - stanza repo structure exists");
}

View File

@ -19,7 +19,7 @@ testRun(void)
FUNCTION_HARNESS_VOID();
// Create default storage object for testing
Storage *storageData = storagePosixNewP(strNewZ(testDataPath()), .write = true);
const Storage *const hrnStorage = storagePosixNewP(HRN_PATH_STR, .write = true);
// *****************************************************************************************************************************
if (testBegin("cmdRemote()"))
@ -158,7 +158,7 @@ testRun(void)
protocolClientNoOp(client);
TEST_RESULT_BOOL(
storageExistsP(storagePosixNewP(strNewZ(testDataPath())), STRDEF("lock/test-archive" LOCK_FILE_EXT)),
storageExistsP(storagePosixNewP(HRN_PATH_STR), STRDEF("lock/test-archive" LOCK_FILE_EXT)),
true, "lock exists");
protocolClientFree(client);
@ -191,13 +191,13 @@ testRun(void)
IoWrite *write = ioFdWriteNew(STRDEF("server write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000);
ioWriteOpen(write);
storagePutP(storageNewWriteP(storageData, STRDEF("lock/all" STOP_FILE_EXT)), NULL);
storagePutP(storageNewWriteP(hrnStorage, STRDEF("lock/all" STOP_FILE_EXT)), NULL);
TEST_ERROR(
protocolClientNew(STRDEF("test"), PROTOCOL_SERVICE_REMOTE_STR, read, write), StopError,
"raised from test: stop file exists for all stanzas");
storageRemoveP(storageData, STRDEF("lock/all" STOP_FILE_EXT));
storageRemoveP(hrnStorage, STRDEF("lock/all" STOP_FILE_EXT));
}
HARNESS_FORK_PARENT_END();
}

View File

@ -20,13 +20,13 @@ testRun(void)
FUNCTION_HARNESS_VOID();
// Create default storage object for testing
Storage *storageTest = storagePosixNewP(strNewZ(testPath()), .write = true);
Storage *storageTest = storagePosixNewP(TEST_PATH_STR, .write = true);
// *****************************************************************************************************************************
if (testBegin("cmdRepoCreate()"))
{
StringList *argList = strLstNew();
strLstAdd(argList, strNewFmt("--repo-path=%s/repo", testPath()));
strLstAddZ(argList, "--repo-path=" TEST_PATH_REPO);
harnessCfgLoad(cfgCmdRepoCreate, argList);
// -------------------------------------------------------------------------------------------------------------------------
@ -39,7 +39,7 @@ testRun(void)
if (testBegin("cmdStorageList() and storageListRender()"))
{
StringList *argList = strLstNew();
strLstAdd(argList, strNewFmt("--repo-path=%s/repo", testPath()));
strLstAddZ(argList, "--repo-path=" TEST_PATH_REPO);
strLstAddZ(argList, "--output=text");
strLstAddZ(argList, "--sort=none");
harnessCfgLoad(cfgCmdRepoLs, argList);
@ -105,8 +105,8 @@ testRun(void)
storagePutP(storageNewWriteP(storageTest, STRDEF("repo/aaa"), .timeModified = 1578671569), BUFSTRDEF("TESTDATA"));
storagePutP(storageNewWriteP(storageTest, STRDEF("repo/bbb/ccc")), BUFSTRDEF("TESTDATA2"));
ASSERT(system(strZ(strNewFmt("ln -s ../bbb %s/repo/link", testPath()))) == 0);
ASSERT(system(strZ(strNewFmt("mkfifo %s/repo/pipe", testPath()))) == 0);
ASSERT(system("ln -s ../bbb " TEST_PATH "/repo/link") == 0);
ASSERT(system("mkfifo " TEST_PATH "/repo/pipe") == 0);
output = bufNew(0);
cfgOptionSet(cfgOptOutput, cfgSourceParam, VARSTRDEF("text"));
@ -168,7 +168,7 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
// Redirect stdout to a file
int stdoutSave = dup(STDOUT_FILENO);
String *stdoutFile = strNewFmt("%s/stdout.txt", testPath());
const String *stdoutFile = STRDEF(TEST_PATH "/stdout.txt");
THROW_ON_SYS_ERROR(freopen(strZ(stdoutFile), "w", stdout) == NULL, FileWriteError, "unable to reopen stdout");
@ -297,7 +297,7 @@ testRun(void)
TEST_TITLE("error when missing destination");
StringList *argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH_REPO);
harnessCfgLoad(cfgCmdRepoPut, argList);
TEST_ERROR(storagePutProcess(ioBufferReadNew(fileBuffer)), ParamRequiredError, "destination file required");
@ -314,7 +314,7 @@ testRun(void)
TEST_TITLE("put an encrypted file with custom key");
argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH_REPO);
hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, "--" CFGOPT_CIPHER_PASS "=custom");
strLstAdd(argList, fileEncCustomName);
@ -326,7 +326,7 @@ testRun(void)
TEST_TITLE("put a raw file");
argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH_REPO);
hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, "--raw");
strLstAdd(argList, fileRawName);
@ -348,7 +348,7 @@ testRun(void)
TEST_TITLE("put encrypted archive.info");
argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH_REPO);
hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, STORAGE_PATH_ARCHIVE "/test/" INFO_ARCHIVE_FILE);
harnessCfgLoad(cfgCmdRepoPut, argList);
@ -359,7 +359,7 @@ testRun(void)
TEST_TITLE("put encrypted archive.info.copy");
argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH_REPO);
hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, STORAGE_PATH_ARCHIVE "/test/" INFO_ARCHIVE_FILE ".copy");
harnessCfgLoad(cfgCmdRepoPut, argList);
@ -370,7 +370,7 @@ testRun(void)
TEST_TITLE("put encrypted backup.info");
argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH_REPO);
hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/" INFO_BACKUP_FILE);
harnessCfgLoad(cfgCmdRepoPut, argList);
@ -381,7 +381,7 @@ testRun(void)
TEST_TITLE("put encrypted backup.info.copy");
argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH_REPO);
hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/" INFO_BACKUP_FILE ".copy");
harnessCfgLoad(cfgCmdRepoPut, argList);
@ -398,7 +398,7 @@ testRun(void)
bufUsedSet(archiveFileBuffer, bufSize(archiveFileBuffer));
argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH_REPO);
hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, "--" CFGOPT_CIPHER_PASS "=custom");
strLstAdd(
@ -414,7 +414,7 @@ testRun(void)
TEST_TITLE("put encrypted backup.manifest");
argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH_REPO);
hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, "--" CFGOPT_CIPHER_PASS "=custom");
strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/latest/" BACKUP_MANIFEST_FILE);
@ -426,7 +426,7 @@ testRun(void)
TEST_TITLE("put encrypted backup.manifest.copy");
argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH_REPO);
hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, "--" CFGOPT_CIPHER_PASS "=custom");
strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/latest/" BACKUP_MANIFEST_FILE ".copy");
@ -452,7 +452,7 @@ testRun(void)
TEST_TITLE("put encrypted backup_label");
argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH_REPO);
hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, "--" CFGOPT_CIPHER_PASS "=custom2");
strLstAdd(argList, STRDEF(STORAGE_PATH_BACKUP "/test/latest/pg_data/backup_label"));
@ -464,7 +464,7 @@ testRun(void)
TEST_TITLE("error when missing source");
argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH_REPO);
harnessCfgLoad(cfgCmdRepoGet, argList);
TEST_ERROR(storageGetProcess(ioBufferWriteNew(bufNew(0))), ParamRequiredError, "source file required");
@ -484,7 +484,7 @@ testRun(void)
argList = strLstNew();
hrnCfgArgRawZ(argList, cfgOptRepoPath, "/");
strLstAdd(argList, strNewFmt("%s/repo/%s", testPath(), strZ(fileName)));
strLstAdd(argList, strNewFmt(TEST_PATH "/repo/%s", strZ(fileName)));
harnessCfgLoad(cfgCmdRepoGet, argList);
writeBuffer = bufNew(0);
@ -495,7 +495,7 @@ testRun(void)
TEST_TITLE("get an encrypted file with custom key");
argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH_REPO);
hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, "--" CFGOPT_CIPHER_PASS "=custom");
strLstAdd(argList, fileEncCustomName);
@ -509,7 +509,7 @@ testRun(void)
TEST_TITLE("get a raw file");
argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH_REPO);
hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, "--raw");
strLstAdd(argList, fileRawName);
@ -519,7 +519,7 @@ testRun(void)
// Redirect stdout to a file
int stdoutSave = dup(STDOUT_FILENO);
String *stdoutFile = strNewFmt("%s/repo/stdout.txt", testPath());
const String *stdoutFile = STRDEF(TEST_PATH "/repo/stdout.txt");
THROW_ON_SYS_ERROR(freopen(strZ(stdoutFile), "w", stdout) == NULL, FileWriteError, "unable to reopen stdout");
@ -536,7 +536,7 @@ testRun(void)
TEST_TITLE("ignore missing file");
argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH_REPO);
strLstAddZ(argList, "--" CFGOPT_IGNORE_MISSING);
strLstAddZ(argList, BOGUS_STR);
harnessCfgLoad(cfgCmdRepoGet, argList);
@ -558,13 +558,13 @@ testRun(void)
writeBuffer = bufNew(0);
TEST_ERROR(
storageGetProcess(ioBufferWriteNew(writeBuffer)), OptionInvalidValueError,
strZ(strNewFmt("absolute path '/somewhere/%s' is not in base path '%s/repo'", INFO_ARCHIVE_FILE, testPath())));
"absolute path '/somewhere/" INFO_ARCHIVE_FILE "' is not in base path '" TEST_PATH "/repo'");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("get file in repo root directory error");
argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH_REPO);
hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAdd(argList, fileEncCustomName);
harnessCfgLoad(cfgCmdRepoGet, argList);
@ -578,7 +578,7 @@ testRun(void)
TEST_TITLE("get encrypted archive.info - stanza mismatch");
argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH_REPO);
strLstAddZ(argList, "--" CFGOPT_STANZA "=test2");
hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, STORAGE_PATH_ARCHIVE "/test/" INFO_ARCHIVE_FILE);
@ -592,7 +592,7 @@ testRun(void)
TEST_TITLE("get encrypted archive.info");
argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH_REPO);
hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, STORAGE_PATH_ARCHIVE "/test/" INFO_ARCHIVE_FILE);
harnessCfgLoad(cfgCmdRepoGet, argList);
@ -605,7 +605,7 @@ testRun(void)
TEST_TITLE("get encrypted archive.info.copy");
argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH_REPO);
strLstAddZ(argList, "--" CFGOPT_STANZA "=test");
hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, STORAGE_PATH_ARCHIVE "/test/" INFO_ARCHIVE_FILE ".copy");
@ -619,7 +619,7 @@ testRun(void)
TEST_TITLE("get encrypted backup.info");
argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH_REPO);
hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/" INFO_BACKUP_FILE);
harnessCfgLoad(cfgCmdRepoGet, argList);
@ -632,7 +632,7 @@ testRun(void)
TEST_TITLE("get encrypted backup.info.copy");
argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH_REPO);
hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/" INFO_BACKUP_FILE ".copy");
harnessCfgLoad(cfgCmdRepoGet, argList);
@ -648,10 +648,13 @@ testRun(void)
TEST_TITLE("get encrypted WAL archive file");
argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH_REPO);
hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAdd(argList, strNewFmt(
"%s/repo/" STORAGE_PATH_ARCHIVE "/test/12-1/000000010000000100000001-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",testPath()));
strLstAdd(
argList,
strNewFmt(
"%s/repo/" STORAGE_PATH_ARCHIVE "/test/12-1/000000010000000100000001-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
TEST_PATH));
harnessCfgLoad(cfgCmdRepoGet, argList);
writeBuffer = bufNew(0);
@ -662,7 +665,7 @@ testRun(void)
TEST_TITLE("get encrypted backup.manifest");
argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH_REPO);
hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/latest/" BACKUP_MANIFEST_FILE);
harnessCfgLoad(cfgCmdRepoGet, argList);
@ -675,7 +678,7 @@ testRun(void)
TEST_TITLE("get encrypted backup.manifest.copy");
argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH_REPO);
hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/latest/" BACKUP_MANIFEST_FILE ".copy");
harnessCfgLoad(cfgCmdRepoGet, argList);
@ -688,7 +691,7 @@ testRun(void)
TEST_TITLE("get encrypted backup.history manifest");
argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH_REPO);
hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/backup.history/2020/label.manifest.gz");
harnessCfgLoad(cfgCmdRepoGet, argList);
@ -701,7 +704,7 @@ testRun(void)
TEST_TITLE("get encrypted backup_label");
argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH_REPO);
hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAdd(argList, STRDEF(STORAGE_PATH_BACKUP "/test/latest/pg_data/backup_label"));
harnessCfgLoad(cfgCmdRepoGet, argList);
@ -722,7 +725,7 @@ testRun(void)
if (testBegin("cmdStorageRemove()"))
{
StringList *argList = strLstNew();
strLstAdd(argList, strNewFmt("--repo-path=%s/repo", testPath()));
strLstAddZ(argList, "--repo-path=" TEST_PATH "/repo");
harnessCfgLoad(cfgCmdRepoRm, argList);
// -------------------------------------------------------------------------------------------------------------------------

View File

@ -87,7 +87,7 @@ testRestoreCompare(const Storage *storage, const String *pgPath, const Manifest
"pg path info list for restore compare");
// Compare
TEST_RESULT_STR_Z(callbackData.content, hrnReplaceKey(compare), " compare result manifest");
TEST_RESULT_STR_Z(callbackData.content, compare, " compare result manifest");
FUNCTION_HARNESS_RETURN_VOID();
}
@ -151,7 +151,7 @@ testRun(void)
hrnProtocolLocalShimInstall(testLocalHandlerList, PROTOCOL_SERVER_HANDLER_LIST_SIZE(testLocalHandlerList));
// Create default storage object for testing
Storage *storageTest = storagePosixNewP(strNewZ(testPath()), .write = true);
Storage *storageTest = storagePosixNewP(TEST_PATH_STR, .write = true);
// *****************************************************************************************************************************
if (testBegin("restoreFile()"))
@ -163,8 +163,8 @@ testRun(void)
// Load Parameters
StringList *argList = strLstNew();
strLstAddZ(argList, "--stanza=test1");
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAdd(argList, strNewFmt("--pg1-path=%s/pg", testPath()));
strLstAddZ(argList, "--repo1-path=" TEST_PATH "/repo");
strLstAddZ(argList, "--pg1-path=" TEST_PATH "/pg");
harnessCfgLoad(cfgCmdRestore, argList);
// Create the pg path
@ -173,16 +173,16 @@ testRun(void)
TEST_RESULT_BOOL(
restoreFile(
repoFile1, repoIdx, repoFileReferenceFull, compressTypeNone, STRDEF("sparse-zero"),
STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"), true, 0x10000000000UL, 1557432154, 0600, strNewZ(testUser()),
strNewZ(testGroup()), 0, true, false, NULL),
STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"), true, 0x10000000000UL, 1557432154, 0600, TEST_USER_STR,
TEST_GROUP_STR, 0, true, false, NULL),
false, "zero sparse 1TB file");
TEST_RESULT_UINT(storageInfoP(storagePg(), STRDEF("sparse-zero")).size, 0x10000000000UL, " check size");
TEST_RESULT_BOOL(
restoreFile(
repoFile1, repoIdx, repoFileReferenceFull, compressTypeNone, STRDEF("normal-zero"),
STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"), false, 0, 1557432154, 0600, strNewZ(testUser()),
strNewZ(testGroup()), 0, false, false, NULL),
STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"), false, 0, 1557432154, 0600, TEST_USER_STR, TEST_GROUP_STR, 0,
false, false, NULL),
true, "zero-length file");
TEST_RESULT_UINT(storageInfoP(storagePg(), STRDEF("normal-zero")).size, 0, " check size");
@ -199,8 +199,8 @@ testRun(void)
TEST_ERROR(
restoreFile(
repoFile1, repoIdx, repoFileReferenceFull, compressTypeGz, STRDEF("normal"),
STRDEF("ffffffffffffffffffffffffffffffffffffffff"), false, 7, 1557432154, 0600, strNewZ(testUser()),
strNewZ(testGroup()), 0, false, false, STRDEF("badpass")),
STRDEF("ffffffffffffffffffffffffffffffffffffffff"), false, 7, 1557432154, 0600, TEST_USER_STR, TEST_GROUP_STR, 0,
false, false, STRDEF("badpass")),
ChecksumError,
"error restoring 'normal': actual checksum 'd1cd8a7d11daa26814b93eb604e1d49ab4b43770' does not match expected checksum"
" 'ffffffffffffffffffffffffffffffffffffffff'");
@ -214,8 +214,8 @@ testRun(void)
TEST_RESULT_BOOL(
restoreFile(
repoFile1, repoIdx, repoFileReferenceFull, compressTypeGz, STRDEF("normal"),
STRDEF("d1cd8a7d11daa26814b93eb604e1d49ab4b43770"), false, 7, 1557432154, 0600, strNewZ(testUser()),
strNewZ(testGroup()), 0, false, false, STRDEF("badpass")),
STRDEF("d1cd8a7d11daa26814b93eb604e1d49ab4b43770"), false, 7, 1557432154, 0600, TEST_USER_STR, TEST_GROUP_STR, 0,
false, false, STRDEF("badpass")),
true, "copy file");
StorageInfo info = storageInfoP(storagePg(), STRDEF("normal"));
@ -223,8 +223,8 @@ testRun(void)
TEST_RESULT_UINT(info.size, 7, " check size");
TEST_RESULT_UINT(info.mode, 0600, " check mode");
TEST_RESULT_INT(info.timeModified, 1557432154, " check time");
TEST_RESULT_STR_Z(info.user, testUser(), " check user");
TEST_RESULT_STR_Z(info.group, testGroup(), " check group");
TEST_RESULT_STR(info.user, TEST_USER_STR, " check user");
TEST_RESULT_STR(info.group, TEST_GROUP_STR, " check group");
TEST_RESULT_STR_Z(strNewBuf(storageGetP(storageNewReadP(storagePg(), STRDEF("normal")))), "acefile", " check contents");
// -------------------------------------------------------------------------------------------------------------------------
@ -237,8 +237,8 @@ testRun(void)
TEST_RESULT_BOOL(
restoreFile(
repoFile1, repoIdx, repoFileReferenceFull, compressTypeNone, STRDEF("delta"),
STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"), false, 9, 1557432154, 0600, strNewZ(testUser()),
strNewZ(testGroup()), 0, true, false, NULL),
STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"), false, 9, 1557432154, 0600, TEST_USER_STR, TEST_GROUP_STR, 0,
true, false, NULL),
true, "sha1 delta missing");
TEST_RESULT_STR_Z(
strNewBuf(storageGetP(storageNewReadP(storagePg(), STRDEF("delta")))), "atestfile", " check contents");
@ -249,8 +249,8 @@ testRun(void)
TEST_RESULT_BOOL(
restoreFile(
repoFile1, repoIdx, repoFileReferenceFull, compressTypeNone, STRDEF("delta"),
STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"), false, 9, 1557432154, 0600, strNewZ(testUser()),
strNewZ(testGroup()), 0, true, false, NULL),
STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"), false, 9, 1557432154, 0600, TEST_USER_STR, TEST_GROUP_STR, 0,
true, false, NULL),
false, "sha1 delta existing");
ioBufferSizeSet(oldBufferSize);
@ -258,8 +258,8 @@ testRun(void)
TEST_RESULT_BOOL(
restoreFile(
repoFile1, repoIdx, repoFileReferenceFull, compressTypeNone, STRDEF("delta"),
STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"), false, 9, 1557432154, 0600, strNewZ(testUser()),
strNewZ(testGroup()), 1557432155, true, true, NULL),
STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"), false, 9, 1557432154, 0600, TEST_USER_STR, TEST_GROUP_STR,
1557432155, true, true, NULL),
false, "sha1 delta force existing");
// Change the existing file so it no longer matches by size
@ -268,8 +268,8 @@ testRun(void)
TEST_RESULT_BOOL(
restoreFile(
repoFile1, repoIdx, repoFileReferenceFull, compressTypeNone, STRDEF("delta"),
STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"), false, 9, 1557432154, 0600, strNewZ(testUser()),
strNewZ(testGroup()), 0, true, false, NULL),
STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"), false, 9, 1557432154, 0600, TEST_USER_STR, TEST_GROUP_STR, 0,
true, false, NULL),
true, "sha1 delta existing, size differs");
TEST_RESULT_STR_Z(
strNewBuf(storageGetP(storageNewReadP(storagePg(), STRDEF("delta")))), "atestfile", " check contents");
@ -279,8 +279,8 @@ testRun(void)
TEST_RESULT_BOOL(
restoreFile(
repoFile1, repoIdx, repoFileReferenceFull, compressTypeNone, STRDEF("delta"),
STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"), false, 9, 1557432154, 0600, strNewZ(testUser()),
strNewZ(testGroup()), 1557432155, true, true, NULL),
STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"), false, 9, 1557432154, 0600, TEST_USER_STR, TEST_GROUP_STR,
1557432155, true, true, NULL),
true, "delta force existing, size differs");
TEST_RESULT_STR_Z(
strNewBuf(storageGetP(storageNewReadP(storagePg(), STRDEF("delta")))), "atestfile", " check contents");
@ -291,8 +291,8 @@ testRun(void)
TEST_RESULT_BOOL(
restoreFile(
repoFile1, repoIdx, repoFileReferenceFull, compressTypeNone, STRDEF("delta"),
STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"), false, 9, 1557432154, 0600, strNewZ(testUser()),
strNewZ(testGroup()), 0, true, false, NULL),
STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"), false, 9, 1557432154, 0600, TEST_USER_STR, TEST_GROUP_STR, 0,
true, false, NULL),
true, "sha1 delta existing, content differs");
TEST_RESULT_STR_Z(
strNewBuf(storageGetP(storageNewReadP(storagePg(), STRDEF("delta")))), "atestfile", " check contents");
@ -302,15 +302,15 @@ testRun(void)
TEST_RESULT_BOOL(
restoreFile(
repoFile1, repoIdx, repoFileReferenceFull, compressTypeNone, STRDEF("delta"),
STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"), false, 9, 1557432154, 0600, strNewZ(testUser()),
strNewZ(testGroup()), 1557432155, true, true, NULL),
STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"), false, 9, 1557432154, 0600, TEST_USER_STR, TEST_GROUP_STR,
1557432155, true, true, NULL),
true, "delta force existing, timestamp differs");
TEST_RESULT_BOOL(
restoreFile(
repoFile1, repoIdx, repoFileReferenceFull, compressTypeNone, STRDEF("delta"),
STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"), false, 9, 1557432154, 0600, strNewZ(testUser()),
strNewZ(testGroup()), 1557432153, true, true, NULL),
STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"), false, 9, 1557432154, 0600, TEST_USER_STR, TEST_GROUP_STR,
1557432153, true, true, NULL),
true, "delta force existing, timestamp after copy time");
// Change the existing file to zero-length
@ -319,16 +319,16 @@ testRun(void)
TEST_RESULT_BOOL(
restoreFile(
repoFile1, repoIdx, repoFileReferenceFull, compressTypeNone, STRDEF("delta"),
STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"), false, 0, 1557432154, 0600, strNewZ(testUser()),
strNewZ(testGroup()), 0, true, false, NULL),
STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"), false, 0, 1557432154, 0600, TEST_USER_STR, TEST_GROUP_STR, 0,
true, false, NULL),
false, "sha1 delta existing, content differs");
}
// *****************************************************************************************************************************
if (testBegin("restorePathValidate()"))
{
const String *pgPath = strNewFmt("%s/pg", testPath());
const String *repoPath = strNewFmt("%s/repo", testPath());
const String *pgPath = STRDEF(TEST_PATH "/pg");
const String *repoPath = STRDEF(TEST_PATH "/repo");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("error on data directory missing");
@ -339,7 +339,7 @@ testRun(void)
strLstAdd(argList, strNewFmt("--pg1-path=%s", strZ(pgPath)));
harnessCfgLoad(cfgCmdRestore, argList);
TEST_ERROR_FMT(restorePathValidate(), PathMissingError, "$PGDATA directory '%s/pg' does not exist", testPath());
TEST_ERROR(restorePathValidate(), PathMissingError, "$PGDATA directory '" TEST_PATH "/pg' does not exist");
// Create PGDATA
storagePathCreateP(storagePgWrite(), NULL);
@ -354,7 +354,7 @@ testRun(void)
"unable to restore while PostgreSQL is running\n"
"HINT: presence of 'postmaster.pid' in '%s/pg' indicates PostgreSQL is running.\n"
"HINT: remove 'postmaster.pid' only if PostgreSQL is not running.",
testPath());
TEST_PATH);
storageRemoveP(storagePgWrite(), STRDEF("postmaster.pid"), .errorOnMissing = true);
@ -371,7 +371,7 @@ testRun(void)
TEST_RESULT_VOID(restorePathValidate(), "restore --delta with invalid PGDATA");
TEST_RESULT_BOOL(cfgOptionBool(cfgOptDelta), false, "--delta set to false");
TEST_RESULT_LOG(
"P00 WARN: --delta or --force specified but unable to find 'PG_VERSION' or 'backup.manifest' in '{[path]}/pg' to"
"P00 WARN: --delta or --force specified but unable to find 'PG_VERSION' or 'backup.manifest' in '" TEST_PATH "/pg' to"
" confirm that this is a valid $PGDATA directory. --delta and --force have been disabled and if any files"
" exist in the destination directories the restore will be aborted.");
@ -382,15 +382,15 @@ testRun(void)
argList = strLstNew();
strLstAddZ(argList, "--stanza=test1");
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAdd(argList, strNewFmt("--pg1-path=%s/pg", testPath()));
strLstAddZ(argList, "--repo1-path=" TEST_PATH "/repo");
strLstAddZ(argList, "--pg1-path=" TEST_PATH "/pg");
strLstAddZ(argList, "--force");
harnessCfgLoad(cfgCmdRestore, argList);
TEST_RESULT_VOID(restorePathValidate(), "restore --force with invalid PGDATA");
TEST_RESULT_BOOL(cfgOptionBool(cfgOptForce), false, "--force set to false");
TEST_RESULT_LOG(
"P00 WARN: --delta or --force specified but unable to find 'PG_VERSION' or 'backup.manifest' in '{[path]}/pg' to"
"P00 WARN: --delta or --force specified but unable to find 'PG_VERSION' or 'backup.manifest' in '" TEST_PATH "/pg' to"
" confirm that this is a valid $PGDATA directory. --delta and --force have been disabled and if any files"
" exist in the destination directories the restore will be aborted.");
@ -441,8 +441,8 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("restoreBackupSet()"))
{
const String *pgPath = strNewFmt("%s/pg", testPath());
const String *repoPath = strNewFmt("%s/repo", testPath());
const String *pgPath = STRDEF(TEST_PATH "/pg");
const String *repoPath = STRDEF(TEST_PATH "/repo");
StringList *argList = strLstNew();
strLstAddZ(argList, "--stanza=test1");
@ -479,7 +479,7 @@ testRun(void)
TEST_TITLE("target time");
setenv("TZ", "UTC", true);
const String *repoPath2 = strNewFmt("%s/repo2", testPath());
const String *repoPath2 = STRDEF(TEST_PATH "/repo2");
argList = strLstNew();
strLstAddZ(argList, "--stanza=test1");
@ -640,8 +640,8 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("restoreManifestMap()"))
{
const String *pgPath = strNewFmt("%s/pg", testPath());
const String *repoPath = strNewFmt("%s/repo", testPath());
const String *pgPath = STRDEF(TEST_PATH "/pg");
const String *repoPath = STRDEF(TEST_PATH "/repo");
Manifest *manifest = testManifestMinimal(STRDEF("20161219-212741F"), PG_VERSION_94, pgPath);
// -------------------------------------------------------------------------------------------------------------------------
@ -657,7 +657,7 @@ testRun(void)
TEST_RESULT_STR(manifestTargetFind(manifest, MANIFEST_TARGET_PGDATA_STR)->path, pgPath, "base directory is not remapped");
// Now change pg1-path so the data directory gets remapped
pgPath = strNewFmt("%s/pg2", testPath());
pgPath = STRDEF(TEST_PATH "/pg2");
argList = strLstNew();
strLstAddZ(argList, "--stanza=test1");
@ -667,7 +667,7 @@ testRun(void)
TEST_RESULT_VOID(restoreManifestMap(manifest), "base directory is remapped");
TEST_RESULT_STR(manifestTargetFind(manifest, MANIFEST_TARGET_PGDATA_STR)->path, pgPath, "base directory is remapped");
TEST_RESULT_LOG("P00 INFO: remap data directory to '{[path]}/pg2'");
TEST_RESULT_LOG("P00 INFO: remap data directory to '" TEST_PATH "/pg2'");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("remap tablespaces");
@ -880,7 +880,7 @@ testRun(void)
{
userInitInternal();
const String *pgPath = strNewFmt("%s/pg", testPath());
const String *pgPath = STRDEF(TEST_PATH "/pg");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("owner is not root and all ownership is good");
@ -899,8 +899,8 @@ testRun(void)
TEST_RESULT_VOID(restoreManifestOwner(manifest), "check ownership");
TEST_RESULT_LOG(
"P00 WARN: unknown user '{[user]}' in backup manifest mapped to current user\n"
"P00 WARN: unknown group '{[group]}' in backup manifest mapped to current group");
"P00 WARN: unknown user '" TEST_USER "' in backup manifest mapped to current user\n"
"P00 WARN: unknown group '" TEST_GROUP "' in backup manifest mapped to current group");
userInitInternal();
@ -948,7 +948,7 @@ testRun(void)
TEST_RESULT_VOID(restoreManifestOwner(manifest), "check ownership");
TEST_RESULT_LOG("P00 WARN: unknown group in backup manifest mapped to '{[group]}'");
TEST_RESULT_LOG("P00 WARN: unknown group in backup manifest mapped to '" TEST_GROUP "'");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("owner is root and group is bad");
@ -961,7 +961,7 @@ testRun(void)
TEST_RESULT_VOID(restoreManifestOwner(manifest), "check ownership");
TEST_RESULT_LOG("P00 WARN: unknown user in backup manifest mapped to '{[user]}'");
TEST_RESULT_LOG("P00 WARN: unknown user in backup manifest mapped to '" TEST_USER "'");
// -------------------------------------------------------------------------------------------------------------------------
#ifdef TEST_CONTAINER_REQUIRED
@ -995,26 +995,26 @@ testRun(void)
TEST_TITLE("restoreCleanOwnership() update to root (existing)");
// Expect an error here since we can't really set ownership to root
TEST_ERROR_FMT(
restoreCleanOwnership(STR(testPath()), STRDEF("root"), STRDEF("root"), userId(), groupId(), false), FileOwnerError,
"unable to set ownership for '%s': [1] Operation not permitted", testPath());
TEST_ERROR(
restoreCleanOwnership(TEST_PATH_STR, STRDEF("root"), STRDEF("root"), userId(), groupId(), false), FileOwnerError,
"unable to set ownership for '" TEST_PATH "': [1] Operation not permitted");
TEST_RESULT_LOG("P00 DETAIL: update ownership for '{[path]}'");
TEST_RESULT_LOG("P00 DETAIL: update ownership for '" TEST_PATH "'");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("restoreCleanOwnership() update to bogus (new)");
// Will succeed because bogus will be remapped to the current user/group
restoreCleanOwnership(STR(testPath()), STRDEF("bogus"), STRDEF("bogus"), 0, 0, true);
restoreCleanOwnership(TEST_PATH_STR, STRDEF("bogus"), STRDEF("bogus"), 0, 0, true);
// Test again with only group for coverage
restoreCleanOwnership(STR(testPath()), STRDEF("bogus"), STRDEF("bogus"), userId(), 0, true);
restoreCleanOwnership(TEST_PATH_STR, STRDEF("bogus"), STRDEF("bogus"), userId(), 0, true);
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("directory with bad permissions/mode");
const String *pgPath = strNewFmt("%s/pg", testPath());
const String *repoPath = strNewFmt("%s/repo", testPath());
const String *pgPath = STRDEF(TEST_PATH "/pg");
const String *repoPath = STRDEF(TEST_PATH "/repo");
Manifest *manifest = testManifestMinimal(STRDEF("20161219-212741F_20161219-21275D"), PG_VERSION_96, pgPath);
StringList *argList = strLstNew();
@ -1025,26 +1025,26 @@ testRun(void)
storagePathCreateP(storagePgWrite(), NULL, .mode = 0600);
userLocalData.userId = getuid() + 1;
userLocalData.userId = TEST_USER_ID + 1;
TEST_ERROR_FMT(
restoreCleanBuild(manifest), PathOpenError, "unable to restore to path '%s/pg' not owned by current user", testPath());
restoreCleanBuild(manifest), PathOpenError, "unable to restore to path '%s/pg' not owned by current user", TEST_PATH);
TEST_RESULT_LOG("P00 DETAIL: check '{[path]}/pg' exists");
TEST_RESULT_LOG("P00 DETAIL: check '" TEST_PATH "/pg' exists");
userLocalData.userRoot = true;
TEST_ERROR_FMT(
restoreCleanBuild(manifest), PathOpenError, "unable to restore to path '%s/pg' without rwx permissions", testPath());
restoreCleanBuild(manifest), PathOpenError, "unable to restore to path '%s/pg' without rwx permissions", TEST_PATH);
TEST_RESULT_LOG("P00 DETAIL: check '{[path]}/pg' exists");
TEST_RESULT_LOG("P00 DETAIL: check '" TEST_PATH "/pg' exists");
userInitInternal();
TEST_ERROR_FMT(
restoreCleanBuild(manifest), PathOpenError, "unable to restore to path '%s/pg' without rwx permissions", testPath());
restoreCleanBuild(manifest), PathOpenError, "unable to restore to path '%s/pg' without rwx permissions", TEST_PATH);
TEST_RESULT_LOG("P00 DETAIL: check '{[path]}/pg' exists");
TEST_RESULT_LOG("P00 DETAIL: check '" TEST_PATH "/pg' exists");
storagePathRemoveP(storagePgWrite(), NULL);
storagePathCreateP(storagePgWrite(), NULL, .mode = 0700);
@ -1058,9 +1058,9 @@ testRun(void)
restoreCleanBuild(manifest), PathNotEmptyError,
"unable to restore to path '%s/pg' because it contains files\n"
"HINT: try using --delta if this is what you intended.",
testPath());
TEST_PATH);
TEST_RESULT_LOG("P00 DETAIL: check '{[path]}/pg' exists");
TEST_RESULT_LOG("P00 DETAIL: check '" TEST_PATH "/pg' exists");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("succeed when all directories empty");
@ -1079,9 +1079,9 @@ testRun(void)
TEST_RESULT_VOID(restoreCleanBuild(manifest), "restore");
TEST_RESULT_LOG(
"P00 DETAIL: check '{[path]}/pg' exists\n"
"P00 DETAIL: check '{[path]}/conf' exists\n"
"P00 DETAIL: create symlink '{[path]}/pg/pg_hba.conf' to '../conf/pg_hba.conf'");
"P00 DETAIL: check '" TEST_PATH "/pg' exists\n"
"P00 DETAIL: check '" TEST_PATH "/conf' exists\n"
"P00 DETAIL: create symlink '" TEST_PATH "/pg/pg_hba.conf' to '../conf/pg_hba.conf'");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("error when linked file already exists without delta");
@ -1093,11 +1093,11 @@ testRun(void)
restoreCleanBuild(manifest), FileExistsError,
"unable to restore file '%s/conf/pg_hba.conf' because it already exists\n"
"HINT: try using --delta if this is what you intended.",
testPath());
TEST_PATH);
TEST_RESULT_LOG(
"P00 DETAIL: check '{[path]}/pg' exists\n"
"P00 DETAIL: check '{[path]}/conf' exists");
"P00 DETAIL: check '" TEST_PATH "/pg' exists\n"
"P00 DETAIL: check '" TEST_PATH "/conf' exists");
storageRemoveP(storagePgWrite(), STRDEF("../conf/pg_hba.conf"), .errorOnMissing = true);
@ -1116,9 +1116,9 @@ testRun(void)
TEST_RESULT_VOID(restoreCleanBuild(manifest), "restore");
TEST_RESULT_LOG(
"P00 DETAIL: check '{[path]}/pg' exists\n"
"P00 DETAIL: check '{[path]}/conf' exists\n"
"P00 DETAIL: create symlink '{[path]}/pg/pg_hba.conf' to '../conf/pg_hba.conf'");
"P00 DETAIL: check '" TEST_PATH "/pg' exists\n"
"P00 DETAIL: check '" TEST_PATH "/conf' exists\n"
"P00 DETAIL: create symlink '" TEST_PATH "/pg/pg_hba.conf' to '../conf/pg_hba.conf'");
TEST_SYSTEM_FMT("rm -rf %s/*", strZ(pgPath));
@ -1126,9 +1126,9 @@ testRun(void)
TEST_RESULT_VOID(restoreCleanBuild(manifest), "normal restore ignore recovery.conf");
TEST_RESULT_LOG(
"P00 DETAIL: check '{[path]}/pg' exists\n"
"P00 DETAIL: check '{[path]}/conf' exists\n"
"P00 DETAIL: create symlink '{[path]}/pg/pg_hba.conf' to '../conf/pg_hba.conf'");
"P00 DETAIL: check '" TEST_PATH "/pg' exists\n"
"P00 DETAIL: check '" TEST_PATH "/conf' exists\n"
"P00 DETAIL: create symlink '" TEST_PATH "/pg/pg_hba.conf' to '../conf/pg_hba.conf'");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("succeed when all directories empty and PG12 and preserve but no recovery files");
@ -1140,9 +1140,9 @@ testRun(void)
TEST_RESULT_VOID(restoreCleanBuild(manifest), "restore");
TEST_RESULT_LOG(
"P00 DETAIL: check '{[path]}/pg' exists\n"
"P00 DETAIL: check '{[path]}/conf' exists\n"
"P00 DETAIL: create symlink '{[path]}/pg/pg_hba.conf' to '../conf/pg_hba.conf'");
"P00 DETAIL: check '" TEST_PATH "/pg' exists\n"
"P00 DETAIL: check '" TEST_PATH "/conf' exists\n"
"P00 DETAIL: create symlink '" TEST_PATH "/pg/pg_hba.conf' to '../conf/pg_hba.conf'");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("succeed when all directories empty and ignore PG12 recovery files");
@ -1158,10 +1158,10 @@ testRun(void)
TEST_RESULT_VOID(restoreCleanBuild(manifest), "restore");
TEST_RESULT_LOG(
"P00 DETAIL: check '{[path]}/pg' exists\n"
"P00 DETAIL: check '{[path]}/conf' exists\n"
"P00 DETAIL: check '" TEST_PATH "/pg' exists\n"
"P00 DETAIL: check '" TEST_PATH "/conf' exists\n"
"P00 DETAIL: skip 'postgresql.auto.conf' -- recovery type is preserve\n"
"P00 DETAIL: create symlink '{[path]}/pg/pg_hba.conf' to '../conf/pg_hba.conf'");
"P00 DETAIL: create symlink '" TEST_PATH "/pg/pg_hba.conf' to '../conf/pg_hba.conf'");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("succeed when all directories empty and PG12");
@ -1177,9 +1177,9 @@ testRun(void)
TEST_RESULT_VOID(restoreCleanBuild(manifest), "restore");
TEST_RESULT_LOG(
"P00 DETAIL: check '{[path]}/pg' exists\n"
"P00 DETAIL: check '{[path]}/conf' exists\n"
"P00 DETAIL: create symlink '{[path]}/pg/pg_hba.conf' to '../conf/pg_hba.conf'");
"P00 DETAIL: check '" TEST_PATH "/pg' exists\n"
"P00 DETAIL: check '" TEST_PATH "/conf' exists\n"
"P00 DETAIL: create symlink '" TEST_PATH "/pg/pg_hba.conf' to '../conf/pg_hba.conf'");
}
// *****************************************************************************************************************************
@ -1504,12 +1504,11 @@ testRun(void)
TEST_RESULT_STR_Z(
restoreRecoveryConf(PG_VERSION_94, restoreLabel),
hrnReplaceKey(
RECOVERY_SETTING_HEADER
"a_setting = 'a'\n"
"b_setting = 'b'\n"
"restore_command = '{[project-exe]} --lock-path={[path-data]}/lock --log-path={[path-data]} --pg1-path=/pg"
" --repo1-path=/repo --stanza=test1 archive-get %f \"%p\"'\n"),
RECOVERY_SETTING_HEADER
"a_setting = 'a'\n"
"b_setting = 'b'\n"
"restore_command = '" TEST_PROJECT_EXE " --lock-path=" HRN_PATH "/lock --log-path=" HRN_PATH " --pg1-path=/pg"
" --repo1-path=/repo --stanza=test1 archive-get %f \"%p\"'\n",
"check recovery options");
// -------------------------------------------------------------------------------------------------------------------------
@ -1689,7 +1688,7 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("restoreRecoveryWrite*()"))
{
const String *pgPath = strNewFmt("%s/pg", testPath());
const String *pgPath = STRDEF(TEST_PATH "/pg");
storagePathCreateP(storageTest, pgPath, .mode = 0700);
const String *restoreLabel = STRDEF("LABEL");
@ -1733,7 +1732,7 @@ testRun(void)
TEST_RESULT_LOG(
"P00 WARN: postgresql.auto.conf does not exist -- creating to contain recovery settings\n"
"P00 INFO: write {[path]}/pg/postgresql.auto.conf");
"P00 INFO: write " TEST_PATH "/pg/postgresql.auto.conf");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("PG12 restore type none");
@ -1756,7 +1755,7 @@ testRun(void)
TEST_RESULT_BOOL(storageExistsP(storagePg(), PG_FILE_RECOVERYSIGNAL_STR), true, "recovery.signal exists");
TEST_RESULT_BOOL(storageExistsP(storagePg(), PG_FILE_STANDBYSIGNAL_STR), false, "standby.signal missing");
TEST_RESULT_LOG("P00 INFO: write updated {[path]}/pg/postgresql.auto.conf");
TEST_RESULT_LOG("P00 INFO: write updated " TEST_PATH "/pg/postgresql.auto.conf");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("PG12 restore type standby and remove existing recovery settings");
@ -1792,7 +1791,7 @@ testRun(void)
TEST_RESULT_BOOL(storageExistsP(storagePg(), PG_FILE_RECOVERYSIGNAL_STR), false, "recovery.signal exists");
TEST_RESULT_BOOL(storageExistsP(storagePg(), PG_FILE_STANDBYSIGNAL_STR), true, "standby.signal missing");
TEST_RESULT_LOG("P00 INFO: write updated {[path]}/pg/postgresql.auto.conf");
TEST_RESULT_LOG("P00 INFO: write updated " TEST_PATH "/pg/postgresql.auto.conf");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("PG12 restore type preserve");
@ -1842,15 +1841,15 @@ testRun(void)
TEST_RESULT_BOOL(storageExistsP(storagePg(), PG_FILE_RECOVERYSIGNAL_STR), true, "recovery.signal exists");
TEST_RESULT_BOOL(storageExistsP(storagePg(), PG_FILE_STANDBYSIGNAL_STR), false, "standby.signal missing");
TEST_RESULT_LOG("P00 INFO: write updated {[path]}/pg/postgresql.auto.conf");
TEST_RESULT_LOG("P00 INFO: write updated " TEST_PATH "/pg/postgresql.auto.conf");
}
// *****************************************************************************************************************************
if (testBegin("cmdRestore()"))
{
const String *pgPath = strNewFmt("%s/pg", testPath());
const String *repoPath = strNewFmt("%s/repo", testPath());
const String *repoPathEncrpyt = strNewFmt("%s/repo-encrypt", testPath());
const String *pgPath = STRDEF(TEST_PATH "/pg");
const String *repoPath = STRDEF(TEST_PATH "/repo");
const String *repoPathEncrpyt = STRDEF(TEST_PATH "/repo-encrypt");
// Set log level to detail
harnessLogLevelSet(logLevelDetail);
@ -1938,7 +1937,7 @@ testRun(void)
manifestTargetAdd(
manifest, &(ManifestTarget){
.type = manifestTargetTypeLink, .name = STRDEF(MANIFEST_TARGET_PGTBLSPC "/1"),
.path = strNewFmt("%s/ts/1", testPath()), .tablespaceId = 1, .tablespaceName = STRDEF("ts1")});
.path = STRDEF(TEST_PATH "/ts/1"), .tablespaceId = 1, .tablespaceName = STRDEF("ts1")});
manifestPathAdd(
manifest, &(ManifestPath){
.name = STRDEF(MANIFEST_TARGET_PGDATA "/" MANIFEST_TARGET_PGTBLSPC), .mode = 0700, .group = groupName(),
@ -1952,7 +1951,7 @@ testRun(void)
manifestLinkAdd(
manifest, &(ManifestLink){
.name = STRDEF(MANIFEST_TARGET_PGDATA "/" MANIFEST_TARGET_PGTBLSPC "/1"),
.destination = strNewFmt("%s/ts/1", testPath()), .group = groupName(), .user = userName()});
.destination = STRDEF(TEST_PATH "/ts/1"), .group = groupName(), .user = userName()});
// pg_tblspc/1/16384 path
manifestPathAdd(
@ -2008,21 +2007,21 @@ testRun(void)
" HINT: backup.info cannot be opened and is required to perform a backup.\n"
" HINT: has a stanza-create been performed?\n"
"P00 INFO: repo2: restore backup set 20161219-212741F\n"
"P00 DETAIL: check '{[path]}/pg' exists\n"
"P00 DETAIL: check '{[path]}/ts/1' exists\n"
"P00 DETAIL: update mode for '{[path]}/pg' to 0700\n"
"P00 DETAIL: create path '{[path]}/pg/global'\n"
"P00 DETAIL: create path '{[path]}/pg/pg_tblspc'\n"
"P00 DETAIL: create symlink '{[path]}/pg/pg_tblspc/1' to '{[path]}/ts/1'\n"
"P00 DETAIL: create path '{[path]}/pg/pg_tblspc/1/16384'\n"
"P01 INFO: restore file {[path]}/pg/PG_VERSION (4B, 100%%) checksum 797e375b924134687cbf9eacd37a4355f3d825e4\n"
"P00 INFO: write {[path]}/pg/recovery.conf\n"
"P00 DETAIL: sync path '{[path]}/pg'\n"
"P00 DETAIL: sync path '{[path]}/pg/pg_tblspc'\n"
"P00 DETAIL: sync path '{[path]}/pg/pg_tblspc/1'\n"
"P00 DETAIL: sync path '{[path]}/pg/pg_tblspc/1/16384'\n"
"P00 DETAIL: check '" TEST_PATH "/pg' exists\n"
"P00 DETAIL: check '" TEST_PATH "/ts/1' exists\n"
"P00 DETAIL: update mode for '" TEST_PATH "/pg' to 0700\n"
"P00 DETAIL: create path '" TEST_PATH "/pg/global'\n"
"P00 DETAIL: create path '" TEST_PATH "/pg/pg_tblspc'\n"
"P00 DETAIL: create symlink '" TEST_PATH "/pg/pg_tblspc/1' to '" TEST_PATH "/ts/1'\n"
"P00 DETAIL: create path '" TEST_PATH "/pg/pg_tblspc/1/16384'\n"
"P01 INFO: restore file " TEST_PATH "/pg/PG_VERSION (4B, 100%%) checksum 797e375b924134687cbf9eacd37a4355f3d825e4\n"
"P00 INFO: write " TEST_PATH "/pg/recovery.conf\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg/pg_tblspc'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg/pg_tblspc/1'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg/pg_tblspc/1/16384'\n"
"P00 WARN: backup does not contain 'global/pg_control' -- cluster will not start\n"
"P00 DETAIL: sync path '{[path]}/pg/global'", testPath(), testPath(), testPath(), testPath())));
"P00 DETAIL: sync path '" TEST_PATH "/pg/global'", TEST_PATH, TEST_PATH, TEST_PATH, TEST_PATH)));
// Remove recovery.conf before file comparison since it will have a new timestamp. Make sure it existed, though.
storageRemoveP(storagePgWrite(), PG_FILE_RECOVERYCONF_STR, .errorOnMissing = true);
@ -2033,11 +2032,11 @@ testRun(void)
"PG_VERSION {file, s=4, t=1482182860}\n"
"global {path}\n"
"pg_tblspc {path}\n"
"pg_tblspc/1 {link, d={[path]}/ts/1}\n");
"pg_tblspc/1 {link, d=" TEST_PATH "/ts/1}\n");
testRestoreCompare(
storagePg(), STRDEF("pg_tblspc/1"), manifest,
". {link, d={[path]}/ts/1}\n"
". {link, d=" TEST_PATH "/ts/1}\n"
"16384 {path}\n");
// -------------------------------------------------------------------------------------------------------------------------
@ -2124,26 +2123,26 @@ testRun(void)
TEST_RESULT_LOG(
"P00 INFO: repo1: restore backup set 20161219-212741F\n"
"P00 DETAIL: check '{[path]}/pg' exists\n"
"P00 DETAIL: check '{[path]}/ts/1' exists\n"
"P00 INFO: remove invalid files/links/paths from '{[path]}/pg'\n"
"P00 DETAIL: remove invalid file '{[path]}/pg/bogus-file'\n"
"P00 DETAIL: remove link '{[path]}/pg/pg_tblspc/1' because destination changed\n"
"P00 DETAIL: remove special file '{[path]}/pg/pipe'\n"
"P00 INFO: remove invalid files/links/paths from '{[path]}/ts/1'\n"
"P00 DETAIL: create symlink '{[path]}/pg/pg_tblspc/1' to '{[path]}/ts/1'\n"
"P01 DETAIL: restore file {[path]}/pg/PG_VERSION - exists and matches size 4 and modification time 1482182860 (4B, 50%)"
"P00 DETAIL: check '" TEST_PATH "/pg' exists\n"
"P00 DETAIL: check '" TEST_PATH "/ts/1' exists\n"
"P00 INFO: remove invalid files/links/paths from '" TEST_PATH "/pg'\n"
"P00 DETAIL: remove invalid file '" TEST_PATH "/pg/bogus-file'\n"
"P00 DETAIL: remove link '" TEST_PATH "/pg/pg_tblspc/1' because destination changed\n"
"P00 DETAIL: remove special file '" TEST_PATH "/pg/pipe'\n"
"P00 INFO: remove invalid files/links/paths from '" TEST_PATH "/ts/1'\n"
"P00 DETAIL: create symlink '" TEST_PATH "/pg/pg_tblspc/1' to '" TEST_PATH "/ts/1'\n"
"P01 DETAIL: restore file " TEST_PATH "/pg/PG_VERSION - exists and matches size 4 and modification time 1482182860"
" (4B, 50%) checksum 797e375b924134687cbf9eacd37a4355f3d825e4\n"
"P01 INFO: restore file " TEST_PATH "/pg/tablespace_map (0B, 50%)\n"
"P01 INFO: restore file " TEST_PATH "/pg/pg_tblspc/1/16384/PG_VERSION (4B, 100%)"
" checksum 797e375b924134687cbf9eacd37a4355f3d825e4\n"
"P01 INFO: restore file {[path]}/pg/tablespace_map (0B, 50%)\n"
"P01 INFO: restore file {[path]}/pg/pg_tblspc/1/16384/PG_VERSION (4B, 100%)"
" checksum 797e375b924134687cbf9eacd37a4355f3d825e4\n"
"P00 WARN: recovery type is preserve but recovery file does not exist at '{[path]}/pg/recovery.conf'\n"
"P00 DETAIL: sync path '{[path]}/pg'\n"
"P00 DETAIL: sync path '{[path]}/pg/pg_tblspc'\n"
"P00 DETAIL: sync path '{[path]}/pg/pg_tblspc/1'\n"
"P00 DETAIL: sync path '{[path]}/pg/pg_tblspc/1/16384'\n"
"P00 WARN: recovery type is preserve but recovery file does not exist at '" TEST_PATH "/pg/recovery.conf'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg/pg_tblspc'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg/pg_tblspc/1'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg/pg_tblspc/1/16384'\n"
"P00 WARN: backup does not contain 'global/pg_control' -- cluster will not start\n"
"P00 DETAIL: sync path '{[path]}/pg/global'");
"P00 DETAIL: sync path '" TEST_PATH "/pg/global'");
testRestoreCompare(
storagePg(), NULL, manifest,
@ -2151,12 +2150,12 @@ testRun(void)
"PG_VERSION {file, s=4, t=1482182860}\n"
"global {path}\n"
"pg_tblspc {path}\n"
"pg_tblspc/1 {link, d={[path]}/ts/1}\n"
"pg_tblspc/1 {link, d=" TEST_PATH "/ts/1}\n"
"tablespace_map {file, s=0, t=1482182860}\n");
testRestoreCompare(
storagePg(), STRDEF("pg_tblspc/1"), manifest,
". {link, d={[path]}/ts/1}\n"
". {link, d=" TEST_PATH "/ts/1}\n"
"16384 {path}\n"
"16384/PG_VERSION {file, s=4, t=1482182860}\n");
@ -2185,21 +2184,21 @@ testRun(void)
TEST_RESULT_LOG(
"P00 INFO: repo1: restore backup set 20161219-212741F\n"
"P00 DETAIL: check '{[path]}/pg' exists\n"
"P00 DETAIL: check '{[path]}/ts/1' exists\n"
"P00 INFO: remove invalid files/links/paths from '{[path]}/pg'\n"
"P00 INFO: remove invalid files/links/paths from '{[path]}/ts/1'\n"
"P01 INFO: restore file {[path]}/pg/PG_VERSION (4B, 50%) checksum 797e375b924134687cbf9eacd37a4355f3d825e4\n"
"P01 INFO: restore file {[path]}/pg/tablespace_map (0B, 50%)\n"
"P01 INFO: restore file {[path]}/pg/pg_tblspc/1/16384/PG_VERSION (4B, 100%)"
"P00 DETAIL: check '" TEST_PATH "/pg' exists\n"
"P00 DETAIL: check '" TEST_PATH "/ts/1' exists\n"
"P00 INFO: remove invalid files/links/paths from '" TEST_PATH "/pg'\n"
"P00 INFO: remove invalid files/links/paths from '" TEST_PATH "/ts/1'\n"
"P01 INFO: restore file " TEST_PATH "/pg/PG_VERSION (4B, 50%) checksum 797e375b924134687cbf9eacd37a4355f3d825e4\n"
"P01 INFO: restore file " TEST_PATH "/pg/tablespace_map (0B, 50%)\n"
"P01 INFO: restore file " TEST_PATH "/pg/pg_tblspc/1/16384/PG_VERSION (4B, 100%)"
" checksum 797e375b924134687cbf9eacd37a4355f3d825e4\n"
"P00 WARN: recovery type is preserve but recovery file does not exist at '{[path]}/pg/recovery.conf'\n"
"P00 DETAIL: sync path '{[path]}/pg'\n"
"P00 DETAIL: sync path '{[path]}/pg/pg_tblspc'\n"
"P00 DETAIL: sync path '{[path]}/pg/pg_tblspc/1'\n"
"P00 DETAIL: sync path '{[path]}/pg/pg_tblspc/1/16384'\n"
"P00 WARN: recovery type is preserve but recovery file does not exist at '" TEST_PATH "/pg/recovery.conf'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg/pg_tblspc'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg/pg_tblspc/1'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg/pg_tblspc/1/16384'\n"
"P00 WARN: backup does not contain 'global/pg_control' -- cluster will not start\n"
"P00 DETAIL: sync path '{[path]}/pg/global'");
"P00 DETAIL: sync path '" TEST_PATH "/pg/global'");
testRestoreCompare(
storagePg(), NULL, manifest,
@ -2207,12 +2206,12 @@ testRun(void)
"PG_VERSION {file, s=4, t=1482182860}\n"
"global {path}\n"
"pg_tblspc {path}\n"
"pg_tblspc/1 {link, d={[path]}/ts/1}\n"
"pg_tblspc/1 {link, d=" TEST_PATH "/ts/1}\n"
"tablespace_map {file, s=0, t=1482182860}\n");
testRestoreCompare(
storagePg(), STRDEF("pg_tblspc/1"), manifest,
". {link, d={[path]}/ts/1}\n"
". {link, d=" TEST_PATH "/ts/1}\n"
"16384 {path}\n"
"16384/PG_VERSION {file, s=4, t=1482182860}\n");
@ -2455,7 +2454,7 @@ testRun(void)
manifestTargetAdd(
manifest, &(ManifestTarget){
.type = manifestTargetTypeLink, .name = STRDEF(MANIFEST_TARGET_PGTBLSPC "/1"),
.path = strNewFmt("%s/ts/1", testPath()), .tablespaceId = 1, .tablespaceName = STRDEF("ts1")});
.path = STRDEF(TEST_PATH "/ts/1"), .tablespaceId = 1, .tablespaceName = STRDEF("ts1")});
manifestPathAdd(
manifest, &(ManifestPath){
.name = STRDEF(MANIFEST_TARGET_PGDATA "/" MANIFEST_TARGET_PGTBLSPC), .mode = 0700, .group = groupName(),
@ -2473,7 +2472,7 @@ testRun(void)
manifestLinkAdd(
manifest, &(ManifestLink){
.name = STRDEF(MANIFEST_TARGET_PGDATA "/" MANIFEST_TARGET_PGTBLSPC "/1"),
.destination = strNewFmt("%s/ts/1", testPath()), .group = groupName(), .user = userName()});
.destination = STRDEF(TEST_PATH "/ts/1"), .group = groupName(), .user = userName()});
// Always sort
lstSort(manifest->pub.targetList, sortOrderAsc);
@ -2505,48 +2504,53 @@ testRun(void)
"P00 INFO: map link 'pg_hba.conf' to '../config/pg_hba.conf'\n"
"P00 INFO: map link 'pg_wal' to '../wal'\n"
"P00 INFO: map link 'postgresql.conf' to '../config/postgresql.conf'\n"
"P00 DETAIL: check '{[path]}/pg' exists\n"
"P00 DETAIL: check '{[path]}/config' exists\n"
"P00 DETAIL: check '{[path]}/wal' exists\n"
"P00 DETAIL: check '{[path]}/ts/1/PG_10_201707211' exists\n"
"P00 DETAIL: check '" TEST_PATH "/pg' exists\n"
"P00 DETAIL: check '" TEST_PATH "/config' exists\n"
"P00 DETAIL: check '" TEST_PATH "/wal' exists\n"
"P00 DETAIL: check '" TEST_PATH "/ts/1/PG_10_201707211' exists\n"
"P00 DETAIL: skip 'tablespace_map' -- tablespace links will be created based on mappings\n"
"P00 INFO: remove invalid files/links/paths from '{[path]}/pg'\n"
"P00 DETAIL: remove invalid path '{[path]}/pg/bogus1'\n"
"P00 DETAIL: remove invalid path '{[path]}/pg/global/bogus3'\n"
"P00 DETAIL: remove invalid link '{[path]}/pg/pg_wal2'\n"
"P00 DETAIL: remove invalid file '{[path]}/pg/tablespace_map'\n"
"P00 DETAIL: create path '{[path]}/pg/base'\n"
"P00 DETAIL: create path '{[path]}/pg/base/1'\n"
"P00 DETAIL: create path '{[path]}/pg/base/16384'\n"
"P00 DETAIL: create path '{[path]}/pg/base/32768'\n"
"P00 DETAIL: create symlink '{[path]}/pg/pg_hba.conf' to '../config/pg_hba.conf'\n"
"P00 DETAIL: create symlink '{[path]}/pg/postgresql.conf' to '../config/postgresql.conf'\n"
"P01 INFO: restore file {[path]}/pg/base/32768/32769 (32KB, 49%) checksum a40f0986acb1531ce0cc75a23dcf8aa406ae9081\n"
"P01 INFO: restore file {[path]}/pg/base/16384/16385 (16KB, 74%) checksum d74e5f7ebe52a3ed468ba08c5b6aefaccd1ca88f\n"
"P01 INFO: restore file {[path]}/pg/global/pg_control.pgbackrest.tmp (8KB, 87%)"
"P00 INFO: remove invalid files/links/paths from '" TEST_PATH "/pg'\n"
"P00 DETAIL: remove invalid path '" TEST_PATH "/pg/bogus1'\n"
"P00 DETAIL: remove invalid path '" TEST_PATH "/pg/global/bogus3'\n"
"P00 DETAIL: remove invalid link '" TEST_PATH "/pg/pg_wal2'\n"
"P00 DETAIL: remove invalid file '" TEST_PATH "/pg/tablespace_map'\n"
"P00 DETAIL: create path '" TEST_PATH "/pg/base'\n"
"P00 DETAIL: create path '" TEST_PATH "/pg/base/1'\n"
"P00 DETAIL: create path '" TEST_PATH "/pg/base/16384'\n"
"P00 DETAIL: create path '" TEST_PATH "/pg/base/32768'\n"
"P00 DETAIL: create symlink '" TEST_PATH "/pg/pg_hba.conf' to '../config/pg_hba.conf'\n"
"P00 DETAIL: create symlink '" TEST_PATH "/pg/postgresql.conf' to '../config/postgresql.conf'\n"
"P01 INFO: restore file " TEST_PATH "/pg/base/32768/32769 (32KB, 49%) checksum"
" a40f0986acb1531ce0cc75a23dcf8aa406ae9081\n"
"P01 INFO: restore file " TEST_PATH "/pg/base/16384/16385 (16KB, 74%) checksum"
" d74e5f7ebe52a3ed468ba08c5b6aefaccd1ca88f\n"
"P01 INFO: restore file " TEST_PATH "/pg/global/pg_control.pgbackrest.tmp (8KB, 87%)"
" checksum 5e2b96c19c4f5c63a5afa2de504d29fe64a4c908\n"
"P01 INFO: restore file {[path]}/pg/base/1/2 (8KB, 99%) checksum 4d7b2a36c5387decf799352a3751883b7ceb96aa\n"
"P01 INFO: restore file {[path]}/pg/postgresql.conf (15B, 99%) checksum 98b8abb2e681e2a5a7d8ab082c0a79727887558d\n"
"P01 INFO: restore file {[path]}/pg/pg_hba.conf (11B, 99%) checksum 401215e092779574988a854d8c7caed7f91dba4b\n"
"P01 INFO: restore file {[path]}/pg/base/32768/PG_VERSION (4B, 99%)"
"P01 INFO: restore file " TEST_PATH "/pg/base/1/2 (8KB, 99%) checksum 4d7b2a36c5387decf799352a3751883b7ceb96aa\n"
"P01 INFO: restore file " TEST_PATH "/pg/postgresql.conf (15B, 99%) checksum"
" 98b8abb2e681e2a5a7d8ab082c0a79727887558d\n"
"P01 INFO: restore file " TEST_PATH "/pg/pg_hba.conf (11B, 99%) checksum"
" 401215e092779574988a854d8c7caed7f91dba4b\n"
"P01 INFO: restore file " TEST_PATH "/pg/base/32768/PG_VERSION (4B, 99%)"
" checksum 8dbabb96e032b8d9f1993c0e4b9141e71ade01a1\n"
"P01 INFO: restore file {[path]}/pg/base/16384/PG_VERSION (4B, 99%)"
"P01 INFO: restore file " TEST_PATH "/pg/base/16384/PG_VERSION (4B, 99%)"
" checksum 8dbabb96e032b8d9f1993c0e4b9141e71ade01a1\n"
"P01 INFO: restore file {[path]}/pg/base/1/PG_VERSION (4B, 99%) checksum 8dbabb96e032b8d9f1993c0e4b9141e71ade01a1\n"
"P01 INFO: restore file {[path]}/pg/PG_VERSION (4B, 100%) checksum 8dbabb96e032b8d9f1993c0e4b9141e71ade01a1\n"
"P01 INFO: restore file {[path]}/pg/global/999 (0B, 100%)\n"
"P00 DETAIL: sync path '{[path]}/config'\n"
"P00 DETAIL: sync path '{[path]}/pg'\n"
"P00 DETAIL: sync path '{[path]}/pg/base'\n"
"P00 DETAIL: sync path '{[path]}/pg/base/1'\n"
"P00 DETAIL: sync path '{[path]}/pg/base/16384'\n"
"P00 DETAIL: sync path '{[path]}/pg/base/32768'\n"
"P00 DETAIL: sync path '{[path]}/pg/pg_tblspc'\n"
"P00 DETAIL: sync path '{[path]}/pg/pg_wal'\n"
"P00 DETAIL: sync path '{[path]}/pg/pg_tblspc/1'\n"
"P00 DETAIL: sync path '{[path]}/pg/pg_tblspc/1/PG_10_201707211'\n"
"P01 INFO: restore file " TEST_PATH "/pg/base/1/PG_VERSION (4B, 99%) checksum"
" 8dbabb96e032b8d9f1993c0e4b9141e71ade01a1\n"
"P01 INFO: restore file " TEST_PATH "/pg/PG_VERSION (4B, 100%) checksum 8dbabb96e032b8d9f1993c0e4b9141e71ade01a1\n"
"P01 INFO: restore file " TEST_PATH "/pg/global/999 (0B, 100%)\n"
"P00 DETAIL: sync path '" TEST_PATH "/config'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg/base'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg/base/1'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg/base/16384'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg/base/32768'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg/pg_tblspc'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg/pg_wal'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg/pg_tblspc/1'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg/pg_tblspc/1/PG_10_201707211'\n"
"P00 INFO: restore global/pg_control (performed last to ensure aborted restores cannot be started)\n"
"P00 DETAIL: sync path '{[path]}/pg/global'");
"P00 DETAIL: sync path '" TEST_PATH "/pg/global'");
testRestoreCompare(
storagePg(), NULL, manifest,
@ -2567,13 +2571,13 @@ testRun(void)
"global/pg_control {file, s=8192, t=1482182860}\n"
"pg_hba.conf {link, d=../config/pg_hba.conf}\n"
"pg_tblspc {path}\n"
"pg_tblspc/1 {link, d={[path]}/ts/1}\n"
"pg_tblspc/1 {link, d=" TEST_PATH "/ts/1}\n"
"pg_wal {link, d=../wal}\n"
"postgresql.conf {link, d=../config/postgresql.conf}\n");
testRestoreCompare(
storagePg(), STRDEF("pg_tblspc/1"), manifest,
". {link, d={[path]}/ts/1}\n"
". {link, d=" TEST_PATH "/ts/1}\n"
"16384 {path}\n"
"16384/PG_VERSION {file, s=4, t=1482182860}\n"
"PG_10_201707211 {path}\n");
@ -2620,47 +2624,47 @@ testRun(void)
"P00 INFO: map link 'postgresql.conf' to '../config/postgresql.conf'\n"
"P00 DETAIL: databases found for selective restore (1, 16384, 32768)\n"
"P00 DETAIL: databases excluded (zeroed) from selective restore (32768)\n"
"P00 DETAIL: check '{[path]}/pg' exists\n"
"P00 DETAIL: check '{[path]}/config' exists\n"
"P00 DETAIL: check '{[path]}/wal' exists\n"
"P00 DETAIL: check '{[path]}/ts/1/PG_10_201707211' exists\n"
"P00 DETAIL: check '" TEST_PATH "/pg' exists\n"
"P00 DETAIL: check '" TEST_PATH "/config' exists\n"
"P00 DETAIL: check '" TEST_PATH "/wal' exists\n"
"P00 DETAIL: check '" TEST_PATH "/ts/1/PG_10_201707211' exists\n"
"P00 DETAIL: skip 'tablespace_map' -- tablespace links will be created based on mappings\n"
"P00 DETAIL: remove 'global/pg_control' so cluster will not start if restore does not complete\n"
"P00 INFO: remove invalid files/links/paths from '{[path]}/pg'\n"
"P00 INFO: remove invalid files/links/paths from '{[path]}/wal'\n"
"P00 INFO: remove invalid files/links/paths from '{[path]}/ts/1/PG_10_201707211'\n"
"P01 DETAIL: restore zeroed file {[path]}/pg/base/32768/32769 (32KB, 49%)\n"
"P01 DETAIL: restore file {[path]}/pg/base/16384/16385 - exists and matches backup (16KB, 74%)"
"P00 INFO: remove invalid files/links/paths from '" TEST_PATH "/pg'\n"
"P00 INFO: remove invalid files/links/paths from '" TEST_PATH "/wal'\n"
"P00 INFO: remove invalid files/links/paths from '" TEST_PATH "/ts/1/PG_10_201707211'\n"
"P01 DETAIL: restore zeroed file " TEST_PATH "/pg/base/32768/32769 (32KB, 49%)\n"
"P01 DETAIL: restore file " TEST_PATH "/pg/base/16384/16385 - exists and matches backup (16KB, 74%)"
" checksum d74e5f7ebe52a3ed468ba08c5b6aefaccd1ca88f\n"
"P01 INFO: restore file {[path]}/pg/global/pg_control.pgbackrest.tmp (8KB, 87%)"
"P01 INFO: restore file " TEST_PATH "/pg/global/pg_control.pgbackrest.tmp (8KB, 87%)"
" checksum 5e2b96c19c4f5c63a5afa2de504d29fe64a4c908\n"
"P01 DETAIL: restore file {[path]}/pg/base/1/2 - exists and matches backup (8KB, 99%)"
"P01 DETAIL: restore file " TEST_PATH "/pg/base/1/2 - exists and matches backup (8KB, 99%)"
" checksum 4d7b2a36c5387decf799352a3751883b7ceb96aa\n"
"P01 DETAIL: restore file {[path]}/pg/postgresql.conf - exists and matches backup (15B, 99%)"
"P01 DETAIL: restore file " TEST_PATH "/pg/postgresql.conf - exists and matches backup (15B, 99%)"
" checksum 98b8abb2e681e2a5a7d8ab082c0a79727887558d\n"
"P01 DETAIL: restore file {[path]}/pg/pg_hba.conf - exists and matches backup (11B, 99%)"
"P01 DETAIL: restore file " TEST_PATH "/pg/pg_hba.conf - exists and matches backup (11B, 99%)"
" checksum 401215e092779574988a854d8c7caed7f91dba4b\n"
"P01 DETAIL: restore file {[path]}/pg/base/32768/PG_VERSION - exists and matches backup (4B, 99%)"
"P01 DETAIL: restore file " TEST_PATH "/pg/base/32768/PG_VERSION - exists and matches backup (4B, 99%)"
" checksum 8dbabb96e032b8d9f1993c0e4b9141e71ade01a1\n"
"P01 DETAIL: restore file {[path]}/pg/base/16384/PG_VERSION - exists and matches backup (4B, 99%)"
"P01 DETAIL: restore file " TEST_PATH "/pg/base/16384/PG_VERSION - exists and matches backup (4B, 99%)"
" checksum 8dbabb96e032b8d9f1993c0e4b9141e71ade01a1\n"
"P01 DETAIL: restore file {[path]}/pg/base/1/PG_VERSION - exists and matches backup (4B, 99%)"
"P01 DETAIL: restore file " TEST_PATH "/pg/base/1/PG_VERSION - exists and matches backup (4B, 99%)"
" checksum 8dbabb96e032b8d9f1993c0e4b9141e71ade01a1\n"
"P01 DETAIL: restore file {[path]}/pg/PG_VERSION - exists and matches backup (4B, 100%)"
"P01 DETAIL: restore file " TEST_PATH "/pg/PG_VERSION - exists and matches backup (4B, 100%)"
" checksum 8dbabb96e032b8d9f1993c0e4b9141e71ade01a1\n"
"P01 DETAIL: restore file {[path]}/pg/global/999 - exists and is zero size (0B, 100%)\n"
"P00 DETAIL: sync path '{[path]}/config'\n"
"P00 DETAIL: sync path '{[path]}/pg'\n"
"P00 DETAIL: sync path '{[path]}/pg/base'\n"
"P00 DETAIL: sync path '{[path]}/pg/base/1'\n"
"P00 DETAIL: sync path '{[path]}/pg/base/16384'\n"
"P00 DETAIL: sync path '{[path]}/pg/base/32768'\n"
"P00 DETAIL: sync path '{[path]}/pg/pg_tblspc'\n"
"P00 DETAIL: sync path '{[path]}/pg/pg_wal'\n"
"P00 DETAIL: sync path '{[path]}/pg/pg_tblspc/1'\n"
"P00 DETAIL: sync path '{[path]}/pg/pg_tblspc/1/PG_10_201707211'\n"
"P01 DETAIL: restore file " TEST_PATH "/pg/global/999 - exists and is zero size (0B, 100%)\n"
"P00 DETAIL: sync path '" TEST_PATH "/config'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg/base'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg/base/1'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg/base/16384'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg/base/32768'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg/pg_tblspc'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg/pg_wal'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg/pg_tblspc/1'\n"
"P00 DETAIL: sync path '" TEST_PATH "/pg/pg_tblspc/1/PG_10_201707211'\n"
"P00 INFO: restore global/pg_control (performed last to ensure aborted restores cannot be started)\n"
"P00 DETAIL: sync path '{[path]}/pg/global'");
"P00 DETAIL: sync path '" TEST_PATH "/pg/global'");
// Check stanza archive spool path was removed
TEST_STORAGE_LIST_EMPTY(storageSpool(), STORAGE_PATH_ARCHIVE);
@ -2679,7 +2683,7 @@ testRun(void)
cmdRestore(), FileMissingError,
"raised from local-1 shim protocol: unable to open missing file"
" '%s/repo/backup/test1/20161219-212741F_20161219-212918I/pg_data/global/pg_control' for read",
testPath());
TEST_PATH);
// Free local processes that were not freed because of the error
protocolFree();

View File

@ -18,7 +18,7 @@ testRun(void)
{
FUNCTION_HARNESS_VOID();
Storage *storageTest = storagePosixNewP(strNewZ(testPath()), .write = true);
Storage *storageTest = storagePosixNewP(TEST_PATH_STR, .write = true);
const String *stanza = STRDEF("db");
const String *fileName = STRDEF("test.info");
@ -30,15 +30,15 @@ testRun(void)
StringList *argListBase = strLstNew();
strLstAddZ(argListBase, "--no-online");
strLstAdd(argListBase, strNewFmt("--stanza=%s", strZ(stanza)));
strLstAdd(argListBase, strNewFmt("--pg1-path=%s/%s", testPath(), strZ(stanza)));
strLstAdd(argListBase, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAdd(argListBase, strNewFmt("--pg1-path=" TEST_PATH "/%s", strZ(stanza)));
strLstAddZ(argListBase, "--repo1-path=" TEST_PATH "/repo");
// *****************************************************************************************************************************
if (testBegin("cmdStanzaCreate(), checkStanzaInfo(), cmdStanzaDelete()"))
{
// Load Parameters
StringList *argList = strLstDup(argListBase);
hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 2, "%s/repo2", testPath());
hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 2, TEST_PATH "/repo2");
hrnCfgArgRawZ(argList, cfgOptRepo, "2");
TEST_ERROR_FMT(
@ -123,11 +123,11 @@ testRun(void)
TEST_TITLE("cmdStanzaCreate success - multi-repo and encryption");
argList = strLstDup(argListBase);
hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 2, "%s/repo2", testPath());
hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 2, TEST_PATH "/repo2");
hrnCfgArgKeyRawStrId(argList, cfgOptRepoCipherType, 2, cipherTypeAes256Cbc);
hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 2, "12345678");
hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 3, "%s/repo3", testPath());
hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 4, "%s/repo4", testPath());
hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 3, TEST_PATH "/repo3");
hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 4, TEST_PATH "/repo4");
hrnCfgArgKeyRawStrId(argList, cfgOptRepoCipherType, 4, cipherTypeAes256Cbc);
hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 4, "87654321");
harnessCfgLoad(cfgCmdStanzaCreate, argList);
@ -242,12 +242,12 @@ testRun(void)
TEST_TITLE("cmdStanzaDelete - multi-repo and encryption, delete");
StringList *argListCmd = strLstNew();
hrnCfgArgKeyRawFmt(argListCmd, cfgOptRepoPath, 1, "%s/repo", testPath());
hrnCfgArgKeyRawFmt(argListCmd, cfgOptRepoPath, 2, "%s/repo2", testPath());
hrnCfgArgKeyRawFmt(argListCmd, cfgOptRepoPath, 3, "%s/repo3", testPath());
hrnCfgArgKeyRawFmt(argListCmd, cfgOptRepoPath, 4, "%s/repo4", testPath());
hrnCfgArgKeyRawZ(argListCmd, cfgOptRepoPath, 1, TEST_PATH "/repo");
hrnCfgArgKeyRawZ(argListCmd, cfgOptRepoPath, 2, TEST_PATH "/repo2");
hrnCfgArgKeyRawZ(argListCmd, cfgOptRepoPath, 3, TEST_PATH "/repo3");
hrnCfgArgKeyRawZ(argListCmd, cfgOptRepoPath, 4, TEST_PATH "/repo4");
hrnCfgArgRawFmt(argListCmd, cfgOptStanza, "%s", strZ(stanza));
hrnCfgArgKeyRawFmt(argListCmd, cfgOptPgPath, 1, "%s/%s", testPath(), strZ(stanza));
hrnCfgArgKeyRawFmt(argListCmd, cfgOptPgPath, 1, TEST_PATH "/%s", strZ(stanza));
TEST_ERROR_FMT(
harnessCfgLoad(cfgCmdStanzaDelete, argListCmd), OptionRequiredError, "stanza-delete command requires option: repo\n"
@ -302,7 +302,7 @@ testRun(void)
TEST_TITLE("cmdStanzaCreate errors");
argList = strLstDup(argListBase);
hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 2, "%s/repo2", testPath());
hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 2, TEST_PATH "/repo2");
hrnCfgArgKeyRawStrId(argList, cfgOptRepoCipherType, 2, cipherTypeAes256Cbc);
hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 2, "12345678");
harnessCfgLoad(cfgCmdStanzaCreate, argList);
@ -546,13 +546,13 @@ testRun(void)
if (testBegin("pgValidate(), online=y"))
{
const String *pg1 = STRDEF("pg1");
String *pg1Path = strNewFmt("%s/%s", testPath(), strZ(pg1));
String *pg1Path = strNewFmt(TEST_PATH "/%s", strZ(pg1));
// Load Parameters
StringList *argList = strLstNew();
strLstAdd(argList, strNewFmt("--stanza=%s", strZ(stanza)));
strLstAdd(argList, strNewFmt("--pg1-path=%s", strZ(pg1Path)));
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAddZ(argList, "--repo1-path=" TEST_PATH "/repo");
harnessCfgLoad(cfgCmdStanzaCreate, argList);
// pgControl and database match
@ -613,8 +613,7 @@ testRun(void)
harnessPqScriptSet((HarnessPq [])
{
HRNPQ_MACRO_OPEN_GE_92(
1, "dbname='postgres' port=5432", PG_VERSION_92, strZ(strNewFmt("%s/pg2", testPath())), false, NULL, NULL),
HRNPQ_MACRO_OPEN_GE_92(1, "dbname='postgres' port=5432", PG_VERSION_92, TEST_PATH "/pg2", false, NULL, NULL),
HRNPQ_MACRO_DONE()
});
@ -622,17 +621,17 @@ testRun(void)
pgValidate(), DbMismatchError, "version '%s' and path '%s' queried from cluster do not match version '%s' and '%s'"
" read from '%s/" PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL
"'\nHINT: the pg1-path and pg1-port settings likely reference different clusters.",
strZ(pgVersionToStr(PG_VERSION_92)), strZ(strNewFmt("%s/pg2", testPath())), strZ(pgVersionToStr(PG_VERSION_92)),
strZ(pgVersionToStr(PG_VERSION_92)), TEST_PATH "/pg2", strZ(pgVersionToStr(PG_VERSION_92)),
strZ(pg1Path), strZ(pg1Path));
// Primary at pg2
//--------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
strLstAdd(argList, strNewFmt("--stanza=%s", strZ(stanza)));
strLstAdd(argList, strNewFmt("--pg1-path=%s", testPath()));
strLstAddZ(argList, "--pg1-path=" TEST_PATH);
strLstAdd(argList, strNewFmt("--pg2-path=%s", strZ(pg1Path)));
strLstAddZ(argList, "--pg2-port=5434");
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAddZ(argList, "--repo1-path=" TEST_PATH "/repo");
harnessCfgLoad(cfgCmdStanzaCreate, argList);
// Create pg_control for primary
@ -642,12 +641,12 @@ testRun(void)
// Create pg_control for standby
storagePutP(
storageNewWriteP(storageTest, strNewFmt("%s/" PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, testPath())),
storageNewWriteP(storageTest, STRDEF(TEST_PATH "/" PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL)),
hrnPgControlToBuffer((PgControl){.version = PG_VERSION_94, .systemId = 6569239123849665700}));
harnessPqScriptSet((HarnessPq [])
{
HRNPQ_MACRO_OPEN_GE_92(1, "dbname='postgres' port=5432", PG_VERSION_92, testPath(), true, NULL, NULL),
HRNPQ_MACRO_OPEN_GE_92(1, "dbname='postgres' port=5432", PG_VERSION_92, TEST_PATH, true, NULL, NULL),
HRNPQ_MACRO_OPEN_GE_92(2, "dbname='postgres' port=5434", PG_VERSION_92, strZ(pg1Path), false, NULL, NULL),
HRNPQ_MACRO_DONE()
});
@ -671,7 +670,7 @@ testRun(void)
// Load Parameters
StringList *argList = strLstDup(argListBase);
hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 2, "%s/repo2", testPath());
hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 2, TEST_PATH "/repo2");
hrnCfgArgRawZ(argList, cfgOptRepo, "2");
TEST_ERROR_FMT(
@ -985,7 +984,7 @@ testRun(void)
{
// Load Parameters
StringList *argListCmd = strLstNew();
strLstAdd(argListCmd, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAddZ(argListCmd, "--repo1-path=" TEST_PATH "/repo");
//--------------------------------------------------------------------------------------------------------------------------
const String *stanzaOther = STRDEF("otherstanza");
@ -993,7 +992,7 @@ testRun(void)
// Load Parameters
StringList *argList = strLstDup(argListCmd);
strLstAdd(argList, strNewFmt("--stanza=%s", strZ(stanzaOther)));
strLstAdd(argList,strNewFmt("--pg1-path=%s/%s", testPath(), strZ(stanzaOther)));
strLstAdd(argList, strNewFmt("--pg1-path=" TEST_PATH "/%s", strZ(stanzaOther)));
strLstAddZ(argList, "--no-online");
harnessCfgLoad(cfgCmdStanzaCreate, argList);
@ -1007,7 +1006,7 @@ testRun(void)
argList = strLstDup(argListCmd);
strLstAdd(argList, strNewFmt("--stanza=%s", strZ(stanza)));
strLstAdd(argList,strNewFmt("--pg1-path=%s/%s", testPath(), strZ(stanza)));
strLstAdd(argList, strNewFmt("--pg1-path=" TEST_PATH "/%s", strZ(stanza)));
harnessCfgLoad(cfgCmdStanzaDelete, argList);
// stanza already deleted
@ -1057,7 +1056,7 @@ testRun(void)
"create stop file");
TEST_ERROR_FMT(
cmdStanzaDelete(), FileRemoveError,
"unable to remove '%s/repo/backup/%s/20190708-154306F/backup.manifest': [20] Not a directory", testPath(),
"unable to remove '%s/repo/backup/%s/20190708-154306F/backup.manifest': [20] Not a directory", TEST_PATH,
strZ(stanza));
TEST_RESULT_VOID(
storageRemoveP(storageTest, strNewFmt("repo/backup/%s/20190708-154306F", strZ(stanza))), "remove backup directory");
@ -1119,7 +1118,7 @@ testRun(void)
// Specify repo option
StringList *argListDel = strLstDup(argList);
hrnCfgArgKeyRawFmt(argListDel, cfgOptRepoPath, 2, "%s/repo2", testPath());
hrnCfgArgKeyRawZ(argListDel, cfgOptRepoPath, 2, TEST_PATH "/repo2");
hrnCfgArgRawZ(argListDel, cfgOptRepo, "2");
harnessCfgLoad(cfgCmdStanzaDelete, argListDel);
@ -1136,8 +1135,8 @@ testRun(void)
argList = strLstDup(argListCmd);
hrnCfgArgRaw(argList, cfgOptStanza, stanza);
hrnCfgArgKeyRawFmt(argList, cfgOptPgPath, 1, "%s/%s", testPath(), strZ(stanza));
hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 2, "%s/repo2", testPath());
hrnCfgArgKeyRawFmt(argList, cfgOptPgPath, 1, TEST_PATH "/%s", strZ(stanza));
hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 2, TEST_PATH "/repo2");
hrnCfgArgRawZ(argList, cfgOptRepo, "1");
strLstAddZ(argList,"--force");
harnessCfgLoad(cfgCmdStanzaDelete, argList);

View File

@ -25,7 +25,7 @@ testRun(void)
static const ProtocolServerHandler testLocalHandlerList[] = {PROTOCOL_SERVER_HANDLER_VERIFY_LIST};
hrnProtocolLocalShimInstall(testLocalHandlerList, PROTOCOL_SERVER_HANDLER_LIST_SIZE(testLocalHandlerList));
Storage *storageTest = storagePosixNewP(strNewZ(testPath()), .write = true);
Storage *storageTest = storagePosixNewP(TEST_PATH_STR, .write = true);
const String *stanza = STRDEF("db");
String *backupStanzaPath = strNewFmt("repo/backup/%s", strZ(stanza));
@ -37,7 +37,7 @@ testRun(void)
StringList *argListBase = strLstNew();
strLstAdd(argListBase, strNewFmt("--stanza=%s", strZ(stanza)));
strLstAdd(argListBase, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAddZ(argListBase, "--repo1-path=" TEST_PATH "/repo");
const char *fileContents = "acefile";
uint64_t fileSize = 7;
@ -285,7 +285,7 @@ testRun(void)
"P00 WARN: unable to open missing file '%s/%s/%s/" BACKUP_MANIFEST_FILE INFO_COPY_EXT "' for read\n"
"P00 ERROR: [028]: '%s' may not be recoverable - PG data (id 1, version 9.2, system-id 6625592122879095702) is not "
"in the backup.info history, skipping",
testPath(), strZ(backupStanzaPath), strZ(backupLabel), strZ(backupLabel))));
TEST_PATH, strZ(backupStanzaPath), strZ(backupLabel), strZ(backupLabel))));
//--------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("rerun test with db-system-id invalid and no main");
@ -325,7 +325,7 @@ testRun(void)
"P00 WARN: %s/backup.manifest is missing or unusable, using copy\n"
"P00 ERROR: [028]: '%s' may not be recoverable - PG data (id 1, version 9.4, system-id 0) is not "
"in the backup.info history, skipping",
testPath(), strZ(backupStanzaPath), strZ(backupLabel), strZ(backupLabel), strZ(backupLabel))));
TEST_PATH, strZ(backupStanzaPath), strZ(backupLabel), strZ(backupLabel), strZ(backupLabel))));
//--------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("rerun copy test with db-id invalid");
@ -364,7 +364,7 @@ testRun(void)
"P00 WARN: %s/backup.manifest is missing or unusable, using copy\n"
"P00 ERROR: [028]: '%s' may not be recoverable - PG data (id 0, version 9.4, system-id 6625592122879095702) is not "
"in the backup.info history, skipping",
testPath(), strZ(backupStanzaPath), strZ(backupLabel), strZ(backupLabel), strZ(backupLabel))));
TEST_PATH, strZ(backupStanzaPath), strZ(backupLabel), strZ(backupLabel), strZ(backupLabel))));
//--------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("missing main manifest, errored copy");
@ -384,7 +384,7 @@ testRun(void)
strZ(strNewFmt(
"P00 WARN: unable to open missing file '%s/%s/%s/" BACKUP_MANIFEST_FILE "' for read\n"
"P00 WARN: invalid checksum, actual 'e056f784a995841fd4e2802b809299b8db6803a2' but expected 'BOGUS' "
STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE INFO_COPY_EXT, testPath(), strZ(backupStanzaPath), strZ(backupLabel),
STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE INFO_COPY_EXT, TEST_PATH, strZ(backupStanzaPath), strZ(backupLabel),
strZ(backupLabel))));
//--------------------------------------------------------------------------------------------------------------------------
@ -798,8 +798,8 @@ testRun(void)
"P00 ERROR: [029]: No usable backup.info file\n"
"P00 WARN: unable to open missing file '%s/%s/archive.info' for read\n"
"P00 WARN: unable to open missing file '%s/%s/archive.info.copy' for read\n"
"P00 ERROR: [029]: No usable archive.info file", testPath(), strZ(backupStanzaPath), testPath(),
strZ(archiveStanzaPath), testPath(), strZ(archiveStanzaPath))));
"P00 ERROR: [029]: No usable archive.info file", TEST_PATH, strZ(backupStanzaPath), TEST_PATH,
strZ(archiveStanzaPath), TEST_PATH, strZ(archiveStanzaPath))));
//--------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("backup.info invalid checksum, backup.info.copy valid, archive.info not exist, archive copy checksum invalid");
@ -816,7 +816,7 @@ testRun(void)
"P00 WARN: unable to open missing file '%s/%s/archive.info' for read\n"
"P00 WARN: invalid checksum, actual 'e056f784a995841fd4e2802b809299b8db6803a2' but expected 'BOGUS'"
" <REPO:ARCHIVE>/archive.info.copy\n"
"P00 ERROR: [029]: No usable archive.info file", testPath(), strZ(archiveStanzaPath))));
"P00 ERROR: [029]: No usable archive.info file", TEST_PATH, strZ(archiveStanzaPath))));
//--------------------------------------------------------------------------------------------------------------------------
@ -862,7 +862,7 @@ testRun(void)
strZ(strNewFmt(
"P00 WARN: unable to open missing file '%s/%s/backup.info.copy' for read\n"
"P00 WARN: unable to open missing file '%s/%s/archive.info.copy' for read\n"
"P00 WARN: no archives or backups exist in the repo", testPath(), strZ(backupStanzaPath), testPath(),
"P00 WARN: no archives or backups exist in the repo", TEST_PATH, strZ(backupStanzaPath), TEST_PATH,
strZ(archiveStanzaPath))));
//--------------------------------------------------------------------------------------------------------------------------
@ -877,7 +877,7 @@ testRun(void)
strZ(strNewFmt(
"P00 WARN: unable to open missing file '%s/%s/backup.info' for read\n"
"P00 WARN: unable to open missing file '%s/%s/backup.info.copy' for read\n"
"P00 ERROR: [029]: No usable backup.info file", testPath(), strZ(backupStanzaPath), testPath(),
"P00 ERROR: [029]: No usable backup.info file", TEST_PATH, strZ(backupStanzaPath), TEST_PATH,
strZ(backupStanzaPath))));
}
@ -924,7 +924,7 @@ testRun(void)
//--------------------------------------------------------------------------------------------------------------------------
// Load Parameters with multi-repo
StringList *argList = strLstDup(argListBase);
hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 4, "%s/repo4", testPath());
hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 4, TEST_PATH "/repo4");
harnessCfgLoad(cfgCmdVerify, argList);
// Store valid archive/backup info files
@ -1094,7 +1094,7 @@ testRun(void)
// Load Parameters - single non-default repo
argList = strLstNew();
hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 2, "%s/repo", testPath());
hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 2, TEST_PATH "/repo");
hrnCfgArgRawFmt(argList, cfgOptStanza, "%s", strZ(stanza));
hrnCfgArgRawZ(argList, cfgOptRepo, "2");
harnessCfgLoad(cfgCmdVerify, argList);
@ -1281,8 +1281,8 @@ testRun(void)
"total valid files: 2\n"
" missing: 1, checksum invalid: 1, size invalid: 0, other: 1\n"
" backup: 20181119-153000F, status: in-progress, total files checked: 0, total valid files: 0",
testPath(), strZ(archiveStanzaPath), testPath(), strZ(backupStanzaPath), testPath(), strZ(backupStanzaPath),
testPath(), strZ(backupStanzaPath), testPath(), strZ(backupStanzaPath), testPath(), strZ(backupStanzaPath))));
TEST_PATH, strZ(archiveStanzaPath), TEST_PATH, strZ(backupStanzaPath), TEST_PATH, strZ(backupStanzaPath),
TEST_PATH, strZ(backupStanzaPath), TEST_PATH, strZ(backupStanzaPath), TEST_PATH, strZ(backupStanzaPath))));
harnessLogLevelReset();
}

View File

@ -83,7 +83,7 @@ testSuite(CompressType type, const char *decompressCmd)
varLstAdd(compressParamList, varNewUInt(1));
// Create default storage object for testing
Storage *storageTest = storagePosixNewP(strNewZ(testPath()), .write = true);
Storage *storageTest = storagePosixNewP(TEST_PATH_STR, .write = true);
TEST_TITLE("simple data");
@ -98,7 +98,7 @@ testSuite(CompressType type, const char *decompressCmd)
TEST_TITLE("compressed output can be decompressed with command-line tool");
storagePutP(storageNewWriteP(storageTest, STRDEF("test.cmp")), compressed);
TEST_SYSTEM_FMT("%s {[path]}/test.cmp > {[path]}/test.out", decompressCmd);
TEST_SYSTEM_FMT("%s " TEST_PATH "/test.cmp > " TEST_PATH "/test.out", decompressCmd);
TEST_RESULT_BOOL(bufEq(decompressed, storageGetP(storageNewReadP(storageTest, STRDEF("test.out")))), true, "check output");
TEST_RESULT_BOOL(

View File

@ -611,8 +611,7 @@ testRun(void)
TEST_ERROR(ioFdWriteOneStr(999999, STRDEF("test")), FileWriteError, "unable to write to fd: [9] Bad file descriptor");
// -------------------------------------------------------------------------------------------------------------------------
String *fileName = strNewFmt("%s/test.txt", testPath());
int fd = open(strZ(fileName), O_CREAT | O_TRUNC | O_WRONLY, 0700);
int fd = open(TEST_PATH "/test.txt", O_CREAT | O_TRUNC | O_WRONLY, 0700);
TEST_RESULT_VOID(ioFdWriteOneStr(fd, STRDEF("test1\ntest2")), "write string to file");

View File

@ -256,8 +256,8 @@ testRun(void)
TEST_RESULT_VOID(
hrnServerRunP(
ioFdReadNew(STRDEF("test server read"), HARNESS_FORK_CHILD_READ(), 5000), hrnServerProtocolTls,
.certificate = strNewFmt("%s/" HRN_SERVER_CERT_PREFIX "-alt-name.crt", testRepoPath()),
.key = strNewFmt("%s/" HRN_SERVER_CERT_PREFIX ".key", testRepoPath())),
.certificate = STRDEF(HRN_PATH_REPO "/" HRN_SERVER_CERT_PREFIX "-alt-name.crt"),
.key = STRDEF(HRN_PATH_REPO "/" HRN_SERVER_CERT_PREFIX ".key")),
"tls alt name server run");
}
HARNESS_FORK_CHILD_END();
@ -292,7 +292,7 @@ testRun(void)
ioClientOpen(
tlsClientNew(
sckClientNew(STRDEF("test.pgbackrest.org"), hrnServerPort(0), 5000), STRDEF("test.pgbackrest.org"),
0, true, strNewFmt("%s/" HRN_SERVER_CERT_PREFIX "-ca.crt", testRepoPath()), NULL)),
0, true, STRDEF(HRN_PATH_REPO "/" HRN_SERVER_CERT_PREFIX "-ca.crt"), NULL)),
"open connection");
// -----------------------------------------------------------------------------------------------------------------
@ -306,7 +306,7 @@ testRun(void)
tlsClientNew(
sckClientNew(STRDEF("host.test2.pgbackrest.org"), hrnServerPort(0), 5000),
STRDEF("host.test2.pgbackrest.org"), 0, true,
strNewFmt("%s/" HRN_SERVER_CERT_PREFIX "-ca.crt", testRepoPath()), NULL)),
STRDEF(HRN_PATH_REPO "/" HRN_SERVER_CERT_PREFIX "-ca.crt"), NULL)),
"open connection");
// -----------------------------------------------------------------------------------------------------------------
@ -319,7 +319,7 @@ testRun(void)
ioClientOpen(
tlsClientNew(
sckClientNew(STRDEF("test3.pgbackrest.org"), hrnServerPort(0), 5000), STRDEF("test3.pgbackrest.org"),
0, true, strNewFmt("%s/" HRN_SERVER_CERT_PREFIX "-ca.crt", testRepoPath()), NULL)),
0, true, STRDEF(HRN_PATH_REPO "/" HRN_SERVER_CERT_PREFIX "-ca.crt"), NULL)),
CryptoError,
"unable to find hostname 'test3.pgbackrest.org' in certificate common name or subject alternative names");
@ -333,7 +333,7 @@ testRun(void)
ioClientOpen(
tlsClientNew(
sckClientNew(STRDEF("localhost"), hrnServerPort(0), 5000), STRDEF("X"), 0, true,
strNewFmt("%s/" HRN_SERVER_CERT_PREFIX ".crt", testRepoPath()),
STRDEF(HRN_PATH_REPO "/" HRN_SERVER_CERT_PREFIX ".crt"),
NULL)),
CryptoError,
"unable to verify certificate presented by 'localhost:%u': [20] unable to get local issuer certificate",
@ -386,7 +386,7 @@ testRun(void)
TEST_ASSIGN(
client,
tlsClientNew(
sckClientNew(hrnServerHost(), hrnServerPort(0), 5000), hrnServerHost(), 0, testContainer(), NULL,
sckClientNew(hrnServerHost(), hrnServerPort(0), 5000), hrnServerHost(), 0, TEST_IN_CONTAINER, NULL,
NULL),
"new client");

View File

@ -15,12 +15,12 @@ testRun(void)
FUNCTION_HARNESS_VOID();
// Create default storage object for testing
Storage *storageTest = storagePosixNewP(strNewZ(testPath()), .write = true);
Storage *storageTest = storagePosixNewP(TEST_PATH_STR, .write = true);
// *****************************************************************************************************************************
if (testBegin("lockAcquireFile() and lockReleaseFile()"))
{
String *archiveLock = strNewFmt("%s/main-archive" LOCK_FILE_EXT, testPath());
const String *archiveLock = STRDEF(TEST_PATH "/main-archive" LOCK_FILE_EXT);
int lockFdTest = -1;
TEST_RESULT_INT(system(strZ(strNewFmt("touch %s", strZ(archiveLock)))), 0, "touch lock file");
@ -58,7 +58,7 @@ testRun(void)
TEST_RESULT_VOID(lockReleaseFile(lockFdTest, archiveLock), "release lock again without error");
// -------------------------------------------------------------------------------------------------------------------------
String *subPathLock = strNewFmt("%s/sub1/sub2/db-backup" LOCK_FILE_EXT, testPath());
const String *subPathLock = STRDEF(TEST_PATH "/sub1/sub2/db-backup" LOCK_FILE_EXT);
TEST_ASSIGN(lockFdTest, lockAcquireFile(subPathLock, STRDEF("1-test"), 0, true), "get lock in subpath");
TEST_RESULT_BOOL(storageExistsP(storageTest, subPathLock), true, "lock file was created");
@ -67,7 +67,7 @@ testRun(void)
TEST_RESULT_BOOL(storageExistsP(storageTest, subPathLock), false, "lock file was removed");
// -------------------------------------------------------------------------------------------------------------------------
String *dirLock = strNewFmt("%s/dir" LOCK_FILE_EXT, testPath());
const String *dirLock = STRDEF(TEST_PATH "/dir" LOCK_FILE_EXT);
TEST_RESULT_INT(system(strZ(strNewFmt("mkdir -p 750 %s", strZ(dirLock)))), 0, "create dirtest.lock dir");
@ -76,7 +76,7 @@ testRun(void)
strZ(strNewFmt("unable to acquire lock on file '%s': Is a directory", strZ(dirLock))));
// -------------------------------------------------------------------------------------------------------------------------
String *noPermLock = strNewFmt("%s/noperm/noperm", testPath());
const String *noPermLock = STRDEF(TEST_PATH "/noperm/noperm");
TEST_RESULT_INT(system(strZ(strNewFmt("mkdir -p 750 %s", strZ(strPath(noPermLock))))), 0, "create noperm dir");
TEST_RESULT_INT(system(strZ(strNewFmt("chmod 000 %s", strZ(strPath(noPermLock))))), 0, "chmod noperm dir");
@ -89,7 +89,7 @@ testRun(void)
strZ(noPermLock), strZ(noPermLock))));
// -------------------------------------------------------------------------------------------------------------------------
String *backupLock = strNewFmt("%s/main-backup" LOCK_FILE_EXT, testPath());
const String *backupLock = STRDEF(TEST_PATH "/main-backup" LOCK_FILE_EXT);
HARNESS_FORK_BEGIN()
{
@ -120,9 +120,8 @@ testRun(void)
if (testBegin("lockAcquire(), lockRelease()"))
{
const String *stanza = STRDEF("test");
String *lockPath = strNewZ(testPath());
String *archiveLockFile = strNewFmt("%s/%s-archive" LOCK_FILE_EXT, testPath(), strZ(stanza));
String *backupLockFile = strNewFmt("%s/%s-backup" LOCK_FILE_EXT, testPath(), strZ(stanza));
String *archiveLockFile = strNewFmt(TEST_PATH "/%s-archive" LOCK_FILE_EXT, strZ(stanza));
String *backupLockFile = strNewFmt(TEST_PATH "/%s-backup" LOCK_FILE_EXT, strZ(stanza));
int lockFdTest = -1;
// -------------------------------------------------------------------------------------------------------------------------
@ -132,36 +131,36 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
TEST_ASSIGN(lockFdTest, lockAcquireFile(archiveLockFile, STRDEF("1-test"), 0, true), "archive lock by file");
TEST_RESULT_BOOL(
lockAcquire(lockPath, stanza, STRDEF("2-test"), lockTypeArchive, 0, false), false, "archive already locked");
lockAcquire(TEST_PATH_STR, stanza, STRDEF("2-test"), lockTypeArchive, 0, false), false, "archive already locked");
TEST_ERROR(
lockAcquire(lockPath, stanza, STRDEF("2-test"), lockTypeArchive, 0, true), LockAcquireError,
lockAcquire(TEST_PATH_STR, stanza, STRDEF("2-test"), lockTypeArchive, 0, true), LockAcquireError,
strZ(strNewFmt(
"unable to acquire lock on file '%s': Resource temporarily unavailable\n"
"HINT: is another pgBackRest process running?", strZ(archiveLockFile))));
TEST_ERROR(
lockAcquire(lockPath, stanza, STRDEF("2-test"), lockTypeAll, 0, true), LockAcquireError,
lockAcquire(TEST_PATH_STR, stanza, STRDEF("2-test"), lockTypeAll, 0, true), LockAcquireError,
strZ(strNewFmt(
"unable to acquire lock on file '%s': Resource temporarily unavailable\n"
"HINT: is another pgBackRest process running?", strZ(archiveLockFile))));
TEST_RESULT_VOID(lockReleaseFile(lockFdTest, archiveLockFile), "release lock");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_BOOL(lockAcquire(lockPath, stanza, STRDEF("1-test"), lockTypeArchive, 0, true), true, "archive lock");
TEST_RESULT_BOOL(lockAcquire(TEST_PATH_STR, stanza, STRDEF("1-test"), lockTypeArchive, 0, true), true, "archive lock");
TEST_RESULT_BOOL(storageExistsP(storageTest, archiveLockFile), true, "archive lock file was created");
TEST_ERROR(
lockAcquire(lockPath, stanza, STRDEF("1-test"), lockTypeArchive, 0, false), AssertError,
lockAcquire(TEST_PATH_STR, stanza, STRDEF("1-test"), lockTypeArchive, 0, false), AssertError,
"lock is already held by this process");
TEST_RESULT_VOID(lockRelease(true), "release archive lock");
// // -------------------------------------------------------------------------------------------------------------------------
TEST_ASSIGN(lockFdTest, lockAcquireFile(backupLockFile, STRDEF("1-test"), 0, true), "backup lock by file");
TEST_ERROR(
lockAcquire(lockPath, stanza, STRDEF("2-test"), lockTypeBackup, 0, true), LockAcquireError,
lockAcquire(TEST_PATH_STR, stanza, STRDEF("2-test"), lockTypeBackup, 0, true), LockAcquireError,
strZ(strNewFmt(
"unable to acquire lock on file '%s': Resource temporarily unavailable\n"
"HINT: is another pgBackRest process running?", strZ(backupLockFile))));
TEST_ERROR(
lockAcquire(lockPath, stanza, STRDEF("2-test"), lockTypeAll, 0, true), LockAcquireError,
lockAcquire(TEST_PATH_STR, stanza, STRDEF("2-test"), lockTypeAll, 0, true), LockAcquireError,
strZ(strNewFmt(
"unable to acquire lock on file '%s': Resource temporarily unavailable\n"
"HINT: is another pgBackRest process running?", strZ(backupLockFile))));
@ -169,11 +168,11 @@ testRun(void)
TEST_RESULT_VOID(lockReleaseFile(lockFdTest, backupLockFile), "release lock");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_BOOL(lockAcquire(lockPath, stanza, STRDEF("1-test"), lockTypeAll, 0, true), true, "all lock");
TEST_RESULT_BOOL(lockAcquire(TEST_PATH_STR, stanza, STRDEF("1-test"), lockTypeAll, 0, true), true, "all lock");
TEST_RESULT_BOOL(storageExistsP(storageTest, archiveLockFile), true, "archive lock file was created");
TEST_RESULT_BOOL(storageExistsP(storageTest, backupLockFile), true, "backup lock file was created");
TEST_ERROR(
lockAcquire(lockPath, stanza, STRDEF("1-test"), lockTypeAll, 0, false), AssertError,
lockAcquire(TEST_PATH_STR, stanza, STRDEF("1-test"), lockTypeAll, 0, false), AssertError,
"assertion 'failOnNoLock || lockType != lockTypeAll' failed");
TEST_RESULT_VOID(lockRelease(true), "release all locks");
@ -183,14 +182,14 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("acquire lock on the same exec-id and release");
TEST_RESULT_BOOL(lockAcquire(lockPath, stanza, STRDEF("1-test"), lockTypeBackup, 0, true), true, "backup lock");
TEST_RESULT_BOOL(lockAcquire(TEST_PATH_STR, stanza, STRDEF("1-test"), lockTypeBackup, 0, true), true, "backup lock");
// Make it look there is no lock
lockFdTest = lockFd[lockTypeBackup];
String *lockFileTest = strDup(lockFile[lockTypeBackup]);
lockTypeHeld = lockTypeNone;
TEST_RESULT_BOOL(lockAcquire(lockPath, stanza, STRDEF("1-test"), lockTypeBackup, 0, true), true, "backup lock again");
TEST_RESULT_BOOL(lockAcquire(TEST_PATH_STR, stanza, STRDEF("1-test"), lockTypeBackup, 0, true), true, "backup lock again");
TEST_RESULT_VOID(lockRelease(true), "release backup lock");
// Release lock manually

View File

@ -185,12 +185,10 @@ testRun(void)
true, "check timestamp format: %s", strZ(logTime));
// Redirect output to files
char stdoutFile[1024];
snprintf(stdoutFile, sizeof(stdoutFile), "%s/stdout.log", testPath());
const char *const stdoutFile = TEST_PATH "/stdout.log";
logFdStdOut = testLogOpen(stdoutFile, O_WRONLY | O_CREAT | O_TRUNC, 0640);
char stderrFile[1024];
snprintf(stderrFile, sizeof(stderrFile), "%s/stderr.log", testPath());
const char *const stderrFile = TEST_PATH "/stderr.log";
logFdStdErr = testLogOpen(stderrFile, O_WRONLY | O_CREAT | O_TRUNC, 0640);
TEST_RESULT_VOID(
@ -220,8 +218,7 @@ testRun(void)
TEST_RESULT_VOID(logInit(logLevelDebug, logLevelDebug, logLevelDebug, false, 0, 999, false), "init logging to debug");
// Log to file
char fileFile[1024];
snprintf(fileFile, sizeof(stdoutFile), "%s/file.log", testPath());
const char *const fileFile = TEST_PATH "/file.log";
logFileSet(fileFile);
logBuffer[0] = 0;

View File

@ -16,19 +16,19 @@ testRun(void)
TEST_RESULT_VOID(userInit(), "initialize info");
TEST_RESULT_VOID(userInit(), "initialize info again");
TEST_RESULT_UINT(userId(), getuid(), "check user id");
TEST_RESULT_UINT(userId(), TEST_USER_ID, "check user id");
TEST_RESULT_UINT(userIdFromName(userName()), userId(), "get user id");
TEST_RESULT_UINT(userIdFromName(NULL), (uid_t)-1, "get null user id");
TEST_RESULT_UINT(userIdFromName(STRDEF("bogus")), (uid_t)-1, "get bogus user id");
TEST_RESULT_STR_Z(userName(), testUser(), "check user name");
TEST_RESULT_STR(userName(), TEST_USER_STR, "check user name");
TEST_RESULT_STR_Z(userNameFromId(77777), NULL, "invalid user name by id");
TEST_RESULT_BOOL(userRoot(), false, "check user is root");
TEST_RESULT_UINT(groupId(), getgid(), "check group id");
TEST_RESULT_UINT(groupId(), TEST_GROUP_ID, "check group id");
TEST_RESULT_UINT(groupIdFromName(groupName()), groupId(), "get group id");
TEST_RESULT_UINT(groupIdFromName(NULL), (gid_t)-1, "get null group id");
TEST_RESULT_UINT(groupIdFromName(STRDEF("bogus")), (uid_t)-1, "get bogus group id");
TEST_RESULT_STR_Z(groupName(), testGroup(), "check name name");
TEST_RESULT_STR(groupName(), TEST_GROUP_STR, "check name name");
TEST_RESULT_STR_Z(groupNameFromId(77777), NULL, "invalid group name by id");
}

View File

@ -18,8 +18,8 @@ testRun(void)
strLstAddZ(argList, "pgbackrest");
strLstAddZ(argList, "--stanza=test1");
hrnCfgArgRawZ(argList, cfgOptArchiveTimeout, "5");
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAdd(argList, strNewFmt("--pg1-path=%s/db path", testPath()));
strLstAddZ(argList, "--repo1-path=" TEST_PATH "/repo");
strLstAddZ(argList, "--pg1-path=" TEST_PATH "/db path");
strLstAddZ(argList, "--pg2-path=/db2");
strLstAddZ(argList, "--log-subprocess");
strLstAddZ(argList, "--no-config");
@ -50,8 +50,8 @@ testRun(void)
argList = strLstNew();
strLstAddZ(argList, "pgbackrest");
strLstAddZ(argList, "--stanza=test1");
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAdd(argList, strNewFmt("--pg1-path=%s/db path", testPath()));
strLstAddZ(argList, "--repo1-path=" TEST_PATH "/repo");
strLstAddZ(argList, "--pg1-path=" TEST_PATH "/db path");
strLstAddZ(argList, "--db-include=1");
strLstAddZ(argList, "--db-include=2");
strLstAddZ(argList, "--recovery-option=a=b");

View File

@ -470,7 +470,7 @@ testRun(void)
strLstAddZ(argList, "pgbackrest");
strLstAddZ(argList, "--stanza=db");
strLstAddZ(argList, "--pg1-path=/path");
strLstAdd(argList, strNewFmt("--lock-path=%s/lock", testDataPath()));
strLstAddZ(argList, "--lock-path=" HRN_PATH "/lock");
strLstAddZ(argList, "--log-path=/bogus");
strLstAddZ(argList, "--log-level-file=info");
strLstAddZ(argList, "backup");
@ -491,7 +491,7 @@ testRun(void)
StringList *argList = strLstNew();
strLstAddZ(argList, PROJECT_BIN);
strLstAddZ(argList, "--" CFGOPT_STANZA "=db");
strLstAdd(argList, strNewFmt("--" CFGOPT_LOCK_PATH "=%s/lock", testDataPath()));
strLstAddZ(argList, "--" CFGOPT_LOCK_PATH "=" HRN_PATH "/lock");
strLstAddZ(argList, CFGCMD_EXPIRE);
TEST_RESULT_VOID(cfgLoad(strLstSize(argList), strLstPtr(argList)), "load config");
@ -600,8 +600,8 @@ testRun(void)
strLstAddZ(argList, "--stanza=db");
strLstAddZ(argList, "--pg1-path=/path");
strLstAddZ(argList, "--repo1-retention-full=1");
strLstAdd(argList, strNewFmt("--lock-path=%s/lock", testDataPath()));
strLstAdd(argList, strNewFmt("--log-path=%s", testPath()));
strLstAddZ(argList, "--lock-path=" HRN_PATH "/lock");
strLstAddZ(argList, "--log-path=" TEST_PATH);
strLstAddZ(argList, "--log-level-console=off");
strLstAddZ(argList, "--log-level-stderr=off");
strLstAddZ(argList, "--log-level-file=warn");
@ -611,7 +611,7 @@ testRun(void)
strLstAddZ(argList, "backup");
TEST_RESULT_VOID(cfgLoad(strLstSize(argList), strLstPtr(argList)), "lock and open log file");
TEST_RESULT_INT(lstat(strZ(strNewFmt("%s/db-backup.log", testPath())), &statLog), 0, " check log file exists");
TEST_RESULT_INT(lstat(TEST_PATH "/db-backup.log", &statLog), 0, " check log file exists");
TEST_RESULT_PTR_NE(cfgOptionStr(cfgOptExecId), NULL, " exec-id is set");
TEST_RESULT_BOOL(socketLocal.init, true, " check socketLocal.init");
TEST_RESULT_BOOL(socketLocal.block, false, " check socketLocal.block");
@ -627,7 +627,7 @@ testRun(void)
argList = strLstNew();
strLstAddZ(argList, "pgbackrest");
strLstAddZ(argList, "--stanza=db");
strLstAdd(argList, strNewFmt("--log-path=%s", testPath()));
strLstAddZ(argList, "--log-path=" TEST_PATH);
hrnCfgArgRawZ(argList, cfgOptPgPath, "/path/to");
strLstAddZ(argList, "--process=1");
hrnCfgArgRawStrId(argList, cfgOptRemoteType, protocolStorageTypeRepo);
@ -636,14 +636,14 @@ testRun(void)
strLstAddZ(argList, CFGCMD_BACKUP ":" CONFIG_COMMAND_ROLE_LOCAL);
TEST_RESULT_VOID(cfgLoad(strLstSize(argList), strLstPtr(argList)), "open log file");
TEST_RESULT_INT(lstat(strZ(strNewFmt("%s/db-backup-local-001.log", testPath())), &statLog), 0, " check log file exists");
TEST_RESULT_INT(lstat(TEST_PATH "/db-backup-local-001.log", &statLog), 0, " check log file exists");
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptExecId), "1111-fe70d611", " exec-id is preserved");
// Remote command opens log file with special filename
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
strLstAddZ(argList, "pgbackrest");
strLstAdd(argList, strNewFmt("--log-path=%s", testPath()));
strLstAddZ(argList, "--log-path=" TEST_PATH);
hrnCfgArgRawStrId(argList, cfgOptRemoteType, protocolStorageTypeRepo);
strLstAddZ(argList, "--" CFGOPT_LOG_LEVEL_FILE "=info");
strLstAddZ(argList, "--" CFGOPT_LOG_SUBPROCESS);
@ -651,14 +651,14 @@ testRun(void)
strLstAddZ(argList, CFGCMD_INFO ":" CONFIG_COMMAND_ROLE_REMOTE);
TEST_RESULT_VOID(cfgLoad(strLstSize(argList), strLstPtr(argList)), "open log file");
TEST_RESULT_INT(lstat(strZ(strNewFmt("%s/all-info-remote-000.log", testPath())), &statLog), 0, " check log file exists");
TEST_RESULT_INT(lstat(TEST_PATH "/all-info-remote-000.log", &statLog), 0, " check log file exists");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("remote command without archive-async option");
argList = strLstNew();
strLstAddZ(argList, "pgbackrest");
strLstAdd(argList, strNewFmt("--log-path=%s", testPath()));
strLstAddZ(argList, "--log-path=" TEST_PATH);
strLstAddZ(argList, "--" CFGOPT_STANZA "=test");
hrnCfgArgRawZ(argList, cfgOptPgPath, "/path/to/pg");
hrnCfgArgRawStrId(argList, cfgOptRemoteType, protocolStorageTypeRepo);
@ -668,15 +668,14 @@ testRun(void)
strLstAddZ(argList, CFGCMD_ARCHIVE_GET ":" CONFIG_COMMAND_ROLE_REMOTE);
TEST_RESULT_VOID(cfgLoad(strLstSize(argList), strLstPtr(argList)), "open log file");
TEST_RESULT_INT(
lstat(strZ(strNewFmt("%s/test-archive-get-remote-001.log", testPath())), &statLog), 0, " check log file exists");
TEST_RESULT_INT(lstat(TEST_PATH "/test-archive-get-remote-001.log", &statLog), 0, " check log file exists");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("local command with archive-async option");
argList = strLstNew();
strLstAddZ(argList, "pgbackrest");
strLstAdd(argList, strNewFmt("--log-path=%s", testPath()));
strLstAddZ(argList, "--log-path=" TEST_PATH);
strLstAddZ(argList, "--" CFGOPT_STANZA "=test");
hrnCfgArgRawStrId(argList, cfgOptRemoteType, protocolStorageTypeRepo);
strLstAddZ(argList, "--" CFGOPT_LOG_LEVEL_FILE "=info");
@ -686,24 +685,21 @@ testRun(void)
strLstAddZ(argList, CFGCMD_ARCHIVE_PUSH ":" CONFIG_COMMAND_ROLE_LOCAL);
TEST_RESULT_VOID(cfgLoad(strLstSize(argList), strLstPtr(argList)), "open log file");
TEST_RESULT_INT(
lstat(strZ(strNewFmt("%s/test-archive-push-async-local-001.log", testPath())), &statLog), 0,
" check log file exists");
TEST_RESULT_INT(lstat(TEST_PATH "/test-archive-push-async-local-001.log", &statLog), 0, " check log file exists");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("archive-get command with async role");
argList = strLstNew();
strLstAddZ(argList, PROJECT_BIN);
strLstAdd(argList, strNewFmt("--" CFGOPT_LOG_PATH "=%s", testPath()));
strLstAdd(argList, strNewFmt("--lock-path=%s/lock", testDataPath()));
strLstAddZ(argList, "--" CFGOPT_LOG_PATH "=" TEST_PATH);
strLstAddZ(argList, "--lock-path=" HRN_PATH "/lock");
strLstAddZ(argList, "--" CFGOPT_STANZA "=test");
hrnCfgArgRawZ(argList, cfgOptPgPath, "/path/to/pg");
strLstAddZ(argList, CFGCMD_ARCHIVE_GET ":" CONFIG_COMMAND_ROLE_ASYNC);
TEST_RESULT_VOID(cfgLoad(strLstSize(argList), strLstPtr(argList)), "open log file");
TEST_RESULT_INT(
lstat(strZ(strNewFmt("%s/test-archive-get-async.log", testPath())), &statLog), 0, " check log file exists");
TEST_RESULT_INT(lstat(TEST_PATH "/test-archive-get-async.log", &statLog), 0, " check log file exists");
lockRelease(true);
}

View File

@ -40,7 +40,7 @@ testRun(void)
FUNCTION_HARNESS_VOID();
Storage *storageTest = storagePosixNewP(FSLASH_STR);
Storage *storageTestWrite = storagePosixNewP(strNewZ(testPath()), .write = true);
Storage *storageTestWrite = storagePosixNewP(TEST_PATH_STR, .write = true);
// *****************************************************************************************************************************
if (testBegin("size"))
@ -69,9 +69,9 @@ testRun(void)
if (testBegin("cfgFileLoad()"))
{
StringList *argList = NULL;
String *configFile = strNewFmt("%s/test.config", testPath());
const String *configFile = STRDEF(TEST_PATH "/test.config");
String *configIncludePath = strNewFmt("%s/conf.d", testPath());
const String *configIncludePath = STRDEF(TEST_PATH "/conf.d");
mkdir(strZ(configIncludePath), 0750);
// Check old config file constants
@ -165,7 +165,7 @@ testRun(void)
String *backupCmdDefConfigValue = strNewZ(cfgParseOptionDefault(cfgCommandId(TEST_COMMAND_BACKUP), cfgOptConfig));
String *backupCmdDefConfigInclPathValue = strNewZ(
cfgParseOptionDefault(cfgCommandId(TEST_COMMAND_BACKUP), cfgOptConfigIncludePath));
String *oldConfigDefault = strNewFmt("%s%s", testPath(), PGBACKREST_CONFIG_ORIG_PATH_FILE);
const String *oldConfigDefault = STRDEF(TEST_PATH PGBACKREST_CONFIG_ORIG_PATH_FILE);
// Create the option structure and initialize with 0
ParseOption parseOptionList[CFG_OPTION_TOTAL] = {{0}};
@ -226,13 +226,13 @@ testRun(void)
parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList = value;
value = strLstNew();
strLstAdd(value, strNewFmt("%s/%s", testPath(), BOGUS_STR));
strLstAddZ(value, TEST_PATH "/" BOGUS_STR);
parseOptionList[cfgOptConfig].indexList[0].valueList = value;
TEST_ERROR_FMT(
cfgFileLoad(storageTest, parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
FileMissingError, STORAGE_ERROR_READ_MISSING, strZ(strNewFmt("%s/BOGUS", testPath())));
FileMissingError, STORAGE_ERROR_READ_MISSING, TEST_PATH "/BOGUS");
strLstFree(parseOptionList[cfgOptConfig].indexList[0].valueList);
strLstFree(parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList);
@ -414,7 +414,7 @@ testRun(void)
// Pass --config-path
value = strLstNew();
strLstAddZ(value, testPath());
strLstAddZ(value, TEST_PATH);
parseOptionList[cfgOptConfigPath].indexListTotal = 1;
parseOptionList[cfgOptConfigPath].indexList = memNew(sizeof(ParseOptionValue));
@ -475,9 +475,8 @@ testRun(void)
// Copy the configFile to pgbackrest.conf (default is /etc/pgbackrest/pgbackrest.conf and new value is testPath so copy the
// config file (that was not read in the previous test) to pgbackrest.conf so it will be read by the override
TEST_RESULT_INT(
system(
strZ(strNewFmt("cp %s %s", strZ(configFile), strZ(strNewFmt("%s/pgbackrest.conf", testPath()))))), 0,
"copy configFile to pgbackrest.conf");
system(strZ(strNewFmt("cp %s " TEST_PATH "/pgbackrest.conf", strZ(configFile)))), 0,
"copy configFile to pgbackrest.conf");
parseOptionList[cfgOptConfig].indexList[0].found = false;
parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceDefault;
@ -486,7 +485,7 @@ testRun(void)
parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceDefault;
value = strLstNew();
strLstAddZ(value, testPath());
strLstAddZ(value, TEST_PATH);
parseOptionList[cfgOptConfigPath].indexList[0].valueList = value;
@ -566,7 +565,7 @@ testRun(void)
if (testBegin("configParse()"))
{
StringList *argList = NULL;
String *configFile = strNewFmt("%s/test.config", testPath());
const String *configFile = STRDEF(TEST_PATH "/test.config");
TEST_RESULT_INT(
sizeof(optionResolveOrder) / sizeof(ConfigOption), CFG_OPTION_TOTAL,

View File

@ -642,7 +642,7 @@ testRun(void)
strLstAddZ(argList, "--pg4-path=/path/to/pg4");
strLstAddZ(argList, "--pg4-port=5433");
strLstAddZ(argList, "--pg5-host=localhost");
strLstAdd(argList, strNewFmt("--pg5-host-user=%s", testUser()));
strLstAddZ(argList, "--pg5-host-user=" TEST_USER);
strLstAddZ(argList, "--pg5-path=/path/to/pg5");
strLstAddZ(argList, "--pg8-path=/path/to/pg8");
strLstAddZ(argList, "--pg8-port=5434");

View File

@ -16,7 +16,7 @@ void
testRun(void)
{
// Create default storage object for testing
Storage *storageTest = storagePosixNewP(strNewZ(testPath()), .write = true);
Storage *storageTest = storagePosixNewP(TEST_PATH_STR, .write = true);
// *****************************************************************************************************************************
if (testBegin("InfoArchive"))
@ -127,16 +127,15 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("infoArchiveLoadFile() and infoArchiveSaveFile()"))
{
TEST_ERROR_FMT(
TEST_ERROR(
infoArchiveLoadFile(storageTest, STRDEF(INFO_ARCHIVE_FILE), cipherTypeNone, NULL), FileMissingError,
"unable to load info file '%s/archive.info' or '%s/archive.info.copy':\n"
"FileMissingError: unable to open missing file '%s/archive.info' for read\n"
"FileMissingError: unable to open missing file '%s/archive.info.copy' for read\n"
"unable to load info file '" TEST_PATH "/archive.info' or '" TEST_PATH "/archive.info.copy':\n"
"FileMissingError: unable to open missing file '" TEST_PATH "/archive.info' for read\n"
"FileMissingError: unable to open missing file '" TEST_PATH "/archive.info.copy' for read\n"
"HINT: archive.info cannot be opened but is required to push/get WAL segments.\n"
"HINT: is archive_command configured correctly in postgresql.conf?\n"
"HINT: has a stanza-create been performed?\n"
"HINT: use --no-archive-check to disable archive checks during backup if you have an alternate archiving scheme.",
testPath(), testPath(), testPath(), testPath());
"HINT: use --no-archive-check to disable archive checks during backup if you have an alternate archiving scheme.");
InfoArchive *infoArchive = infoArchiveNew(PG_VERSION_10, 6569239123849665999, NULL);
TEST_RESULT_VOID(

View File

@ -17,7 +17,7 @@ void
testRun(void)
{
// Create default storage object for testing
Storage *storageTest = storagePosixNewP(strNewZ(testPath()), .write = true);
Storage *storageTest = storagePosixNewP(TEST_PATH_STR, .write = true);
// *****************************************************************************************************************************
if (testBegin("InfoBackup"))
@ -450,7 +450,7 @@ testRun(void)
StringList *argList = strLstNew();
strLstAddZ(argList, "--stanza=db");
hrnCfgArgRawZ(argList, cfgOptPgPath, "/path/to/pg");
strLstAdd(argList, strNewFmt("--repo-path=%s", testPath()));
strLstAddZ(argList, "--repo-path=" TEST_PATH);
harnessCfgLoad(cfgCmdArchiveGet, argList);
// Create manifest for upgrade db (id=2), save to disk
@ -820,14 +820,13 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("infoBackupLoadFile() and infoBackupSaveFile()"))
{
TEST_ERROR_FMT(
TEST_ERROR(
infoBackupLoadFile(storageTest, STRDEF(INFO_BACKUP_FILE), cipherTypeNone, NULL), FileMissingError,
"unable to load info file '%s/backup.info' or '%s/backup.info.copy':\n"
"FileMissingError: unable to open missing file '%s/backup.info' for read\n"
"FileMissingError: unable to open missing file '%s/backup.info.copy' for read\n"
"unable to load info file '" TEST_PATH "/backup.info' or '" TEST_PATH "/backup.info.copy':\n"
"FileMissingError: unable to open missing file '" TEST_PATH "/backup.info' for read\n"
"FileMissingError: unable to open missing file '" TEST_PATH "/backup.info.copy' for read\n"
"HINT: backup.info cannot be opened and is required to perform a backup.\n"
"HINT: has a stanza-create been performed?",
testPath(), testPath(), testPath(), testPath());
"HINT: has a stanza-create been performed?");
InfoBackup *infoBackup = infoBackupNew(PG_VERSION_10, 6569239123849665999, hrnPgCatalogVersion(PG_VERSION_10), NULL);
TEST_RESULT_VOID(

View File

@ -22,7 +22,7 @@ Test Run
void
testRun(void)
{
Storage *storageTest = storagePosixNewP(strNewZ(testPath()), .write = true);
Storage *storageTest = storagePosixNewP(TEST_PATH_STR, .write = true);
// *****************************************************************************************************************************
if (testBegin("struct sizes"))
@ -155,36 +155,36 @@ testRun(void)
#define TEST_MANIFEST_FILE_DEFAULT_PRIMARY_FALSE \
"\n" \
"[target:file:default]\n" \
"group=\"{[group]}\"\n" \
"group=\"" TEST_GROUP "\"\n" \
"master=false\n" \
"mode=\"0400\"\n" \
"user=\"{[user]}\"\n"
"user=\"" TEST_USER "\"\n"
#define TEST_MANIFEST_FILE_DEFAULT_PRIMARY_TRUE \
"\n" \
"[target:file:default]\n" \
"group=\"{[group]}\"\n" \
"group=\"" TEST_GROUP "\"\n" \
"master=true\n" \
"mode=\"0400\"\n" \
"user=\"{[user]}\"\n"
"user=\"" TEST_USER "\"\n"
#define TEST_MANIFEST_LINK_DEFAULT \
"\n" \
"[target:link:default]\n" \
"group=\"{[group]}\"\n" \
"user=\"{[user]}\"\n"
"group=\"" TEST_GROUP "\"\n" \
"user=\"" TEST_USER "\"\n"
#define TEST_MANIFEST_PATH_DEFAULT \
"\n" \
"[target:path:default]\n" \
"group=\"{[group]}\"\n" \
"group=\"" TEST_GROUP "\"\n" \
"mode=\"0700\"\n" \
"user=\"{[user]}\"\n"
"user=\"" TEST_USER "\"\n"
storagePathCreateP(storageTest, STRDEF("pg"), .mode = 0700, .noParentCreate = true);
Storage *storagePg = storagePosixNewP(strNewFmt("%s/pg", testPath()));
Storage *storagePgWrite = storagePosixNewP(strNewFmt("%s/pg", testPath()), .write = true);
Storage *storagePg = storagePosixNewP(STRDEF(TEST_PATH "/pg"));
Storage *storagePgWrite = storagePosixNewP(STRDEF(TEST_PATH "/pg"), .write = true);
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("8.3 with custom exclusions and special file");
@ -195,7 +195,7 @@ testRun(void)
BUFSTRDEF("8.3\n"));
// Create special file
String *specialFile = strNewFmt("%s/pg/testpipe", testPath());
const String *const specialFile = STRDEF(TEST_PATH "/pg/testpipe");
TEST_RESULT_INT(system(strZ(strNewFmt("mkfifo -m 666 %s", strZ(specialFile)))), 0, "create pipe");
// Files that will always be ignored
@ -288,13 +288,13 @@ testRun(void)
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(hrnReplaceKey(
strNewBuf(harnessInfoChecksumZ(
TEST_MANIFEST_HEADER
TEST_MANIFEST_DB_83
TEST_MANIFEST_OPTION_ALL
"\n"
"[backup:target]\n"
"pg_data={\"path\":\"{[path]}/pg\",\"type\":\"path\"}\n"
"pg_data={\"path\":\"" TEST_PATH "/pg\",\"type\":\"path\"}\n"
"\n"
"[target:file]\n"
"pg_data/PG_VERSION={\"size\":4,\"timestamp\":1565282100}\n"
@ -323,13 +323,13 @@ testRun(void)
"pg_data/pg_subtrans={}\n"
"pg_data/pg_xlog={}\n"
"pg_data/pg_xlog/archive_status={}\n"
TEST_MANIFEST_PATH_DEFAULT))),
TEST_MANIFEST_PATH_DEFAULT)),
"check manifest");
TEST_RESULT_LOG(
"P00 INFO: exclude contents of '{[path]}/pg/base' from backup using 'base/' exclusion\n"
"P00 INFO: exclude '{[path]}/pg/global/pg_internal.init' from backup using 'global/pg_internal.init' exclusion\n"
"P00 WARN: exclude special file '{[path]}/pg/testpipe' from backup");
"P00 INFO: exclude contents of '" TEST_PATH "/pg/base' from backup using 'base/' exclusion\n"
"P00 INFO: exclude '" TEST_PATH "/pg/global/pg_internal.init' from backup using 'global/pg_internal.init' exclusion\n"
"P00 WARN: exclude special file '" TEST_PATH "/pg/testpipe' from backup");
storageRemoveP(storageTest, specialFile, .errorOnMissing = true);
@ -367,14 +367,12 @@ testRun(void)
// Config directory and file links
storagePathCreateP(storageTest, STRDEF("config"), .mode = 0700);
THROW_ON_SYS_ERROR(
symlink("../config/postgresql.conf", strZ(strNewFmt("%s/pg/postgresql.conf", testPath()))) == -1, FileOpenError,
"unable to create symlink");
symlink("../config/postgresql.conf", TEST_PATH "/pg/postgresql.conf") == -1, FileOpenError, "unable to create symlink");
storagePutP(
storageNewWriteP(storageTest, STRDEF("config/postgresql.conf"), .modeFile = 0400, .timeModified = 1565282116),
BUFSTRDEF("POSTGRESQLCONF"));
THROW_ON_SYS_ERROR(
symlink("../config/pg_hba.conf", strZ(strNewFmt("%s/pg/pg_hba.conf", testPath()))) == -1, FileOpenError,
"unable to create symlink");
symlink("../config/pg_hba.conf", TEST_PATH "/pg/pg_hba.conf") == -1, FileOpenError, "unable to create symlink");
storagePutP(
storageNewWriteP(storageTest, STRDEF("config/pg_hba.conf"), .modeFile = 0400, .timeModified = 1565282117),
BUFSTRDEF("PGHBACONF"));
@ -391,9 +389,7 @@ testRun(void)
storagePathCreateP(storageTest, STRDEF("ts/1"), .mode = 0777);
storagePathCreateP(storageTest, STRDEF("ts/1/1"), .mode = 0700);
storagePathCreateP(storagePgWrite, MANIFEST_TARGET_PGTBLSPC_STR, .mode = 0700, .noParentCreate = true);
THROW_ON_SYS_ERROR(
symlink("../../ts/1", strZ(strNewFmt("%s/pg/pg_tblspc/1", testPath()))) == -1, FileOpenError,
"unable to create symlink");
THROW_ON_SYS_ERROR(symlink("../../ts/1", TEST_PATH "/pg/pg_tblspc/1") == -1, FileOpenError, "unable to create symlink");
storagePutP(
storageNewWriteP(
storagePgWrite, STRDEF("pg_tblspc/1/1/16384"), .modeFile = 0400, .timeModified = 1565282115),
@ -412,7 +408,7 @@ testRun(void)
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(hrnReplaceKey(
strNewBuf(harnessInfoChecksumZ(
TEST_MANIFEST_HEADER
TEST_MANIFEST_DB_84
TEST_MANIFEST_OPTION_ARCHIVE
@ -420,7 +416,7 @@ testRun(void)
TEST_MANIFEST_OPTION_ONLINE_TRUE
"\n"
"[backup:target]\n"
"pg_data={\"path\":\"{[path]}/pg\",\"type\":\"path\"}\n"
"pg_data={\"path\":\"" TEST_PATH "/pg\",\"type\":\"path\"}\n"
"pg_data/pg_hba.conf={\"file\":\"pg_hba.conf\",\"path\":\"../config\",\"type\":\"link\"}\n"
"pg_data/postgresql.conf={\"file\":\"postgresql.conf\",\"path\":\"../config\",\"type\":\"link\"}\n"
"pg_tblspc/1={\"path\":\"../../ts/1\",\"tablespace-id\":\"1\",\"tablespace-name\":\"ts1\",\"type\":\"link\"}\n"
@ -474,7 +470,7 @@ testRun(void)
"pg_tblspc={}\n"
"pg_tblspc/1={\"mode\":\"0777\"}\n"
"pg_tblspc/1/1={}\n"
TEST_MANIFEST_PATH_DEFAULT))),
TEST_MANIFEST_PATH_DEFAULT)),
"check manifest");
// Remove directory
@ -493,7 +489,7 @@ testRun(void)
storagePathRemoveP(storagePgWrite, STRDEF("pg_xlog/archive_status"), .recurse = true);
storagePathCreateP(storageTest, STRDEF("archivestatus"), .mode = 0777);
THROW_ON_SYS_ERROR(
symlink("../../archivestatus", strZ(strNewFmt("%s/pg/pg_xlog/archive_status", testPath()))) == -1, FileOpenError,
symlink("../../archivestatus", TEST_PATH "/pg/pg_xlog/archive_status") == -1, FileOpenError,
"unable to create symlink");
storagePutP(
storageNewWriteP(
@ -541,13 +537,13 @@ testRun(void)
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(hrnReplaceKey(
strNewBuf(harnessInfoChecksumZ(
TEST_MANIFEST_HEADER
TEST_MANIFEST_DB_90
TEST_MANIFEST_OPTION_ALL
"\n"
"[backup:target]\n"
"pg_data={\"path\":\"{[path]}/pg\",\"type\":\"path\"}\n"
"pg_data={\"path\":\"" TEST_PATH "/pg\",\"type\":\"path\"}\n"
"pg_data/pg_hba.conf={\"file\":\"pg_hba.conf\",\"path\":\"../config\",\"type\":\"link\"}\n"
"pg_data/pg_xlog/archive_status={\"path\":\"../../archivestatus\",\"type\":\"link\"}\n"
"pg_data/postgresql.conf={\"file\":\"postgresql.conf\",\"path\":\"../config\",\"type\":\"link\"}\n"
@ -599,12 +595,11 @@ testRun(void)
"pg_tblspc/1={}\n"
"pg_tblspc/1/PG_9.0_201008051={}\n"
"pg_tblspc/1/PG_9.0_201008051/1={}\n"
TEST_MANIFEST_PATH_DEFAULT))),
TEST_MANIFEST_PATH_DEFAULT)),
"check manifest");
// Remove symlinks and directories
THROW_ON_SYS_ERROR(
unlink(strZ(strNewFmt("%s/pg/pg_tblspc/1", testPath()))) == -1, FileRemoveError, "unable to remove symlink");
THROW_ON_SYS_ERROR(unlink(TEST_PATH "/pg/pg_tblspc/1") == -1, FileRemoveError, "unable to remove symlink");
storagePathRemoveP(storageTest, STRDEF("ts/1/PG_9.0_201008051"), .recurse = true);
// -------------------------------------------------------------------------------------------------------------------------
@ -634,7 +629,7 @@ testRun(void)
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(hrnReplaceKey(
strNewBuf(harnessInfoChecksumZ(
TEST_MANIFEST_HEADER
TEST_MANIFEST_DB_91
TEST_MANIFEST_OPTION_ARCHIVE
@ -642,7 +637,7 @@ testRun(void)
TEST_MANIFEST_OPTION_ONLINE_TRUE
"\n"
"[backup:target]\n"
"pg_data={\"path\":\"{[path]}/pg\",\"type\":\"path\"}\n"
"pg_data={\"path\":\"" TEST_PATH "/pg\",\"type\":\"path\"}\n"
"pg_data/pg_hba.conf={\"file\":\"pg_hba.conf\",\"path\":\"../config\",\"type\":\"link\"}\n"
"pg_data/pg_xlog/archive_status={\"path\":\"../../archivestatus\",\"type\":\"link\"}\n"
"pg_data/postgresql.conf={\"file\":\"postgresql.conf\",\"path\":\"../config\",\"type\":\"link\"}\n"
@ -684,7 +679,7 @@ testRun(void)
"pg_data/pg_xlog={}\n"
"pg_data/pg_xlog/archive_status={\"mode\":\"0777\"}\n"
"pg_data/pg_xlog/somepath={}\n"
TEST_MANIFEST_PATH_DEFAULT))),
TEST_MANIFEST_PATH_DEFAULT)),
"check manifest");
// Remove pg_xlog and the directory that archive_status link pointed to
@ -701,9 +696,7 @@ testRun(void)
// create pg_xlog/wal as a link
storagePathCreateP(storageTest, STRDEF("wal"), .mode = 0700);
THROW_ON_SYS_ERROR(
symlink(strZ(strNewFmt("%s/wal", testPath())), strZ(strNewFmt("%s/pg/pg_xlog", testPath()))) == -1, FileOpenError,
"unable to create symlink");
THROW_ON_SYS_ERROR(symlink(TEST_PATH "/wal", TEST_PATH "/pg/pg_xlog") == -1, FileOpenError, "unable to create symlink");
// Files to conditionally ignore before 9.4
storagePutP(
@ -719,15 +712,15 @@ testRun(void)
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(hrnReplaceKey(
strNewBuf(harnessInfoChecksumZ(
TEST_MANIFEST_HEADER
TEST_MANIFEST_DB_92
TEST_MANIFEST_OPTION_ALL
"\n"
"[backup:target]\n"
"pg_data={\"path\":\"{[path]}/pg\",\"type\":\"path\"}\n"
"pg_data={\"path\":\"" TEST_PATH "/pg\",\"type\":\"path\"}\n"
"pg_data/pg_hba.conf={\"file\":\"pg_hba.conf\",\"path\":\"../config\",\"type\":\"link\"}\n"
"pg_data/pg_xlog={\"path\":\"{[path]}/wal\",\"type\":\"link\"}\n"
"pg_data/pg_xlog={\"path\":\"" TEST_PATH "/wal\",\"type\":\"link\"}\n"
"pg_data/postgresql.conf={\"file\":\"postgresql.conf\",\"path\":\"../config\",\"type\":\"link\"}\n"
"\n"
"[target:file]\n"
@ -746,7 +739,7 @@ testRun(void)
"\n"
"[target:link]\n"
"pg_data/pg_hba.conf={\"destination\":\"../config/pg_hba.conf\"}\n"
"pg_data/pg_xlog={\"destination\":\"{[path]}/wal\"}\n"
"pg_data/pg_xlog={\"destination\":\"" TEST_PATH "/wal\"}\n"
"pg_data/postgresql.conf={\"destination\":\"../config/postgresql.conf\"}\n"
TEST_MANIFEST_LINK_DEFAULT
"\n"
@ -765,7 +758,7 @@ testRun(void)
"pg_data/pg_tblspc={}\n"
"pg_data/pg_wal={}\n"
"pg_data/pg_xlog={}\n"
TEST_MANIFEST_PATH_DEFAULT))),
TEST_MANIFEST_PATH_DEFAULT)),
"check manifest");
// -------------------------------------------------------------------------------------------------------------------------
@ -814,9 +807,7 @@ testRun(void)
// Tablespace 1
storagePathCreateP(storageTest, STRDEF("ts/1/PG_9.4_201409291/1"), .mode = 0700);
THROW_ON_SYS_ERROR(
symlink("../../ts/1", strZ(strNewFmt("%s/pg/pg_tblspc/1", testPath()))) == -1, FileOpenError,
"unable to create symlink");
THROW_ON_SYS_ERROR(symlink("../../ts/1", TEST_PATH "/pg/pg_tblspc/1") == -1, FileOpenError, "unable to create symlink");
storagePutP(
storageNewWriteP(
storagePgWrite, STRDEF("pg_tblspc/1/PG_9.4_201409291/1/16384"), .modeFile = 0400, .timeModified = 1565282115),
@ -844,9 +835,7 @@ testRun(void)
// Tablespace 2
storagePathCreateP(storageTest, STRDEF("ts/2/PG_9.4_201409291/1"), .mode = 0700);
THROW_ON_SYS_ERROR(
symlink("../../ts/2", strZ(strNewFmt("%s/pg/pg_tblspc/2", testPath()))) == -1, FileOpenError,
"unable to create symlink");
THROW_ON_SYS_ERROR(symlink("../../ts/2", TEST_PATH "/pg/pg_tblspc/2") == -1, FileOpenError, "unable to create symlink");
storagePutP(
storageNewWriteP(
storagePgWrite, STRDEF("pg_tblspc/2/PG_9.4_201409291/1/16385"), .modeFile = 0400, .timeModified = 1565282115),
@ -861,7 +850,7 @@ testRun(void)
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(hrnReplaceKey(
strNewBuf(harnessInfoChecksumZ(
TEST_MANIFEST_HEADER
TEST_MANIFEST_DB_94
TEST_MANIFEST_OPTION_ARCHIVE
@ -869,9 +858,9 @@ testRun(void)
TEST_MANIFEST_OPTION_ONLINE_FALSE
"\n"
"[backup:target]\n"
"pg_data={\"path\":\"{[path]}/pg\",\"type\":\"path\"}\n"
"pg_data={\"path\":\"" TEST_PATH "/pg\",\"type\":\"path\"}\n"
"pg_data/pg_hba.conf={\"file\":\"pg_hba.conf\",\"path\":\"../config\",\"type\":\"link\"}\n"
"pg_data/pg_xlog={\"path\":\"{[path]}/wal\",\"type\":\"link\"}\n"
"pg_data/pg_xlog={\"path\":\"" TEST_PATH "/wal\",\"type\":\"link\"}\n"
"pg_data/postgresql.conf={\"file\":\"postgresql.conf\",\"path\":\"../config\",\"type\":\"link\"}\n"
"pg_tblspc/1={\"path\":\"../../ts/1\",\"tablespace-id\":\"1\",\"tablespace-name\":\"ts1\",\"type\":\"link\"}\n"
"pg_tblspc/2={\"path\":\"../../ts/2\",\"tablespace-id\":\"2\",\"tablespace-name\":\"ts2\",\"type\":\"link\"}\n"
@ -903,7 +892,7 @@ testRun(void)
"pg_data/pg_hba.conf={\"destination\":\"../config/pg_hba.conf\"}\n"
"pg_data/pg_tblspc/1={\"destination\":\"../../ts/1\"}\n"
"pg_data/pg_tblspc/2={\"destination\":\"../../ts/2\"}\n"
"pg_data/pg_xlog={\"destination\":\"{[path]}/wal\"}\n"
"pg_data/pg_xlog={\"destination\":\"" TEST_PATH "/wal\"}\n"
"pg_data/postgresql.conf={\"destination\":\"../config/postgresql.conf\"}\n"
TEST_MANIFEST_LINK_DEFAULT
"\n"
@ -932,7 +921,7 @@ testRun(void)
"pg_tblspc/2={}\n"
"pg_tblspc/2/PG_9.4_201409291={}\n"
"pg_tblspc/2/PG_9.4_201409291/1={}\n"
TEST_MANIFEST_PATH_DEFAULT))),
TEST_MANIFEST_PATH_DEFAULT)),
"check manifest");
storageRemoveP(storageTest, STRDEF("pg/pg_tblspc/2"), .errorOnMissing = true);
@ -952,11 +941,10 @@ testRun(void)
manifestNewBuild(storagePg, PG_VERSION_12, hrnPgCatalogVersion(PG_VERSION_12), false, false, NULL, NULL),
FileOpenError,
"unable to get info for missing path/file '%s/pg/pg_tblspc/1/PG_12_201909212': [2] No such file or directory",
testPath());
TEST_PATH);
// Remove the link inside pg/pg_tblspc
THROW_ON_SYS_ERROR(
unlink(strZ(strNewFmt("%s/pg/pg_tblspc/1", testPath()))) == -1, FileRemoveError, "unable to remove symlink");
THROW_ON_SYS_ERROR(unlink(TEST_PATH "/pg/pg_tblspc/1") == -1, FileRemoveError, "unable to remove symlink");
// Write a file into the directory pointed to by pg_xlog - contents will not be ignored online or offline
storagePutP(
@ -985,7 +973,7 @@ testRun(void)
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(hrnReplaceKey(
strNewBuf(harnessInfoChecksumZ(
TEST_MANIFEST_HEADER
TEST_MANIFEST_DB_12
TEST_MANIFEST_OPTION_ARCHIVE
@ -993,9 +981,9 @@ testRun(void)
TEST_MANIFEST_OPTION_ONLINE_TRUE
"\n"
"[backup:target]\n"
"pg_data={\"path\":\"{[path]}/pg\",\"type\":\"path\"}\n"
"pg_data={\"path\":\"" TEST_PATH "/pg\",\"type\":\"path\"}\n"
"pg_data/pg_hba.conf={\"file\":\"pg_hba.conf\",\"path\":\"../config\",\"type\":\"link\"}\n"
"pg_data/pg_xlog={\"path\":\"{[path]}/wal\",\"type\":\"link\"}\n"
"pg_data/pg_xlog={\"path\":\"" TEST_PATH "/wal\",\"type\":\"link\"}\n"
"pg_data/postgresql.conf={\"file\":\"postgresql.conf\",\"path\":\"../config\",\"type\":\"link\"}\n"
"\n"
"[target:file]\n"
@ -1020,7 +1008,7 @@ testRun(void)
"\n"
"[target:link]\n"
"pg_data/pg_hba.conf={\"destination\":\"../config/pg_hba.conf\"}\n"
"pg_data/pg_xlog={\"destination\":\"{[path]}/wal\"}\n"
"pg_data/pg_xlog={\"destination\":\"" TEST_PATH "/wal\"}\n"
"pg_data/postgresql.conf={\"destination\":\"../config/postgresql.conf\"}\n"
TEST_MANIFEST_LINK_DEFAULT
"\n"
@ -1042,7 +1030,7 @@ testRun(void)
"pg_data/pg_wal={}\n"
"pg_data/pg_xact={}\n"
"pg_data/pg_xlog={}\n"
TEST_MANIFEST_PATH_DEFAULT))),
TEST_MANIFEST_PATH_DEFAULT)),
"check manifest");
// -------------------------------------------------------------------------------------------------------------------------
@ -1057,15 +1045,15 @@ testRun(void)
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(hrnReplaceKey(
strNewBuf(harnessInfoChecksumZ(
TEST_MANIFEST_HEADER
TEST_MANIFEST_DB_13
TEST_MANIFEST_OPTION_ALL
"\n"
"[backup:target]\n"
"pg_data={\"path\":\"{[path]}/pg\",\"type\":\"path\"}\n"
"pg_data={\"path\":\"" TEST_PATH "/pg\",\"type\":\"path\"}\n"
"pg_data/pg_hba.conf={\"file\":\"pg_hba.conf\",\"path\":\"../config\",\"type\":\"link\"}\n"
"pg_data/pg_xlog={\"path\":\"{[path]}/wal\",\"type\":\"link\"}\n"
"pg_data/pg_xlog={\"path\":\"" TEST_PATH "/wal\",\"type\":\"link\"}\n"
"pg_data/postgresql.conf={\"file\":\"postgresql.conf\",\"path\":\"../config\",\"type\":\"link\"}\n"
"\n"
"[target:file]\n"
@ -1089,7 +1077,7 @@ testRun(void)
"\n"
"[target:link]\n"
"pg_data/pg_hba.conf={\"destination\":\"../config/pg_hba.conf\"}\n"
"pg_data/pg_xlog={\"destination\":\"{[path]}/wal\"}\n"
"pg_data/pg_xlog={\"destination\":\"" TEST_PATH "/wal\"}\n"
"pg_data/postgresql.conf={\"destination\":\"../config/postgresql.conf\"}\n"
TEST_MANIFEST_LINK_DEFAULT
"\n"
@ -1111,22 +1099,19 @@ testRun(void)
"pg_data/pg_wal={}\n"
"pg_data/pg_xact={}\n"
"pg_data/pg_xlog={}\n"
TEST_MANIFEST_PATH_DEFAULT))),
TEST_MANIFEST_PATH_DEFAULT)),
"check manifest");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("error on link to pg_data");
THROW_ON_SYS_ERROR(
symlink(strZ(strNewFmt("%s/pg/base", testPath())), strZ(strNewFmt("%s/pg/link", testPath()))) == -1,
FileOpenError, "unable to create symlink");
THROW_ON_SYS_ERROR(symlink(TEST_PATH "/pg/base", TEST_PATH "/pg/link") == -1, FileOpenError, "unable to create symlink");
TEST_ERROR(
manifestNewBuild(storagePg, PG_VERSION_94, hrnPgCatalogVersion(PG_VERSION_94), false, false, NULL, NULL),
LinkDestinationError, "link 'link' destination '{[path]}/pg/base' is in PGDATA");
LinkDestinationError, "link 'link' destination '" TEST_PATH "/pg/base' is in PGDATA");
THROW_ON_SYS_ERROR(
unlink(strZ(strNewFmt("%s/pg/link", testPath()))) == -1, FileRemoveError, "unable to remove symlink");
THROW_ON_SYS_ERROR(unlink(TEST_PATH "/pg/link") == -1, FileRemoveError, "unable to remove symlink");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("error on path in pg_tblspc");
@ -1153,31 +1138,26 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("error on link that points to nothing");
THROW_ON_SYS_ERROR(
symlink("../bogus-link", strZ(strNewFmt("%s/pg/link-to-link", testPath()))) == -1, FileOpenError,
"unable to create symlink");
THROW_ON_SYS_ERROR(symlink("../bogus-link", TEST_PATH "/pg/link-to-link") == -1, FileOpenError, "unable to create symlink");
TEST_ERROR(
manifestNewBuild(storagePg, PG_VERSION_94, hrnPgCatalogVersion(PG_VERSION_94), false, true, NULL, NULL), FileOpenError,
"unable to get info for missing path/file '{[path]}/pg/link-to-link': [2] No such file or directory");
"unable to get info for missing path/file '" TEST_PATH "/pg/link-to-link': [2] No such file or directory");
THROW_ON_SYS_ERROR(
unlink(strZ(strNewFmt("%s/pg/link-to-link", testPath()))) == -1, FileRemoveError, "unable to remove symlink");
THROW_ON_SYS_ERROR(unlink(TEST_PATH "/pg/link-to-link") == -1, FileRemoveError, "unable to remove symlink");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("error on link to a link");
storagePathCreateP(storageTest, STRDEF("linktestdir"), .mode = 0777);
THROW_ON_SYS_ERROR(
symlink(strZ(strNewFmt("%s/linktestdir", testPath())), strZ(strNewFmt("%s/linktest", testPath()))) == -1,
FileOpenError, "unable to create symlink");
symlink(TEST_PATH "/linktestdir", TEST_PATH "/linktest") == -1, FileOpenError, "unable to create symlink");
THROW_ON_SYS_ERROR(
symlink(strZ(strNewFmt("%s/linktest", testPath())), strZ(strNewFmt("%s/pg/linktolink", testPath()))) == -1,
FileOpenError, "unable to create symlink");
symlink(TEST_PATH "/linktest", TEST_PATH "/pg/linktolink") == -1, FileOpenError, "unable to create symlink");
TEST_ERROR_FMT(
TEST_ERROR(
manifestNewBuild(storagePg, PG_VERSION_94, hrnPgCatalogVersion(PG_VERSION_94), false, false, NULL, NULL),
LinkDestinationError, "link '%s/pg/linktolink' cannot reference another link '%s/linktest'", testPath(), testPath());
LinkDestinationError, "link '" TEST_PATH "/pg/linktolink' cannot reference another link '" TEST_PATH "/linktest'");
#undef TEST_MANIFEST_HEADER
#undef TEST_MANIFEST_DB_83
@ -1339,7 +1319,7 @@ testRun(void)
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(hrnReplaceKey(
strNewBuf(harnessInfoChecksumZ(
TEST_MANIFEST_HEADER_PRE
"option-delta=false\n"
TEST_MANIFEST_HEADER_POST
@ -1357,7 +1337,7 @@ testRun(void)
"\n"
"[target:path]\n"
"pg_data={}\n"
TEST_MANIFEST_PATH_DEFAULT))),
TEST_MANIFEST_PATH_DEFAULT)),
"check manifest");
// -------------------------------------------------------------------------------------------------------------------------
@ -1389,7 +1369,7 @@ testRun(void)
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(hrnReplaceKey(
strNewBuf(harnessInfoChecksumZ(
TEST_MANIFEST_HEADER_PRE
"option-delta=true\n"
TEST_MANIFEST_HEADER_POST
@ -1406,7 +1386,7 @@ testRun(void)
"\n"
"[target:path]\n"
"pg_data={}\n"
TEST_MANIFEST_PATH_DEFAULT))),
TEST_MANIFEST_PATH_DEFAULT)),
"check manifest");
// -------------------------------------------------------------------------------------------------------------------------
@ -1443,7 +1423,7 @@ testRun(void)
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(hrnReplaceKey(
strNewBuf(harnessInfoChecksumZ(
TEST_MANIFEST_HEADER_PRE
"option-delta=true\n"
TEST_MANIFEST_HEADER_POST
@ -1459,7 +1439,7 @@ testRun(void)
"\n"
"[target:path]\n"
"pg_data={}\n"
TEST_MANIFEST_PATH_DEFAULT))),
TEST_MANIFEST_PATH_DEFAULT)),
"check manifest");
// -------------------------------------------------------------------------------------------------------------------------
@ -1495,7 +1475,7 @@ testRun(void)
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(hrnReplaceKey(
strNewBuf(harnessInfoChecksumZ(
TEST_MANIFEST_HEADER_PRE
"option-delta=true\n"
TEST_MANIFEST_HEADER_POST
@ -1510,7 +1490,7 @@ testRun(void)
"\n"
"[target:path]\n"
"pg_data={}\n"
TEST_MANIFEST_PATH_DEFAULT))),
TEST_MANIFEST_PATH_DEFAULT)),
"check manifest");
// -------------------------------------------------------------------------------------------------------------------------
@ -1557,7 +1537,7 @@ testRun(void)
TEST_RESULT_VOID(manifestSave(manifest, ioBufferWriteNew(contentSave)), "save manifest");
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(hrnReplaceKey(
strNewBuf(harnessInfoChecksumZ(
TEST_MANIFEST_HEADER_PRE
"option-delta=true\n"
"option-hardlink=false\n"
@ -1572,7 +1552,7 @@ testRun(void)
"\n"
"[target:path]\n"
"pg_data={}\n"
TEST_MANIFEST_PATH_DEFAULT))),
TEST_MANIFEST_PATH_DEFAULT)),
"check manifest");
#undef TEST_MANIFEST_HEADER_PRE
@ -2058,12 +2038,11 @@ testRun(void)
{
Manifest *manifest = NULL;
TEST_ERROR_FMT(
TEST_ERROR(
manifestLoadFile(storageTest, BACKUP_MANIFEST_FILE_STR, cipherTypeNone, NULL), FileMissingError,
"unable to load backup manifest file '%s/backup.manifest' or '%s/backup.manifest.copy':\n"
"FileMissingError: unable to open missing file '%s/backup.manifest' for read\n"
"FileMissingError: unable to open missing file '%s/backup.manifest.copy' for read",
testPath(), testPath(), testPath(), testPath());
"unable to load backup manifest file '" TEST_PATH "/backup.manifest' or '" TEST_PATH "/backup.manifest.copy':\n"
"FileMissingError: unable to open missing file '" TEST_PATH "/backup.manifest' for read\n"
"FileMissingError: unable to open missing file '" TEST_PATH "/backup.manifest.copy' for read");
// Also use this test to check that extra sections/keys are ignored using coverage.
// -------------------------------------------------------------------------------------------------------------------------

View File

@ -144,8 +144,8 @@ testRun(void)
if (testBegin("storageInfoList()"))
{
// One million files represents a fairly large cluster
CHECK(testScale() <= 2000);
uint64_t fileTotal = (uint64_t)1000000 * testScale();
CHECK(TEST_SCALE <= 2000);
uint64_t fileTotal = (uint64_t)1000000 * TEST_SCALE;
HARNESS_FORK_BEGIN()
{
@ -223,8 +223,8 @@ testRun(void)
ioBufferSizeSet(4 * 1024 * 1024);
// 1MB is a fairly normal table size
CHECK(testScale() <= 1024 * 1024 * 1024);
uint64_t blockTotal = (uint64_t)1 * testScale();
CHECK(TEST_SCALE <= 1024 * 1024 * 1024);
uint64_t blockTotal = (uint64_t)1 * TEST_SCALE;
// Set iteration
unsigned int iteration = 1;
@ -234,7 +234,7 @@ testRun(void)
uint64_t rateOut = 0; // MB/s (0 disables)
// Get the sample pages from disk
Buffer *block = storageGetP(storageNewReadP(storagePosixNewP(STR(testRepoPath())), STRDEF("test/data/filecopy.table.bin")));
Buffer *block = storageGetP(storageNewReadP(storagePosixNewP(HRN_PATH_REPO_STR), STRDEF("test/data/filecopy.table.bin")));
ASSERT(bufUsed(block) == 1024 * 1024);
// Build the input buffer

View File

@ -153,8 +153,8 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("lstFind()"))
{
CHECK(testScale() <= 10000);
int testMax = 100000 * (int)testScale();
CHECK(TEST_SCALE <= 10000);
int testMax = 100000 * (int)TEST_SCALE;
// Generate a large list of values (use int instead of string so there fewer allocations)
List *list = lstNewP(sizeof(int), .comparator = testComparator);
@ -190,8 +190,8 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("lstRemoveIdx()"))
{
CHECK(testScale() <= 10000);
int testMax = 1000000 * (int)testScale();
CHECK(TEST_SCALE <= 10000);
int testMax = 1000000 * (int)TEST_SCALE;
// Generate a large list of values (use int instead of string so there fewer allocations)
List *list = lstNewP(sizeof(int));
@ -217,10 +217,10 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("iniLoad()"))
{
CHECK(testScale() <= 10000);
CHECK(TEST_SCALE <= 10000);
String *iniStr = strNewZ("[section1]\n");
unsigned int iniMax = 100000 * (unsigned int)testScale();
unsigned int iniMax = 100000 * (unsigned int)TEST_SCALE;
for (unsigned int keyIdx = 0; keyIdx < iniMax; keyIdx++)
strCatFmt(iniStr, "key%u=\"value%u\"\n", keyIdx, keyIdx);
@ -240,13 +240,13 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("manifestNewBuild()/manifestNewLoad()/manifestSave()"))
{
CHECK(testScale() <= 1000000);
CHECK(TEST_SCALE <= 1000000);
// Create a storage driver to test manifest build with an arbitrary number of files
StorageTestManifestNewBuild driver =
{
.interface = storageInterfaceTestDummy,
.fileTotal = 100000 * (unsigned int)testScale(),
.fileTotal = 100000 * (unsigned int)TEST_SCALE,
};
driver.interface.info = storageTestManifestNewBuildInfo;
@ -324,7 +324,7 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("statistics collector"))
{
CHECK(testScale() <= 1000000);
CHECK(TEST_SCALE <= 1000000);
// Setup a list of stats to use for testing
#define TEST_STAT_TOTAL 100
@ -333,7 +333,7 @@ testRun(void)
for (unsigned int statIdx = 0; statIdx < TEST_STAT_TOTAL; statIdx++)
statList[statIdx] = strNewFmt("STAT%u", statIdx);
uint64_t runTotal = (uint64_t)testScale() * (uint64_t)100000;
uint64_t runTotal = (uint64_t)TEST_SCALE * (uint64_t)100000;
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE_FMT("update %d stats %" PRIu64 " times", TEST_STAT_TOTAL, runTotal);

View File

@ -35,7 +35,7 @@ testRun(void)
if (system("sudo pg_ctlcluster 11 test start") != 0)
THROW(AssertError, "unable to start cluster");
if (system(strZ(strNewFmt("sudo -u postgres psql -c 'create user %s superuser'", testUser()))) != 0)
if (system("sudo -u postgres psql -c 'create user " TEST_USER " superuser'") != 0)
THROW(AssertError, "unable to create superuser");
#endif
@ -105,15 +105,15 @@ testRun(void)
#ifndef HARNESS_PQ_REAL
harnessPqScriptSet((HarnessPq [])
{
{.function = HRNPQ_CONNECTDB, .param = strZ(
strNewFmt("[\"dbname='postgres' port=5432 user='%s' host='/var/run/postgresql'\"]", testUser()))},
{.function = HRNPQ_CONNECTDB,
.param = "[\"dbname='postgres' port=5432 user='" TEST_USER "' host='/var/run/postgresql'\"]"},
{.function = HRNPQ_STATUS, .resultInt = CONNECTION_OK},
{.function = NULL}
});
#endif
TEST_ASSIGN(
client, pgClientOpen(pgClientNew(STRDEF("/var/run/postgresql"), 5432, STRDEF("postgres"), strNewZ(testUser()), 500)),
client, pgClientOpen(pgClientNew(STRDEF("/var/run/postgresql"), 5432, STRDEF("postgres"), TEST_USER_STR, 500)),
"new client");
// Invalid query

View File

@ -13,7 +13,7 @@ testRun(void)
{
FUNCTION_HARNESS_VOID();
Storage *storageTest = storagePosixNewP(strNewZ(testPath()), .write = true);
Storage *storageTest = storagePosixNewP(TEST_PATH_STR, .write = true);
// *****************************************************************************************************************************
if (testBegin("pgVersionFromStr() and pgVersionToStr()"))
@ -185,7 +185,7 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("pgWalFromBuffer() and pgWalFromFile()"))
{
String *walFile = strNewFmt("%s/0000000F0000000F0000000F", testPath());
const String *walFile = STRDEF(TEST_PATH "/0000000F0000000F0000000F");
// Create a bogus control file, initially not in long format)
// --------------------------------------------------------------------------------------------------------------------------

View File

@ -149,7 +149,7 @@ testRun(void)
{
FUNCTION_HARNESS_VOID();
Storage *storageTest = storagePosixNewP(strNewZ(testPath()), .write = true);
Storage *storageTest = storagePosixNewP(TEST_PATH_STR, .write = true);
// *****************************************************************************************************************************
if (testBegin("repoIsLocal() and pgIsLocal()"))
@ -296,9 +296,9 @@ testRun(void)
strLstAddZ(argList, "--repo1-host=repo-host");
strLstAddZ(argList, "--repo1-host-user=repo-host-user");
// Local config settings should never be passed to the remote
strLstAdd(argList, strNewFmt("--config=%s/pgbackrest.conf", testPath()));
strLstAdd(argList, strNewFmt("--config-include-path=%s", testPath()));
strLstAdd(argList, strNewFmt("--config-path=%s", testPath()));
strLstAddZ(argList, "--config=" TEST_PATH "/pgbackrest.conf");
strLstAddZ(argList, "--config-include-path=" TEST_PATH);
strLstAddZ(argList, "--config-path=" TEST_PATH);
strLstAddZ(argList, "archive-get");
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
@ -992,8 +992,8 @@ testRun(void)
strLstAddZ(argList, "--stanza=db");
strLstAddZ(argList, "--protocol-timeout=10");
strLstAddZ(argList, "--repo1-host=localhost");
strLstAdd(argList, strNewFmt("--repo1-host-user=%s", testUser()));
strLstAdd(argList, strNewFmt("--repo1-path=%s", testPath()));
strLstAddZ(argList, "--repo1-host-user=" TEST_USER);
strLstAddZ(argList, "--repo1-path=" TEST_PATH);
harnessCfgLoad(cfgCmdInfo, argList);
ProtocolClient *client = NULL;
@ -1020,10 +1020,10 @@ testRun(void)
strLstAddZ(argList, "--stanza=db");
hrnCfgArgRawZ(argList, cfgOptPgPath, "/path/to/pg");
strLstAddZ(argList, "--protocol-timeout=10");
strLstAdd(argList, strNewFmt("--config=%s/pgbackrest.conf", testPath()));
strLstAddZ(argList, "--config=" TEST_PATH "/pgbackrest.conf");
strLstAddZ(argList, "--repo1-host=localhost");
strLstAdd(argList, strNewFmt("--repo1-host-user=%s", testUser()));
strLstAdd(argList, strNewFmt("--repo1-path=%s", testPath()));
strLstAddZ(argList, "--repo1-host-user=" TEST_USER);
strLstAddZ(argList, "--repo1-path=" TEST_PATH);
strLstAddZ(argList, "--process=999");
hrnCfgArgRawStrId(argList, cfgOptRemoteType, protocolStorageTypePg);
harnessCfgLoadRole(cfgCmdArchiveGet, cfgCmdRoleLocal, argList);
@ -1050,14 +1050,14 @@ testRun(void)
strLstAddZ(argList, "--stanza=db");
strLstAddZ(argList, "--pg1-path=/pg");
strLstAddZ(argList, "--protocol-timeout=10");
strLstAdd(argList, strNewFmt("--repo1-host-config=%s/pgbackrest.conf", testPath()));
strLstAddZ(argList, "--repo1-host-config=" TEST_PATH "/pgbackrest.conf");
strLstAddZ(argList, "--repo1-host=localhost");
strLstAdd(argList, strNewFmt("--repo1-host-user=%s", testUser()));
strLstAdd(argList, strNewFmt("--repo1-path=%s", testPath()));
strLstAdd(argList, strNewFmt("--repo2-host-config=%s/pgbackrest.conf", testPath()));
strLstAddZ(argList, "--repo1-host-user=" TEST_USER);
strLstAddZ(argList, "--repo1-path=" TEST_PATH);
strLstAddZ(argList, "--repo2-host-config=" TEST_PATH "/pgbackrest.conf");
strLstAddZ(argList, "--repo2-host=localhost");
strLstAdd(argList, strNewFmt("--repo2-host-user=%s", testUser()));
strLstAdd(argList, strNewFmt("--repo2-path=%s2", testPath()));
strLstAddZ(argList, "--repo2-host-user=" TEST_USER);
strLstAddZ(argList, "--repo2-path=" TEST_PATH "2");
harnessCfgLoad(cfgCmdCheck, argList);
TEST_RESULT_PTR(cfgOptionIdxStrNull(cfgOptRepoCipherPass, 0), NULL, "check repo1 cipher pass before");
@ -1077,8 +1077,8 @@ testRun(void)
strLstAddZ(argList, "--protocol-timeout=10");
strLstAddZ(argList, "--repo1-retention-full=1");
strLstAddZ(argList, "--pg1-host=localhost");
strLstAdd(argList, strNewFmt("--pg1-host-user=%s", testUser()));
strLstAdd(argList, strNewFmt("--pg1-path=%s", testPath()));
strLstAddZ(argList, "--pg1-host-user=" TEST_USER);
strLstAddZ(argList, "--pg1-path=" TEST_PATH);
harnessCfgLoad(cfgCmdBackup, argList);
TEST_ASSIGN(client, protocolRemoteGet(protocolStorageTypePg, 0), "get remote protocol");

View File

@ -290,7 +290,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptRepoAzureContainer, TEST_CONTAINER);
hrnCfgArgRaw(argList, cfgOptRepoStorageHost, hrnServerHost());
hrnCfgArgRawFmt(argList, cfgOptRepoStoragePort, "%u", hrnServerPort(0));
hrnCfgArgRawBool(argList, cfgOptRepoStorageVerifyTls, testContainer());
hrnCfgArgRawBool(argList, cfgOptRepoStorageVerifyTls, TEST_IN_CONTAINER);
hrnCfgEnvRawZ(cfgOptRepoAzureAccount, TEST_ACCOUNT);
hrnCfgEnvRawZ(cfgOptRepoAzureKey, TEST_KEY_SHARED);
harnessCfgLoad(cfgCmdArchivePush, argList);

View File

@ -19,7 +19,7 @@ testRun(void)
strLstAddZ(argList, "--stanza=db");
hrnCfgArgRawZ(argList, cfgOptPgPath, "/path/to/pg");
strLstAddZ(argList, "--repo1-type=cifs");
strLstAdd(argList, strNewFmt("--repo1-path=%s", testPath()));
strLstAddZ(argList, "--repo1-path=" TEST_PATH);
harnessCfgLoad(cfgCmdArchiveGet, argList);
const Storage *storage = NULL;

View File

@ -184,7 +184,7 @@ testRun(void)
{
FUNCTION_HARNESS_VOID();
Storage *storageTest = storagePosixNewP(strNewZ(testPath()), .write = true);
Storage *storageTest = storagePosixNewP(TEST_PATH_STR, .write = true);
// Get test host and ports
const String *const testHost = hrnServerHost();
@ -327,7 +327,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptRepoPath, "/");
hrnCfgArgRawZ(argList, cfgOptRepoGcsBucket, TEST_BUCKET);
hrnCfgArgRawFmt(argList, cfgOptRepoGcsEndpoint, "%s:%u", strZ(hrnServerHost()), testPort);
hrnCfgArgRawBool(argList, cfgOptRepoStorageVerifyTls, testContainer());
hrnCfgArgRawBool(argList, cfgOptRepoStorageVerifyTls, TEST_IN_CONTAINER);
hrnCfgEnvRawZ(cfgOptRepoGcsKey, TEST_KEY_FILE);
harnessCfgLoad(cfgCmdArchivePush, argList);
hrnCfgEnvRemoveRaw(cfgOptRepoGcsKey);

View File

@ -45,18 +45,18 @@ testRun(void)
FUNCTION_HARNESS_VOID();
// Create default storage object for testing
Storage *storageTest = storagePosixNewP(strNewZ(testPath()), .write = true);
Storage *storageTest = storagePosixNewP(TEST_PATH_STR, .write = true);
Storage *storageTmp = storagePosixNewP(STRDEF("/tmp"), .write = true);
ioBufferSizeSet(2);
// Directory and file that cannot be accessed to test permissions errors
#ifdef TEST_CONTAINER_REQUIRED
String *fileNoPerm = strNewFmt("%s/noperm/noperm", testPath());
const String *fileNoPerm = STRDEF(TEST_PATH "/noperm/noperm");
String *pathNoPerm = strPath(fileNoPerm);
#endif // TEST_CONTAINER_REQUIRED
// Write file for testing if storage is read-only
String *writeFile = strNewFmt("%s/writefile", testPath());
const String *writeFile = STRDEF(TEST_PATH "/writefile");
// This test should always be first so the storage helper is uninitialized
// *****************************************************************************************************************************
@ -135,8 +135,8 @@ testRun(void)
#endif // TEST_CONTAINER_REQUIRED
// -------------------------------------------------------------------------------------------------------------------------
String *fileExists = strNewFmt("%s/exists", testPath());
String *pathExists = strNewFmt("%s/pathExists", testPath());
const String *fileExists = STRDEF(TEST_PATH "/exists");
const String *pathExists = STRDEF(TEST_PATH "/pathExists");
TEST_RESULT_INT(system(strZ(strNewFmt("touch %s", strZ(fileExists)))), 0, "create exists file");
TEST_SYSTEM_FMT("mkdir %s", strZ(pathExists));
@ -182,7 +182,7 @@ testRun(void)
TEST_RESULT_BOOL(storageInfoP(storagePosixNewP(FSLASH_STR), NULL).exists, true, "info for /");
// -------------------------------------------------------------------------------------------------------------------------
String *fileName = strNewFmt("%s/fileinfo", testPath());
const String *fileName = STRDEF(TEST_PATH "/fileinfo");
TEST_ERROR_FMT(
storageInfoP(storageTest, fileName), FileOpenError, STORAGE_ERROR_INFO_MISSING ": [2] No such file or directory",
@ -198,15 +198,15 @@ testRun(void)
TEST_ERROR(
storageInfoP(storageTest, STRDEF("/etc"), .ignoreMissing = true), AssertError,
"absolute path '/etc' is not in base path '{[path]}'");
"absolute path '/etc' is not in base path '" TEST_PATH "'");
TEST_RESULT_BOOL(
storageInfoP(storageTest, STRDEF("/etc"), .ignoreMissing = true, .noPathEnforce = true).exists, true,
"path not enforced");
// -------------------------------------------------------------------------------------------------------------------------
HRN_STORAGE_TIME(storageTest, testPath(), 1555160000);
HRN_STORAGE_TIME(storageTest, TEST_PATH, 1555160000);
TEST_ASSIGN(info, storageInfoP(storageTest, strNewZ(testPath())), "get path info");
TEST_ASSIGN(info, storageInfoP(storageTest, TEST_PATH_STR), "get path info");
TEST_RESULT_STR(info.name, NULL, " name is not set");
TEST_RESULT_BOOL(info.exists, true, " check exists");
TEST_RESULT_INT(info.type, storageTypePath, " check type");
@ -214,10 +214,10 @@ testRun(void)
TEST_RESULT_INT(info.mode, 0770, " check mode");
TEST_RESULT_INT(info.timeModified, 1555160000, " check mod time");
TEST_RESULT_STR(info.linkDestination, NULL, " no link destination");
TEST_RESULT_UINT(info.userId, getuid(), " check user id");
TEST_RESULT_STR_Z(info.user, testUser(), " check user");
TEST_RESULT_UINT(info.groupId, getgid(), " check group id");
TEST_RESULT_STR_Z(info.group, testGroup(), " check group");
TEST_RESULT_UINT(info.userId, TEST_USER_ID, " check user id");
TEST_RESULT_STR(info.user, TEST_USER_STR, " check user");
TEST_RESULT_UINT(info.groupId, TEST_GROUP_ID, " check group id");
TEST_RESULT_STR(info.group, TEST_GROUP_STR, " check group");
// -------------------------------------------------------------------------------------------------------------------------
const Buffer *buffer = BUFSTRDEF("TESTFILE");
@ -245,7 +245,7 @@ testRun(void)
storageRemoveP(storageTest, fileName, .errorOnMissing = true);
// -------------------------------------------------------------------------------------------------------------------------
String *linkName = strNewFmt("%s/testlink", testPath());
const String *linkName = STRDEF(TEST_PATH "/testlink");
TEST_RESULT_INT(system(strZ(strNewFmt("ln -s /tmp %s", strZ(linkName)))), 0, "create link");
TEST_ASSIGN(info, storageInfoP(storageTest, linkName), "get link info");
@ -255,8 +255,8 @@ testRun(void)
TEST_RESULT_UINT(info.size, 0, " check size");
TEST_RESULT_INT(info.mode, 0777, " check mode");
TEST_RESULT_STR_Z(info.linkDestination, "/tmp", " check link destination");
TEST_RESULT_STR_Z(info.user, testUser(), " check user");
TEST_RESULT_STR_Z(info.group, testGroup(), " check group");
TEST_RESULT_STR(info.user, TEST_USER_STR, " check user");
TEST_RESULT_STR(info.group, TEST_GROUP_STR, " check group");
TEST_ASSIGN(info, storageInfoP(storageTest, linkName, .followLink = true), "get info from path pointed to by link");
TEST_RESULT_STR(info.name, NULL, " name is not set");
@ -271,7 +271,7 @@ testRun(void)
storageRemoveP(storageTest, linkName, .errorOnMissing = true);
// -------------------------------------------------------------------------------------------------------------------------
String *pipeName = strNewFmt("%s/testpipe", testPath());
const String *pipeName = STRDEF(TEST_PATH "/testpipe");
TEST_RESULT_INT(system(strZ(strNewFmt("mkfifo -m 666 %s", strZ(pipeName)))), 0, "create pipe");
TEST_ASSIGN(info, storageInfoP(storageTest, pipeName), "get info from pipe (special file)");
@ -281,8 +281,8 @@ testRun(void)
TEST_RESULT_UINT(info.size, 0, " check size");
TEST_RESULT_INT(info.mode, 0666, " check mode");
TEST_RESULT_STR(info.linkDestination, NULL, " check link destination");
TEST_RESULT_STR_Z(info.user, testUser(), " check user");
TEST_RESULT_STR_Z(info.group, testGroup(), " check group");
TEST_RESULT_STR(info.user, TEST_USER_STR, " check user");
TEST_RESULT_STR(info.group, TEST_GROUP_STR, " check group");
storageRemoveP(storageTest, pipeName, .errorOnMissing = true);
}
@ -297,7 +297,7 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
TEST_ERROR_FMT(
storageInfoListP(storageTest, STRDEF(BOGUS_STR), (StorageInfoListCallback)1, NULL, .errorOnMissing = true),
PathMissingError, STORAGE_ERROR_LIST_INFO_MISSING, strZ(strNewFmt("%s/BOGUS", testPath())));
PathMissingError, STORAGE_ERROR_LIST_INFO_MISSING, strZ(strNewFmt("%s/BOGUS", TEST_PATH)));
TEST_RESULT_BOOL(
storageInfoListP(storageTest, STRDEF(BOGUS_STR), (StorageInfoListCallback)1, NULL), false, "ignore missing dir");
@ -334,19 +334,18 @@ testRun(void)
TEST_RESULT_VOID(
storageInfoListP(storageTest, STRDEF("pg"), hrnStorageInfoListCallback, &callbackData),
"directory with one dot file sorted");
TEST_RESULT_STR_Z(
callbackData.content, strZ(strNewFmt(". {path, m=0766, u=%s, g=%s}\n", testUser(), testGroup())), " check content");
TEST_RESULT_STR_Z(callbackData.content, ". {path, m=0766, u=" TEST_USER ", g=" TEST_GROUP "}\n", " check content");
// -------------------------------------------------------------------------------------------------------------------------
#ifdef TEST_CONTAINER_REQUIRED
storagePathCreateP(storageTest, STRDEF("pg/.include"), .mode = 0755);
ASSERT(system(strZ(strNewFmt("sudo chown 77777:77777 %s/pg/.include", testPath()))) == 0);
ASSERT(system(strZ(strNewFmt("sudo chown 77777:77777 %s/pg/.include", TEST_PATH))) == 0);
#endif // TEST_CONTAINER_REQUIRED
storagePutP(storageNewWriteP(storageTest, STRDEF("pg/file"), .modeFile = 0660), BUFSTRDEF("TESTDATA"));
ASSERT(system(strZ(strNewFmt("ln -s ../file %s/pg/link", testPath()))) == 0);
ASSERT(system(strZ(strNewFmt("mkfifo -m 777 %s/pg/pipe", testPath()))) == 0);
ASSERT(system(strZ(strNewFmt("ln -s ../file %s/pg/link", TEST_PATH))) == 0);
ASSERT(system(strZ(strNewFmt("mkfifo -m 777 %s/pg/pipe", TEST_PATH))) == 0);
callbackData = (HarnessStorageInfoListCallbackData)
{
@ -374,7 +373,7 @@ testRun(void)
" check content");
#ifdef TEST_CONTAINER_REQUIRED
ASSERT(system(strZ(strNewFmt("sudo rmdir %s/pg/.include", testPath()))) == 0);
ASSERT(system(strZ(strNewFmt("sudo rmdir %s/pg/.include", TEST_PATH))) == 0);
#endif // TEST_CONTAINER_REQUIRED
// -------------------------------------------------------------------------------------------------------------------------
@ -433,7 +432,7 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
TEST_ERROR_FMT(
storageListP(storageTest, STRDEF(BOGUS_STR), .errorOnMissing = true), PathMissingError, STORAGE_ERROR_LIST_INFO_MISSING,
strZ(strNewFmt("%s/BOGUS", testPath())));
strZ(strNewFmt("%s/BOGUS", TEST_PATH)));
TEST_RESULT_PTR(storageListP(storageTest, STRDEF(BOGUS_STR), .nullOnMissing = true), NULL, "null for missing dir");
TEST_RESULT_UINT(strLstSize(storageListP(storageTest, STRDEF(BOGUS_STR))), 0, "empty list for missing dir");
@ -468,8 +467,8 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("storageCopy()"))
{
String *sourceFile = strNewFmt("%s/source.txt", testPath());
String *destinationFile = strNewFmt("%s/destination.txt", testPath());
const String *sourceFile = STRDEF(TEST_PATH "/source.txt");
const String *const destinationFile = STRDEF(TEST_PATH "/destination.txt");
StorageRead *source = storageNewReadP(storageTest, sourceFile);
StorageWrite *destination = storageNewWriteP(storageTest, destinationFile);
@ -501,8 +500,8 @@ testRun(void)
TEST_CREATE_NOPERM();
#endif // TEST_CONTAINER_REQUIRED
String *sourceFile = strNewFmt("%s/source.txt", testPath());
String *destinationFile = strNewFmt("%s/sub/destination.txt", testPath());
const String *sourceFile = STRDEF(TEST_PATH "/source.txt");
const String *destinationFile = STRDEF(TEST_PATH "/sub/destination.txt");
StorageRead *source = storageNewReadP(storageTest, sourceFile);
StorageWrite *destination = storageNewWriteP(storageTest, destinationFile);
@ -544,7 +543,7 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
sourceFile = destinationFile;
source = storageNewReadP(storageTest, sourceFile);
destinationFile = strNewFmt("%s/sub/destination2.txt", testPath());
destinationFile = STRDEF(TEST_PATH "/sub/destination2.txt");
destination = storageNewWriteP(storageTest, destinationFile);
TEST_RESULT_VOID(storageMoveP(storageTest, source, destination), "move file to same path");
@ -552,7 +551,7 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
sourceFile = destinationFile;
source = storageNewReadP(storageTest, sourceFile);
destinationFile = strNewFmt("%s/source.txt", testPath());
destinationFile = STRDEF(TEST_PATH "/source.txt");
destination = storageNewWriteP(storageTest, destinationFile, .noSyncPath = true);
TEST_RESULT_VOID(storageMoveP(storageTest, source, destination), "move file to parent path (no sync)");
@ -572,7 +571,7 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
sourceFile = destinationFile;
source = storageNewReadP(storageTmp, sourceFile);
destinationFile = strNewFmt("%s/source.txt", testPath());
destinationFile = STRDEF(TEST_PATH "/source.txt");
destination = storageNewWriteP(storageTest, destinationFile, .noSyncPath = true);
TEST_RESULT_VOID(storageMoveP(storageTest, source, destination), "move file to another filesystem without path sync");
@ -636,24 +635,24 @@ testRun(void)
TEST_RESULT_VOID(storagePathCreateP(storageTest, STRDEF("sub1")), "create sub1 again");
TEST_ERROR_FMT(
storagePathCreateP(storageTest, STRDEF("sub1"), .errorOnExists = true), PathCreateError,
"unable to create path '%s/sub1': [17] File exists", testPath());
"unable to create path '%s/sub1': [17] File exists", TEST_PATH);
TEST_RESULT_VOID(storagePathCreateP(storageTest, STRDEF("sub2"), .mode = 0777), "create sub2 with custom mode");
TEST_RESULT_INT(storageInfoP(storageTest, STRDEF("sub2")).mode, 0777, "check sub2 dir mode");
TEST_ERROR_FMT(
storagePathCreateP(storageTest, STRDEF("sub3/sub4"), .noParentCreate = true), PathCreateError,
"unable to create path '%s/sub3/sub4': [2] No such file or directory", testPath());
"unable to create path '%s/sub3/sub4': [2] No such file or directory", TEST_PATH);
TEST_RESULT_VOID(storagePathCreateP(storageTest, STRDEF("sub3/sub4")), "create sub3/sub4");
TEST_RESULT_INT(system(strZ(strNewFmt("rm -rf %s/sub*", testPath()))), 0, "remove sub paths");
TEST_RESULT_INT(system(strZ(strNewFmt("rm -rf %s/sub*", TEST_PATH))), 0, "remove sub paths");
}
// *****************************************************************************************************************************
if (testBegin("storagePathRemove()"))
{
// -------------------------------------------------------------------------------------------------------------------------
String *pathRemove1 = strNewFmt("%s/remove1", testPath());
const String *pathRemove1 = STRDEF(TEST_PATH "/remove1");
TEST_ERROR_FMT(
storagePathRemoveP(storageTest, pathRemove1, .errorOnMissing = true), PathRemoveError,
@ -723,7 +722,7 @@ testRun(void)
#endif // TEST_CONTAINER_REQUIRED
// -------------------------------------------------------------------------------------------------------------------------
String *pathName = strNewFmt("%s/testpath", testPath());
const String *pathName = STRDEF(TEST_PATH "/testpath");
TEST_ERROR_FMT(
storagePathSyncP(storageTest, pathName), PathMissingError, STORAGE_ERROR_PATH_SYNC_MISSING, strZ(pathName));
@ -742,7 +741,7 @@ testRun(void)
if (testBegin("storageNewRead()"))
{
StorageRead *file = NULL;
String *fileName = strNewFmt("%s/readtest.txt", testPath());
const String *fileName = STRDEF(TEST_PATH "/readtest.txt");
TEST_ASSIGN(file, storageNewReadP(storageTest, fileName), "new read file (defaults)");
TEST_ERROR_FMT(ioReadOpen(storageReadIo(file)), FileMissingError, STORAGE_ERROR_READ_MISSING, strZ(fileName));
@ -758,7 +757,7 @@ testRun(void)
// *****************************************************************************************************************************
if (testBegin("storageNewWrite()"))
{
String *fileName = strNewFmt("%s/sub1/testfile", testPath());
const String *fileName = STRDEF(TEST_PATH "/sub1/testfile");
StorageWrite *file = NULL;
#ifdef TEST_CONTAINER_REQUIRED
@ -773,7 +772,7 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
TEST_ASSIGN(
file,
storageNewWriteP(storageTest, fileName, .user = strNewZ(testUser()), .group = strNewZ(testGroup()), .timeModified = 1),
storageNewWriteP(storageTest, fileName, .user = TEST_USER_STR, .group = TEST_GROUP_STR, .timeModified = 1),
"new write file (defaults)");
TEST_RESULT_VOID(ioWriteOpen(storageWriteIo(file)), " open file");
TEST_RESULT_INT(ioWriteFd(storageWriteIo(file)), ((StorageWritePosix *)file->driver)->fd, "check write fd");
@ -784,11 +783,11 @@ testRun(void)
// Test that a premature free (from error or otherwise) does not rename the file
// -------------------------------------------------------------------------------------------------------------------------
fileName = strNewFmt("%s/sub1/testfile-abort", testPath());
fileName = STRDEF(TEST_PATH "/sub1/testfile-abort");
String *fileNameTmp = strNewFmt("%s." STORAGE_FILE_TEMP_EXT, strZ(fileName));
TEST_ASSIGN(
file, storageNewWriteP(storageTest, fileName, .user = strNewZ(testUser())), "new write file (defaults)");
file, storageNewWriteP(storageTest, fileName, .user = TEST_USER_STR), "new write file (defaults)");
TEST_RESULT_VOID(ioWriteOpen(storageWriteIo(file)), " open file");
TEST_RESULT_VOID(ioWrite(storageWriteIo(file), BUFSTRDEF("TESTDATA")), "write data");
TEST_RESULT_VOID(ioWriteFlush(storageWriteIo(file)), "flush data");
@ -799,10 +798,10 @@ testRun(void)
TEST_RESULT_UINT(storageInfoP(storageTest, fileNameTmp).size, 8, " check temp file size");
// -------------------------------------------------------------------------------------------------------------------------
fileName = strNewFmt("%s/sub2/testfile", testPath());
fileName = STRDEF(TEST_PATH "/sub2/testfile");
TEST_ASSIGN(
file, storageNewWriteP(storageTest, fileName, .modePath = 0700, .modeFile = 0600, .group = strNewZ(testGroup())),
file, storageNewWriteP(storageTest, fileName, .modePath = 0700, .modeFile = 0600, .group = TEST_GROUP_STR),
"new write file (set mode)");
TEST_RESULT_VOID(ioWriteOpen(storageWriteIo(file)), " open file");
TEST_RESULT_VOID(ioWriteClose(storageWriteIo(file)), " close file");
@ -817,48 +816,46 @@ testRun(void)
Storage *storageTest = storagePosixNewP(STRDEF("/"), .write = true);
TEST_ERROR_FMT(
storageGetP(storageNewReadP(storageTest, strNewZ(testPath()))), FileReadError,
"unable to read '%s': [21] Is a directory", testPath());
storageGetP(storageNewReadP(storageTest, TEST_PATH_STR)), FileReadError,
"unable to read '%s': [21] Is a directory", TEST_PATH);
// -------------------------------------------------------------------------------------------------------------------------
String *emptyFile = strNewFmt("%s/test.empty", testPath());
const String *emptyFile = STRDEF(TEST_PATH "/test.empty");
TEST_RESULT_VOID(storagePutP(storageNewWriteP(storageTest, emptyFile), NULL), "put empty file");
TEST_RESULT_BOOL(storageExistsP(storageTest, emptyFile), true, "check empty file exists");
// -------------------------------------------------------------------------------------------------------------------------
const Buffer *buffer = BUFSTRDEF("TESTFILE\n");
TEST_RESULT_VOID(
storagePutP(storageNewWriteP(storageTest, strNewFmt("%s/test.txt", testPath())), buffer), "put test file");
TEST_RESULT_VOID(storagePutP(storageNewWriteP(storageTest, STRDEF(TEST_PATH "/test.txt")), buffer), "put test file");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_PTR(
storageGetP(storageNewReadP(storageTest, strNewFmt("%s/%s", testPath(), BOGUS_STR), .ignoreMissing = true)),
NULL, "get missing file");
storageGetP(storageNewReadP(storageTest, STRDEF(TEST_PATH "/" BOGUS_STR), .ignoreMissing = true)), NULL,
"get missing file");
// -------------------------------------------------------------------------------------------------------------------------
TEST_ASSIGN(buffer, storageGetP(storageNewReadP(storageTest, strNewFmt("%s/test.empty", testPath()))), "get empty");
TEST_ASSIGN(buffer, storageGetP(storageNewReadP(storageTest, STRDEF(TEST_PATH "/test.empty"))), "get empty");
TEST_RESULT_UINT(bufSize(buffer), 0, "size is 0");
// -------------------------------------------------------------------------------------------------------------------------
TEST_ASSIGN(buffer, storageGetP(storageNewReadP(storageTest, strNewFmt("%s/test.txt", testPath()))), "get text");
TEST_ASSIGN(buffer, storageGetP(storageNewReadP(storageTest, STRDEF(TEST_PATH "/test.txt"))), "get text");
TEST_RESULT_UINT(bufSize(buffer), 9, "check size");
TEST_RESULT_BOOL(memcmp(bufPtrConst(buffer), "TESTFILE\n", bufSize(buffer)) == 0, true, "check content");
// -------------------------------------------------------------------------------------------------------------------------
TEST_ASSIGN(
buffer, storageGetP(storageNewReadP(storageTest, strNewFmt("%s/test.txt", testPath())), .exactSize = 4), "get exact");
TEST_ASSIGN(buffer, storageGetP(storageNewReadP(storageTest, STRDEF(TEST_PATH "/test.txt")), .exactSize = 4), "get exact");
TEST_RESULT_UINT(bufSize(buffer), 4, "check size");
TEST_RESULT_BOOL(memcmp(bufPtrConst(buffer), "TEST", bufSize(buffer)) == 0, true, "check content");
TEST_ERROR_FMT(
storageGetP(storageNewReadP(storageTest, strNewFmt("%s/test.txt", testPath())), .exactSize = 64), FileReadError,
"unable to read 64 byte(s) from '%s/test.txt'", testPath());
storageGetP(storageNewReadP(storageTest, STRDEF(TEST_PATH "/test.txt")), .exactSize = 64), FileReadError,
"unable to read 64 byte(s) from '%s/test.txt'", TEST_PATH);
// -------------------------------------------------------------------------------------------------------------------------
ioBufferSizeSet(2);
TEST_ASSIGN(buffer, storageGetP(storageNewReadP(storageTest, strNewFmt("%s/test.txt", testPath()))), "get text");
TEST_ASSIGN(buffer, storageGetP(storageNewReadP(storageTest, STRDEF(TEST_PATH "/test.txt"))), "get text");
TEST_RESULT_UINT(bufSize(buffer), 9, "check size");
TEST_RESULT_BOOL(memcmp(bufPtrConst(buffer), "TESTFILE\n", bufSize(buffer)) == 0, true, "check content");
@ -867,8 +864,7 @@ testRun(void)
ioBufferSizeSet(2);
TEST_ASSIGN(
buffer, storageGetP(storageNewReadP(storageTest, strNewFmt("%s/test.txt", testPath()), .limit = VARUINT64(7))), "get");
TEST_ASSIGN(buffer, storageGetP(storageNewReadP(storageTest, STRDEF(TEST_PATH "/test.txt"), .limit = VARUINT64(7))), "get");
TEST_RESULT_UINT(bufSize(buffer), 7, "check size");
TEST_RESULT_BOOL(memcmp(bufPtrConst(buffer), "TESTFIL", bufSize(buffer)) == 0, true, "check content");
}
@ -884,10 +880,10 @@ testRun(void)
TEST_RESULT_VOID(storageRemoveP(storageTest, STRDEF("missing")), "remove missing file");
TEST_ERROR_FMT(
storageRemoveP(storageTest, STRDEF("missing"), .errorOnMissing = true), FileRemoveError,
"unable to remove '%s/missing': [2] No such file or directory", testPath());
"unable to remove '%s/missing': [2] No such file or directory", TEST_PATH);
// -------------------------------------------------------------------------------------------------------------------------
String *fileExists = strNewFmt("%s/exists", testPath());
const String *fileExists = STRDEF(TEST_PATH "/exists");
TEST_RESULT_INT(system(strZ(strNewFmt("touch %s", strZ(fileExists)))), 0, "create exists file");
TEST_RESULT_VOID(storageRemoveP(storageTest, fileExists), "remove exists file");
@ -921,7 +917,7 @@ testRun(void)
#endif // TEST_CONTAINER_REQUIRED
// -------------------------------------------------------------------------------------------------------------------------
String *fileName = strNewFmt("%s/test.file", testPath());
const String *fileName = STRDEF(TEST_PATH "/test.file");
TEST_ASSIGN(file, storageNewReadP(storageTest, fileName), "new missing read file");
TEST_ERROR_FMT(ioReadOpen(storageReadIo(file)), FileMissingError, STORAGE_ERROR_READ_MISSING, strZ(fileName));
@ -1030,7 +1026,7 @@ testRun(void)
#endif // TEST_CONTAINER_REQUIRED
// -------------------------------------------------------------------------------------------------------------------------
String *fileName = strNewFmt("%s/sub1/test.file", testPath());
const String *fileName = STRDEF(TEST_PATH "/sub1/test.file");
TEST_ASSIGN(file, storageNewWriteP(storageTest, fileName, .noCreatePath = true, .noAtomic = true), "new write file");
TEST_ERROR_FMT(ioWriteOpen(storageWriteIo(file)), FileMissingError, STORAGE_ERROR_WRITE_MISSING, strZ(fileName));
@ -1105,7 +1101,7 @@ testRun(void)
storageRemoveP(storageTest, fileName, .errorOnMissing = true);
// -------------------------------------------------------------------------------------------------------------------------
fileName = strNewFmt("%s/sub2/test.file", testPath());
fileName = STRDEF(TEST_PATH "/sub2/test.file");
TEST_ASSIGN(
file,
@ -1157,7 +1153,7 @@ testRun(void)
StringList *argList = strLstNew();
strLstAddZ(argList, "--stanza=db");
hrnCfgArgRawZ(argList, cfgOptPgPath, "/path/to/pg");
strLstAdd(argList, strNewFmt("--repo-path=%s", testPath()));
strLstAddZ(argList, "--repo-path=" TEST_PATH);
harnessCfgLoad(cfgCmdArchiveGet, argList);
const Storage *storage = NULL;
@ -1171,46 +1167,42 @@ testRun(void)
TEST_ERROR(storagePathP(storage, STRDEF("<BOGUS>/path")), AssertError, "invalid expression '<BOGUS>'");
TEST_ERROR(storageNewWriteP(storage, writeFile), AssertError, "assertion 'this->write' failed");
TEST_RESULT_STR_Z(storagePathP(storage, NULL), testPath(), "check base path");
TEST_RESULT_STR(
storagePathP(storage, STORAGE_REPO_ARCHIVE_STR), strNewFmt("%s/archive/db", testPath()), "check archive path");
TEST_RESULT_STR(
storagePathP(storage, STRDEF(STORAGE_REPO_ARCHIVE "/simple")), strNewFmt("%s/archive/db/simple", testPath()),
TEST_RESULT_STR_Z(storagePathP(storage, NULL), TEST_PATH, "check base path");
TEST_RESULT_STR_Z(
storagePathP(storage, STORAGE_REPO_ARCHIVE_STR), TEST_PATH "/archive/db", "check archive path");
TEST_RESULT_STR_Z(
storagePathP(storage, STRDEF(STORAGE_REPO_ARCHIVE "/simple")), TEST_PATH "/archive/db/simple",
"check simple path");
TEST_RESULT_STR(
TEST_RESULT_STR_Z(
storagePathP(storage, STRDEF(STORAGE_REPO_ARCHIVE "/9.4-1/700000007000000070000000")),
strNewFmt("%s/archive/db/9.4-1/7000000070000000/700000007000000070000000", testPath()), "check segment path");
TEST_RESULT_STR(
TEST_PATH "/archive/db/9.4-1/7000000070000000/700000007000000070000000", "check segment path");
TEST_RESULT_STR_Z(
storagePathP(storage, STRDEF(STORAGE_REPO_ARCHIVE "/9.4-1/00000008.history")),
strNewFmt("%s/archive/db/9.4-1/00000008.history", testPath()), "check history path");
TEST_RESULT_STR(
TEST_PATH "/archive/db/9.4-1/00000008.history", "check history path");
TEST_RESULT_STR_Z(
storagePathP(storage, STRDEF(STORAGE_REPO_ARCHIVE "/9.4-1/000000010000014C0000001A.00000028.backup")),
strNewFmt("%s/archive/db/9.4-1/000000010000014C/000000010000014C0000001A.00000028.backup", testPath()),
TEST_PATH "/archive/db/9.4-1/000000010000014C/000000010000014C0000001A.00000028.backup",
"check archive backup path");
TEST_RESULT_STR(
storagePathP(storage, STORAGE_REPO_BACKUP_STR), strNewFmt("%s/backup/db", testPath()), "check backup path");
TEST_RESULT_STR_Z(storagePathP(storage, STORAGE_REPO_BACKUP_STR), TEST_PATH "/backup/db", "check backup path");
// Change the stanza to NULL with the stanzaInit flag still true, make sure helper does not fail when stanza option not set
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
strLstAdd(argList, strNewFmt("--repo-path=%s", testPath()));
strLstAddZ(argList, "--repo-path=" TEST_PATH);
harnessCfgLoad(cfgCmdInfo, argList);
TEST_ASSIGN(storage, storageRepo(), "new repo storage no stanza");
TEST_RESULT_STR(storageHelper.stanza, NULL, "stanza NULL");
TEST_RESULT_STR(
storagePathP(storage, STORAGE_REPO_ARCHIVE_STR), strNewFmt("%s/archive", testPath()),
"check archive path - NULL stanza");
TEST_RESULT_STR(
storagePathP(storage, STRDEF(STORAGE_REPO_ARCHIVE "/simple")),
strNewFmt("%s/archive/simple", testPath()), "check simple archive path - NULL stanza");
TEST_RESULT_STR(
storagePathP(storage, STORAGE_REPO_BACKUP_STR), strNewFmt("%s/backup", testPath()),
"check backup path - NULL stanza");
TEST_RESULT_STR(
storagePathP(storage, STRDEF(STORAGE_REPO_BACKUP "/simple")),
strNewFmt("%s/backup/simple", testPath()), "check simple backup path - NULL stanza");
TEST_RESULT_STR_Z(
storagePathP(storage, STORAGE_REPO_ARCHIVE_STR), TEST_PATH "/archive", "check archive path - NULL stanza");
TEST_RESULT_STR_Z(
storagePathP(storage, STRDEF(STORAGE_REPO_ARCHIVE "/simple")), TEST_PATH "/archive/simple",
"check simple archive path - NULL stanza");
TEST_RESULT_STR_Z(storagePathP(storage, STORAGE_REPO_BACKUP_STR), TEST_PATH "/backup", "check backup path - NULL stanza");
TEST_RESULT_STR_Z(
storagePathP(storage, STRDEF(STORAGE_REPO_BACKUP "/simple")), TEST_PATH "/backup/simple",
"check simple backup path - NULL stanza");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_PTR(storageHelper.storageRepoWrite, NULL, "repo write storage not cached");
@ -1230,9 +1222,9 @@ testRun(void)
StringList *argList = strLstNew();
strLstAddZ(argList, "--stanza=db");
strLstAddZ(argList, "--archive-async");
strLstAdd(argList, strNewFmt("--spool-path=%s", testPath()));
strLstAdd(argList, strNewFmt("--pg1-path=%s/db", testPath()));
strLstAdd(argList, strNewFmt("--pg2-path=%s/db2", testPath()));
strLstAddZ(argList, "--spool-path=" TEST_PATH);
strLstAddZ(argList, "--pg1-path=" TEST_PATH "/db");
strLstAddZ(argList, "--pg2-path=" TEST_PATH "/db2");
harnessCfgLoad(cfgCmdArchiveGet, argList);
TEST_RESULT_PTR(storageHelper.storageSpool, NULL, "storage not cached");
@ -1243,27 +1235,23 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("STORAGE_SPOOL_ARCHIVE expression");
TEST_RESULT_STR(
storagePathP(storage, STRDEF(STORAGE_SPOOL_ARCHIVE)), strNewFmt("%s/archive/db", testPath()), "check spool path");
TEST_RESULT_STR(
storagePathP(storage, strNewFmt("%s/%s", STORAGE_SPOOL_ARCHIVE, "file.ext")),
strNewFmt("%s/archive/db/file.ext", testPath()), "check spool file");
TEST_RESULT_STR_Z(storagePathP(storage, STRDEF(STORAGE_SPOOL_ARCHIVE)), TEST_PATH "/archive/db", "check spool path");
TEST_RESULT_STR_Z(
storagePathP(storage, strNewFmt("%s/%s", STORAGE_SPOOL_ARCHIVE, "file.ext")), TEST_PATH "/archive/db/file.ext",
"check spool file");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_STR_Z(storagePathP(storage, NULL), testPath(), "check base path");
TEST_RESULT_STR(
storagePathP(storage, STRDEF(STORAGE_SPOOL_ARCHIVE_OUT)), strNewFmt("%s/archive/db/out", testPath()),
"check spool out path");
TEST_RESULT_STR(
storagePathP(storage, strNewFmt("%s/%s", STORAGE_SPOOL_ARCHIVE_OUT, "file.ext")),
strNewFmt("%s/archive/db/out/file.ext", testPath()), "check spool out file");
TEST_RESULT_STR_Z(storagePathP(storage, NULL), TEST_PATH, "check base path");
TEST_RESULT_STR_Z(
storagePathP(storage, STORAGE_SPOOL_ARCHIVE_OUT_STR), TEST_PATH "/archive/db/out", "check spool out path");
TEST_RESULT_STR_Z(
storagePathP(storage, STRDEF(STORAGE_SPOOL_ARCHIVE_OUT "/file.ext")), TEST_PATH "/archive/db/out/file.ext",
"check spool out file");
TEST_RESULT_STR(
storagePathP(storage, STRDEF(STORAGE_SPOOL_ARCHIVE_IN)), strNewFmt("%s/archive/db/in", testPath()),
"check spool in path");
TEST_RESULT_STR(
storagePathP(storage, strNewFmt("%s/%s", STORAGE_SPOOL_ARCHIVE_IN, "file.ext")),
strNewFmt("%s/archive/db/in/file.ext", testPath()), "check spool in file");
TEST_RESULT_STR_Z(storagePathP(storage, STORAGE_SPOOL_ARCHIVE_IN_STR), TEST_PATH "/archive/db/in", "check spool in path");
TEST_RESULT_STR_Z(
storagePathP(storage, STRDEF(STORAGE_SPOOL_ARCHIVE_IN "/file.ext")), TEST_PATH "/archive/db/in/file.ext",
"check spool in file");
TEST_ERROR(storagePathP(storage, STRDEF("<" BOGUS_STR ">")), AssertError, "invalid expression '<BOGUS>'");
@ -1283,17 +1271,17 @@ testRun(void)
TEST_RESULT_PTR(storageHelper.storagePg[0], storage, "pg storage cached");
TEST_RESULT_PTR(storagePg(), storage, "get cached pg storage");
TEST_RESULT_STR(storage->path, strNewFmt("%s/db", testPath()), "check pg storage path");
TEST_RESULT_STR_Z(storage->path, TEST_PATH "/db", "check pg storage path");
TEST_RESULT_BOOL(storage->write, false, "check pg storage write");
TEST_RESULT_STR(storagePgIdx(1)->path, strNewFmt("%s/db2", testPath()), "check pg 2 storage path");
TEST_RESULT_STR_Z(storagePgIdx(1)->path, TEST_PATH "/db2", "check pg 2 storage path");
TEST_RESULT_PTR(storageHelper.storagePgWrite, NULL, "pg write storage not cached");
TEST_ASSIGN(storage, storagePgWrite(), "new pg write storage");
TEST_RESULT_PTR(storageHelper.storagePgWrite[0], storage, "pg write storage cached");
TEST_RESULT_PTR(storagePgWrite(), storage, "get cached pg write storage");
TEST_RESULT_STR(storagePgIdxWrite(1)->path, strNewFmt("%s/db2", testPath()), "check pg 2 write storage path");
TEST_RESULT_STR_Z(storagePgIdxWrite(1)->path, TEST_PATH "/db2", "check pg 2 write storage path");
TEST_RESULT_STR(storage->path, strNewFmt("%s/db", testPath()), "check pg write storage path");
TEST_RESULT_STR_Z(storage->path, TEST_PATH "/db", "check pg write storage path");
TEST_RESULT_BOOL(storage->write, true, "check pg write storage write");
// Change the stanza to NULL, stanzaInit flag to false and make sure helper fails because stanza is required
@ -1304,7 +1292,7 @@ testRun(void)
storageHelper.stanza = NULL;
argList = strLstNew();
strLstAdd(argList, strNewFmt("--repo-path=%s", testPath()));
strLstAddZ(argList, "--repo-path=" TEST_PATH);
harnessCfgLoad(cfgCmdInfo, argList);
TEST_ERROR(storageSpool(), AssertError, "stanza cannot be NULL for this storage object");

View File

@ -20,17 +20,17 @@ testRun(void)
FUNCTION_HARNESS_VOID();
// Test storage
Storage *storageTest = storagePosixNewP(strNewZ(testPath()), .write = true);
Storage *storageTest = storagePosixNewP(TEST_PATH_STR, .write = true);
// Load configuration to set repo-path and stanza
StringList *argList = strLstNew();
strLstAddZ(argList, "--stanza=db");
strLstAddZ(argList, "--protocol-timeout=10");
strLstAddZ(argList, "--buffer-size=16384");
hrnCfgArgKeyRawFmt(argList, cfgOptPgPath, 1, "%s/pg", testPath());
hrnCfgArgKeyRawZ(argList, cfgOptPgPath, 1, TEST_PATH "/pg");
strLstAddZ(argList, "--repo1-host=localhost");
strLstAdd(argList, strNewFmt("--repo1-host-user=%s", testUser()));
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAddZ(argList, "--repo1-host-user=" TEST_USER);
strLstAddZ(argList, "--repo1-path=" TEST_PATH "/repo");
hrnCfgArgRawZ(argList, cfgOptRepo, "1");
harnessCfgLoadRole(cfgCmdArchiveGet, cfgCmdRoleLocal, argList);
@ -60,7 +60,7 @@ testRun(void)
TEST_RESULT_UINT(storageInterface(storageRemote).feature, storageInterface(storageTest).feature, " check features");
TEST_RESULT_BOOL(storageFeature(storageRemote, storageFeaturePath), true, " check path feature");
TEST_RESULT_BOOL(storageFeature(storageRemote, storageFeatureCompress), true, " check compress feature");
TEST_RESULT_STR(storagePathP(storageRemote, NULL), strNewFmt("%s/repo", testPath()), " check path");
TEST_RESULT_STR_Z(storagePathP(storageRemote, NULL), TEST_PATH "/repo", " check path");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("check protocol function directly (pg)");
@ -69,15 +69,13 @@ testRun(void)
TEST_RESULT_VOID(storageRemoteFeatureProtocol(NULL, server), "protocol feature");
TEST_RESULT_STR(
strNewBuf(serverWrite),
strNewFmt(".\"%s/repo\"\n.%" PRIu64 "\n{}\n", testPath(), storageInterface(storageTest).feature),
strNewBuf(serverWrite), strNewFmt(".\"" TEST_PATH "/repo\"\n.%" PRIu64 "\n{}\n", storageInterface(storageTest).feature),
"check result");
bufUsedSet(serverWrite, 0);
TEST_RESULT_VOID(storageRemoteFeatureProtocol(NULL, server), "protocol feature");
TEST_RESULT_STR(
strNewBuf(serverWrite),
strNewFmt(".\"%s/repo\"\n.%" PRIu64 "\n{}\n", testPath(), storageInterface(storageTest).feature),
strNewBuf(serverWrite), strNewFmt(".\"" TEST_PATH "/repo\"\n.%" PRIu64 "\n{}\n", storageInterface(storageTest).feature),
"check result cache");
bufUsedSet(serverWrite, 0);
@ -89,8 +87,7 @@ testRun(void)
TEST_RESULT_VOID(storageRemoteFeatureProtocol(NULL, server), "protocol feature");
TEST_RESULT_STR(
strNewBuf(serverWrite),
strNewFmt(".\"%s/repo\"\n.%" PRIu64 "\n{}\n", testPath(), storageInterface(storageTest).feature),
strNewBuf(serverWrite), strNewFmt(".\"" TEST_PATH "/repo\"\n.%" PRIu64 "\n{}\n", storageInterface(storageTest).feature),
"check result");
bufUsedSet(serverWrite, 0);
}
@ -106,7 +103,7 @@ testRun(void)
TEST_ERROR(
storageInfoP(storageRemote, STRDEF(BOGUS_STR)), FileOpenError,
"unable to get info for missing path/file '{[path]}/repo/BOGUS'");
"unable to get info for missing path/file '" TEST_PATH "/repo/BOGUS'");
TEST_RESULT_BOOL(storageInfoP(storageRemote, STRDEF(BOGUS_STR), .ignoreMissing = true).exists, false, "missing file/path");
// -------------------------------------------------------------------------------------------------------------------------
@ -124,10 +121,10 @@ testRun(void)
TEST_RESULT_INT(info.mode, 0750, " check mode");
TEST_RESULT_INT(info.timeModified, 1555160000, " check mod time");
TEST_RESULT_STR(info.linkDestination, NULL, " no link destination");
TEST_RESULT_UINT(info.userId, getuid(), " check user id");
TEST_RESULT_STR_Z(info.user, testUser(), " check user");
TEST_RESULT_UINT(info.groupId, getgid(), " check group id");
TEST_RESULT_STR_Z(info.group, testGroup(), " check group");
TEST_RESULT_UINT(info.userId, TEST_USER_ID, " check user id");
TEST_RESULT_STR(info.user, TEST_USER_STR, " check user");
TEST_RESULT_UINT(info.groupId, TEST_GROUP_ID, " check group id");
TEST_RESULT_STR(info.group, TEST_GROUP_STR, " check group");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("file info");
@ -142,10 +139,10 @@ testRun(void)
TEST_RESULT_INT(info.mode, 0640, " check mode");
TEST_RESULT_INT(info.timeModified, 1555160001, " check mod time");
TEST_RESULT_STR(info.linkDestination, NULL, " no link destination");
TEST_RESULT_UINT(info.userId, getuid(), " check user id");
TEST_RESULT_STR_Z(info.user, testUser(), " check user");
TEST_RESULT_UINT(info.groupId, getgid(), " check group id");
TEST_RESULT_STR_Z(info.group, testGroup(), " check group");
TEST_RESULT_UINT(info.userId, TEST_USER_ID, " check user id");
TEST_RESULT_STR(info.user, TEST_USER_STR, " check user");
TEST_RESULT_UINT(info.groupId, TEST_GROUP_ID, " check group id");
TEST_RESULT_STR(info.group, TEST_GROUP_STR, " check group");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("special info");
@ -159,10 +156,10 @@ testRun(void)
TEST_RESULT_UINT(info.size, 0, " check size");
TEST_RESULT_INT(info.mode, 0666, " check mode");
TEST_RESULT_STR(info.linkDestination, NULL, " no link destination");
TEST_RESULT_UINT(info.userId, getuid(), " check user id");
TEST_RESULT_STR_Z(info.user, testUser(), " check user");
TEST_RESULT_UINT(info.groupId, getgid(), " check group id");
TEST_RESULT_STR_Z(info.group, testGroup(), " check group");
TEST_RESULT_UINT(info.userId, TEST_USER_ID, " check user id");
TEST_RESULT_STR(info.user, TEST_USER_STR, " check user");
TEST_RESULT_UINT(info.groupId, TEST_GROUP_ID, " check group id");
TEST_RESULT_STR(info.group, TEST_GROUP_STR, " check group");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("link info");
@ -176,10 +173,10 @@ testRun(void)
TEST_RESULT_UINT(info.size, 0, " check size");
TEST_RESULT_INT(info.mode, 0777, " check mode");
TEST_RESULT_STR_Z(info.linkDestination, "../repo/test", " check link destination");
TEST_RESULT_UINT(info.userId, getuid(), " check user id");
TEST_RESULT_STR_Z(info.user, testUser(), " check user");
TEST_RESULT_UINT(info.groupId, getgid(), " check group id");
TEST_RESULT_STR_Z(info.group, testGroup(), " check group");
TEST_RESULT_UINT(info.userId, TEST_USER_ID, " check user id");
TEST_RESULT_STR(info.user, TEST_USER_STR, " check user");
TEST_RESULT_UINT(info.groupId, TEST_GROUP_ID, " check group id");
TEST_RESULT_STR(info.group, TEST_GROUP_STR, " check group");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("link info follow");
@ -191,10 +188,10 @@ testRun(void)
TEST_RESULT_UINT(info.size, 6, " check size");
TEST_RESULT_INT(info.mode, 0640, " check mode");
TEST_RESULT_STR(info.linkDestination, NULL, " no link destination");
TEST_RESULT_UINT(info.userId, getuid(), " check user id");
TEST_RESULT_STR_Z(info.user, testUser(), " check user");
TEST_RESULT_UINT(info.groupId, getgid(), " check group id");
TEST_RESULT_STR_Z(info.group, testGroup(), " check group");
TEST_RESULT_UINT(info.userId, TEST_USER_ID, " check user id");
TEST_RESULT_STR(info.user, TEST_USER_STR, " check user");
TEST_RESULT_UINT(info.groupId, TEST_GROUP_ID, " check group id");
TEST_RESULT_STR(info.group, TEST_GROUP_STR, " check group");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("protocol output that is not tested elsewhere (detail)");
@ -228,17 +225,16 @@ testRun(void)
cfgOptionSet(cfgOptRemoteType, cfgSourceParam, VARSTRDEF("pg"));
paramList = varLstNew();
varLstAdd(paramList, varNewStrZ(hrnReplaceKey("{[path]}/repo/test")));
varLstAdd(paramList, varNewStrZ(TEST_PATH "/repo/test"));
varLstAdd(paramList, varNewUInt(storageInfoLevelBasic));
varLstAdd(paramList, varNewBool(false));
TEST_RESULT_VOID(storageRemoteInfoProtocol(paramList, server), "protocol list");
TEST_RESULT_STR_Z(
strNewBuf(serverWrite),
hrnReplaceKey(
"{\"out\":true}\n"
".0\n.1555160001\n.6\n"
"{}\n"),
"{\"out\":true}\n"
".0\n.1555160001\n.6\n"
"{}\n",
"check result");
bufUsedSet(serverWrite, 0);
@ -247,17 +243,16 @@ testRun(void)
TEST_TITLE("check protocol function directly with a file (detail level)");
paramList = varLstNew();
varLstAdd(paramList, varNewStrZ(hrnReplaceKey("{[path]}/repo/test")));
varLstAdd(paramList, varNewStrZ(TEST_PATH "/repo/test"));
varLstAdd(paramList, varNewUInt(storageInfoLevelDetail));
varLstAdd(paramList, varNewBool(false));
TEST_RESULT_VOID(storageRemoteInfoProtocol(paramList, server), "protocol list");
TEST_RESULT_STR_Z(
strNewBuf(serverWrite),
hrnReplaceKey(
"{\"out\":true}\n"
".0\n.1555160001\n.6\n.{[user-id]}\n.\"{[user]}\"\n.{[group-id]}\n.\"{[group]}\"\n.416\n"
"{}\n"),
"{\"out\":true}\n"
".0\n.1555160001\n.6\n." TEST_USER_ID_Z "\n.\"" TEST_USER "\"\n." TEST_GROUP_ID_Z "\n.\"" TEST_GROUP "\"\n.416\n"
"{}\n",
"check result");
bufUsedSet(serverWrite, 0);
@ -298,9 +293,8 @@ testRun(void)
true, "info list");
TEST_RESULT_STR_Z(
callbackData.content,
hrnReplaceKey(
". {path, m=0750, u={[user]}, g={[group]}}\n"
"test {file, s=6, m=0640, t=1555160001, u={[user]}, g={[group]}}\n"),
". {path, m=0750, u=" TEST_USER ", g=" TEST_GROUP "}\n"
"test {file, s=6, m=0640, t=1555160001, u=" TEST_USER ", g=" TEST_GROUP "}\n",
"check content");
// -------------------------------------------------------------------------------------------------------------------------
@ -313,16 +307,15 @@ testRun(void)
HRN_STORAGE_TIME(storageRemote, NULL, 1555160000);
VariantList *paramList = varLstNew();
varLstAdd(paramList, varNewStrZ(hrnReplaceKey("{[path]}/repo")));
varLstAdd(paramList, varNewStrZ(TEST_PATH "/repo"));
varLstAdd(paramList, varNewUInt(storageInfoLevelDetail));
TEST_RESULT_VOID(storageRemoteInfoListProtocol(paramList, server), "call protocol");
TEST_RESULT_STR_Z(
strNewBuf(serverWrite),
hrnReplaceKey(
".\".\"\n.1\n.1555160000\n.{[user-id]}\n.\"{[user]}\"\n.{[group-id]}\n.\"{[group]}\"\n.488\n"
".\n"
"{\"out\":true}\n"),
".\".\"\n.1\n.1555160000\n." TEST_USER_ID_Z "\n.\"" TEST_USER "\"\n." TEST_GROUP_ID_Z "\n.\"" TEST_GROUP "\"\n.488\n"
".\n"
"{\"out\":true}\n",
"check result");
bufUsedSet(serverWrite, 0);
@ -345,7 +338,7 @@ testRun(void)
TEST_ERROR_FMT(
strZ(strNewBuf(storageGetP(storageNewReadP(storageRemote, STRDEF("test.txt"))))), FileMissingError,
"raised from remote-0 protocol on 'localhost': " STORAGE_ERROR_READ_MISSING,
strZ(strNewFmt("%s/repo/test.txt", testPath())));
strZ(strNewFmt("%s/repo/test.txt", TEST_PATH)));
storagePutP(storageNewWriteP(storageTest, STRDEF("repo/test.txt")), contentBuf);
@ -358,7 +351,7 @@ testRun(void)
TEST_ASSIGN(fileRead, storageNewReadP(storageRemote, STRDEF("test.txt")), "new file");
TEST_RESULT_BOOL(bufEq(storageGetP(fileRead), contentBuf), true, "get file");
TEST_RESULT_BOOL(storageReadIgnoreMissing(fileRead), false, "check ignore missing");
TEST_RESULT_STR_Z(storageReadName(fileRead), hrnReplaceKey("{[path]}/repo/test.txt"), "check name");
TEST_RESULT_STR_Z(storageReadName(fileRead), TEST_PATH "/repo/test.txt", "check name");
TEST_RESULT_UINT(storageReadRemote(fileRead->driver, bufNew(32), false), 0, "nothing more to read");
TEST_ASSIGN(fileRead, storageNewReadP(storageRemote, STRDEF("test.txt")), "get file");
@ -402,7 +395,7 @@ testRun(void)
ioBufferSizeSet(4);
paramList = varLstNew();
varLstAdd(paramList, varNewStr(strNewFmt("%s/repo/test.txt", testPath())));
varLstAdd(paramList, varNewStrZ(TEST_PATH "/repo/test.txt"));
varLstAdd(paramList, varNewBool(false));
varLstAdd(paramList, varNewUInt64(8));
@ -437,7 +430,7 @@ testRun(void)
storagePutP(storageNewWriteP(storageTest, STRDEF("repo/test.txt")), BUFSTRDEF("TESTDATA"));
paramList = varLstNew();
varLstAdd(paramList, varNewStr(strNewFmt("%s/repo/test.txt", testPath())));
varLstAdd(paramList, varNewStrZ(TEST_PATH "/repo/test.txt"));
varLstAdd(paramList, varNewBool(false));
varLstAdd(paramList, NULL);
@ -461,7 +454,7 @@ testRun(void)
// Check for error on a bogus filter
// -------------------------------------------------------------------------------------------------------------------------
paramList = varLstNew();
varLstAdd(paramList, varNewStr(strNewFmt("%s/repo/test.txt", testPath())));
varLstAdd(paramList, varNewStrZ(TEST_PATH "/repo/test.txt"));
varLstAdd(paramList, varNewBool(false));
varLstAdd(paramList, NULL);
varLstAdd(paramList, varNewVarLst(varLstAdd(varLstNew(), varNewKv(kvPut(kvNew(), varNewStrZ("bogus"), NULL)))));
@ -499,7 +492,7 @@ testRun(void)
TEST_RESULT_BOOL(storageWriteCreatePath(write), true, "path will be created");
TEST_RESULT_UINT(storageWriteModeFile(write), STORAGE_MODE_FILE_DEFAULT, "file mode is default");
TEST_RESULT_UINT(storageWriteModePath(write), STORAGE_MODE_PATH_DEFAULT, "path mode is default");
TEST_RESULT_STR_Z(storageWriteName(write), hrnReplaceKey("{[path]}/repo/test.txt"), "check file name");
TEST_RESULT_STR_Z(storageWriteName(write), TEST_PATH "/repo/test.txt", "check file name");
TEST_RESULT_BOOL(storageWriteSyncFile(write), true, "file is synced");
TEST_RESULT_BOOL(storageWriteSyncPath(write), true, "path is synced");
@ -540,7 +533,7 @@ testRun(void)
ioBufferSizeSet(10);
VariantList *paramList = varLstNew();
varLstAdd(paramList, varNewStr(strNewFmt("%s/repo/test3.txt", testPath())));
varLstAdd(paramList, varNewStrZ(TEST_PATH "/repo/test3.txt"));
varLstAdd(paramList, varNewUInt64(0640));
varLstAdd(paramList, varNewUInt64(0750));
varLstAdd(paramList, NULL);
@ -580,7 +573,7 @@ testRun(void)
ioBufferSizeSet(10);
paramList = varLstNew();
varLstAdd(paramList, varNewStr(strNewFmt("%s/repo/test4.txt", testPath())));
varLstAdd(paramList, varNewStrZ(TEST_PATH "/repo/test4.txt"));
varLstAdd(paramList, varNewUInt64(0640));
varLstAdd(paramList, varNewUInt64(0750));
varLstAdd(paramList, NULL);
@ -625,7 +618,7 @@ testRun(void)
// Check protocol function directly
// -------------------------------------------------------------------------------------------------------------------------
VariantList *paramList = varLstNew();
varLstAdd(paramList, varNewStr(strNewFmt("%s/repo/%s", testPath(), strZ(path))));
varLstAdd(paramList, varNewStr(strNewFmt(TEST_PATH "/repo/%s", strZ(path))));
varLstAdd(paramList, varNewBool(true)); // errorOnExists
varLstAdd(paramList, varNewBool(true)); // noParentCreate (true=error if it does not have a parent, false=create parent)
varLstAdd(paramList, varNewUInt64(0)); // path mode
@ -633,12 +626,12 @@ testRun(void)
TEST_ERROR_FMT(
storageRemotePathCreateProtocol(paramList, server), PathCreateError,
"raised from remote-0 protocol on 'localhost': unable to create path '%s/repo/testpath': [17] File exists",
testPath());
TEST_PATH);
// Error if parent path not exist
path = STRDEF("parent/testpath");
paramList = varLstNew();
varLstAdd(paramList, varNewStr(strNewFmt("%s/repo/%s", testPath(), strZ(path))));
varLstAdd(paramList, varNewStr(strNewFmt(TEST_PATH "/repo/%s", strZ(path))));
varLstAdd(paramList, varNewBool(false)); // errorOnExists
varLstAdd(paramList, varNewBool(true)); // noParentCreate (true=error if it does not have a parent, false=create parent)
varLstAdd(paramList, varNewUInt64(0)); // path mode
@ -646,11 +639,11 @@ testRun(void)
TEST_ERROR_FMT(
storageRemotePathCreateProtocol(paramList, server), PathCreateError,
"raised from remote-0 protocol on 'localhost': unable to create path '%s/repo/parent/testpath': "
"[2] No such file or directory", testPath());
"[2] No such file or directory", TEST_PATH);
// Create parent and path with default mode
paramList = varLstNew();
varLstAdd(paramList, varNewStr(strNewFmt("%s/repo/%s", testPath(), strZ(path))));
varLstAdd(paramList, varNewStr(strNewFmt(TEST_PATH "/repo/%s", strZ(path))));
varLstAdd(paramList, varNewBool(true)); // errorOnExists
varLstAdd(paramList, varNewBool(false)); // noParentCreate (true=error if it does not have a parent, false=create parent)
varLstAdd(paramList, varNewUInt64(0777)); // path mode
@ -681,7 +674,7 @@ testRun(void)
// Check protocol function directly
// -------------------------------------------------------------------------------------------------------------------------
VariantList *paramList = varLstNew();
varLstAdd(paramList, varNewStr(strNewFmt("%s/repo/%s", testPath(), strZ(path))));
varLstAdd(paramList, varNewStr(strNewFmt(TEST_PATH "/repo/%s", strZ(path))));
varLstAdd(paramList, varNewBool(true)); // recurse
TEST_RESULT_VOID(storageRemotePathRemoveProtocol(paramList, server), " protocol path remove missing");
@ -720,16 +713,16 @@ testRun(void)
// Check protocol function directly
// -------------------------------------------------------------------------------------------------------------------------
VariantList *paramList = varLstNew();
varLstAdd(paramList, varNewStr(strNewFmt("%s/repo/%s", testPath(), strZ(file))));
varLstAdd(paramList, varNewStr(strNewFmt(TEST_PATH "/repo/%s", strZ(file))));
varLstAdd(paramList, varNewBool(true));
TEST_ERROR_FMT(
storageRemoteRemoveProtocol(paramList, server), FileRemoveError,
"raised from remote-0 protocol on 'localhost': unable to remove '%s/repo/file.txt': "
"[2] No such file or directory", testPath());
"[2] No such file or directory", TEST_PATH);
paramList = varLstNew();
varLstAdd(paramList, varNewStr(strNewFmt("%s/repo/%s", testPath(), strZ(file))));
varLstAdd(paramList, varNewStr(strNewFmt(TEST_PATH "/repo/%s", strZ(file))));
varLstAdd(paramList, varNewBool(false));
TEST_RESULT_VOID(storageRemoteRemoveProtocol(paramList, server), "protocol file remove - no error on missing");
@ -759,18 +752,18 @@ testRun(void)
// Check protocol function directly
// -------------------------------------------------------------------------------------------------------------------------
VariantList *paramList = varLstNew();
varLstAdd(paramList, varNewStr(strNewFmt("%s/repo/%s", testPath(), strZ(path))));
varLstAdd(paramList, varNewStr(strNewFmt(TEST_PATH "/repo/%s", strZ(path))));
TEST_RESULT_VOID(storageRemotePathSyncProtocol(paramList, server), "protocol path sync");
TEST_RESULT_STR_Z(strNewBuf(serverWrite), "{}\n", " check result");
bufUsedSet(serverWrite, 0);
paramList = varLstNew();
varLstAdd(paramList, varNewStr(strNewFmt("%s/repo/anewpath", testPath())));
varLstAdd(paramList, varNewStrZ(TEST_PATH "/repo/anewpath"));
TEST_ERROR_FMT(
storageRemotePathSyncProtocol(paramList, server), PathMissingError,
"raised from remote-0 protocol on 'localhost': " STORAGE_ERROR_PATH_SYNC_MISSING,
strZ(strNewFmt("%s/repo/anewpath", testPath())));
strZ(strNewFmt("%s/repo/anewpath", TEST_PATH)));
}
protocolFree();

View File

@ -230,7 +230,7 @@ testRun(void)
hrnCfgArgRaw(commonArgWithoutEndpointList, cfgOptRepoS3Region, region);
// TLS can only be verified in a container
if (!testContainer())
if (!TEST_IN_CONTAINER)
hrnCfgArgRawBool(commonArgWithoutEndpointList, cfgOptRepoStorageVerifyTls, false);
// Config settings that are required for every test (with endpoint)
@ -265,7 +265,7 @@ testRun(void)
strNewFmt(
"{ioClient: {type: tls, driver: {ioClient: {type: socket, driver: {host: bucket.s3.amazonaws.com, port: 443"
", timeout: 60000}}, timeout: 60000, verifyPeer: %s}}, reusable: 0, timeout: 60000}",
cvtBoolToConstZ(testContainer())),
cvtBoolToConstZ(TEST_IN_CONTAINER)),
"check http client");
// -------------------------------------------------------------------------------------------------------------------------
@ -319,7 +319,7 @@ testRun(void)
argList = strLstDup(commonArgWithoutEndpointList);
hrnCfgArgRawZ(argList, cfgOptRepoS3Endpoint, "custom.endpoint:333");
hrnCfgArgRawZ(argList, cfgOptRepoStorageCaPath, "/path/to/cert");
hrnCfgArgRawFmt(argList, cfgOptRepoStorageCaFile, "%s/" HRN_SERVER_CERT_PREFIX ".crt", testRepoPath());
hrnCfgArgRawZ(argList, cfgOptRepoStorageCaFile, HRN_PATH_REPO "/" HRN_SERVER_CERT_PREFIX ".crt");
hrnCfgEnvRaw(cfgOptRepoS3Token, securityToken);
harnessCfgLoad(cfgCmdArchivePush, argList);
@ -331,7 +331,7 @@ testRun(void)
strNewFmt(
"{ioClient: {type: tls, driver: {ioClient: {type: socket, driver: {host: bucket.custom.endpoint, port: 333"
", timeout: 60000}}, timeout: 60000, verifyPeer: %s}}, reusable: 0, timeout: 60000}",
cvtBoolToConstZ(testContainer())),
cvtBoolToConstZ(TEST_IN_CONTAINER)),
"check http client");
// -------------------------------------------------------------------------------------------------------------------------

View File

@ -31,9 +31,62 @@ The test code is included directly so it can freely interact with the included C
#include "common/debug.h"
#endif
#ifdef HRN_FEATURE_STRING
#include "common/type/string.h"
#endif
// Name of the project exe
#define TEST_PROJECT_EXE "{[C_TEST_PROJECT_EXE]}"
#ifdef HRN_FEATURE_STRING
STRING_EXTERN(TEST_PROJECT_EXE_STR, TEST_PROJECT_EXE);
#endif
// Path where the test is running
#define TEST_PATH "{[C_TEST_PATH]}"
#ifdef HRN_FEATURE_STRING
STRING_EXTERN(TEST_PATH_STR, TEST_PATH);
#endif
// Path to the source repository
#define HRN_PATH_REPO "{[C_HRN_PATH_REPO]}"
#ifdef HRN_FEATURE_STRING
STRING_EXTERN(HRN_PATH_REPO_STR, HRN_PATH_REPO);
#endif
// Path where the harness can store data without interfering with the test
#define HRN_PATH "{[C_HRN_PATH]}"
#ifdef HRN_FEATURE_STRING
STRING_EXTERN(HRN_PATH_STR, HRN_PATH);
#endif
// User running the test
#define TEST_USER "{[C_TEST_USER]}"
#define TEST_USER_ID {[C_TEST_USER_ID]}
#define TEST_USER_ID_Z "{[C_TEST_USER_ID]}"
#ifdef HRN_FEATURE_STRING
STRING_EXTERN(TEST_USER_STR, TEST_USER);
#endif
// Group running the test
#define TEST_GROUP "{[C_TEST_GROUP]}"
#define TEST_GROUP_ID {[C_TEST_GROUP_ID]}
#define TEST_GROUP_ID_Z "{[C_TEST_GROUP_ID]}"
#ifdef HRN_FEATURE_STRING
STRING_EXTERN(TEST_GROUP_STR, TEST_GROUP);
#endif
// Scaling factor for performance tests
#define TEST_SCALE {[C_TEST_SCALE]}
// Is this test running in a container?
#define TEST_IN_CONTAINER {[C_TEST_CONTAINER]}
// Path to source -- used to construct __FILENAME__ tests
#define TEST_PGB_PATH "{[C_TEST_PGB_PATH]}"
@ -130,10 +183,9 @@ main(int argListSize, const char *argList[])
{[C_TEST_CONTAINER]}, // Is this test running in a container?
{[C_TEST_IDX]}, // The 0-based index of this test
{[C_TEST_TIMING]}, // Is timing enabled (may be disabled for reproducible documentation)
{[C_TEST_SCALE]}, // Scaling factor for performance tests
"{[C_TEST_PATH]}", // Path where tests write data
"{[C_TEST_DATA_PATH]}", // Path where the harness stores temp files (expect, diff, etc.)
"{[C_TEST_REPO_PATH]}"); // Path with a copy of the repository
"{[C_HRN_PATH]}", // Path where the harness stores temp files (expect, diff, etc.)
"{[C_HRN_PATH_REPO]}"); // Path with a copy of the repository
// Set default test log level
#ifdef HRN_FEATURE_LOG