You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-13 01:00:23 +02:00
Reduce reliance on static checksums in unit tests.
Testing against static checksums is valuable but it can be become burdensome when supporting multiple architectures. Reduce the number of tests we are doing against static checksums when the architecture can cause the checksum to vary.
This commit is contained in:
@ -261,6 +261,11 @@ testRun(void)
|
||||
memset(bufPtr(walBuffer1), 0, bufSize(walBuffer1));
|
||||
pgWalTestToBuffer((PgWal){.version = PG_VERSION_11, .systemId = 0xFACEFACEFACEFACE}, walBuffer1);
|
||||
|
||||
// Check sha1 checksum against fixed values once to make sure they are not getting munged. After this we'll calculate them
|
||||
// directly from the buffers to reduce the cost of maintaining checksums.
|
||||
const char *walBuffer1Sha1 = TEST_64BIT() ?
|
||||
"aae7591a1dbc58f21d0d004886075094f622e6dd" : "28a13fd8cf6fcd9f9a8108aed4c8bcc58040863a";
|
||||
|
||||
storagePutP(storageNewWriteP(storagePgWrite(), strNew("pg_wal/000000010000000100000001")), walBuffer1);
|
||||
|
||||
TEST_RESULT_VOID(cmdArchivePush(), "push the WAL segment");
|
||||
@ -268,10 +273,7 @@ testRun(void)
|
||||
|
||||
TEST_RESULT_BOOL(
|
||||
storageExistsP(
|
||||
storageTest,
|
||||
strNewFmt(
|
||||
"repo/archive/test/11-1/0000000100000001/000000010000000100000001-%s.gz",
|
||||
TEST_64BIT() ? "aae7591a1dbc58f21d0d004886075094f622e6dd" : "28a13fd8cf6fcd9f9a8108aed4c8bcc58040863a")),
|
||||
storageTest, strNewFmt("repo/archive/test/11-1/0000000100000001/000000010000000100000001-%s.gz", walBuffer1Sha1)),
|
||||
true, "check repo for WAL file");
|
||||
|
||||
TEST_RESULT_VOID(cmdArchivePush(), "push the WAL segment again");
|
||||
@ -285,6 +287,7 @@ testRun(void)
|
||||
bufUsedSet(walBuffer2, bufSize(walBuffer2));
|
||||
memset(bufPtr(walBuffer2), 0xFF, bufSize(walBuffer2));
|
||||
pgWalTestToBuffer((PgWal){.version = PG_VERSION_11, .systemId = 0xFACEFACEFACEFACE}, walBuffer2);
|
||||
const char *walBuffer2Sha1 = strPtr(bufHex(cryptoHashOne(HASH_TYPE_SHA1_STR, walBuffer2)));
|
||||
|
||||
storagePutP(storageNewWriteP(storagePgWrite(), strNew("pg_wal/000000010000000100000001")), walBuffer2);
|
||||
|
||||
@ -293,8 +296,6 @@ testRun(void)
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("WAL with absolute path and no pg1-path");
|
||||
|
||||
const char *sha1 = TEST_64BIT() ? "755defa48a0a0872767b6dea49bdd3b64902f147" : "9c2a6ec4491a2118bcdc9b653366581d8821c982";
|
||||
|
||||
argListTemp = strLstNew();
|
||||
strLstAddZ(argListTemp, "--" CFGOPT_STANZA "=test");
|
||||
strLstAdd(argListTemp, strNewFmt("--" CFGOPT_REPO1_PATH "=%s/repo", testPath()));
|
||||
@ -309,7 +310,8 @@ testRun(void)
|
||||
storagePutP(
|
||||
storageNewWriteP(
|
||||
storageTest,
|
||||
strNewFmt("repo/archive/test/11-1/0000000100000001/000000010000000100000002-%s.gz.pgbackrest.tmp", sha1)),
|
||||
strNewFmt("repo/archive/test/11-1/0000000100000001/000000010000000100000002-%s.gz.pgbackrest.tmp",
|
||||
walBuffer2Sha1)),
|
||||
BUFSTRDEF("PARTIAL")),
|
||||
"write WAL tmp file");
|
||||
|
||||
@ -317,12 +319,13 @@ testRun(void)
|
||||
harnessLogResult("P00 INFO: pushed WAL file '000000010000000100000002' to the archive");
|
||||
|
||||
TEST_RESULT_BOOL(
|
||||
storageExistsP(storageTest, strNewFmt("repo/archive/test/11-1/0000000100000001/000000010000000100000002-%s.gz", sha1)),
|
||||
storageExistsP(
|
||||
storageTest, strNewFmt("repo/archive/test/11-1/0000000100000001/000000010000000100000002-%s.gz", walBuffer2Sha1)),
|
||||
true, "check repo for WAL file");
|
||||
TEST_RESULT_BOOL(
|
||||
storageExistsP(
|
||||
storageTest,
|
||||
strNewFmt("repo/archive/test/11-1/0000000100000001/000000010000000100000002-%s.gz.pgbackrest.tmp", sha1)),
|
||||
strNewFmt("repo/archive/test/11-1/0000000100000001/000000010000000100000002-%s.gz.pgbackrest.tmp", walBuffer2Sha1)),
|
||||
false, "check WAL tmp file is gone");
|
||||
|
||||
// Push a history file
|
||||
@ -426,10 +429,7 @@ testRun(void)
|
||||
|
||||
TEST_RESULT_BOOL(
|
||||
storageExistsP(
|
||||
storageTest,
|
||||
strNewFmt(
|
||||
"repo/archive/test/11-1/0000000100000001/000000010000000100000002-%s",
|
||||
TEST_64BIT() ? "755defa48a0a0872767b6dea49bdd3b64902f147" : "9c2a6ec4491a2118bcdc9b653366581d8821c982")),
|
||||
storageTest, strNewFmt("repo/archive/test/11-1/0000000100000001/000000010000000100000002-%s", walBuffer2Sha1)),
|
||||
true, "check repo for WAL file");
|
||||
}
|
||||
|
||||
@ -587,6 +587,7 @@ testRun(void)
|
||||
bufUsedSet(walBuffer1, bufSize(walBuffer1));
|
||||
memset(bufPtr(walBuffer1), 0xFF, bufSize(walBuffer1));
|
||||
pgWalTestToBuffer((PgWal){.version = PG_VERSION_94, .systemId = 0xAAAABBBBCCCCDDDD}, walBuffer1);
|
||||
const char *walBuffer1Sha1 = strPtr(bufHex(cryptoHashOne(HASH_TYPE_SHA1_STR, walBuffer1)));
|
||||
|
||||
storagePutP(storageNewWriteP(storagePgWrite(), strNew("pg_xlog/000000010000000100000001")), walBuffer1);
|
||||
|
||||
@ -595,10 +596,7 @@ testRun(void)
|
||||
|
||||
TEST_RESULT_BOOL(
|
||||
storageExistsP(
|
||||
storageTest,
|
||||
strNewFmt(
|
||||
"repo/archive/test/9.4-1/0000000100000001/000000010000000100000001-%s",
|
||||
TEST_64BIT() ? "ce58ec898a080e59d71dce49051843b03a497d99" : "765ee94e4f65d081f2dc3b8e77556da95bc31cbf")),
|
||||
storageTest, strNewFmt("repo/archive/test/9.4-1/0000000100000001/000000010000000100000001-%s", walBuffer1Sha1)),
|
||||
true, "check repo for WAL file");
|
||||
|
||||
// Direct tests of the async function
|
||||
@ -660,10 +658,7 @@ testRun(void)
|
||||
|
||||
TEST_RESULT_BOOL(
|
||||
storageExistsP(
|
||||
storageTest,
|
||||
strNewFmt(
|
||||
"repo/archive/test/9.4-1/0000000100000001/000000010000000100000001-%s",
|
||||
TEST_64BIT() ? "ce58ec898a080e59d71dce49051843b03a497d99" : "765ee94e4f65d081f2dc3b8e77556da95bc31cbf")),
|
||||
storageTest, strNewFmt("repo/archive/test/9.4-1/0000000100000001/000000010000000100000001-%s", walBuffer1Sha1)),
|
||||
true, "check repo for WAL 1 file");
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
@ -675,6 +670,7 @@ testRun(void)
|
||||
bufUsedSet(walBuffer2, bufSize(walBuffer2));
|
||||
memset(bufPtr(walBuffer2), 0x0C, bufSize(walBuffer2));
|
||||
pgWalTestToBuffer((PgWal){.version = PG_VERSION_94, .systemId = 0xAAAABBBBCCCCDDDD}, walBuffer2);
|
||||
const char *walBuffer2Sha1 = strPtr(bufHex(cryptoHashOne(HASH_TYPE_SHA1_STR, walBuffer2)));
|
||||
|
||||
storagePutP(storageNewWriteP(storagePgWrite(), strNew("pg_xlog/000000010000000100000002")), walBuffer2);
|
||||
|
||||
@ -689,10 +685,7 @@ testRun(void)
|
||||
|
||||
TEST_RESULT_BOOL(
|
||||
storageExistsP(
|
||||
storageTest,
|
||||
strNewFmt(
|
||||
"repo/archive/test/9.4-1/0000000100000001/000000010000000100000002-%s",
|
||||
TEST_64BIT() ? "251820f85b31554bbf33061fce7dabf18c16afe0" : "ae8cb1fe45d40bc364df6bc6e8803774f0e3eaeb")),
|
||||
storageTest, strNewFmt("repo/archive/test/9.4-1/0000000100000001/000000010000000100000002-%s", walBuffer2Sha1)),
|
||||
true, "check repo for WAL 2 file");
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
|
Reference in New Issue
Block a user