You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-15 01:04:37 +02:00
Add zNewFmt().
This replaces strZ(strNewFmt()), making the code simpler and reducing indentation.
This commit is contained in:
@ -32,6 +32,7 @@ SRCS_BUILD = \
|
||||
common/type/object.c \
|
||||
common/type/pack.c \
|
||||
common/type/string.c \
|
||||
common/type/stringZ.c \
|
||||
common/type/stringId.c \
|
||||
common/type/stringList.c \
|
||||
common/type/variant.c \
|
||||
|
@ -1137,8 +1137,7 @@ bldCfgRenderParseAutoC(const Storage *const storageRepo, const BldCfg bldCfg)
|
||||
for (unsigned int ruleStrIdx = 0; ruleStrIdx < strLstSize(ruleStrList); ruleStrIdx++)
|
||||
{
|
||||
strCatFmt(
|
||||
configVal, " %s,\n",
|
||||
strZ(strNewFmt("parseRuleValStr%s", strZ(bldCfgRenderEnumStr(strLstGet(ruleStrList, ruleStrIdx))))));
|
||||
configVal, " %s,\n", zNewFmt("parseRuleValStr%s", strZ(bldCfgRenderEnumStr(strLstGet(ruleStrList, ruleStrIdx)))));
|
||||
}
|
||||
|
||||
strCatZ(configVal, "} ParseRuleValueStr;\n");
|
||||
|
@ -914,7 +914,7 @@ cmdArchiveGetAsync(void)
|
||||
"get %u WAL file(s) from archive: %s%s",
|
||||
strLstSize(cfgCommandParam()), strZ(strLstGet(cfgCommandParam(), 0)),
|
||||
strLstSize(cfgCommandParam()) == 1 ?
|
||||
"" : strZ(strNewFmt("...%s", strZ(strLstGet(cfgCommandParam(), strLstSize(cfgCommandParam()) - 1)))));
|
||||
"" : zNewFmt("...%s", strZ(strLstGet(cfgCommandParam(), strLstSize(cfgCommandParam()) - 1))));
|
||||
|
||||
// Check for archive files
|
||||
ArchiveGetCheckResult checkResult = archiveGetCheck(cfgCommandParam());
|
||||
@ -1010,7 +1010,7 @@ cmdArchiveGetAsync(void)
|
||||
archiveModeGet, walSegment, protocolParallelJobErrorCode(job),
|
||||
strNewFmt(
|
||||
"%s%s", strZ(protocolParallelJobErrorMessage(job)),
|
||||
strSize(warning) == 0 ? "" : strZ(strNewFmt("\n%s", strZ(warning)))));
|
||||
strSize(warning) == 0 ? "" : zNewFmt("\n%s", strZ(warning))));
|
||||
}
|
||||
|
||||
protocolParallelJobFree(job);
|
||||
|
@ -257,7 +257,7 @@ archivePushCheck(bool pgPathSet)
|
||||
ArchiveMismatchError,
|
||||
"%s version %s, system-id %" PRIu64 " do not match %s stanza version %s, system-id %" PRIu64
|
||||
"\nHINT: are you archiving to the correct stanza?",
|
||||
pgPathSet ? PG_NAME : strZ(strNewFmt("%s stanza", cfgOptionGroupName(cfgOptGrpRepo, 0))),
|
||||
pgPathSet ? PG_NAME : zNewFmt("%s stanza", cfgOptionGroupName(cfgOptGrpRepo, 0)),
|
||||
strZ(pgVersionToStr(result.pgVersion)), result.pgSystemId,
|
||||
cfgOptionGroupName(cfgOptGrpRepo, repoIdx), strZ(pgVersionToStr(archiveInfo.version)),
|
||||
archiveInfo.systemId);
|
||||
@ -553,7 +553,7 @@ cmdArchivePushAsync(void)
|
||||
LOG_INFO_FMT(
|
||||
"push %u WAL file(s) to archive: %s%s", strLstSize(jobData.walFileList), strZ(strLstGet(jobData.walFileList, 0)),
|
||||
strLstSize(jobData.walFileList) == 1 ?
|
||||
"" : strZ(strNewFmt("...%s", strZ(strLstGet(jobData.walFileList, strLstSize(jobData.walFileList) - 1)))));
|
||||
"" : zNewFmt("...%s", strZ(strLstGet(jobData.walFileList, strLstSize(jobData.walFileList) - 1))));
|
||||
|
||||
// Drop files if queue max has been exceeded
|
||||
if (cfgOptionTest(cfgOptArchivePushQueueMax) && archivePushDrop(jobData.walPath, jobData.walFileList))
|
||||
|
@ -30,7 +30,7 @@ cmdStart(void)
|
||||
{
|
||||
LOG_WARN_FMT(
|
||||
"stop file does not exist%s",
|
||||
(cfgOptionTest(cfgOptStanza) ? strZ(strNewFmt(" for stanza %s", strZ(cfgOptionDisplay(cfgOptStanza)))) : ""));
|
||||
(cfgOptionTest(cfgOptStanza) ? zNewFmt(" for stanza %s", strZ(cfgOptionDisplay(cfgOptStanza))) : ""));
|
||||
}
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
@ -88,7 +88,7 @@ cmdStop(void)
|
||||
{
|
||||
LOG_WARN_FMT(
|
||||
"stop file already exists for %s",
|
||||
cfgOptionTest(cfgOptStanza) ? strZ(strNewFmt("stanza %s", strZ(cfgOptionDisplay(cfgOptStanza)))) : "all stanzas");
|
||||
cfgOptionTest(cfgOptStanza) ? zNewFmt("stanza %s", strZ(cfgOptionDisplay(cfgOptStanza))) : "all stanzas");
|
||||
}
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
@ -620,7 +620,7 @@ removeExpiredArchive(InfoBackup *infoBackup, bool timeBasedFullRetention, unsign
|
||||
"%s: %s archive retention on backup %s, start = %s%s",
|
||||
cfgOptionGroupName(cfgOptGrpRepo, repoIdx), strZ(archiveId), strZ(backupData->backupLabel),
|
||||
strZ(archiveRange.start),
|
||||
archiveRange.stop != NULL ? strZ(strNewFmt(", stop = %s", strZ(archiveRange.stop))) : "");
|
||||
archiveRange.stop != NULL ? zNewFmt(", stop = %s", strZ(archiveRange.stop)) : "");
|
||||
|
||||
// Add the archive range to the list
|
||||
lstAdd(archiveRangeList, &archiveRange);
|
||||
|
@ -1476,12 +1476,13 @@ infoRender(void)
|
||||
// Stanza status
|
||||
strCatFmt(
|
||||
resultStr, "%s%s\n",
|
||||
statusCode == INFO_STANZA_STATUS_CODE_MIXED ? INFO_STANZA_MIXED :
|
||||
strZ(strNewFmt(INFO_STANZA_STATUS_ERROR " (%s)",
|
||||
strZ(varStr(kvGet(stanzaStatus, STATUS_KEY_MESSAGE_VAR))))),
|
||||
statusCode == INFO_STANZA_STATUS_CODE_MIXED ?
|
||||
INFO_STANZA_MIXED :
|
||||
zNewFmt(
|
||||
INFO_STANZA_STATUS_ERROR " (%s)",
|
||||
strZ(varStr(kvGet(stanzaStatus, STATUS_KEY_MESSAGE_VAR)))),
|
||||
backupLockHeld == true ?
|
||||
strZ(strNewFmt(" (" INFO_STANZA_STATUS_MESSAGE_LOCK_BACKUP "%s)", strZ(percentCompleteStr))) :
|
||||
"");
|
||||
zNewFmt(" (" INFO_STANZA_STATUS_MESSAGE_LOCK_BACKUP "%s)", strZ(percentCompleteStr)) : "");
|
||||
|
||||
// Output the status per repo
|
||||
VariantList *repoSection = kvGetList(stanzaInfo, STANZA_KEY_REPO_VAR);
|
||||
@ -1509,7 +1510,7 @@ infoRender(void)
|
||||
strCatFmt(
|
||||
resultStr, "%s%s%s\n",
|
||||
multiRepo ? INFO_STANZA_STATUS_ERROR " (" INFO_STANZA_STATUS_MESSAGE_OTHER ")\n" : "",
|
||||
formatSpacer, strZ(strLstJoin(repoError, strZ(strNewFmt("\n%s", formatSpacer)))));
|
||||
formatSpacer, strZ(strLstJoin(repoError, zNewFmt("\n%s", formatSpacer))));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1527,8 +1528,7 @@ infoRender(void)
|
||||
resultStr, "%s (%s%s\n", INFO_STANZA_STATUS_ERROR,
|
||||
strZ(varStr(kvGet(stanzaStatus, STATUS_KEY_MESSAGE_VAR))),
|
||||
backupLockHeld == true ?
|
||||
strZ(strNewFmt(", " INFO_STANZA_STATUS_MESSAGE_LOCK_BACKUP "%s)", strZ(percentCompleteStr))) :
|
||||
")");
|
||||
zNewFmt(", " INFO_STANZA_STATUS_MESSAGE_LOCK_BACKUP "%s)", strZ(percentCompleteStr)) : ")");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1296,10 +1296,10 @@ verifyCreateFileErrorsStr(
|
||||
// List all if verbose text, otherwise only list if type has errors
|
||||
strCatFmt(
|
||||
result, "\n %s%s%s%s",
|
||||
verboseText || errMissing ? strZ(strNewFmt("missing: %u, ", errMissing)) : "",
|
||||
verboseText || errChecksum ? strZ(strNewFmt("checksum invalid: %u, ", errChecksum)) : "",
|
||||
verboseText || errSize ? strZ(strNewFmt("size invalid: %u, ", errSize)) : "",
|
||||
verboseText || errOther ? strZ(strNewFmt("other: %u", errOther)) : "");
|
||||
verboseText || errMissing ? zNewFmt("missing: %u, ", errMissing) : "",
|
||||
verboseText || errChecksum ? zNewFmt("checksum invalid: %u, ", errChecksum) : "",
|
||||
verboseText || errSize ? zNewFmt("size invalid: %u, ", errSize) : "",
|
||||
verboseText || errOther ? zNewFmt("other: %u", errOther) : "");
|
||||
|
||||
// Clean up trailing comma when necessary
|
||||
if (strEndsWithZ(result, ", "))
|
||||
|
@ -112,7 +112,7 @@ tlsCertKeyLoad(SSL_CTX *const context, const String *const certFile, const Strin
|
||||
// Load certificate
|
||||
cryptoError(
|
||||
SSL_CTX_use_certificate_chain_file(context, strZ(certFile)) != 1,
|
||||
strZ(strNewFmt("unable to load cert file '%s'", strZ(certFile))));
|
||||
zNewFmt("unable to load cert file '%s'", strZ(certFile)));
|
||||
|
||||
// Check that key has the correct permissions
|
||||
const StorageInfo keyInfo = storageInfoP(
|
||||
@ -141,13 +141,13 @@ tlsCertKeyLoad(SSL_CTX *const context, const String *const certFile, const Strin
|
||||
// Load key and verify that the key and cert go together
|
||||
cryptoError(
|
||||
SSL_CTX_use_PrivateKey_file(context, strZ(keyFile), SSL_FILETYPE_PEM) != 1,
|
||||
strZ(strNewFmt("unable to load key file '%s'", strZ(keyFile))));
|
||||
zNewFmt("unable to load key file '%s'", strZ(keyFile)));
|
||||
|
||||
// Verify again that the cert and key go together. It is not clear why this is needed since the key has already been
|
||||
// verified in SSL_CTX_use_PrivateKey_file(), but it may be that older versions of OpenSSL need it.
|
||||
cryptoError(
|
||||
SSL_CTX_check_private_key(context) != 1,
|
||||
strZ(strNewFmt("cert '%s' and key '%s' do not match", strZ(certFile), strZ(keyFile))));
|
||||
zNewFmt("cert '%s' and key '%s' do not match", strZ(certFile), strZ(keyFile)));
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
}
|
||||
|
@ -327,14 +327,13 @@ tlsServerNew(
|
||||
// Load CA store
|
||||
cryptoError( // {vm_covered}
|
||||
SSL_CTX_load_verify_locations(driver->context, strZ(caFile), NULL) != 1, // {vm_covered}
|
||||
strZ(strNewFmt("unable to load CA file '%s'", strZ(caFile)))); // {vm_covered}
|
||||
zNewFmt("unable to load CA file '%s'", strZ(caFile))); // {vm_covered}
|
||||
|
||||
// Tell OpenSSL to send the list of root certs we trust to clients in CertificateRequests. This lets a client with a
|
||||
// keystore select the appropriate client certificate to send to us. Also, this ensures that the SSL context will own
|
||||
// the rootCertList and free it when no longer needed.
|
||||
STACK_OF(X509_NAME) *rootCertList = SSL_load_client_CA_file(strZ(caFile)); // {vm_covered}
|
||||
cryptoError( // {vm_covered}
|
||||
rootCertList == NULL, strZ(strNewFmt("unable to generate CA list from '%s'", strZ(caFile)))); // {vm_covered}
|
||||
cryptoError(rootCertList == NULL, zNewFmt("unable to generate CA list from '%s'", strZ(caFile))); // {vm_covered}
|
||||
|
||||
SSL_CTX_set_client_CA_list(driver->context, rootCertList); // {vm_covered}
|
||||
|
||||
|
@ -368,7 +368,7 @@ bufToLog(const Buffer *this)
|
||||
{
|
||||
String *result = strNewFmt(
|
||||
"{used: %zu, size: %zu%s", bufUsed(this), bufSize(this),
|
||||
bufSizeLimit(this) ? strZ(strNewFmt(", sizeAlloc: %zu}", bufSizeAlloc(this))) : "}");
|
||||
bufSizeLimit(this) ? zNewFmt(", sizeAlloc: %zu}", bufSizeAlloc(this)) : "}");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ String Handler
|
||||
#include "common/memContext.h"
|
||||
#include "common/type/string.h"
|
||||
#include "common/type/stringList.h"
|
||||
#include "common/type/stringZ.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Constant strings that are generally useful
|
||||
|
@ -38,6 +38,7 @@ typedef struct String String;
|
||||
#include "common/assert.h"
|
||||
#include "common/encode.h"
|
||||
#include "common/type/buffer.h"
|
||||
#include "common/type/stringZ.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Constructors
|
||||
|
36
src/common/type/stringZ.c
Normal file
36
src/common/type/stringZ.c
Normal file
@ -0,0 +1,36 @@
|
||||
/***********************************************************************************************************************************
|
||||
Zero-Terminated String Handler
|
||||
***********************************************************************************************************************************/
|
||||
#include "build.auto.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "common/memContext.h"
|
||||
#include "common/type/stringZ.h"
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
char *
|
||||
zNewFmt(const char *const format, ...)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(STRINGZ, format);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(format != NULL);
|
||||
|
||||
// Determine how long the allocated string needs to be and create object
|
||||
va_list argumentList;
|
||||
va_start(argumentList, format);
|
||||
const size_t size = (size_t)vsnprintf(NULL, 0, format, argumentList) + 1;
|
||||
char *const result = memNew(size);
|
||||
va_end(argumentList);
|
||||
|
||||
// Format string
|
||||
va_start(argumentList, format);
|
||||
vsnprintf(result, size, format, argumentList);
|
||||
va_end(argumentList);
|
||||
|
||||
FUNCTION_TEST_RETURN(STRINGZ, result);
|
||||
}
|
@ -1,5 +1,8 @@
|
||||
/***********************************************************************************************************************************
|
||||
Zero-Terminated String Handler
|
||||
|
||||
These functions are shortcuts for creating/modifying zero-terminated strings without needing to wrap a strNew*() call in strZ().
|
||||
The benefit is simpler code with less indentation, but be aware that memory is still being allocated.
|
||||
***********************************************************************************************************************************/
|
||||
#ifndef COMMON_TYPE_STRINGZ_H
|
||||
#define COMMON_TYPE_STRINGZ_H
|
||||
@ -11,4 +14,10 @@ Zero-terminated strings that are generally useful
|
||||
#define NULL_Z "null"
|
||||
#define TRUE_Z "true"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
***********************************************************************************************************************************/
|
||||
// Format a zero-terminated string
|
||||
char *zNewFmt(const char *format, ...) __attribute__((format(printf, 1, 2)));
|
||||
|
||||
#endif
|
||||
|
@ -195,7 +195,7 @@ storageWriteGcsBlockAsync(StorageWriteGcs *this, bool done)
|
||||
strNewFmt(
|
||||
HTTP_HEADER_CONTENT_RANGE_BYTES " %" PRIu64 "-%" PRIu64 "/%s", this->uploadTotal,
|
||||
this->uploadTotal + bufUsed(this->chunkBuffer) - 1,
|
||||
done ? strZ(strNewFmt("%" PRIu64, this->uploadTotal + bufUsed(this->chunkBuffer))) : "*"));
|
||||
done ? zNewFmt("%" PRIu64, this->uploadTotal + bufUsed(this->chunkBuffer)) : "*"));
|
||||
|
||||
httpQueryAdd(query, GCS_QUERY_UPLOAD_ID_STR, this->uploadId);
|
||||
|
||||
|
@ -136,11 +136,12 @@ unit:
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------------------------
|
||||
- name: type-string
|
||||
total: 26
|
||||
total: 27
|
||||
feature: string
|
||||
|
||||
coverage:
|
||||
- common/type/string
|
||||
- common/type/stringZ
|
||||
- common/type/stringId
|
||||
- common/type/stringList
|
||||
|
||||
|
@ -94,7 +94,7 @@ Macros for defining groups of functions that implement various queries and comma
|
||||
|
||||
#define HRNPQ_MACRO_SET_APPLICATION_NAME(sessionParam) \
|
||||
{.session = sessionParam, .function = HRNPQ_SENDQUERY, \
|
||||
.param = strZ(strNewFmt("[\"set application_name = '" PROJECT_NAME " [%s]'\"]", cfgCommandName())), \
|
||||
.param = zNewFmt("[\"set application_name = '" PROJECT_NAME " [%s]'\"]", cfgCommandName()), \
|
||||
.resultInt = 1}, \
|
||||
{.session = sessionParam, .function = HRNPQ_CONSUMEINPUT}, \
|
||||
{.session = sessionParam, .function = HRNPQ_ISBUSY}, \
|
||||
@ -198,7 +198,7 @@ Macros for defining groups of functions that implement various queries and comma
|
||||
{.session = sessionParam, .function = HRNPQ_NFIELDS, .resultInt = 1}, \
|
||||
{.session = sessionParam, .function = HRNPQ_FTYPE, .param = "[0]", .resultInt = HRNPQ_TYPE_INT8}, \
|
||||
{.session = sessionParam, .function = HRNPQ_GETVALUE, .param = "[0,0]", \
|
||||
.resultZ = strZ(strNewFmt("%" PRId64, (int64_t)(timeParam)))}, \
|
||||
.resultZ = zNewFmt("%" PRId64, (int64_t)(timeParam))}, \
|
||||
{.session = sessionParam, .function = HRNPQ_CLEAR}, \
|
||||
{.session = sessionParam, .function = HRNPQ_GETRESULT, .resultNull = true}
|
||||
|
||||
@ -235,11 +235,11 @@ Macros for defining groups of functions that implement various queries and comma
|
||||
#define HRNPQ_MACRO_START_BACKUP_LE_95(sessionParam, startFastParam, lsnParam, walSegmentNameParam) \
|
||||
{.session = sessionParam, \
|
||||
.function = HRNPQ_SENDQUERY, \
|
||||
.param = strZ(strNewFmt( \
|
||||
.param = zNewFmt( \
|
||||
"[\"select lsn::text as lsn,\\n" \
|
||||
" pg_catalog.pg_xlogfile_name(lsn)::text as wal_segment_name\\n" \
|
||||
" from pg_catalog.pg_start_backup('pgBackRest backup started at ' || current_timestamp, %s) as lsn\"]", \
|
||||
cvtBoolToConstZ(startFastParam))), \
|
||||
cvtBoolToConstZ(startFastParam)), \
|
||||
.resultInt = 1}, \
|
||||
{.session = sessionParam, .function = HRNPQ_CONSUMEINPUT}, \
|
||||
{.session = sessionParam, .function = HRNPQ_ISBUSY}, \
|
||||
@ -257,11 +257,11 @@ Macros for defining groups of functions that implement various queries and comma
|
||||
#define HRNPQ_MACRO_START_BACKUP_96(sessionParam, startFastParam, lsnParam, walSegmentNameParam) \
|
||||
{.session = sessionParam, \
|
||||
.function = HRNPQ_SENDQUERY, \
|
||||
.param = strZ(strNewFmt( \
|
||||
.param = zNewFmt( \
|
||||
"[\"select lsn::text as lsn,\\n" \
|
||||
" pg_catalog.pg_xlogfile_name(lsn)::text as wal_segment_name\\n" \
|
||||
" from pg_catalog.pg_start_backup('pgBackRest backup started at ' || current_timestamp, %s, false) as lsn\"]", \
|
||||
cvtBoolToConstZ(startFastParam))), \
|
||||
cvtBoolToConstZ(startFastParam)), \
|
||||
.resultInt = 1}, \
|
||||
{.session = sessionParam, .function = HRNPQ_CONSUMEINPUT}, \
|
||||
{.session = sessionParam, .function = HRNPQ_ISBUSY}, \
|
||||
@ -279,11 +279,11 @@ Macros for defining groups of functions that implement various queries and comma
|
||||
#define HRNPQ_MACRO_START_BACKUP_GE_10(sessionParam, startFastParam, lsnParam, walSegmentNameParam) \
|
||||
{.session = sessionParam, \
|
||||
.function = HRNPQ_SENDQUERY, \
|
||||
.param = strZ(strNewFmt( \
|
||||
.param = zNewFmt( \
|
||||
"[\"select lsn::text as lsn,\\n" \
|
||||
" pg_catalog.pg_walfile_name(lsn)::text as wal_segment_name\\n" \
|
||||
" from pg_catalog.pg_start_backup('pgBackRest backup started at ' || current_timestamp, %s, false) as lsn\"]", \
|
||||
cvtBoolToConstZ(startFastParam))), \
|
||||
cvtBoolToConstZ(startFastParam)), \
|
||||
.resultInt = 1}, \
|
||||
{.session = sessionParam, .function = HRNPQ_CONSUMEINPUT}, \
|
||||
{.session = sessionParam, .function = HRNPQ_ISBUSY}, \
|
||||
@ -301,11 +301,11 @@ Macros for defining groups of functions that implement various queries and comma
|
||||
#define HRNPQ_MACRO_START_BACKUP_GE_15(sessionParam, startFastParam, lsnParam, walSegmentNameParam) \
|
||||
{.session = sessionParam, \
|
||||
.function = HRNPQ_SENDQUERY, \
|
||||
.param = strZ(strNewFmt( \
|
||||
.param = zNewFmt( \
|
||||
"[\"select lsn::text as lsn,\\n" \
|
||||
" pg_catalog.pg_walfile_name(lsn)::text as wal_segment_name\\n" \
|
||||
" from pg_catalog.pg_backup_start('pgBackRest backup started at ' || current_timestamp, %s) as lsn\"]", \
|
||||
cvtBoolToConstZ(startFastParam))), \
|
||||
cvtBoolToConstZ(startFastParam)), \
|
||||
.resultInt = 1}, \
|
||||
{.session = sessionParam, .function = HRNPQ_CONSUMEINPUT}, \
|
||||
{.session = sessionParam, .function = HRNPQ_ISBUSY}, \
|
||||
@ -474,7 +474,7 @@ Macros for defining groups of functions that implement various queries and comma
|
||||
{.session = sessionParam, .function = HRNPQ_NFIELDS, .resultInt = 2}, \
|
||||
{.session = sessionParam, .function = HRNPQ_FTYPE, .param = "[0]", .resultInt = HRNPQ_TYPE_OID}, \
|
||||
{.session = sessionParam, .function = HRNPQ_FTYPE, .param = "[1]", .resultInt = HRNPQ_TYPE_TEXT}, \
|
||||
{.session = sessionParam, .function = HRNPQ_GETVALUE, .param = "[0,0]", .resultZ = strZ(strNewFmt("%d", id1Param))}, \
|
||||
{.session = sessionParam, .function = HRNPQ_GETVALUE, .param = "[0,0]", .resultZ = zNewFmt("%d", id1Param)}, \
|
||||
{.session = sessionParam, .function = HRNPQ_GETVALUE, .param = "[0,1]", .resultZ = name1Param}, \
|
||||
{.session = sessionParam, .function = HRNPQ_CLEAR}, \
|
||||
{.session = sessionParam, .function = HRNPQ_GETRESULT, .resultNull = true}
|
||||
@ -492,10 +492,10 @@ Macros for defining groups of functions that implement various queries and comma
|
||||
sessionParam, walNameParam, lsnNameParam, targetLsnParam, targetReachedParam, replayLsnParam) \
|
||||
{.session = sessionParam, \
|
||||
.function = HRNPQ_SENDQUERY, \
|
||||
.param = strZ(strNewFmt( \
|
||||
.param = zNewFmt( \
|
||||
"[\"select replayLsn::text,\\n" \
|
||||
" (replayLsn > '%s')::bool as targetReached\\n" \
|
||||
" from pg_catalog.pg_last_" walNameParam "_replay_" lsnNameParam "() as replayLsn\"]", targetLsnParam)), \
|
||||
" from pg_catalog.pg_last_" walNameParam "_replay_" lsnNameParam "() as replayLsn\"]", targetLsnParam), \
|
||||
.resultInt = 1}, \
|
||||
{.session = sessionParam, .function = HRNPQ_CONSUMEINPUT}, \
|
||||
{.session = sessionParam, .function = HRNPQ_ISBUSY}, \
|
||||
@ -520,10 +520,10 @@ Macros for defining groups of functions that implement various queries and comma
|
||||
sessionParam, lsnNameParam, targetLsnParam, targetReachedParam, checkpointLsnParam, sleepParam) \
|
||||
{.session = sessionParam, \
|
||||
.function = HRNPQ_SENDQUERY, \
|
||||
.param = strZ(strNewFmt( \
|
||||
.param = zNewFmt( \
|
||||
"[\"select (checkpoint_" lsnNameParam " > '%s')::bool as targetReached,\\n" \
|
||||
" checkpoint_" lsnNameParam "::text as checkpointLsn\\n" \
|
||||
" from pg_catalog.pg_control_checkpoint()\"]", targetLsnParam)), \
|
||||
" from pg_catalog.pg_control_checkpoint()\"]", targetLsnParam), \
|
||||
.resultInt = 1, .sleep = sleepParam}, \
|
||||
{.session = sessionParam, .function = HRNPQ_CONSUMEINPUT}, \
|
||||
{.session = sessionParam, .function = HRNPQ_ISBUSY}, \
|
||||
|
@ -52,10 +52,10 @@ void hrnServerInit(void)
|
||||
|
||||
// Set correct permissions on private keys
|
||||
THROW_ON_SYS_ERROR(
|
||||
chmod(strZ(strNewFmt("%s/" HRN_SERVER_CERT_PREFIX "server.key", hrnPathRepo())), 0600) == -1, FileModeError,
|
||||
chmod(zNewFmt("%s/" HRN_SERVER_CERT_PREFIX "server.key", hrnPathRepo()), 0600) == -1, FileModeError,
|
||||
"unable to set mode on server key");
|
||||
THROW_ON_SYS_ERROR(
|
||||
chmod(strZ(strNewFmt("%s/" HRN_SERVER_CERT_PREFIX "client.key", hrnPathRepo())), 0600) == -1, FileModeError,
|
||||
chmod(zNewFmt("%s/" HRN_SERVER_CERT_PREFIX "client.key", hrnPathRepo()), 0600) == -1, FileModeError,
|
||||
"unable to set mode on client key");
|
||||
|
||||
// Add hostname when running in a container
|
||||
|
@ -335,7 +335,7 @@ testRun(void)
|
||||
TEST_RESULT_LOG("P00 INFO: pushed WAL file '000000010000000100000001' to the archive");
|
||||
|
||||
TEST_STORAGE_EXISTS(
|
||||
storageRepoIdxWrite(0), strZ(strNewFmt(STORAGE_REPO_ARCHIVE "/11-1/000000010000000100000001-%s.gz", walBuffer1Sha1)),
|
||||
storageRepoIdxWrite(0), zNewFmt(STORAGE_REPO_ARCHIVE "/11-1/000000010000000100000001-%s.gz", walBuffer1Sha1),
|
||||
.remove = true, .comment = "check repo for WAL file, then remove");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -361,7 +361,7 @@ testRun(void)
|
||||
TEST_RESULT_LOG("P00 INFO: pushed WAL file '000000010000000100000001' to the archive");
|
||||
|
||||
TEST_STORAGE_EXISTS(
|
||||
storageRepoIdxWrite(0), strZ(strNewFmt(STORAGE_REPO_ARCHIVE "/11-1/000000010000000100000001-%s.gz", walBuffer1Sha1)),
|
||||
storageRepoIdxWrite(0), zNewFmt(STORAGE_REPO_ARCHIVE "/11-1/000000010000000100000001-%s.gz", walBuffer1Sha1),
|
||||
.comment = "check repo for WAL file");
|
||||
|
||||
// No warning emitted re WAL file already existing with the same checksum due to --no-archive-mode-check
|
||||
@ -396,8 +396,7 @@ testRun(void)
|
||||
// Create tmp file to make it look like a prior push failed partway through to ensure that retries work
|
||||
HRN_STORAGE_PUT_Z(
|
||||
storageTest,
|
||||
strZ(
|
||||
strNewFmt("repo/archive/test/11-1/0000000100000001/000000010000000100000002-%s.gz.pgbackrest.tmp", walBuffer2Sha1)),
|
||||
zNewFmt("repo/archive/test/11-1/0000000100000001/000000010000000100000002-%s.gz.pgbackrest.tmp", walBuffer2Sha1),
|
||||
"PARTIAL", .comment = "write WAL tmp file");
|
||||
|
||||
TEST_RESULT_VOID(cmdArchivePush(), "push the WAL segment");
|
||||
@ -405,9 +404,7 @@ testRun(void)
|
||||
|
||||
TEST_STORAGE_EXISTS(
|
||||
storageRepoIdxWrite(0),
|
||||
strZ(
|
||||
strNewFmt(
|
||||
STORAGE_REPO_ARCHIVE "/11-1/0000000100000001/000000010000000100000002-%s.gz", walBuffer2Sha1)),
|
||||
zNewFmt(STORAGE_REPO_ARCHIVE "/11-1/0000000100000001/000000010000000100000002-%s.gz", walBuffer2Sha1),
|
||||
.comment = "check repo for WAL file");
|
||||
TEST_RESULT_BOOL(
|
||||
storageExistsP(
|
||||
@ -500,11 +497,11 @@ testRun(void)
|
||||
TEST_RESULT_LOG("P00 INFO: pushed WAL file '000000010000000100000002' to the archive");
|
||||
|
||||
TEST_STORAGE_EXISTS(
|
||||
storageTest, strZ(strNewFmt("repo2/archive/test/11-1/0000000100000001/000000010000000100000002-%s", walBuffer2Sha1)),
|
||||
storageTest, zNewFmt("repo2/archive/test/11-1/0000000100000001/000000010000000100000002-%s", walBuffer2Sha1),
|
||||
.remove = true, .comment = "check repo2 for WAL file then remove");
|
||||
|
||||
TEST_STORAGE_EXISTS(
|
||||
storageTest, strZ(strNewFmt("repo3/archive/test/11-1/0000000100000001/000000010000000100000002-%s", walBuffer2Sha1)),
|
||||
storageTest, zNewFmt("repo3/archive/test/11-1/0000000100000001/000000010000000100000002-%s", walBuffer2Sha1),
|
||||
.remove = true, .comment = "check repo3 for WAL file then remove");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -521,8 +518,8 @@ testRun(void)
|
||||
|
||||
TEST_STORAGE_LIST_EMPTY(storageTest, "repo2/archive/test/11-1/0000000100000001", .comment = "check repo2 for no WAL file");
|
||||
TEST_STORAGE_LIST(
|
||||
storageTest, "repo3/archive/test/11-1/0000000100000001",
|
||||
strZ(strNewFmt("000000010000000100000002-%s\n", walBuffer2Sha1)), .comment = "check repo3 for WAL file");
|
||||
storageTest, "repo3/archive/test/11-1/0000000100000001", zNewFmt("000000010000000100000002-%s\n", walBuffer2Sha1),
|
||||
.comment = "check repo3 for WAL file");
|
||||
|
||||
HRN_STORAGE_MODE(storageTest, "repo2/archive/test/11-1/0000000100000001");
|
||||
|
||||
@ -536,8 +533,8 @@ testRun(void)
|
||||
"P00 INFO: pushed WAL file '000000010000000100000002' to the archive");
|
||||
|
||||
TEST_STORAGE_LIST(
|
||||
storageTest, "repo2/archive/test/11-1/0000000100000001",
|
||||
strZ(strNewFmt("000000010000000100000002-%s\n", walBuffer2Sha1)), .comment = "check repo2 for WAL file");
|
||||
storageTest, "repo2/archive/test/11-1/0000000100000001", zNewFmt("000000010000000100000002-%s\n", walBuffer2Sha1),
|
||||
.comment = "check repo2 for WAL file");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("WAL already exists in both repos");
|
||||
@ -554,10 +551,10 @@ testRun(void)
|
||||
TEST_TITLE("push succeeds on one repo when other repo fails to load archive.info");
|
||||
|
||||
TEST_STORAGE_EXISTS(
|
||||
storageTest, strZ(strNewFmt("repo2/archive/test/11-1/0000000100000001/000000010000000100000002-%s", walBuffer2Sha1)),
|
||||
storageTest, zNewFmt("repo2/archive/test/11-1/0000000100000001/000000010000000100000002-%s", walBuffer2Sha1),
|
||||
.remove = true);
|
||||
TEST_STORAGE_EXISTS(
|
||||
storageTest, strZ(strNewFmt("repo3/archive/test/11-1/0000000100000001/000000010000000100000002-%s", walBuffer2Sha1)),
|
||||
storageTest, zNewFmt("repo3/archive/test/11-1/0000000100000001/000000010000000100000002-%s", walBuffer2Sha1),
|
||||
.remove = true);
|
||||
HRN_STORAGE_MODE(storageTest, "repo2", .mode = 0200);
|
||||
|
||||
@ -576,7 +573,7 @@ testRun(void)
|
||||
|
||||
// Make sure WAL got pushed to repo3
|
||||
TEST_STORAGE_EXISTS(
|
||||
storageTest, strZ(strNewFmt("repo3/archive/test/11-1/0000000100000001/000000010000000100000002-%s", walBuffer2Sha1)),
|
||||
storageTest, zNewFmt("repo3/archive/test/11-1/0000000100000001/000000010000000100000002-%s", walBuffer2Sha1),
|
||||
.remove = true);
|
||||
|
||||
HRN_STORAGE_MODE(storageTest, "repo2");
|
||||
@ -594,7 +591,7 @@ testRun(void)
|
||||
|
||||
// Make sure WAL got pushed to repo3
|
||||
TEST_STORAGE_EXISTS(
|
||||
storageTest, strZ(strNewFmt("repo3/archive/test/11-1/0000000100000001/000000010000000100000002-%s", walBuffer2Sha1)),
|
||||
storageTest, zNewFmt("repo3/archive/test/11-1/0000000100000001/000000010000000100000002-%s", walBuffer2Sha1),
|
||||
.remove = true);
|
||||
|
||||
HRN_STORAGE_MODE(storageTest, "repo2/archive/test/11-1");
|
||||
@ -760,7 +757,7 @@ testRun(void)
|
||||
TEST_RESULT_LOG("P00 INFO: pushed WAL file '000000010000000100000001' to the archive asynchronously");
|
||||
|
||||
TEST_STORAGE_EXISTS(
|
||||
storageTest, strZ(strNewFmt("repo/archive/test/9.4-1/0000000100000001/000000010000000100000001-%s", walBuffer1Sha1)),
|
||||
storageTest, zNewFmt("repo/archive/test/9.4-1/0000000100000001/000000010000000100000001-%s", walBuffer1Sha1),
|
||||
.comment = "check repo for WAL file");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -818,7 +815,7 @@ testRun(void)
|
||||
HRN_STORAGE_PUT_EMPTY(storagePgWrite(), "pg_xlog/archive_status/000000010000000100000001.ready");
|
||||
|
||||
TEST_STORAGE_EXISTS(
|
||||
storageTest, strZ(strNewFmt("repo/archive/test/9.4-1/0000000100000001/000000010000000100000001-%s", walBuffer1Sha1)),
|
||||
storageTest, zNewFmt("repo/archive/test/9.4-1/0000000100000001/000000010000000100000001-%s", walBuffer1Sha1),
|
||||
.comment = "check repo1 for WAL 1 file");
|
||||
|
||||
// Create a ready file for WAL 2 but don't create the segment yet -- this will test the file error
|
||||
@ -836,11 +833,11 @@ testRun(void)
|
||||
TEST_PATH "/pg/pg_xlog/000000010000000100000002");
|
||||
|
||||
TEST_STORAGE_EXISTS(
|
||||
storageTest, strZ(strNewFmt("repo/archive/test/9.4-1/0000000100000001/000000010000000100000001-%s", walBuffer1Sha1)),
|
||||
storageTest, zNewFmt("repo/archive/test/9.4-1/0000000100000001/000000010000000100000001-%s", walBuffer1Sha1),
|
||||
.comment = "check repo1 for WAL 1 file");
|
||||
|
||||
TEST_STORAGE_EXISTS(
|
||||
storageTest, strZ(strNewFmt("repo3/archive/test/9.4-1/0000000100000001/000000010000000100000001-%s", walBuffer1Sha1)),
|
||||
storageTest, zNewFmt("repo3/archive/test/9.4-1/0000000100000001/000000010000000100000001-%s", walBuffer1Sha1),
|
||||
.comment = "check repo3 for WAL 1 file");
|
||||
|
||||
TEST_STORAGE_LIST(
|
||||
@ -871,10 +868,10 @@ testRun(void)
|
||||
"P01 DETAIL: pushed WAL file '000000010000000100000002' to the archive");
|
||||
|
||||
TEST_STORAGE_EXISTS(
|
||||
storageTest, strZ(strNewFmt("repo/archive/test/9.4-1/0000000100000001/000000010000000100000002-%s", walBuffer2Sha1)),
|
||||
storageTest, zNewFmt("repo/archive/test/9.4-1/0000000100000001/000000010000000100000002-%s", walBuffer2Sha1),
|
||||
.comment = "check repo1 for WAL 2 file");
|
||||
TEST_STORAGE_EXISTS(
|
||||
storageTest, strZ(strNewFmt("repo3/archive/test/9.4-1/0000000100000001/000000010000000100000002-%s", walBuffer2Sha1)),
|
||||
storageTest, zNewFmt("repo3/archive/test/9.4-1/0000000100000001/000000010000000100000002-%s", walBuffer2Sha1),
|
||||
.comment = "check repo3 for WAL 2 file");
|
||||
|
||||
TEST_STORAGE_LIST(
|
||||
@ -919,10 +916,10 @@ testRun(void)
|
||||
"P01 DETAIL: pushed WAL file '000000010000000100000003' to the archive");
|
||||
|
||||
TEST_STORAGE_EXISTS(
|
||||
storageTest, strZ(strNewFmt("repo/archive/test/9.4-1/0000000100000001/000000010000000100000003-%s", walBuffer3Sha1)),
|
||||
storageTest, zNewFmt("repo/archive/test/9.4-1/0000000100000001/000000010000000100000003-%s", walBuffer3Sha1),
|
||||
.comment = "check repo1 for WAL 3 file");
|
||||
TEST_STORAGE_EXISTS(
|
||||
storageTest, strZ(strNewFmt("repo3/archive/test/9.4-1/0000000100000001/000000010000000100000003-%s", walBuffer3Sha1)),
|
||||
storageTest, zNewFmt("repo3/archive/test/9.4-1/0000000100000001/000000010000000100000003-%s", walBuffer3Sha1),
|
||||
.comment = "check repo3 for WAL 3 file");
|
||||
|
||||
// Remove the ready file to prevent WAL 3 from being considered for the next test
|
||||
|
@ -1176,7 +1176,7 @@ testRun(void)
|
||||
TEST_RESULT_STR_Z(result.copyChecksum, "9bc8ab2dda60ef4beed07d1e19ce0676d5edde67", "copy checksum");
|
||||
TEST_RESULT_PTR(result.pageChecksumResult, NULL, "page checksum result is NULL");
|
||||
TEST_STORAGE_EXISTS(
|
||||
storageRepo(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/%s.gz", strZ(backupLabel), strZ(pgFile))),
|
||||
storageRepo(), zNewFmt(STORAGE_REPO_BACKUP "/%s/%s.gz", strZ(backupLabel), strZ(pgFile)),
|
||||
.comment = "copy file to repo compress success");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -1207,7 +1207,7 @@ testRun(void)
|
||||
TEST_RESULT_UINT(result.backupCopyResult, backupCopyResultChecksum, "checksum file");
|
||||
TEST_RESULT_STR_Z(result.copyChecksum, "9bc8ab2dda60ef4beed07d1e19ce0676d5edde67", "compressed repo file checksum matches");
|
||||
TEST_STORAGE_EXISTS(
|
||||
storageRepo(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/%s.gz", strZ(backupLabel), strZ(pgFile))),
|
||||
storageRepo(), zNewFmt(STORAGE_REPO_BACKUP "/%s/%s.gz", strZ(backupLabel), strZ(pgFile)),
|
||||
.comment = "compressed file exists");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -1426,9 +1426,10 @@ testRun(void)
|
||||
TEST_TITLE("assign label when history is older");
|
||||
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(
|
||||
strNewFmt(STORAGE_REPO_BACKUP "/backup.history/2019/%s.manifest.gz",
|
||||
strZ(backupLabelFormat(backupTypeFull, NULL, timestamp - 4)))));
|
||||
storageRepoWrite(),
|
||||
zNewFmt(
|
||||
STORAGE_REPO_BACKUP "/backup.history/2019/%s.manifest.gz",
|
||||
strZ(backupLabelFormat(backupTypeFull, NULL, timestamp - 4))));
|
||||
|
||||
TEST_RESULT_STR(backupLabelCreate(backupTypeFull, NULL, timestamp), backupLabel, "create label");
|
||||
|
||||
@ -1436,8 +1437,7 @@ testRun(void)
|
||||
TEST_TITLE("assign label when backup is older");
|
||||
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(
|
||||
strNewFmt(STORAGE_REPO_BACKUP "/%s", strZ(backupLabelFormat(backupTypeFull, NULL, timestamp - 2)))));
|
||||
storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s", strZ(backupLabelFormat(backupTypeFull, NULL, timestamp - 2))));
|
||||
|
||||
TEST_RESULT_STR(backupLabelCreate(backupTypeFull, NULL, timestamp), backupLabel, "create label");
|
||||
|
||||
@ -1445,8 +1445,7 @@ testRun(void)
|
||||
TEST_TITLE("advance time when backup is same");
|
||||
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(
|
||||
strNewFmt(STORAGE_REPO_BACKUP "/%s", strZ(backupLabelFormat(backupTypeFull, NULL, timestamp)))));
|
||||
storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s", strZ(backupLabelFormat(backupTypeFull, NULL, timestamp))));
|
||||
|
||||
TEST_RESULT_STR_Z(backupLabelCreate(backupTypeFull, NULL, timestamp), "20191203-193413F", "create label");
|
||||
|
||||
@ -1454,8 +1453,7 @@ testRun(void)
|
||||
TEST_TITLE("error when new label is in the past even with advanced time");
|
||||
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(
|
||||
strNewFmt(STORAGE_REPO_BACKUP "/%s", strZ(backupLabelFormat(backupTypeFull, NULL, timestamp + 1)))));
|
||||
storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s", strZ(backupLabelFormat(backupTypeFull, NULL, timestamp + 1))));
|
||||
|
||||
TEST_ERROR(
|
||||
backupLabelCreate(backupTypeFull, NULL, timestamp), ClockError,
|
||||
@ -1467,9 +1465,10 @@ testRun(void)
|
||||
TEST_TITLE("error when new label is in the past even with advanced time (from history)");
|
||||
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(
|
||||
strNewFmt(STORAGE_REPO_BACKUP "/backup.history/2019/%s.manifest.gz",
|
||||
strZ(backupLabelFormat(backupTypeFull, NULL, timestamp + 3600)))));
|
||||
storageRepoWrite(),
|
||||
zNewFmt(
|
||||
STORAGE_REPO_BACKUP "/backup.history/2019/%s.manifest.gz",
|
||||
strZ(backupLabelFormat(backupTypeFull, NULL, timestamp + 3600))));
|
||||
|
||||
TEST_ERROR(
|
||||
backupLabelCreate(backupTypeFull, NULL, timestamp), ClockError,
|
||||
@ -2239,7 +2238,7 @@ testRun(void)
|
||||
// Copy a file to be resumed that has not changed in the repo
|
||||
HRN_STORAGE_COPY(
|
||||
storagePg(), PG_FILE_PGVERSION, storageRepoWrite(),
|
||||
strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/PG_VERSION", strZ(resumeLabel))));
|
||||
zNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/PG_VERSION", strZ(resumeLabel)));
|
||||
|
||||
ManifestFilePack **const filePack = manifestFilePackFindInternal(manifestResume, STRDEF("pg_data/PG_VERSION"));
|
||||
ManifestFile file = manifestFileUnpack(manifestResume, *filePack);
|
||||
@ -2331,11 +2330,11 @@ testRun(void)
|
||||
// File exists in cluster and repo but not in the resume manifest
|
||||
HRN_STORAGE_PUT_Z(storagePgWrite(), "not-in-resume", "TEST", .timeModified = backupTimeStart);
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/not-in-resume.gz", strZ(resumeLabel))));
|
||||
storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/not-in-resume.gz", strZ(resumeLabel)));
|
||||
|
||||
// Remove checksum from file so it won't be resumed
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/global/pg_control.gz", strZ(resumeLabel))));
|
||||
storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/global/pg_control.gz", strZ(resumeLabel)));
|
||||
|
||||
ManifestFilePack **const filePack = manifestFilePackFindInternal(manifestResume, STRDEF("pg_data/global/pg_control"));
|
||||
ManifestFile file = manifestFileUnpack(manifestResume, *filePack);
|
||||
@ -2347,7 +2346,7 @@ testRun(void)
|
||||
// Size does not match between cluster and resume manifest
|
||||
HRN_STORAGE_PUT_Z(storagePgWrite(), "size-mismatch", "TEST", .timeModified = backupTimeStart);
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/size-mismatch.gz", strZ(resumeLabel))));
|
||||
storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/size-mismatch.gz", strZ(resumeLabel)));
|
||||
manifestFileAdd(
|
||||
manifestResume, &(ManifestFile){
|
||||
.name = STRDEF("pg_data/size-mismatch"), .checksumSha1 = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
@ -2356,7 +2355,7 @@ testRun(void)
|
||||
// Time does not match between cluster and resume manifest
|
||||
HRN_STORAGE_PUT_Z(storagePgWrite(), "time-mismatch", "TEST", .timeModified = backupTimeStart);
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/time-mismatch.gz", strZ(resumeLabel))));
|
||||
storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/time-mismatch.gz", strZ(resumeLabel)));
|
||||
manifestFileAdd(
|
||||
manifestResume, &(ManifestFile){
|
||||
.name = STRDEF("pg_data/time-mismatch"), .checksumSha1 = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", .size = 4,
|
||||
@ -2365,22 +2364,19 @@ testRun(void)
|
||||
// Size is zero in cluster and resume manifest. ??? We'd like to remove this requirement after the migration.
|
||||
HRN_STORAGE_PUT_EMPTY(storagePgWrite(), "zero-size", .timeModified = backupTimeStart);
|
||||
HRN_STORAGE_PUT_Z(
|
||||
storageRepoWrite(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/zero-size.gz", strZ(resumeLabel))),
|
||||
"ZERO-SIZE");
|
||||
storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/zero-size.gz", strZ(resumeLabel)), "ZERO-SIZE");
|
||||
manifestFileAdd(
|
||||
manifestResume, &(ManifestFile){.name = STRDEF("pg_data/zero-size"), .size = 0, .timestamp = backupTimeStart});
|
||||
|
||||
// Path is not in manifest
|
||||
HRN_STORAGE_PATH_CREATE(
|
||||
storageRepoWrite(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/bogus_path", strZ(resumeLabel))));
|
||||
HRN_STORAGE_PATH_CREATE(storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/bogus_path", strZ(resumeLabel)));
|
||||
|
||||
// File is not in manifest
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/global/bogus.gz", strZ(resumeLabel))));
|
||||
storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/global/bogus.gz", strZ(resumeLabel)));
|
||||
|
||||
// File has incorrect compression type
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/global/bogus", strZ(resumeLabel))));
|
||||
HRN_STORAGE_PUT_EMPTY(storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/global/bogus", strZ(resumeLabel)));
|
||||
|
||||
// Save the resume manifest
|
||||
manifestSave(
|
||||
@ -2521,13 +2517,11 @@ testRun(void)
|
||||
manifestBackupLabelSet(manifestResume, resumeLabel);
|
||||
|
||||
// Reference in manifest
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/PG_VERSION.gz", strZ(resumeLabel))));
|
||||
HRN_STORAGE_PUT_EMPTY(storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/PG_VERSION.gz", strZ(resumeLabel)));
|
||||
|
||||
// Reference in resumed manifest
|
||||
HRN_STORAGE_PUT_EMPTY(storagePgWrite(), "resume-ref", .timeModified = backupTimeStart);
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/resume-ref.gz", strZ(resumeLabel))));
|
||||
HRN_STORAGE_PUT_EMPTY(storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/resume-ref.gz", strZ(resumeLabel)));
|
||||
manifestFileAdd(
|
||||
manifestResume, &(ManifestFile){.name = STRDEF("pg_data/resume-ref"), .size = 0, .reference = STRDEF("BOGUS")});
|
||||
|
||||
@ -2535,7 +2529,7 @@ testRun(void)
|
||||
// also that the repo file is intenionally corrupt to generate a warning about corruption in the repository.
|
||||
HRN_STORAGE_PUT_Z(storagePgWrite(), "time-mismatch2", "TEST", .timeModified = backupTimeStart + 100);
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/time-mismatch2.gz", strZ(resumeLabel))));
|
||||
storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/time-mismatch2.gz", strZ(resumeLabel)));
|
||||
manifestFileAdd(
|
||||
manifestResume, &(ManifestFile){
|
||||
.name = STRDEF("pg_data/time-mismatch2"), .checksumSha1 = "984816fd329622876e14907634264e6f332e9fb3", .size = 4,
|
||||
@ -2877,7 +2871,7 @@ testRun(void)
|
||||
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageTest,
|
||||
strZ(strNewFmt("pg1-tblspc/32768/%s/1/5", strZ(pgTablespaceId(PG_VERSION_11, hrnPgCatalogVersion(PG_VERSION_11))))),
|
||||
zNewFmt("pg1-tblspc/32768/%s/1/5", strZ(pgTablespaceId(PG_VERSION_11, hrnPgCatalogVersion(PG_VERSION_11)))),
|
||||
.timeModified = backupTimeStart);
|
||||
|
||||
// Disable storageFeatureSymLink so tablespace (and latest) symlinks will not be created
|
||||
|
@ -1975,8 +1975,8 @@ testRun(void)
|
||||
TEST_RESULT_STR(storageInfoP(storageRepo(), STRDEF(STORAGE_REPO_BACKUP "/latest")).linkDestination,
|
||||
STRDEF("20181119-152850F"), "latest link updated");
|
||||
TEST_STORAGE_LIST(
|
||||
storageRepo(), STORAGE_REPO_ARCHIVE "/12-2/0000000100000000", strZ(strNewFmt(
|
||||
"%s%s", archiveExpectList(2, 4, "0000000100000000"), archiveExpectList(6, 10, "0000000100000000"))),
|
||||
storageRepo(), STORAGE_REPO_ARCHIVE "/12-2/0000000100000000",
|
||||
zNewFmt("%s%s", archiveExpectList(2, 4, "0000000100000000"), archiveExpectList(6, 10, "0000000100000000")),
|
||||
.comment = "no archives removed from latest except what was already removed");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -45,7 +45,7 @@ testRun(void)
|
||||
const char *helpVersion = PROJECT_NAME " " PROJECT_VERSION;
|
||||
|
||||
// General help text is used in more than one test
|
||||
const char *generalHelp = strZ(strNewFmt(
|
||||
const char *generalHelp = zNewFmt(
|
||||
"%s - General help\n"
|
||||
"\n"
|
||||
"Usage:\n"
|
||||
@ -73,7 +73,7 @@ testRun(void)
|
||||
" version Get version.\n"
|
||||
"\n"
|
||||
"Use 'pgbackrest help [command]' for more information.\n",
|
||||
helpVersion));
|
||||
helpVersion);
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("helpRenderSplitSize()"))
|
||||
@ -144,14 +144,14 @@ testRun(void)
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("version command");
|
||||
|
||||
const char *commandHelp = strZ(strNewFmt(
|
||||
const char *commandHelp = zNewFmt(
|
||||
"%s%s",
|
||||
helpVersion,
|
||||
" - 'version' command help\n"
|
||||
"\n"
|
||||
"Get version.\n"
|
||||
"\n"
|
||||
"Displays installed pgBackRest version.\n"));
|
||||
"Displays installed pgBackRest version.\n");
|
||||
|
||||
argList = strLstNew();
|
||||
strLstAddZ(argList, "/path/to/pgbackrest");
|
||||
@ -164,7 +164,7 @@ testRun(void)
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("restore command");
|
||||
|
||||
commandHelp = strZ(strNewFmt(
|
||||
commandHelp = zNewFmt(
|
||||
"%s%s%s",
|
||||
helpVersion,
|
||||
" - 'restore' command help\n"
|
||||
@ -318,7 +318,7 @@ testRun(void)
|
||||
"\n"
|
||||
" --pg-path postgreSQL data directory\n"
|
||||
"\n"
|
||||
"Use 'pgbackrest help restore [option]' for more information.\n"));
|
||||
"Use 'pgbackrest help restore [option]' for more information.\n");
|
||||
|
||||
argList = strLstNew();
|
||||
strLstAddZ(argList, "/path/to/pgbackrest");
|
||||
@ -367,7 +367,7 @@ testRun(void)
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("default and current option value");
|
||||
|
||||
const char *optionHelp = strZ(strNewFmt(
|
||||
const char *optionHelp = zNewFmt(
|
||||
"%s - 'archive-push' command - 'buffer-size' option help\n"
|
||||
"\n"
|
||||
"Buffer size for I/O operations.\n"
|
||||
@ -383,7 +383,7 @@ testRun(void)
|
||||
"\n"
|
||||
"Allowed values are 16KiB, 32KiB, 64KiB, 128KiB, 256KiB, 512KiB, 1MiB, 2MiB,\n"
|
||||
"4MiB, 8MiB, and 16MiB.\n",
|
||||
helpVersion));
|
||||
helpVersion);
|
||||
|
||||
argList = strLstNew();
|
||||
strLstAddZ(argList, "/path/to/pgbackrest");
|
||||
@ -414,10 +414,10 @@ testRun(void)
|
||||
#define HELP_OPTION_DEPRECATED_NAMES \
|
||||
"deprecated names: repo-azure-host, repo-s3-host\n"
|
||||
|
||||
optionHelp = strZ(strNewFmt(
|
||||
optionHelp = zNewFmt(
|
||||
HELP_OPTION
|
||||
HELP_OPTION_DEPRECATED_NAMES,
|
||||
helpVersion));
|
||||
helpVersion);
|
||||
|
||||
argList = strLstNew();
|
||||
strLstAddZ(argList, "/path/to/pgbackrest");
|
||||
@ -427,12 +427,12 @@ testRun(void)
|
||||
TEST_RESULT_VOID(testCfgLoad(argList), "help for archive-push command, repo1-s3-host option");
|
||||
TEST_RESULT_STR_Z(helpRender(helpData), optionHelp, "check text");
|
||||
|
||||
optionHelp = strZ(strNewFmt(
|
||||
optionHelp = zNewFmt(
|
||||
HELP_OPTION
|
||||
"current: s3-host\n"
|
||||
"\n"
|
||||
HELP_OPTION_DEPRECATED_NAMES,
|
||||
helpVersion));
|
||||
helpVersion);
|
||||
|
||||
// Set a current value for deprecated option name
|
||||
hrnCfgArgRawZ(argList, cfgOptRepoType, "s3");
|
||||
@ -443,7 +443,7 @@ testRun(void)
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("cipher pass redacted");
|
||||
|
||||
optionHelp = strZ(strNewFmt(
|
||||
optionHelp = zNewFmt(
|
||||
"%s - 'archive-push' command - 'repo-cipher-pass' option help\n"
|
||||
"\n"
|
||||
"Repository cipher passphrase.\n"
|
||||
@ -451,7 +451,7 @@ testRun(void)
|
||||
"Passphrase used to encrypt/decrypt files of the repository.\n"
|
||||
"\n"
|
||||
"current: <redacted>\n",
|
||||
helpVersion));
|
||||
helpVersion);
|
||||
|
||||
argList = strLstNew();
|
||||
strLstAddZ(argList, "/path/to/pgbackrest");
|
||||
@ -467,7 +467,7 @@ testRun(void)
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("deprecated and new option name produce same results");
|
||||
|
||||
optionHelp = strZ(strNewFmt(
|
||||
optionHelp = zNewFmt(
|
||||
"%s - 'backup' command - 'repo-hardlink' option help\n"
|
||||
"\n"
|
||||
"Hardlink files between backups in the repository.\n"
|
||||
@ -480,7 +480,7 @@ testRun(void)
|
||||
"default: n\n"
|
||||
"\n"
|
||||
"deprecated name: hardlink\n",
|
||||
helpVersion));
|
||||
helpVersion);
|
||||
|
||||
argList = strLstNew();
|
||||
strLstAddZ(argList, "/path/to/pgbackrest");
|
||||
@ -501,7 +501,7 @@ testRun(void)
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("check admonition");
|
||||
|
||||
optionHelp = strZ(strNewFmt(
|
||||
optionHelp = zNewFmt(
|
||||
"%s - 'backup' command - 'repo-retention-archive' option help\n"
|
||||
"\n"
|
||||
"Number of backups worth of continuous WAL to retain.\n"
|
||||
@ -524,7 +524,7 @@ testRun(void)
|
||||
"expired WAL and is therefore not recommended.\n"
|
||||
"\n"
|
||||
"deprecated name: retention-archive\n",
|
||||
helpVersion));
|
||||
helpVersion);
|
||||
|
||||
argList = strLstNew();
|
||||
strLstAddZ(argList, "/path/to/pgbackrest");
|
||||
|
@ -620,7 +620,7 @@ testRun(void)
|
||||
writeBuffer = bufNew(0);
|
||||
TEST_ERROR(
|
||||
storageGetProcess(ioBufferWriteNew(writeBuffer)), OptionInvalidValueError,
|
||||
strZ(strNewFmt("unable to determine cipher passphrase for '%s'", strZ(fileEncCustomName))));
|
||||
zNewFmt("unable to determine cipher passphrase for '%s'", strZ(fileEncCustomName)));
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("get encrypted archive.info - stanza mismatch");
|
||||
|
@ -202,7 +202,7 @@ testRun(void)
|
||||
TEST_TITLE("compressed encrypted repo file - fail");
|
||||
|
||||
HRN_STORAGE_PUT_Z(
|
||||
storageRepoWrite(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/%s", strZ(repoFileReferenceFull), strZ(repoFile1))),
|
||||
storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s/%s", strZ(repoFileReferenceFull), strZ(repoFile1)),
|
||||
"acefile", .compressType = compressTypeGz, .cipherType = cipherTypeAes256Cbc, .cipherPass = "badpass",
|
||||
.comment = "create a compressed encrypted repo file");
|
||||
|
||||
@ -2108,7 +2108,7 @@ testRun(void)
|
||||
TEST_RESULT_VOID(cmdRestore(), "successful restore");
|
||||
|
||||
TEST_RESULT_LOG(
|
||||
strZ(strNewFmt(
|
||||
zNewFmt(
|
||||
"P00 WARN: repo1: [FileMissingError] unable to load info file"
|
||||
" '%s/repo/backup/test1/backup.info' or '%s/repo/backup/test1/backup.info.copy':\n"
|
||||
" FileMissingError: unable to open missing file '%s/repo/backup/test1/backup.info' for read\n"
|
||||
@ -2127,7 +2127,7 @@ testRun(void)
|
||||
"P00 WARN: backup does not contain 'global/pg_control' -- cluster will not start\n"
|
||||
"P00 DETAIL: sync path '" TEST_PATH "/pg/global'\n"
|
||||
"P00 INFO: restore size = 4B, file total = 1",
|
||||
TEST_PATH, TEST_PATH, TEST_PATH, TEST_PATH)));
|
||||
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.
|
||||
HRN_STORAGE_REMOVE(storagePgWrite(), PG_FILE_RECOVERYCONF, .errorOnMissing = true);
|
||||
@ -2185,8 +2185,7 @@ testRun(void)
|
||||
|
||||
// Change destination of tablespace link
|
||||
THROW_ON_SYS_ERROR(
|
||||
symlink("/bogus", strZ(strNewFmt("%s/pg_tblspc/1", strZ(pgPath)))) == -1, FileOpenError,
|
||||
"unable to create symlink");
|
||||
symlink("/bogus", zNewFmt("%s/pg_tblspc/1", strZ(pgPath))) == -1, FileOpenError, "unable to create symlink");
|
||||
|
||||
MEM_CONTEXT_BEGIN(manifest->pub.memContext)
|
||||
{
|
||||
@ -2711,8 +2710,7 @@ testRun(void)
|
||||
manifestLinkAdd(
|
||||
manifest, &(ManifestLink){.name = name, .destination = destination, .group = groupName(), .user = userName()});
|
||||
THROW_ON_SYS_ERROR(
|
||||
symlink("../wal", strZ(strNewFmt("%s/pg_wal", strZ(pgPath)))) == -1, FileOpenError,
|
||||
"unable to create symlink");
|
||||
symlink("../wal", zNewFmt("%s/pg_wal", strZ(pgPath))) == -1, FileOpenError, "unable to create symlink");
|
||||
|
||||
// pg_xact path
|
||||
manifestPathAdd(
|
||||
@ -2765,9 +2763,7 @@ testRun(void)
|
||||
HRN_STORAGE_PUT_Z(storagePgWrite(), "yyy", "yyy", .modeFile = 0600);
|
||||
|
||||
// Add a few bogus links to be deleted
|
||||
THROW_ON_SYS_ERROR(
|
||||
symlink("../wal", strZ(strNewFmt("%s/pg_wal2", strZ(pgPath)))) == -1, FileOpenError,
|
||||
"unable to create symlink");
|
||||
THROW_ON_SYS_ERROR(symlink("../wal", zNewFmt("%s/pg_wal2", strZ(pgPath))) == -1, FileOpenError, "unable to create symlink");
|
||||
|
||||
TEST_RESULT_VOID(cmdRestore(), "successful restore");
|
||||
|
||||
|
@ -1008,7 +1008,7 @@ testRun(void)
|
||||
|
||||
HRN_STORAGE_PUT(
|
||||
storageRepoIdxWrite(0),
|
||||
strZ(strNewFmt(STORAGE_REPO_ARCHIVE "/11-2/0000000200000007/000000020000000700000FFE-%s", walBufferSha1)), walBuffer,
|
||||
zNewFmt(STORAGE_REPO_ARCHIVE "/11-2/0000000200000007/000000020000000700000FFE-%s", walBufferSha1), walBuffer,
|
||||
.comment = "valid WAL");
|
||||
HRN_STORAGE_PUT(
|
||||
storageRepoIdxWrite(0),
|
||||
@ -1058,15 +1058,14 @@ testRun(void)
|
||||
walBuffer, .compressType = compressTypeGz, .comment = "first WAL compressed - but checksum failure");
|
||||
HRN_STORAGE_PUT(
|
||||
storageRepoIdxWrite(0),
|
||||
strZ(
|
||||
strNewFmt(
|
||||
zNewFmt(
|
||||
STORAGE_REPO_ARCHIVE "/11-2/0000000200000007/000000020000000700000FFF-%s",
|
||||
strZ(bufHex(cryptoHashOne(HASH_TYPE_SHA1_STR, BUFSTRDEF("invalidsize")))))),
|
||||
strZ(bufHex(cryptoHashOne(HASH_TYPE_SHA1_STR, BUFSTRDEF("invalidsize"))))),
|
||||
BUFSTRDEF("invalidsize"), .comment = "WAL - invalid size");
|
||||
HRN_STORAGE_PUT(
|
||||
storageRepoIdxWrite(0),
|
||||
strZ(strNewFmt(STORAGE_REPO_ARCHIVE "/11-2/0000000200000008/000000020000000800000000-%s", walBufferSha1)),
|
||||
walBuffer, .comment = "WAL - continue range");
|
||||
zNewFmt(STORAGE_REPO_ARCHIVE "/11-2/0000000200000008/000000020000000800000000-%s", walBufferSha1), walBuffer,
|
||||
.comment = "WAL - continue range");
|
||||
|
||||
// Set log detail level to capture ranges
|
||||
harnessLogLevelSet(logLevelDetail);
|
||||
@ -1141,15 +1140,15 @@ testRun(void)
|
||||
|
||||
HRN_STORAGE_PUT(
|
||||
storageRepoIdxWrite(0),
|
||||
strZ(strNewFmt(STORAGE_REPO_ARCHIVE "/11-2/0000000200000008/000000020000000800000002-%s", walBufferSha1)),
|
||||
zNewFmt(STORAGE_REPO_ARCHIVE "/11-2/0000000200000008/000000020000000800000002-%s", walBufferSha1),
|
||||
walBuffer, .comment = "WAL - starts next range");
|
||||
HRN_STORAGE_PUT(
|
||||
storageRepoIdxWrite(0),
|
||||
strZ(strNewFmt(STORAGE_REPO_ARCHIVE "/11-2/0000000300000000/000000030000000000000000-%s", walBufferSha1)),
|
||||
zNewFmt(STORAGE_REPO_ARCHIVE "/11-2/0000000300000000/000000030000000000000000-%s", walBufferSha1),
|
||||
walBuffer, .comment = "WAL - starts next timeline");
|
||||
HRN_STORAGE_PUT(
|
||||
storageRepoIdxWrite(0),
|
||||
strZ(strNewFmt(STORAGE_REPO_ARCHIVE "/11-2/0000000300000000/000000030000000000000001-%s", walBufferSha1)),
|
||||
zNewFmt(STORAGE_REPO_ARCHIVE "/11-2/0000000300000000/000000030000000000000001-%s", walBufferSha1),
|
||||
walBuffer, .comment = "WAL - end next timeline");
|
||||
|
||||
// Set log level to errors only
|
||||
@ -1631,7 +1630,7 @@ testRun(void)
|
||||
.comment = "valid manifest copy - full");
|
||||
|
||||
HRN_STORAGE_PUT_Z(
|
||||
storageRepoWrite(), STORAGE_REPO_BACKUP "/20201119-163000F/bundle/1", strZ(strNewFmt("XXX%s", fileContents)),
|
||||
storageRepoWrite(), STORAGE_REPO_BACKUP "/20201119-163000F/bundle/1", zNewFmt("XXX%s", fileContents),
|
||||
.comment = "valid file");
|
||||
|
||||
// Create WAL file with just header info and small WAL size
|
||||
@ -1643,7 +1642,7 @@ testRun(void)
|
||||
|
||||
HRN_STORAGE_PUT(
|
||||
storageRepoWrite(),
|
||||
strZ(strNewFmt(STORAGE_REPO_ARCHIVE "/11-2/0000000200000000/000000020000000000000001-%s", walBufferSha1)), walBuffer,
|
||||
zNewFmt(STORAGE_REPO_ARCHIVE "/11-2/0000000200000000/000000020000000000000001-%s", walBufferSha1), walBuffer,
|
||||
.comment = "valid WAL");
|
||||
|
||||
// Redirect stdout to a file
|
||||
@ -1855,7 +1854,7 @@ testRun(void)
|
||||
|
||||
HRN_STORAGE_PUT(
|
||||
storageRepoIdxWrite(0),
|
||||
strZ(strNewFmt(STORAGE_REPO_ARCHIVE "/11-2/0000000200000007/000000020000000700000FFE-%s", walBufferSha1)), walBuffer,
|
||||
zNewFmt(STORAGE_REPO_ARCHIVE "/11-2/0000000200000007/000000020000000700000FFE-%s", walBufferSha1), walBuffer,
|
||||
.comment = "valid WAL");
|
||||
|
||||
harnessLogLevelSet(logLevelDetail);
|
||||
@ -1926,7 +1925,7 @@ testRun(void)
|
||||
|
||||
HRN_STORAGE_PUT(
|
||||
storageRepoIdxWrite(0),
|
||||
strZ(strNewFmt(STORAGE_REPO_ARCHIVE "/11-2/0000000200000007/000000020000000700000FFE-%s", walBufferSha1)), walBuffer,
|
||||
zNewFmt(STORAGE_REPO_ARCHIVE "/11-2/0000000200000007/000000020000000700000FFE-%s", walBufferSha1), walBuffer,
|
||||
.comment = "valid WAL");
|
||||
|
||||
harnessLogLevelSet(logLevelDetail);
|
||||
@ -1981,7 +1980,7 @@ testRun(void)
|
||||
|
||||
HRN_STORAGE_PUT(
|
||||
storageRepoIdxWrite(0),
|
||||
strZ(strNewFmt(STORAGE_REPO_ARCHIVE "/11-2/0000000200000007/000000020000000700000FFE-%s", walBufferSha1)), walBuffer,
|
||||
zNewFmt(STORAGE_REPO_ARCHIVE "/11-2/0000000200000007/000000020000000700000FFE-%s", walBufferSha1), walBuffer,
|
||||
.comment = "valid WAL");
|
||||
|
||||
harnessLogLevelSet(logLevelDetail);
|
||||
|
@ -87,7 +87,7 @@ testRun(void)
|
||||
// Add ints to the list
|
||||
for (int listIdx = 1; listIdx <= LIST_INITIAL_SIZE; listIdx++)
|
||||
{
|
||||
TEST_RESULT_VOID(lstAdd(list, &listIdx), strZ(strNewFmt("add item %d", listIdx)));
|
||||
TEST_RESULT_VOID(lstAdd(list, &listIdx), zNewFmt("add item %d", listIdx));
|
||||
}
|
||||
|
||||
lstMove(list, memContextPrior());
|
||||
@ -96,7 +96,7 @@ testRun(void)
|
||||
|
||||
// Insert an int at the beginning
|
||||
int insertIdx = 0;
|
||||
TEST_RESULT_INT(*(int *)lstInsert(list, 0, &insertIdx), 0, strZ(strNewFmt("insert item %d", insertIdx)));
|
||||
TEST_RESULT_INT(*(int *)lstInsert(list, 0, &insertIdx), 0, zNewFmt("insert item %d", insertIdx));
|
||||
|
||||
// Check the size
|
||||
TEST_RESULT_INT(lstSize(list), 9, "list size");
|
||||
@ -106,7 +106,7 @@ testRun(void)
|
||||
for (unsigned int listIdx = 0; listIdx < lstSize(list); listIdx++)
|
||||
{
|
||||
int *item = lstGet(list, listIdx);
|
||||
TEST_RESULT_INT(*item, listIdx, strZ(strNewFmt("check item %u", listIdx)));
|
||||
TEST_RESULT_INT(*item, listIdx, zNewFmt("check item %u", listIdx));
|
||||
}
|
||||
|
||||
// Remove first item
|
||||
@ -117,7 +117,7 @@ testRun(void)
|
||||
{
|
||||
int *item = listIdx == lstSize(list) - 1 ? lstGetLast(list) : lstGet(list, listIdx);
|
||||
|
||||
TEST_RESULT_INT(*item, listIdx + 1, strZ(strNewFmt("check item %u", listIdx)));
|
||||
TEST_RESULT_INT(*item, listIdx + 1, zNewFmt("check item %u", listIdx));
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -129,7 +129,7 @@ testRun(void)
|
||||
for (int listIdx = 0; listIdx < 8; listIdx++)
|
||||
{
|
||||
int item = listIdx + 9;
|
||||
TEST_RESULT_VOID(lstAdd(list, &item), strZ(strNewFmt("add item %d", item)));
|
||||
TEST_RESULT_VOID(lstAdd(list, &item), zNewFmt("add item %d", item));
|
||||
}
|
||||
|
||||
TEST_RESULT_UINT(lstSize(list), list->listSizeMax, "size equals max size");
|
||||
@ -141,7 +141,7 @@ testRun(void)
|
||||
for (unsigned int listIdx = 0; listIdx < lstSize(list); listIdx++)
|
||||
{
|
||||
int *item = lstGet(list, listIdx);
|
||||
TEST_RESULT_INT(*item, listIdx + 1, strZ(strNewFmt("check item %u", listIdx)));
|
||||
TEST_RESULT_INT(*item, listIdx + 1, zNewFmt("check item %u", listIdx));
|
||||
}
|
||||
|
||||
TEST_ERROR(lstGet(list, lstSize(list)), AssertError, "cannot get index 15 from list with 15 value(s)");
|
||||
|
@ -273,7 +273,7 @@ testRun(void)
|
||||
|
||||
while (pckReadNext(packRead))
|
||||
{
|
||||
TEST_RESULT_UINT(pckReadU64P(packRead, .id = pckReadId(packRead)), value, strZ(strNewFmt("read %u", value)));
|
||||
TEST_RESULT_UINT(pckReadU64P(packRead, .id = pckReadId(packRead)), value, zNewFmt("read %u", value));
|
||||
value++;
|
||||
}
|
||||
|
||||
|
@ -341,8 +341,7 @@ testRun(void)
|
||||
else
|
||||
{
|
||||
TEST_RESULT_STR(
|
||||
strLstAddFmt(list, "STR%02d", listIdx), strNewFmt("STR%02d", listIdx),
|
||||
strZ(strNewFmt("add item %d", listIdx)));
|
||||
strLstAddFmt(list, "STR%02d", listIdx), strNewFmt("STR%02d", listIdx), zNewFmt("add item %d", listIdx));
|
||||
}
|
||||
}
|
||||
|
||||
@ -357,11 +356,9 @@ testRun(void)
|
||||
for (unsigned int listIdx = 0; listIdx < strLstSize(list); listIdx++)
|
||||
{
|
||||
if (listIdx == 0)
|
||||
{
|
||||
TEST_RESULT_STR(strLstGet(list, listIdx), NULL, "check null item");
|
||||
}
|
||||
else
|
||||
TEST_RESULT_STR(strLstGet(list, listIdx), strNewFmt("STR%02u", listIdx), strZ(strNewFmt("check item %u", listIdx)));
|
||||
TEST_RESULT_STR(strLstGet(list, listIdx), strNewFmt("STR%02u", listIdx), zNewFmt("check item %u", listIdx));
|
||||
}
|
||||
|
||||
TEST_RESULT_VOID(strLstFree(list), "free string list");
|
||||
@ -428,13 +425,9 @@ testRun(void)
|
||||
for (unsigned int listIdx = 0; listIdx < strLstSize(list); listIdx++)
|
||||
{
|
||||
if (listIdx == 0)
|
||||
{
|
||||
TEST_RESULT_PTR(szList[listIdx], NULL, "check null item");
|
||||
}
|
||||
else
|
||||
{
|
||||
TEST_RESULT_Z_STR(szList[listIdx], strNewFmt("STR%02u", listIdx), strZ(strNewFmt("check item %u", listIdx)));
|
||||
}
|
||||
TEST_RESULT_Z_STR(szList[listIdx], strNewFmt("STR%02u", listIdx), zNewFmt("check item %u", listIdx));
|
||||
}
|
||||
|
||||
TEST_RESULT_PTR(szList[strLstSize(list)], NULL, "check null terminator");
|
||||
@ -695,6 +688,12 @@ testRun(void)
|
||||
TEST_RESULT_Z(buffer, "ab", " check buffer");
|
||||
}
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("z*()"))
|
||||
{
|
||||
TEST_RESULT_Z(zNewFmt("id=%d", 777), "id=777", "format");
|
||||
}
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("strLstToLog()"))
|
||||
{
|
||||
|
@ -23,12 +23,12 @@ testOptionFind(const char *optionName, unsigned int optionId, unsigned int optio
|
||||
{
|
||||
CfgParseOptionResult option = cfgParseOptionP(STR(optionName));
|
||||
|
||||
TEST_RESULT_BOOL(option.found, true, strZ(strNewFmt("check %s found", optionName)));
|
||||
TEST_RESULT_UINT(option.id, optionId, strZ(strNewFmt("check %s id %u", optionName, optionId)));
|
||||
TEST_RESULT_UINT(option.keyIdx, optionKeyIdx, strZ(strNewFmt("check %s key idx %u", optionName, optionKeyIdx)));
|
||||
TEST_RESULT_BOOL(option.negate, negate, strZ(strNewFmt("check %s negate %d", optionName, negate)));
|
||||
TEST_RESULT_BOOL(option.reset, reset, strZ(strNewFmt("check %s reset %d", optionName, reset)));
|
||||
TEST_RESULT_BOOL(option.deprecated, deprecated, strZ(strNewFmt("check %s deprecated %d", optionName, deprecated)));
|
||||
TEST_RESULT_BOOL(option.found, true, zNewFmt("check %s found", optionName));
|
||||
TEST_RESULT_UINT(option.id, optionId, zNewFmt("check %s id %u", optionName, optionId));
|
||||
TEST_RESULT_UINT(option.keyIdx, optionKeyIdx, zNewFmt("check %s key idx %u", optionName, optionKeyIdx));
|
||||
TEST_RESULT_BOOL(option.negate, negate, zNewFmt("check %s negate %d", optionName, negate));
|
||||
TEST_RESULT_BOOL(option.reset, reset, zNewFmt("check %s reset %d", optionName, reset));
|
||||
TEST_RESULT_BOOL(option.deprecated, deprecated, zNewFmt("check %s deprecated %d", optionName, deprecated));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -2109,14 +2109,14 @@ testRun(void)
|
||||
// Only check 1-8 since 8 was the max index when these option names were deprecated
|
||||
for (unsigned int optionIdx = 0; optionIdx < 8; optionIdx++)
|
||||
{
|
||||
testOptionFind(strZ(strNewFmt("db%u-cmd", optionIdx + 1)), cfgOptPgHostCmd, optionIdx, false, false, true);
|
||||
testOptionFind(strZ(strNewFmt("db%u-config", optionIdx + 1)), cfgOptPgHostConfig, optionIdx, false, false, true);
|
||||
testOptionFind(strZ(strNewFmt("db%u-host", optionIdx + 1)), cfgOptPgHost, optionIdx, false, false, true);
|
||||
testOptionFind(strZ(strNewFmt("db%u-path", optionIdx + 1)), cfgOptPgPath, optionIdx, false, false, true);
|
||||
testOptionFind(strZ(strNewFmt("db%u-port", optionIdx + 1)), cfgOptPgPort, optionIdx, false, false, true);
|
||||
testOptionFind(strZ(strNewFmt("db%u-socket-path", optionIdx + 1)), cfgOptPgSocketPath, optionIdx, false, false, true);
|
||||
testOptionFind(strZ(strNewFmt("db%u-ssh-port", optionIdx + 1)), cfgOptPgHostPort, optionIdx, false, false, true);
|
||||
testOptionFind(strZ(strNewFmt("db%u-user", optionIdx + 1)), cfgOptPgHostUser, optionIdx, false, false, true);
|
||||
testOptionFind(zNewFmt("db%u-cmd", optionIdx + 1), cfgOptPgHostCmd, optionIdx, false, false, true);
|
||||
testOptionFind(zNewFmt("db%u-config", optionIdx + 1), cfgOptPgHostConfig, optionIdx, false, false, true);
|
||||
testOptionFind(zNewFmt("db%u-host", optionIdx + 1), cfgOptPgHost, optionIdx, false, false, true);
|
||||
testOptionFind(zNewFmt("db%u-path", optionIdx + 1), cfgOptPgPath, optionIdx, false, false, true);
|
||||
testOptionFind(zNewFmt("db%u-port", optionIdx + 1), cfgOptPgPort, optionIdx, false, false, true);
|
||||
testOptionFind(zNewFmt("db%u-socket-path", optionIdx + 1), cfgOptPgSocketPath, optionIdx, false, false, true);
|
||||
testOptionFind(zNewFmt("db%u-ssh-port", optionIdx + 1), cfgOptPgHostPort, optionIdx, false, false, true);
|
||||
testOptionFind(zNewFmt("db%u-user", optionIdx + 1), cfgOptPgHostUser, optionIdx, false, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -986,9 +986,9 @@ testRun(void)
|
||||
protocolClientNew(
|
||||
strNewFmt("local client %u", clientIdx), STRDEF("test"), HRN_FORK_PARENT_READ(clientIdx),
|
||||
HRN_FORK_PARENT_WRITE(clientIdx)),
|
||||
strZ(strNewFmt("local client %u new", clientIdx)));
|
||||
zNewFmt("local client %u new", clientIdx));
|
||||
TEST_RESULT_VOID(
|
||||
protocolParallelClientAdd(parallel, client[clientIdx]), strZ(strNewFmt("local client %u add", clientIdx)));
|
||||
protocolParallelClientAdd(parallel, client[clientIdx]), zNewFmt("local client %u add", clientIdx));
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
@ -1104,7 +1104,7 @@ testRun(void)
|
||||
TEST_TITLE("free clients");
|
||||
|
||||
for (unsigned int clientIdx = 0; clientIdx < HRN_FORK_PROCESS_TOTAL(); clientIdx++)
|
||||
TEST_RESULT_VOID(protocolClientFree(client[clientIdx]), strZ(strNewFmt("free client %u", clientIdx)));
|
||||
TEST_RESULT_VOID(protocolClientFree(client[clientIdx]), zNewFmt("free client %u", clientIdx));
|
||||
}
|
||||
HRN_FORK_PARENT_END();
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ storageTestPathExpression(const String *expression, const String *path)
|
||||
String *result = NULL;
|
||||
|
||||
if (strcmp(strZ(expression), "<TEST>") == 0)
|
||||
result = strNewFmt("test%s", path == NULL ? "" : strZ(strNewFmt("/%s", strZ(path))));
|
||||
result = strNewFmt("test%s", path == NULL ? "" : zNewFmt("/%s", strZ(path)));
|
||||
else if (strcmp(strZ(expression), "<NULL>") != 0)
|
||||
THROW_FMT(AssertError, "invalid expression '%s'", strZ(expression));
|
||||
|
||||
|
@ -560,7 +560,7 @@ testRun(void)
|
||||
hrnServerScriptClose(auth);
|
||||
hrnServerScriptAccept(auth);
|
||||
|
||||
testRequestP(auth, NULL, HTTP_VERB_GET, strZ(strNewFmt(S3_CREDENTIAL_PATH "/%s", strZ(credRole))));
|
||||
testRequestP(auth, NULL, HTTP_VERB_GET, zNewFmt(S3_CREDENTIAL_PATH "/%s", strZ(credRole)));
|
||||
testResponseP(auth, .http = "1.0", .code = 300);
|
||||
|
||||
hrnServerScriptClose(auth);
|
||||
@ -586,7 +586,7 @@ testRun(void)
|
||||
hrnServerScriptClose(auth);
|
||||
hrnServerScriptAccept(auth);
|
||||
|
||||
testRequestP(auth, NULL, HTTP_VERB_GET, strZ(strNewFmt(S3_CREDENTIAL_PATH "/%s", strZ(credRole))));
|
||||
testRequestP(auth, NULL, HTTP_VERB_GET, zNewFmt(S3_CREDENTIAL_PATH "/%s", strZ(credRole)));
|
||||
testResponseP(auth, .http = "1.0", .code = 404);
|
||||
|
||||
hrnServerScriptClose(auth);
|
||||
@ -609,7 +609,7 @@ testRun(void)
|
||||
hrnServerScriptAccept(auth);
|
||||
|
||||
testRequestP(
|
||||
auth, NULL, HTTP_VERB_GET, strZ(strNewFmt(S3_CREDENTIAL_PATH "/%s", strZ(credRole))), .token = "XtokenX");
|
||||
auth, NULL, HTTP_VERB_GET, zNewFmt(S3_CREDENTIAL_PATH "/%s", strZ(credRole)), .token = "XtokenX");
|
||||
testResponseP(auth, .http = "1.0", .content = "{\"Code\":\"IAM role is not configured\"}");
|
||||
|
||||
hrnServerScriptClose(auth);
|
||||
@ -630,14 +630,13 @@ testRun(void)
|
||||
hrnServerScriptAccept(auth);
|
||||
|
||||
testRequestP(
|
||||
auth, NULL, HTTP_VERB_GET, strZ(strNewFmt(S3_CREDENTIAL_PATH "/%s", strZ(credRole))), .token = "YtokenY");
|
||||
auth, NULL, HTTP_VERB_GET, zNewFmt(S3_CREDENTIAL_PATH "/%s", strZ(credRole)), .token = "YtokenY");
|
||||
testResponseP(
|
||||
auth,
|
||||
.content = strZ(
|
||||
strNewFmt(
|
||||
.content = zNewFmt(
|
||||
"{\"Code\":\"Success\",\"AccessKeyId\":\"x\",\"SecretAccessKey\":\"y\",\"Token\":\"z\""
|
||||
",\"Expiration\":\"%s\"}",
|
||||
strZ(testS3DateTime(time(NULL) + (S3_CREDENTIAL_RENEW_SEC - 1))))));
|
||||
strZ(testS3DateTime(time(NULL) + (S3_CREDENTIAL_RENEW_SEC - 1)))));
|
||||
|
||||
hrnServerScriptClose(auth);
|
||||
|
||||
@ -682,15 +681,13 @@ testRun(void)
|
||||
hrnServerScriptClose(auth);
|
||||
hrnServerScriptAccept(auth);
|
||||
|
||||
testRequestP(
|
||||
auth, NULL, HTTP_VERB_GET, strZ(strNewFmt(S3_CREDENTIAL_PATH "/%s", strZ(credRole))), .token = "ZtokenZ");
|
||||
testRequestP(auth, NULL, HTTP_VERB_GET, zNewFmt(S3_CREDENTIAL_PATH "/%s", strZ(credRole)), .token = "ZtokenZ");
|
||||
testResponseP(
|
||||
auth,
|
||||
.content = strZ(
|
||||
strNewFmt(
|
||||
.content = zNewFmt(
|
||||
"{\"Code\":\"Success\",\"AccessKeyId\":\"xx\",\"SecretAccessKey\":\"yy\",\"Token\":\"zz\""
|
||||
",\"Expiration\":\"%s\"}",
|
||||
strZ(testS3DateTime(time(NULL) + (S3_CREDENTIAL_RENEW_SEC * 2))))));
|
||||
strZ(testS3DateTime(time(NULL) + (S3_CREDENTIAL_RENEW_SEC * 2)))));
|
||||
|
||||
hrnServerScriptClose(auth);
|
||||
|
||||
@ -939,8 +936,7 @@ testRun(void)
|
||||
testRequestP(auth, NULL, HTTP_VERB_GET, TEST_SERVICE_URI);
|
||||
testResponseP(
|
||||
auth,
|
||||
.content = strZ(
|
||||
strNewFmt(TEST_SERVICE_RESPONSE, strZ(testS3DateTime(time(NULL) + (S3_CREDENTIAL_RENEW_SEC - 1))))));
|
||||
.content = zNewFmt(TEST_SERVICE_RESPONSE, strZ(testS3DateTime(time(NULL) + (S3_CREDENTIAL_RENEW_SEC - 1)))));
|
||||
|
||||
hrnServerScriptClose(auth);
|
||||
|
||||
@ -959,8 +955,7 @@ testRun(void)
|
||||
testRequestP(auth, NULL, HTTP_VERB_GET, TEST_SERVICE_URI);
|
||||
testResponseP(
|
||||
auth,
|
||||
.content = strZ(
|
||||
strNewFmt(TEST_SERVICE_RESPONSE, strZ(testS3DateTime(time(NULL) + (S3_CREDENTIAL_RENEW_SEC * 2))))));
|
||||
.content = zNewFmt(TEST_SERVICE_RESPONSE, strZ(testS3DateTime(time(NULL) + (S3_CREDENTIAL_RENEW_SEC * 2)))));
|
||||
|
||||
hrnServerScriptClose(auth);
|
||||
|
||||
|
Reference in New Issue
Block a user