Add configuration database type to ISimulator

This commit is contained in:
sfc-gh-tclinkenbeard 2021-08-06 21:19:53 -07:00
parent cd8a82b1b8
commit cdbcb69d86
7 changed files with 77 additions and 19 deletions

View File

@ -116,6 +116,33 @@ std::string KnobValueRef::toString() const {
return std::visit(ToStringFunc{}, value);
}
std::string configDBToString(UseConfigDB configDB) {
switch (configDB) {
case UseConfigDB::DISABLED:
return "disabled";
case UseConfigDB::SIMPLE:
return "simple";
case UseConfigDB::PAXOS:
return "paxos";
default:
ASSERT(false);
return "";
}
}
UseConfigDB configDBFromString(std::string const& str) {
if (str == "disabled") {
return UseConfigDB::DISABLED;
} else if (str == "simple") {
return UseConfigDB::SIMPLE;
} else if (str == "paxos") {
return UseConfigDB::PAXOS;
} else {
TraceEvent(SevWarnAlways, "InvalidConfigDBString");
return UseConfigDB::DISABLED;
}
}
TEST_CASE("/fdbclient/ConfigDB/ConfigKey/EncodeDecode") {
Tuple tuple;
tuple << "class-A"_sr

View File

@ -199,8 +199,5 @@ struct ConfigCommitAnnotationRef {
};
using ConfigCommitAnnotation = Standalone<ConfigCommitAnnotationRef>;
enum class UseConfigDB {
DISABLED,
SIMPLE,
PAXOS,
};
std::string configDBToString(UseConfigDB);
UseConfigDB configDBFromString(std::string const&);

View File

@ -409,6 +409,7 @@ public:
std::vector<Optional<Standalone<StringRef>>> primarySatelliteDcIds;
std::vector<Optional<Standalone<StringRef>>> remoteSatelliteDcIds;
TSSMode tssMode;
UseConfigDB configDB;
// Used by workloads that perform reconfigurations
int testerCount;

View File

@ -227,11 +227,16 @@ class TestConfig {
if (attrib == "restartInfoLocation") {
isFirstTestInRestart = true;
}
if (attrib == "configDB") {
configDBString = value;
}
}
ifs.close();
}
std::string configDBString{ "disabled" };
public:
int extraDB = 0;
int minimumReplication = 0;
@ -260,6 +265,8 @@ public:
stderrSeverity, machineCount, processesPerMachine, coordinators;
Optional<std::string> config;
UseConfigDB getConfigDB() const { return configDBFromString(configDBString); }
bool tomlKeyPresent(const toml::value& data, std::string key) {
if (data.is_table()) {
for (const auto& [k, v] : data.as_table()) {
@ -305,7 +312,8 @@ public:
.add("StderrSeverity", &stderrSeverity)
.add("machineCount", &machineCount)
.add("processesPerMachine", &processesPerMachine)
.add("coordinators", &coordinators);
.add("coordinators", &coordinators)
.add("configDB", &configDBString);
try {
auto file = toml::parse(testFile);
if (file.contains("configuration") && toml::find(file, "configuration").is_table()) {
@ -438,7 +446,8 @@ ACTOR Future<ISimulator::KillType> simulatedFDBDRebooter(Reference<ClusterConnec
bool useSeedFile,
AgentMode runBackupAgents,
std::string whitelistBinPaths,
ProtocolVersion protocolVersion) {
ProtocolVersion protocolVersion,
UseConfigDB configDB) {
state ISimulator::ProcessInfo* simProcess = g_simulator.getCurrentProcess();
state UID randomId = nondeterministicRandom()->randomUniqueID();
state int cycles = 0;
@ -521,7 +530,7 @@ ACTOR Future<ISimulator::KillType> simulatedFDBDRebooter(Reference<ClusterConnec
whitelistBinPaths,
"",
{},
UseConfigDB::SIMPLE));
configDB));
}
if (runBackupAgents != AgentNone) {
futures.push_back(runBackup(connFile));
@ -660,7 +669,8 @@ ACTOR Future<Void> simulatedMachine(ClusterConnectionString connStr,
AgentMode runBackupAgents,
bool sslOnly,
std::string whitelistBinPaths,
ProtocolVersion protocolVersion) {
ProtocolVersion protocolVersion,
UseConfigDB configDB) {
state int bootCount = 0;
state std::vector<std::string> myFolders;
state std::vector<std::string> coordFolders;
@ -730,7 +740,8 @@ ACTOR Future<Void> simulatedMachine(ClusterConnectionString connStr,
useSeedFile,
agentMode,
whitelistBinPaths,
protocolVersion));
protocolVersion,
configDB));
g_simulator.setDiffProtocol = true;
} else {
processes.push_back(simulatedFDBDRebooter(clusterFile,
@ -747,7 +758,8 @@ ACTOR Future<Void> simulatedMachine(ClusterConnectionString connStr,
useSeedFile,
agentMode,
whitelistBinPaths,
g_network->protocolVersion()));
g_network->protocolVersion(),
configDB));
}
TraceEvent("SimulatedMachineProcess", randomId)
.detail("Address", NetworkAddress(ips[i], listenPort, true, false))
@ -973,6 +985,8 @@ ACTOR Future<Void> restartSimulatedSystem(vector<Future<Void>>* systemActors,
ini.SetUnicode();
ini.LoadFile(joinPath(baseFolder, "restartInfo.ini").c_str());
auto configDB = testConfig.getConfigDB();
// allows multiple ipAddr entries
ini.SetMultiKey();
@ -1081,7 +1095,8 @@ ACTOR Future<Void> restartSimulatedSystem(vector<Future<Void>>* systemActors,
AgentAddition,
usingSSL && (listenersPerProcess == 1 || processClass == ProcessClass::TesterClass),
whitelistBinPaths,
protocolVersion),
protocolVersion,
configDB),
processClass == ProcessClass::TesterClass ? "SimulatedTesterMachine" : "SimulatedMachine"));
}
@ -1667,6 +1682,10 @@ void SimulationConfig::setTss(const TestConfig& testConfig) {
}
}
void setConfigDB(TestConfig const& testConfig) {
g_simulator.configDB = testConfig.getConfigDB();
}
// Generates and sets an appropriate configuration for the database according to
// the provided testConfig. Some attributes are randomly generated for more coverage
// of different combinations
@ -1702,6 +1721,7 @@ void SimulationConfig::generateNormalConfig(const TestConfig& testConfig) {
setProcessesPerMachine(testConfig);
setTss(testConfig);
setConfigDB(testConfig);
}
// Configures the system according to the given specifications in order to run
@ -1724,6 +1744,7 @@ void setupSimulatedSystem(vector<Future<Void>>* systemActors,
if (testConfig.configureLocked) {
startingConfigString += " locked";
}
auto configDB = testConfig.getConfigDB();
for (auto kv : startingConfigJSON) {
if ("tss_storage_engine" == kv.first) {
continue;
@ -2006,7 +2027,8 @@ void setupSimulatedSystem(vector<Future<Void>>* systemActors,
requiresExtraDBMachines ? AgentOnly : AgentAddition,
sslOnly,
whitelistBinPaths,
protocolVersion),
protocolVersion,
configDB),
"SimulatedMachine"));
if (requiresExtraDBMachines) {
@ -2032,7 +2054,8 @@ void setupSimulatedSystem(vector<Future<Void>>* systemActors,
AgentNone,
sslOnly,
whitelistBinPaths,
protocolVersion),
protocolVersion,
configDB),
"SimulatedMachine"));
}
@ -2071,7 +2094,8 @@ void setupSimulatedSystem(vector<Future<Void>>* systemActors,
AgentNone,
sslEnabled && sslOnly,
whitelistBinPaths,
protocolVersion),
protocolVersion,
configDB),
"SimulatedTesterMachine"));
}

View File

@ -28,7 +28,6 @@ class ConfigIncrementWorkload : public TestWorkload {
int incrementsPerActor{ 0 };
Version lastKnownCommittedVersion{ ::invalidVersion };
int lastKnownValue{ -1 };
bool useSimpleConfigDB{ true };
double meanSleepWithinTransactions{ 0.01 };
double meanSleepBetweenTransactions{ 0.1 };
@ -107,8 +106,10 @@ class ConfigIncrementWorkload : public TestWorkload {
}
Reference<ISingleThreadTransaction> getTransaction(Database cx) const {
auto type = useSimpleConfigDB ? ISingleThreadTransaction::Type::SIMPLE_CONFIG
: ISingleThreadTransaction::Type::PAXOS_CONFIG;
ASSERT(g_network->isSimulated()); // TODO: Enforce elsewhere
ASSERT(g_simulator.configDB != UseConfigDB::DISABLED);
auto type = (g_simulator.configDB == UseConfigDB::SIMPLE) ? ISingleThreadTransaction::Type::SIMPLE_CONFIG
: ISingleThreadTransaction::Type::PAXOS_CONFIG;
return ISingleThreadTransaction::create(type, cx);
}
@ -117,7 +118,6 @@ public:
: TestWorkload(wcx), transactions("Transactions"), retries("Retries") {
incrementActors = getOption(options, "incrementActors"_sr, 10);
incrementsPerActor = getOption(options, "incrementsPerActor"_sr, 10);
useSimpleConfigDB = getOption(options, "useSimpleConfigDB"_sr, true);
meanSleepWithinTransactions = getOption(options, "meanSleepWithinTransactions"_sr, 0.01);
meanSleepBetweenTransactions = getOption(options, "meanSleepBetweenTransactions"_sr, 0.1);
}

View File

@ -37,6 +37,12 @@
struct NoKnobFound {};
using ParsedKnobValue = std::variant<NoKnobFound, int, double, int64_t, bool, std::string>;
enum class UseConfigDB {
DISABLED,
SIMPLE,
PAXOS,
};
class Knobs {
protected:
Knobs() = default;

View File

@ -1,3 +1,6 @@
[configuration]
configDB = 'simple'
[[test]]
testTitle = 'ConfigIncrement'