change tenantModes option to accept array of string
This commit is contained in:
parent
4e016e49e7
commit
c6998a7185
|
@ -1402,6 +1402,22 @@ struct TenantMode {
|
|||
serializer(ar, mode);
|
||||
}
|
||||
|
||||
// This does not go back-and-forth cleanly with toString
|
||||
// The '_experimental' suffix, if present, needs to be removed in order to be parsed.
|
||||
static TenantMode fromString(std::string mode) {
|
||||
if (mode == "disabled") {
|
||||
return TenantMode::DISABLED;
|
||||
} else if (mode == "optional") {
|
||||
return TenantMode::OPTIONAL_TENANT;
|
||||
} else if (mode == "required") {
|
||||
return TenantMode::REQUIRED;
|
||||
} else {
|
||||
TraceEvent(SevError, "UnknownTenantMode").detail("TenantMode", mode);
|
||||
ASSERT(false);
|
||||
throw internal_error();
|
||||
}
|
||||
}
|
||||
|
||||
std::string toString() const {
|
||||
switch (mode) {
|
||||
case DISABLED:
|
||||
|
|
|
@ -107,7 +107,8 @@ bool destructed = false;
|
|||
class TestConfig : public BasicTestConfig {
|
||||
class ConfigBuilder {
|
||||
using value_type = toml::basic_value<toml::discard_comments>;
|
||||
using base_variant = std::variant<int, float, double, bool, std::string, std::vector<int>, ConfigDBType>;
|
||||
using base_variant = std::
|
||||
variant<int, float, double, bool, std::string, std::vector<int>, std::vector<std::string>, ConfigDBType>;
|
||||
using types =
|
||||
variant_map<variant_concat<base_variant, variant_map<base_variant, Optional>>, std::add_pointer_t>;
|
||||
std::unordered_map<std::string_view, types> confMap;
|
||||
|
@ -148,6 +149,17 @@ class TestConfig : public BasicTestConfig {
|
|||
(*this)(&res);
|
||||
*val = std::move(res);
|
||||
}
|
||||
void operator()(std::vector<std::string>* val) const {
|
||||
auto arr = value.as_array();
|
||||
for (const auto& i : arr) {
|
||||
val->emplace_back(i.as_string());
|
||||
}
|
||||
}
|
||||
void operator()(Optional<std::vector<std::string>>* val) const {
|
||||
std::vector<std::string> res;
|
||||
(*this)(&res);
|
||||
*val = std::move(res);
|
||||
}
|
||||
};
|
||||
|
||||
struct trace_visitor {
|
||||
|
@ -178,6 +190,26 @@ class TestConfig : public BasicTestConfig {
|
|||
(*this)(&(val->get()));
|
||||
}
|
||||
}
|
||||
void operator()(std::vector<std::string> const* val) const {
|
||||
if (val->empty()) {
|
||||
evt.detail(key.c_str(), "[]");
|
||||
return;
|
||||
}
|
||||
std::stringstream value;
|
||||
value << "[" << val->at(0);
|
||||
for (int i = 1; i < val->size(); ++i) {
|
||||
value << "," << val->at(i);
|
||||
}
|
||||
value << "]";
|
||||
evt.detail(key.c_str(), value.str());
|
||||
}
|
||||
void operator()(Optional<std::vector<std::string>> const* val) const {
|
||||
if (!val->present()) {
|
||||
evt.detail(key.c_str(), *val);
|
||||
} else {
|
||||
(*this)(&(val->get()));
|
||||
}
|
||||
}
|
||||
void operator()(ConfigDBType const* val) const { evt.detail(key.c_str(), *val); }
|
||||
void operator()(Optional<ConfigDBType> const* val) const {
|
||||
Optional<std::string> optStr;
|
||||
|
@ -323,11 +355,9 @@ class TestConfig : public BasicTestConfig {
|
|||
}
|
||||
if (attrib == "tenantModes") {
|
||||
std::stringstream ss(value);
|
||||
for (int i; ss >> i;) {
|
||||
tenantModes.push_back(i);
|
||||
if (ss.peek() == ',') {
|
||||
ss.ignore();
|
||||
}
|
||||
std::string token;
|
||||
while (std::getline(ss, token, ',')) {
|
||||
tenantModes.push_back(token);
|
||||
}
|
||||
}
|
||||
if (attrib == "defaultTenant") {
|
||||
|
@ -383,9 +413,9 @@ public:
|
|||
bool injectTargetedSSRestart = false;
|
||||
bool injectSSDelay = false;
|
||||
// By default, tenant mode is set randomly
|
||||
// If provided, set using TenantMode::fromValue
|
||||
// Verify match with TenantMode::fromValue in FDBTypes.h
|
||||
std::vector<int> tenantModes;
|
||||
// If provided, set using TenantMode::fromString
|
||||
// Ensure no '_experimental` suffix in the mode name
|
||||
std::vector<std::string> tenantModes;
|
||||
Optional<std::string> defaultTenant;
|
||||
std::string testClass; // unused -- used in TestHarness
|
||||
float testPriority; // unused -- used in TestHarness
|
||||
|
@ -1203,7 +1233,7 @@ ACTOR Future<Void> restartSimulatedSystem(std::vector<Future<Void>>* systemActor
|
|||
auto tssModeStr = ini.GetValue("META", "tssMode");
|
||||
auto tenantMode = ini.GetValue("META", "tenantMode");
|
||||
if (tenantMode != nullptr) {
|
||||
testConfig->tenantModes.push_back(atoi(tenantMode));
|
||||
testConfig->tenantModes.push_back(tenantMode);
|
||||
}
|
||||
std::string defaultTenant = ini.GetValue("META", "defaultTenant", "");
|
||||
if (!defaultTenant.empty()) {
|
||||
|
@ -2592,8 +2622,8 @@ ACTOR void setupAndRun(std::string dataFolder,
|
|||
if (!rebooting) {
|
||||
if (testConfig.tenantModes.size()) {
|
||||
auto randomPick = deterministicRandom()->randomChoice(testConfig.tenantModes);
|
||||
tenantMode = TenantMode::fromValue(StringRef(std::to_string(randomPick)));
|
||||
if (allowDefaultTenant) {
|
||||
tenantMode = TenantMode::fromString(randomPick);
|
||||
if (tenantMode == TenantMode::REQUIRED && allowDefaultTenant) {
|
||||
defaultTenant = "SimulatedDefaultTenant"_sr;
|
||||
}
|
||||
} else if (allowDefaultTenant && deterministicRandom()->random01() < 0.5) {
|
||||
|
@ -2640,7 +2670,7 @@ ACTOR void setupAndRun(std::string dataFolder,
|
|||
// restartSimulatedSystem can adjust some testConfig params related to tenants
|
||||
// so set/overwrite those options if necessary here
|
||||
if (rebooting && testConfig.tenantModes.size()) {
|
||||
tenantMode = TenantMode::fromValue(StringRef(std::to_string(testConfig.tenantModes[0])));
|
||||
tenantMode = TenantMode::fromString(testConfig.tenantModes[0]);
|
||||
}
|
||||
if (testConfig.defaultTenant.present() && tenantMode != TenantMode::DISABLED && allowDefaultTenant) {
|
||||
// Default tenant set by testConfig or restarting data in restartInfo.ini
|
||||
|
|
|
@ -68,7 +68,11 @@ struct SaveAndKillWorkload : TestWorkload {
|
|||
ini.SetValue("META", "testerCount", format("%d", g_simulator->testerCount).c_str());
|
||||
ini.SetValue("META", "tssMode", format("%d", g_simulator->tssMode).c_str());
|
||||
ini.SetValue("META", "mockDNS", INetworkConnections::net()->convertMockDNSToString().c_str());
|
||||
ini.SetValue("META", "tenantMode", cx->clientInfo->get().tenantMode.toValue().toString().c_str());
|
||||
std::string tenantMode = cx->clientInfo->get().tenantMode.toString();
|
||||
if (tenantMode.find("_experimental") != std::string::npos) {
|
||||
tenantMode.replace(tenantMode.find("_experimental"), std::string::npos, "");
|
||||
}
|
||||
ini.SetValue("META", "tenantMode", tenantMode.c_str());
|
||||
if (cx->defaultTenant.present()) {
|
||||
ini.SetValue("META", "defaultTenant", cx->defaultTenant.get().toString().c_str());
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[configuration]
|
||||
allowDefaultTenant = true
|
||||
tenantModes = [2]
|
||||
tenantModes = ['required']
|
||||
|
||||
[[knobs]]
|
||||
enable_encryption = true
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[configuration]
|
||||
StderrSeverity = 30
|
||||
allowDefaultTenant = false
|
||||
tenantModes = [1]
|
||||
tenantModes = ['optional', 'required']
|
||||
|
||||
[[test]]
|
||||
testTitle = 'FuzzApiCorrectness'
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[configuration]
|
||||
StderrSeverity = 30
|
||||
allowDefaultTenant = false
|
||||
tenantModes = [1]
|
||||
tenantModes = ['optional', 'required']
|
||||
|
||||
[[test]]
|
||||
testTitle = 'FuzzApiCorrectness'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[configuration]
|
||||
allowDefaultTenant = false
|
||||
tenantModes = [1]
|
||||
tenantModes = ['optional', 'required']
|
||||
|
||||
[[test]]
|
||||
testTitle = 'TenantCreation'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[configuration]
|
||||
tenantModes = [1]
|
||||
tenantModes = ['optional', 'required']
|
||||
|
||||
[[test]]
|
||||
testTitle = 'SpecialKeySpaceCorrectnessTest'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[configuration]
|
||||
allowDefaultTenant = false
|
||||
tenantModes = [1]
|
||||
tenantModes = ['optional', 'required']
|
||||
|
||||
[[test]]
|
||||
testTitle = 'TenantCreation'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[configuration]
|
||||
allowDefaultTenant = false
|
||||
tenantModes = [1]
|
||||
tenantModes = ['optional', 'required']
|
||||
|
||||
[[knobs]]
|
||||
allow_tokenless_tenant_access = true
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[configuration]
|
||||
allowDefaultTenant = false
|
||||
tenantModes = [0,1]
|
||||
tenantModes = ['disabled', 'optional']
|
||||
|
||||
[[test]]
|
||||
testTitle = 'TenantEntryCacheTest'
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[configuration]
|
||||
blobGranulesEnabled = true
|
||||
allowDefaultTenant = false
|
||||
tenantModes = [1]
|
||||
tenantModes = ['optional', 'required']
|
||||
injectTargetedSSRestart = true
|
||||
injectSSDelay = true
|
||||
# FIXME: re-enable rocks at some point
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[configuration]
|
||||
blobGranulesEnabled = true
|
||||
allowDefaultTenant = false
|
||||
tenantModes = [1]
|
||||
tenantModes = ['optional', 'required']
|
||||
# FIXME: re-enable rocks at some point
|
||||
storageEngineExcludeTypes = [4, 5]
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[configuration]
|
||||
allowDefaultTenant = false
|
||||
tenantModes = [1]
|
||||
tenantModes = ['optional', 'required']
|
||||
allowCreatingTenants = false
|
||||
extraDatabaseMode = 'Multiple'
|
||||
extraDatabaseCount = 5
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[configuration]
|
||||
allowDefaultTenant = false
|
||||
tenantModes = [1]
|
||||
tenantModes = ['optional', 'required']
|
||||
|
||||
[[test]]
|
||||
testTitle = 'TenantManagementTest'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[configuration]
|
||||
allowDefaultTenant = false
|
||||
tenantModes = [1]
|
||||
tenantModes = ['optional', 'required']
|
||||
allowCreatingTenants = false
|
||||
extraDatabaseMode = 'Single'
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[configuration]
|
||||
allowDefaultTenant = false
|
||||
tenantModes = [1]
|
||||
tenantModes = ['optional', 'required']
|
||||
allowCreatingTenants = false
|
||||
extraDatabaseMode = 'Single'
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[configuration]
|
||||
allowDefaultTenant = false
|
||||
tenantModes = [1]
|
||||
tenantModes = ['optional', 'required']
|
||||
allowCreatingTenants = false
|
||||
extraDatabaseMode = 'Single'
|
||||
|
||||
|
|
Loading…
Reference in New Issue