mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-15 18:32:18 +08:00
Merge pull request #6473 from sfc-gh-tclinkenbeard/change-data-hall
Test renaming data hall on restart
This commit is contained in:
commit
ad98d64799
@ -37,12 +37,6 @@ enum ClogMode { ClogDefault, ClogAll, ClogSend, ClogReceive };
|
|||||||
|
|
||||||
class ISimulator : public INetwork {
|
class ISimulator : public INetwork {
|
||||||
public:
|
public:
|
||||||
ISimulator()
|
|
||||||
: desiredCoordinators(1), physicalDatacenters(1), processesPerMachine(0), listenersPerProcess(1),
|
|
||||||
extraDB(nullptr), usableRegions(1), allowLogSetKills(true), tssMode(TSSMode::Disabled), isStopped(false),
|
|
||||||
lastConnectionFailure(0), connectionFailuresDisableDuration(0), speedUpSimulation(false),
|
|
||||||
backupAgents(BackupAgentType::WaitForType), drAgents(BackupAgentType::WaitForType), allSwapsDisabled(false) {}
|
|
||||||
|
|
||||||
// Order matters!
|
// Order matters!
|
||||||
enum KillType {
|
enum KillType {
|
||||||
KillInstantly,
|
KillInstantly,
|
||||||
@ -393,7 +387,7 @@ public:
|
|||||||
int listenersPerProcess;
|
int listenersPerProcess;
|
||||||
std::set<NetworkAddress> protectedAddresses;
|
std::set<NetworkAddress> protectedAddresses;
|
||||||
std::map<NetworkAddress, ProcessInfo*> currentlyRebootingProcesses;
|
std::map<NetworkAddress, ProcessInfo*> currentlyRebootingProcesses;
|
||||||
class ClusterConnectionString* extraDB;
|
std::unique_ptr<class ClusterConnectionString> extraDB;
|
||||||
Reference<IReplicationPolicy> storagePolicy;
|
Reference<IReplicationPolicy> storagePolicy;
|
||||||
Reference<IReplicationPolicy> tLogPolicy;
|
Reference<IReplicationPolicy> tLogPolicy;
|
||||||
int32_t tLogWriteAntiQuorum;
|
int32_t tLogWriteAntiQuorum;
|
||||||
@ -456,6 +450,9 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ISimulator();
|
||||||
|
virtual ~ISimulator();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Mutex mutex;
|
Mutex mutex;
|
||||||
|
|
||||||
|
@ -53,6 +53,13 @@
|
|||||||
extern "C" int g_expect_full_pointermap;
|
extern "C" int g_expect_full_pointermap;
|
||||||
extern const char* getSourceVersion();
|
extern const char* getSourceVersion();
|
||||||
|
|
||||||
|
ISimulator::ISimulator()
|
||||||
|
: desiredCoordinators(1), physicalDatacenters(1), processesPerMachine(0), listenersPerProcess(1), usableRegions(1),
|
||||||
|
allowLogSetKills(true), tssMode(TSSMode::Disabled), isStopped(false), lastConnectionFailure(0),
|
||||||
|
connectionFailuresDisableDuration(0), speedUpSimulation(false), backupAgents(BackupAgentType::WaitForType),
|
||||||
|
drAgents(BackupAgentType::WaitForType), allSwapsDisabled(false) {}
|
||||||
|
ISimulator::~ISimulator() = default;
|
||||||
|
|
||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
|
|
||||||
// TODO: Defining these here is just asking for ODR violations.
|
// TODO: Defining these here is just asking for ODR violations.
|
||||||
@ -266,6 +273,9 @@ class TestConfig {
|
|||||||
configDBType = configDBTypeFromString(value);
|
configDBType = configDBTypeFromString(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (attrib == "randomlyRenameZoneId") {
|
||||||
|
randomlyRenameZoneId = strcmp(value.c_str(), "true") == 0;
|
||||||
|
}
|
||||||
if (attrib == "blobGranulesEnabled") {
|
if (attrib == "blobGranulesEnabled") {
|
||||||
blobGranulesEnabled = strcmp(value.c_str(), "true") == 0;
|
blobGranulesEnabled = strcmp(value.c_str(), "true") == 0;
|
||||||
}
|
}
|
||||||
@ -307,6 +317,7 @@ public:
|
|||||||
stderrSeverity, machineCount, processesPerMachine, coordinators;
|
stderrSeverity, machineCount, processesPerMachine, coordinators;
|
||||||
bool blobGranulesEnabled = false;
|
bool blobGranulesEnabled = false;
|
||||||
Optional<std::string> config;
|
Optional<std::string> config;
|
||||||
|
bool randomlyRenameZoneId = false;
|
||||||
|
|
||||||
bool allowDefaultTenant = true;
|
bool allowDefaultTenant = true;
|
||||||
bool allowDisablingTenants = true;
|
bool allowDisablingTenants = true;
|
||||||
@ -364,7 +375,8 @@ public:
|
|||||||
.add("extraMachineCountDC", &extraMachineCountDC)
|
.add("extraMachineCountDC", &extraMachineCountDC)
|
||||||
.add("blobGranulesEnabled", &blobGranulesEnabled)
|
.add("blobGranulesEnabled", &blobGranulesEnabled)
|
||||||
.add("allowDefaultTenant", &allowDefaultTenant)
|
.add("allowDefaultTenant", &allowDefaultTenant)
|
||||||
.add("allowDisablingTenants", &allowDisablingTenants);
|
.add("allowDisablingTenants", &allowDisablingTenants)
|
||||||
|
.add("randomlyRenameZoneId", &randomlyRenameZoneId);
|
||||||
try {
|
try {
|
||||||
auto file = toml::parse(testFile);
|
auto file = toml::parse(testFile);
|
||||||
if (file.contains("configuration") && toml::find(file, "configuration").is_table()) {
|
if (file.contains("configuration") && toml::find(file, "configuration").is_table()) {
|
||||||
@ -1039,6 +1051,11 @@ ACTOR Future<Void> restartSimulatedSystem(std::vector<Future<Void>>* systemActor
|
|||||||
|
|
||||||
auto configDBType = testConfig.getConfigDBType();
|
auto configDBType = testConfig.getConfigDBType();
|
||||||
|
|
||||||
|
// Randomly change data center id names to test that localities
|
||||||
|
// can be modified on cluster restart
|
||||||
|
bool renameZoneIds = testConfig.randomlyRenameZoneId ? deterministicRandom()->random01() < 0.1 : false;
|
||||||
|
TEST(renameZoneIds); // Zone ID names altered in restart test
|
||||||
|
|
||||||
// allows multiple ipAddr entries
|
// allows multiple ipAddr entries
|
||||||
ini.SetMultiKey();
|
ini.SetMultiKey();
|
||||||
|
|
||||||
@ -1059,7 +1076,7 @@ ACTOR Future<Void> restartSimulatedSystem(std::vector<Future<Void>>* systemActor
|
|||||||
bool enableExtraDB = (testConfig.extraDB == 3);
|
bool enableExtraDB = (testConfig.extraDB == 3);
|
||||||
ClusterConnectionString conn(ini.GetValue("META", "connectionString"));
|
ClusterConnectionString conn(ini.GetValue("META", "connectionString"));
|
||||||
if (enableExtraDB) {
|
if (enableExtraDB) {
|
||||||
g_simulator.extraDB = new ClusterConnectionString(ini.GetValue("META", "connectionString"));
|
g_simulator.extraDB = std::make_unique<ClusterConnectionString>(ini.GetValue("META", "connectionString"));
|
||||||
}
|
}
|
||||||
if (!testConfig.disableHostname) {
|
if (!testConfig.disableHostname) {
|
||||||
auto mockDNSStr = ini.GetValue("META", "mockDNS");
|
auto mockDNSStr = ini.GetValue("META", "mockDNS");
|
||||||
@ -1087,7 +1104,11 @@ ACTOR Future<Void> restartSimulatedSystem(std::vector<Future<Void>>* systemActor
|
|||||||
if (zoneIDini == nullptr) {
|
if (zoneIDini == nullptr) {
|
||||||
zoneId = machineId;
|
zoneId = machineId;
|
||||||
} else {
|
} else {
|
||||||
zoneId = StringRef(zoneIDini);
|
auto zoneIdStr = std::string(zoneIDini);
|
||||||
|
if (renameZoneIds) {
|
||||||
|
zoneIdStr = "modified/" + zoneIdStr;
|
||||||
|
}
|
||||||
|
zoneId = Standalone<StringRef>(zoneIdStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessClass::ClassType cType =
|
ProcessClass::ClassType cType =
|
||||||
@ -1142,7 +1163,7 @@ ACTOR Future<Void> restartSimulatedSystem(std::vector<Future<Void>>* systemActor
|
|||||||
}
|
}
|
||||||
|
|
||||||
LocalityData localities(Optional<Standalone<StringRef>>(), zoneId, machineId, dcUID);
|
LocalityData localities(Optional<Standalone<StringRef>>(), zoneId, machineId, dcUID);
|
||||||
localities.set(LiteralStringRef("data_hall"), dcUID);
|
localities.set("data_hall"_sr, dcUID);
|
||||||
|
|
||||||
// SOMEDAY: parse backup agent from test file
|
// SOMEDAY: parse backup agent from test file
|
||||||
systemActors->push_back(reportErrors(
|
systemActors->push_back(reportErrors(
|
||||||
@ -2040,9 +2061,9 @@ void setupSimulatedSystem(std::vector<Future<Void>>* systemActors,
|
|||||||
deterministicRandom()->randomShuffle(coordinatorAddresses);
|
deterministicRandom()->randomShuffle(coordinatorAddresses);
|
||||||
|
|
||||||
ASSERT_EQ(coordinatorAddresses.size(), coordinatorCount);
|
ASSERT_EQ(coordinatorAddresses.size(), coordinatorCount);
|
||||||
ClusterConnectionString conn(coordinatorAddresses, LiteralStringRef("TestCluster:0"));
|
ClusterConnectionString conn(coordinatorAddresses, "TestCluster:0"_sr);
|
||||||
if (useHostname) {
|
if (useHostname) {
|
||||||
conn = ClusterConnectionString(coordinatorHostnames, LiteralStringRef("TestCluster:0"));
|
conn = ClusterConnectionString(coordinatorHostnames, "TestCluster:0"_sr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If extraDB==0, leave g_simulator.extraDB as null because the test does not use DR.
|
// If extraDB==0, leave g_simulator.extraDB as null because the test does not use DR.
|
||||||
@ -2050,21 +2071,21 @@ void setupSimulatedSystem(std::vector<Future<Void>>* systemActors,
|
|||||||
// The DR database can be either a new database or itself
|
// The DR database can be either a new database or itself
|
||||||
g_simulator.extraDB =
|
g_simulator.extraDB =
|
||||||
BUGGIFY
|
BUGGIFY
|
||||||
? (useHostname ? new ClusterConnectionString(coordinatorHostnames, LiteralStringRef("TestCluster:0"))
|
? (useHostname ? std::make_unique<ClusterConnectionString>(coordinatorHostnames, "TestCluster:0"_sr)
|
||||||
: new ClusterConnectionString(coordinatorAddresses, LiteralStringRef("TestCluster:0")))
|
: std::make_unique<ClusterConnectionString>(coordinatorAddresses, "TestCluster:0"_sr))
|
||||||
: (useHostname
|
: (useHostname
|
||||||
? new ClusterConnectionString(extraCoordinatorHostnames, LiteralStringRef("ExtraCluster:0"))
|
? std::make_unique<ClusterConnectionString>(extraCoordinatorHostnames, "ExtraCluster:0"_sr)
|
||||||
: new ClusterConnectionString(extraCoordinatorAddresses, LiteralStringRef("ExtraCluster:0")));
|
: std::make_unique<ClusterConnectionString>(extraCoordinatorAddresses, "ExtraCluster:0"_sr));
|
||||||
} else if (testConfig.extraDB == 2) {
|
} else if (testConfig.extraDB == 2) {
|
||||||
// The DR database is a new database
|
// The DR database is a new database
|
||||||
g_simulator.extraDB =
|
g_simulator.extraDB =
|
||||||
useHostname ? new ClusterConnectionString(extraCoordinatorHostnames, LiteralStringRef("ExtraCluster:0"))
|
useHostname ? std::make_unique<ClusterConnectionString>(extraCoordinatorHostnames, "ExtraCluster:0"_sr)
|
||||||
: new ClusterConnectionString(extraCoordinatorAddresses, LiteralStringRef("ExtraCluster:0"));
|
: std::make_unique<ClusterConnectionString>(extraCoordinatorAddresses, "ExtraCluster:0"_sr);
|
||||||
} else if (testConfig.extraDB == 3) {
|
} else if (testConfig.extraDB == 3) {
|
||||||
// The DR database is the same database
|
// The DR database is the same database
|
||||||
g_simulator.extraDB =
|
g_simulator.extraDB = useHostname
|
||||||
useHostname ? new ClusterConnectionString(coordinatorHostnames, LiteralStringRef("TestCluster:0"))
|
? std::make_unique<ClusterConnectionString>(coordinatorHostnames, "TestCluster:0"_sr)
|
||||||
: new ClusterConnectionString(coordinatorAddresses, LiteralStringRef("TestCluster:0"));
|
: std::make_unique<ClusterConnectionString>(coordinatorAddresses, "TestCluster:0"_sr);
|
||||||
}
|
}
|
||||||
|
|
||||||
*pConnString = conn;
|
*pConnString = conn;
|
||||||
@ -2164,7 +2185,7 @@ void setupSimulatedSystem(std::vector<Future<Void>>* systemActors,
|
|||||||
|
|
||||||
// check the sslEnablementMap using only one ip
|
// check the sslEnablementMap using only one ip
|
||||||
LocalityData localities(Optional<Standalone<StringRef>>(), zoneId, machineId, dcUID);
|
LocalityData localities(Optional<Standalone<StringRef>>(), zoneId, machineId, dcUID);
|
||||||
localities.set(LiteralStringRef("data_hall"), dcUID);
|
localities.set("data_hall"_sr, dcUID);
|
||||||
systemActors->push_back(reportErrors(simulatedMachine(conn,
|
systemActors->push_back(reportErrors(simulatedMachine(conn,
|
||||||
ips,
|
ips,
|
||||||
sslEnabled,
|
sslEnabled,
|
||||||
@ -2191,7 +2212,7 @@ void setupSimulatedSystem(std::vector<Future<Void>>* systemActors,
|
|||||||
Standalone<StringRef> newMachineId(deterministicRandom()->randomUniqueID().toString());
|
Standalone<StringRef> newMachineId(deterministicRandom()->randomUniqueID().toString());
|
||||||
|
|
||||||
LocalityData localities(Optional<Standalone<StringRef>>(), newZoneId, newMachineId, dcUID);
|
LocalityData localities(Optional<Standalone<StringRef>>(), newZoneId, newMachineId, dcUID);
|
||||||
localities.set(LiteralStringRef("data_hall"), dcUID);
|
localities.set("data_hall"_sr, dcUID);
|
||||||
systemActors->push_back(reportErrors(simulatedMachine(*g_simulator.extraDB,
|
systemActors->push_back(reportErrors(simulatedMachine(*g_simulator.extraDB,
|
||||||
extraIps,
|
extraIps,
|
||||||
sslEnabled,
|
sslEnabled,
|
||||||
@ -2395,7 +2416,7 @@ ACTOR void setupAndRun(std::string dataFolder,
|
|||||||
100.0));
|
100.0));
|
||||||
// FIXME: snapshot restore does not support multi-region restore, hence restore it as single region always
|
// FIXME: snapshot restore does not support multi-region restore, hence restore it as single region always
|
||||||
if (restoring) {
|
if (restoring) {
|
||||||
startingConfiguration = LiteralStringRef("usable_regions=1");
|
startingConfiguration = "usable_regions=1"_sr;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
g_expect_full_pointermap = 1;
|
g_expect_full_pointermap = 1;
|
||||||
|
@ -37,11 +37,9 @@ struct SaveAndKillWorkload : TestWorkload {
|
|||||||
int isRestoring;
|
int isRestoring;
|
||||||
|
|
||||||
SaveAndKillWorkload(WorkloadContext const& wcx) : TestWorkload(wcx) {
|
SaveAndKillWorkload(WorkloadContext const& wcx) : TestWorkload(wcx) {
|
||||||
restartInfo =
|
restartInfo = getOption(options, "restartInfoLocation"_sr, "simfdb/restartInfo.ini"_sr).toString();
|
||||||
getOption(options, LiteralStringRef("restartInfoLocation"), LiteralStringRef("simfdb/restartInfo.ini"))
|
testDuration = getOption(options, "testDuration"_sr, 10.0);
|
||||||
.toString();
|
isRestoring = getOption(options, "isRestoring"_sr, 0);
|
||||||
testDuration = getOption(options, LiteralStringRef("testDuration"), 10.0);
|
|
||||||
isRestoring = getOption(options, LiteralStringRef("isRestoring"), 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string description() const override { return "SaveAndKillWorkload"; }
|
std::string description() const override { return "SaveAndKillWorkload"; }
|
||||||
@ -70,23 +68,22 @@ struct SaveAndKillWorkload : TestWorkload {
|
|||||||
|
|
||||||
std::vector<ISimulator::ProcessInfo*> processes = g_simulator.getAllProcesses();
|
std::vector<ISimulator::ProcessInfo*> processes = g_simulator.getAllProcesses();
|
||||||
std::map<NetworkAddress, ISimulator::ProcessInfo*> rebootingProcesses = g_simulator.currentlyRebootingProcesses;
|
std::map<NetworkAddress, ISimulator::ProcessInfo*> rebootingProcesses = g_simulator.currentlyRebootingProcesses;
|
||||||
std::map<std::string, ISimulator::ProcessInfo*> allProcessesMap =
|
std::map<std::string, ISimulator::ProcessInfo*> allProcessesMap;
|
||||||
std::map<std::string, ISimulator::ProcessInfo*>();
|
for (const auto& [_, process] : rebootingProcesses) {
|
||||||
for (auto it = rebootingProcesses.begin(); it != rebootingProcesses.end(); it++) {
|
if (allProcessesMap.find(process->dataFolder) == allProcessesMap.end()) {
|
||||||
if (allProcessesMap.find(it->second->dataFolder) == allProcessesMap.end())
|
allProcessesMap[process->dataFolder] = process;
|
||||||
allProcessesMap[it->second->dataFolder] = it->second;
|
}
|
||||||
|
}
|
||||||
|
for (const auto& process : processes) {
|
||||||
|
if (allProcessesMap.find(process->dataFolder) == allProcessesMap.end()) {
|
||||||
|
allProcessesMap[process->dataFolder] = process;
|
||||||
}
|
}
|
||||||
for (auto it = processes.begin(); it != processes.end(); it++) {
|
|
||||||
if (allProcessesMap.find((*it)->dataFolder) == allProcessesMap.end())
|
|
||||||
allProcessesMap[(*it)->dataFolder] = *it;
|
|
||||||
}
|
}
|
||||||
ini.SetValue("META", "processCount", format("%d", allProcessesMap.size() - 1).c_str());
|
ini.SetValue("META", "processCount", format("%d", allProcessesMap.size() - 1).c_str());
|
||||||
std::map<std::string, int> machines;
|
std::map<std::string, int> machines;
|
||||||
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for (auto processIterator = allProcessesMap.begin(); processIterator != allProcessesMap.end();
|
for (const auto& [_, process] : allProcessesMap) {
|
||||||
processIterator++) {
|
|
||||||
ISimulator::ProcessInfo* process = processIterator->second;
|
|
||||||
std::string machineId = printable(process->locality.machineId());
|
std::string machineId = printable(process->locality.machineId());
|
||||||
const char* machineIdString = machineId.c_str();
|
const char* machineIdString = machineId.c_str();
|
||||||
if (strcmp(process->name, "TestSystem") != 0) {
|
if (strcmp(process->name, "TestSystem") != 0) {
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
[[configuration]]
|
||||||
|
randomlyRenameZoneId=true
|
||||||
|
|
||||||
[[test]]
|
[[test]]
|
||||||
testTitle='CloggedConfigureDatabaseTest'
|
testTitle='CloggedConfigureDatabaseTest'
|
||||||
runSetup=false
|
runSetup=false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user