process '_experimental' suffix in fromString helper

This commit is contained in:
Jon Fu 2022-10-20 13:38:13 -07:00
parent 1d86ef7424
commit 3533cff94d
3 changed files with 7 additions and 8 deletions

View File

@ -1405,6 +1405,9 @@ struct TenantMode {
// 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.find("_experimental") != std::string::npos) {
mode.replace(mode.find("_experimental"), std::string::npos, "");
}
if (mode == "disabled") {
return TenantMode::DISABLED;
} else if (mode == "optional") {

View File

@ -2626,14 +2626,14 @@ ACTOR void setupAndRun(std::string dataFolder,
if (tenantMode == TenantMode::REQUIRED && allowDefaultTenant) {
defaultTenant = "SimulatedDefaultTenant"_sr;
}
} else if (allowDefaultTenant && deterministicRandom()->random01() < 0.5) {
} else if (allowDefaultTenant && deterministicRandom()->coinflip()) {
defaultTenant = "SimulatedDefaultTenant"_sr;
if (deterministicRandom()->random01() < 0.9) {
tenantMode = TenantMode::REQUIRED;
} else {
tenantMode = TenantMode::OPTIONAL_TENANT;
}
} else if (deterministicRandom()->random01() < 0.5) {
} else if (deterministicRandom()->coinflip()) {
tenantMode = TenantMode::OPTIONAL_TENANT;
}
}
@ -2680,7 +2680,7 @@ ACTOR void setupAndRun(std::string dataFolder,
if (defaultTenant.present() && allowDefaultTenant) {
tenantsToCreate.push_back_deep(tenantsToCreate.arena(), defaultTenant.get());
}
if (allowCreatingTenants && tenantMode != TenantMode::DISABLED && deterministicRandom()->random01() < 0.5) {
if (allowCreatingTenants && tenantMode != TenantMode::DISABLED && deterministicRandom()->coinflip()) {
int numTenants = deterministicRandom()->randomInt(1, 6);
for (int i = 0; i < numTenants; ++i) {
tenantsToCreate.push_back_deep(tenantsToCreate.arena(),

View File

@ -68,11 +68,7 @@ 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());
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());
ini.SetValue("META", "tenantMode", cx->clientInfo->get().tenantMode.toString().c_str());
if (cx->defaultTenant.present()) {
ini.SetValue("META", "defaultTenant", cx->defaultTenant.get().toString().c_str());
}