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);
|
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 {
|
std::string toString() const {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case DISABLED:
|
case DISABLED:
|
||||||
|
|
|
@ -107,7 +107,8 @@ bool destructed = false;
|
||||||
class TestConfig : public BasicTestConfig {
|
class TestConfig : public BasicTestConfig {
|
||||||
class ConfigBuilder {
|
class ConfigBuilder {
|
||||||
using value_type = toml::basic_value<toml::discard_comments>;
|
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 =
|
using types =
|
||||||
variant_map<variant_concat<base_variant, variant_map<base_variant, Optional>>, std::add_pointer_t>;
|
variant_map<variant_concat<base_variant, variant_map<base_variant, Optional>>, std::add_pointer_t>;
|
||||||
std::unordered_map<std::string_view, types> confMap;
|
std::unordered_map<std::string_view, types> confMap;
|
||||||
|
@ -148,6 +149,17 @@ class TestConfig : public BasicTestConfig {
|
||||||
(*this)(&res);
|
(*this)(&res);
|
||||||
*val = std::move(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 {
|
struct trace_visitor {
|
||||||
|
@ -178,6 +190,26 @@ class TestConfig : public BasicTestConfig {
|
||||||
(*this)(&(val->get()));
|
(*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()(ConfigDBType const* val) const { evt.detail(key.c_str(), *val); }
|
||||||
void operator()(Optional<ConfigDBType> const* val) const {
|
void operator()(Optional<ConfigDBType> const* val) const {
|
||||||
Optional<std::string> optStr;
|
Optional<std::string> optStr;
|
||||||
|
@ -323,11 +355,9 @@ class TestConfig : public BasicTestConfig {
|
||||||
}
|
}
|
||||||
if (attrib == "tenantModes") {
|
if (attrib == "tenantModes") {
|
||||||
std::stringstream ss(value);
|
std::stringstream ss(value);
|
||||||
for (int i; ss >> i;) {
|
std::string token;
|
||||||
tenantModes.push_back(i);
|
while (std::getline(ss, token, ',')) {
|
||||||
if (ss.peek() == ',') {
|
tenantModes.push_back(token);
|
||||||
ss.ignore();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (attrib == "defaultTenant") {
|
if (attrib == "defaultTenant") {
|
||||||
|
@ -383,9 +413,9 @@ public:
|
||||||
bool injectTargetedSSRestart = false;
|
bool injectTargetedSSRestart = false;
|
||||||
bool injectSSDelay = false;
|
bool injectSSDelay = false;
|
||||||
// By default, tenant mode is set randomly
|
// By default, tenant mode is set randomly
|
||||||
// If provided, set using TenantMode::fromValue
|
// If provided, set using TenantMode::fromString
|
||||||
// Verify match with TenantMode::fromValue in FDBTypes.h
|
// Ensure no '_experimental` suffix in the mode name
|
||||||
std::vector<int> tenantModes;
|
std::vector<std::string> tenantModes;
|
||||||
Optional<std::string> defaultTenant;
|
Optional<std::string> defaultTenant;
|
||||||
std::string testClass; // unused -- used in TestHarness
|
std::string testClass; // unused -- used in TestHarness
|
||||||
float testPriority; // 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 tssModeStr = ini.GetValue("META", "tssMode");
|
||||||
auto tenantMode = ini.GetValue("META", "tenantMode");
|
auto tenantMode = ini.GetValue("META", "tenantMode");
|
||||||
if (tenantMode != nullptr) {
|
if (tenantMode != nullptr) {
|
||||||
testConfig->tenantModes.push_back(atoi(tenantMode));
|
testConfig->tenantModes.push_back(tenantMode);
|
||||||
}
|
}
|
||||||
std::string defaultTenant = ini.GetValue("META", "defaultTenant", "");
|
std::string defaultTenant = ini.GetValue("META", "defaultTenant", "");
|
||||||
if (!defaultTenant.empty()) {
|
if (!defaultTenant.empty()) {
|
||||||
|
@ -2592,8 +2622,8 @@ ACTOR void setupAndRun(std::string dataFolder,
|
||||||
if (!rebooting) {
|
if (!rebooting) {
|
||||||
if (testConfig.tenantModes.size()) {
|
if (testConfig.tenantModes.size()) {
|
||||||
auto randomPick = deterministicRandom()->randomChoice(testConfig.tenantModes);
|
auto randomPick = deterministicRandom()->randomChoice(testConfig.tenantModes);
|
||||||
tenantMode = TenantMode::fromValue(StringRef(std::to_string(randomPick)));
|
tenantMode = TenantMode::fromString(randomPick);
|
||||||
if (allowDefaultTenant) {
|
if (tenantMode == TenantMode::REQUIRED && allowDefaultTenant) {
|
||||||
defaultTenant = "SimulatedDefaultTenant"_sr;
|
defaultTenant = "SimulatedDefaultTenant"_sr;
|
||||||
}
|
}
|
||||||
} else if (allowDefaultTenant && deterministicRandom()->random01() < 0.5) {
|
} 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
|
// restartSimulatedSystem can adjust some testConfig params related to tenants
|
||||||
// so set/overwrite those options if necessary here
|
// so set/overwrite those options if necessary here
|
||||||
if (rebooting && testConfig.tenantModes.size()) {
|
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) {
|
if (testConfig.defaultTenant.present() && tenantMode != TenantMode::DISABLED && allowDefaultTenant) {
|
||||||
// Default tenant set by testConfig or restarting data in restartInfo.ini
|
// 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", "testerCount", format("%d", g_simulator->testerCount).c_str());
|
||||||
ini.SetValue("META", "tssMode", format("%d", g_simulator->tssMode).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", "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()) {
|
if (cx->defaultTenant.present()) {
|
||||||
ini.SetValue("META", "defaultTenant", cx->defaultTenant.get().toString().c_str());
|
ini.SetValue("META", "defaultTenant", cx->defaultTenant.get().toString().c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[configuration]
|
[configuration]
|
||||||
allowDefaultTenant = true
|
allowDefaultTenant = true
|
||||||
tenantModes = [2]
|
tenantModes = ['required']
|
||||||
|
|
||||||
[[knobs]]
|
[[knobs]]
|
||||||
enable_encryption = true
|
enable_encryption = true
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[configuration]
|
[configuration]
|
||||||
StderrSeverity = 30
|
StderrSeverity = 30
|
||||||
allowDefaultTenant = false
|
allowDefaultTenant = false
|
||||||
tenantModes = [1]
|
tenantModes = ['optional', 'required']
|
||||||
|
|
||||||
[[test]]
|
[[test]]
|
||||||
testTitle = 'FuzzApiCorrectness'
|
testTitle = 'FuzzApiCorrectness'
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[configuration]
|
[configuration]
|
||||||
StderrSeverity = 30
|
StderrSeverity = 30
|
||||||
allowDefaultTenant = false
|
allowDefaultTenant = false
|
||||||
tenantModes = [1]
|
tenantModes = ['optional', 'required']
|
||||||
|
|
||||||
[[test]]
|
[[test]]
|
||||||
testTitle = 'FuzzApiCorrectness'
|
testTitle = 'FuzzApiCorrectness'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[configuration]
|
[configuration]
|
||||||
allowDefaultTenant = false
|
allowDefaultTenant = false
|
||||||
tenantModes = [1]
|
tenantModes = ['optional', 'required']
|
||||||
|
|
||||||
[[test]]
|
[[test]]
|
||||||
testTitle = 'TenantCreation'
|
testTitle = 'TenantCreation'
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[configuration]
|
[configuration]
|
||||||
tenantModes = [1]
|
tenantModes = ['optional', 'required']
|
||||||
|
|
||||||
[[test]]
|
[[test]]
|
||||||
testTitle = 'SpecialKeySpaceCorrectnessTest'
|
testTitle = 'SpecialKeySpaceCorrectnessTest'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[configuration]
|
[configuration]
|
||||||
allowDefaultTenant = false
|
allowDefaultTenant = false
|
||||||
tenantModes = [1]
|
tenantModes = ['optional', 'required']
|
||||||
|
|
||||||
[[test]]
|
[[test]]
|
||||||
testTitle = 'TenantCreation'
|
testTitle = 'TenantCreation'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[configuration]
|
[configuration]
|
||||||
allowDefaultTenant = false
|
allowDefaultTenant = false
|
||||||
tenantModes = [1]
|
tenantModes = ['optional', 'required']
|
||||||
|
|
||||||
[[knobs]]
|
[[knobs]]
|
||||||
allow_tokenless_tenant_access = true
|
allow_tokenless_tenant_access = true
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[configuration]
|
[configuration]
|
||||||
allowDefaultTenant = false
|
allowDefaultTenant = false
|
||||||
tenantModes = [0,1]
|
tenantModes = ['disabled', 'optional']
|
||||||
|
|
||||||
[[test]]
|
[[test]]
|
||||||
testTitle = 'TenantEntryCacheTest'
|
testTitle = 'TenantEntryCacheTest'
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[configuration]
|
[configuration]
|
||||||
blobGranulesEnabled = true
|
blobGranulesEnabled = true
|
||||||
allowDefaultTenant = false
|
allowDefaultTenant = false
|
||||||
tenantModes = [1]
|
tenantModes = ['optional', 'required']
|
||||||
injectTargetedSSRestart = true
|
injectTargetedSSRestart = true
|
||||||
injectSSDelay = true
|
injectSSDelay = true
|
||||||
# FIXME: re-enable rocks at some point
|
# FIXME: re-enable rocks at some point
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[configuration]
|
[configuration]
|
||||||
blobGranulesEnabled = true
|
blobGranulesEnabled = true
|
||||||
allowDefaultTenant = false
|
allowDefaultTenant = false
|
||||||
tenantModes = [1]
|
tenantModes = ['optional', 'required']
|
||||||
# FIXME: re-enable rocks at some point
|
# FIXME: re-enable rocks at some point
|
||||||
storageEngineExcludeTypes = [4, 5]
|
storageEngineExcludeTypes = [4, 5]
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[configuration]
|
[configuration]
|
||||||
allowDefaultTenant = false
|
allowDefaultTenant = false
|
||||||
tenantModes = [1]
|
tenantModes = ['optional', 'required']
|
||||||
allowCreatingTenants = false
|
allowCreatingTenants = false
|
||||||
extraDatabaseMode = 'Multiple'
|
extraDatabaseMode = 'Multiple'
|
||||||
extraDatabaseCount = 5
|
extraDatabaseCount = 5
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[configuration]
|
[configuration]
|
||||||
allowDefaultTenant = false
|
allowDefaultTenant = false
|
||||||
tenantModes = [1]
|
tenantModes = ['optional', 'required']
|
||||||
|
|
||||||
[[test]]
|
[[test]]
|
||||||
testTitle = 'TenantManagementTest'
|
testTitle = 'TenantManagementTest'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[configuration]
|
[configuration]
|
||||||
allowDefaultTenant = false
|
allowDefaultTenant = false
|
||||||
tenantModes = [1]
|
tenantModes = ['optional', 'required']
|
||||||
allowCreatingTenants = false
|
allowCreatingTenants = false
|
||||||
extraDatabaseMode = 'Single'
|
extraDatabaseMode = 'Single'
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[configuration]
|
[configuration]
|
||||||
allowDefaultTenant = false
|
allowDefaultTenant = false
|
||||||
tenantModes = [1]
|
tenantModes = ['optional', 'required']
|
||||||
allowCreatingTenants = false
|
allowCreatingTenants = false
|
||||||
extraDatabaseMode = 'Single'
|
extraDatabaseMode = 'Single'
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[configuration]
|
[configuration]
|
||||||
allowDefaultTenant = false
|
allowDefaultTenant = false
|
||||||
tenantModes = [1]
|
tenantModes = ['optional', 'required']
|
||||||
allowCreatingTenants = false
|
allowCreatingTenants = false
|
||||||
extraDatabaseMode = 'Single'
|
extraDatabaseMode = 'Single'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue