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

Fix integration tests on alternate architectures.

57ffd2df accidentally hard-coded the integration test architecture to x86_64 and it was not noticed because in CI all the integration tests run on that architecture.

Fix the test code to retrieve the current architecture and use it for integration tests.
This commit is contained in:
David Steele
2025-04-07 11:57:00 -05:00
parent e18ca19895
commit 37544da56c
9 changed files with 45 additions and 10 deletions

View File

@ -31,8 +31,8 @@ TestBuild *
testBldNew(
const String *const pathRepo, const String *const pathTest, const String *const vm, const String *const vmInt,
const unsigned int vmId, const String *const pgVersion, const TestDefModule *const module, const unsigned int test,
const uint64_t scale, const LogLevel logLevel, const bool logTime, const String *const timeZone, const bool coverage,
const bool profile, const bool optimize, const bool backTrace)
const uint64_t scale, const LogLevel logLevel, const bool logTime, const String *const timeZone,
const String *const architecture, const bool coverage, const bool profile, const bool optimize, const bool backTrace)
{
FUNCTION_LOG_BEGIN(logLevelDebug);
FUNCTION_LOG_PARAM(STRING, pathRepo);
@ -47,6 +47,7 @@ testBldNew(
FUNCTION_LOG_PARAM(ENUM, logLevel);
FUNCTION_LOG_PARAM(BOOL, logTime);
FUNCTION_LOG_PARAM(STRING, timeZone);
FUNCTION_LOG_PARAM(STRING, architecture);
FUNCTION_LOG_PARAM(BOOL, coverage);
FUNCTION_LOG_PARAM(BOOL, profile);
FUNCTION_LOG_PARAM(BOOL, optimize);
@ -78,6 +79,7 @@ testBldNew(
.logLevel = logLevel,
.logTime = logTime,
.timeZone = strDup(timeZone),
.architecture = strDup(architecture),
.coverage = coverage,
.profile = profile,
.optimize = optimize,
@ -669,6 +671,9 @@ testBldUnit(TestBuild *const this)
// Log time/timestamp
strReplace(testC, STRDEF("{[C_TEST_TIMING]}"), STR(cvtBoolToConstZ(testBldLogTime(this))));
// Test architecture
strReplace(testC, STRDEF("{[C_TEST_ARCHITECTURE]}"), testBldArchitecture(this));
// Test timezone
strReplace(
testC, STRDEF("{[C_TEST_TZ]}"),

View File

@ -21,7 +21,7 @@ Constructors
TestBuild *testBldNew(
const String *pathRepo, const String *pathTest, const String *const vm, const String *const vmInt, unsigned int vmId,
const String *pgVersion, const TestDefModule *module, unsigned int test, uint64_t scale, LogLevel logLevel, bool logTime,
const String *timeZone, bool coverage, bool profile, bool optimize, bool backTrace);
const String *timeZone, const String *architecture, bool coverage, bool profile, bool optimize, bool backTrace);
/***********************************************************************************************************************************
Getters/Setters
@ -42,6 +42,7 @@ typedef struct TestBuildPub
bool logTime; // Log times/timestamps
uint64_t scale; // Scale performance test
const String *timeZone; // Test in timezone
const String *architecture; // Test architecture
bool coverage; // Generate coverage?
bool profile; // Generate profile report?
bool optimize; // Optimize code?
@ -140,6 +141,13 @@ testBldTimeZone(const TestBuild *const this)
return THIS_PUB(TestBuild)->timeZone;
}
// Test architecture
FN_INLINE_ALWAYS const String *
testBldArchitecture(const TestBuild *const this)
{
return THIS_PUB(TestBuild)->architecture;
}
// Generate coverage?
FN_INLINE_ALWAYS bool
testBldCoverage(const TestBuild *const this)

View File

@ -94,6 +94,9 @@ cmdTest(
if (module->type == testDefTypeIntegration)
vm = strNewZ("none");
// Get test architecture
const String *const architecture = strTrim(execOneP(STRDEF("uname -m")));
// Build test
bool buildRetry = false;
const String *const pathUnit = strNewFmt("%s/unit-%u/%s", strZ(pathTest), vmId, strZ(vm));
@ -106,8 +109,8 @@ cmdTest(
{
// Build unit
TestBuild *const testBld = testBldNew(
pathRepo, pathTest, vm, vmInt, vmId, pgVersion, module, test, scale, logLevel, logTime, timeZone, coverage,
profile, optimize, backTrace);
pathRepo, pathTest, vm, vmInt, vmId, pgVersion, module, test, scale, logLevel, logTime, timeZone, architecture,
coverage, profile, optimize, backTrace);
testBldUnit(testBld);
// Meson setup

View File

@ -1117,7 +1117,7 @@ hrnHostBuildRun(const int line, const StringId id)
const bool isPg = strBeginsWithZ(name, "pg");
const bool isRepo = id == hrnHostLocal.repoHost;
const String *const container = strNewFmt("test-%u-%s", testIdx(), strZ(name));
const String *const image = strNewFmt("pgbackrest/test:%s-test-x86_64", testVm());
const String *const image = strNewFmt("pgbackrest/test:%s-test-%s", testVm(), testArchitecture());
const String *const dataPath = strNewFmt("%s/%s", testPath(), strZ(name));
String *const option = strNewFmt(
"-v '%s/cfg:/etc/pgbackrest:ro' -v '%s:/usr/bin/pgbackrest:ro' -v '%s:%s:ro'", strZ(dataPath), testProjectExe(),

View File

@ -37,6 +37,7 @@ static bool testContainerData = false;
static bool testLogExpectData = false;
static unsigned int testIdxData = 0;
static bool testTiming = true;
static const char *testArchitectureData = NULL;
static const char *testPathData = NULL;
static const char *testUserData = NULL;
static const char *testVmData = NULL;
@ -64,8 +65,9 @@ Initialize harness
void
hrnInit(
const char *const testExe, const char *const testProjectExe, const bool testContainer, const bool testLogExpect,
const unsigned int testIdx, const bool timing, const char *const testPath, const char *const testUser, const char *const testVm,
const char *const testPgVersion,const char *const testDataPath, const char *const testRepoPath)
const unsigned int testIdx, const bool timing, const char *const architecture, const char *const testPath,
const char *const testUser, const char *const testVm, const char *const testPgVersion,const char *const testDataPath,
const char *const testRepoPath)
{
FUNCTION_HARNESS_VOID();
@ -77,6 +79,7 @@ hrnInit(
(void)testLogExpectData;
testIdxData = testIdx;
testTiming = timing;
testArchitectureData = architecture;
testPathData = testPath;
testUserData = testUser;
testVmData = testVm;
@ -751,6 +754,14 @@ testUser(void)
FUNCTION_HARNESS_RETURN(STRINGZ, testUserData);
}
/**********************************************************************************************************************************/
const char *
testArchitecture(void)
{
FUNCTION_HARNESS_VOID();
FUNCTION_HARNESS_RETURN(STRINGZ, testArchitectureData);
}
/**********************************************************************************************************************************/
const char *
testVm(void)

View File

@ -73,6 +73,9 @@ unsigned int testIdx(void);
// PostgreSQL version for integration testing
const char *testPgVersion(void);
// Test architecture
const char *testArchitecture(void);
// User running the test
const char *testUser(void);

View File

@ -41,8 +41,8 @@ Functions
***********************************************************************************************************************************/
void hrnInit(
const char *testExe, const char *testProjectExe, bool testContainer, bool testLogExpect, unsigned int testIdx, bool timing,
const char *testPath, const char *testUser, const char *testVm, const char *testPgVersion, const char *testDataPath,
const char *testRepoPath);
const char *architecture, const char *testPath, const char *testUser, const char *testVm, const char *testPgVersion,
const char *testDataPath, const char *testRepoPath);
void hrnAdd(int run, bool selected);
void hrnComplete(void);

View File

@ -152,6 +152,7 @@ testRun(void)
strReplace(testC, STRDEF("{[C_TEST_USER_ID]}"), STRDEF(TEST_USER_ID_Z));
strReplace(testC, STRDEF("{[C_TEST_USER_ID_Z]}"), STRDEF("\"" TEST_USER_ID_Z "\""));
strReplace(testC, STRDEF("{[C_TEST_USER_LEN]}"), strNewFmt("%zu", sizeof(TEST_USER) - 1));
strReplace(testC, STRDEF("{[C_TEST_ARCHITECTURE]}"), STRDEF(TEST_ARCHITECTURE));
// Test definition
// -------------------------------------------------------------------------------------------------------------------------

View File

@ -110,6 +110,9 @@ STRING_EXTERN(TEST_GROUP_STR, TEST_GROUP);
// Is this test running in a container?
#define TEST_IN_CONTAINER {[C_TEST_CONTAINER]}
// Architecture of host
#define TEST_ARCHITECTURE "{[C_TEST_ARCHITECTURE]}"
// Path to source -- used to construct __FILENAME__ tests
#define TEST_PGB_PATH "{[C_TEST_PGB_PATH]}"
@ -208,6 +211,7 @@ main(int argListSize, const char *argList[])
TEST_LOG_EXPECT, // Is log expect testing enabled?
{[C_TEST_IDX]}, // The 0-based index of this test
{[C_TEST_TIMING]}, // Is timing enabled (may be disabled for reproducible documentation)
TEST_ARCHITECTURE, // Test architecture
TEST_PATH, // Path where tests write data
TEST_USER, // User running the test
TEST_VM, // VM for integration testing