2017-05-26 04:48:44 +08:00
|
|
|
/*
|
|
|
|
* SimulatedCluster.actor.cpp
|
|
|
|
*
|
|
|
|
* This source file is part of the FoundationDB open source project
|
|
|
|
*
|
|
|
|
* Copyright 2013-2018 Apple Inc. and the FoundationDB project authors
|
2018-02-22 02:25:11 +08:00
|
|
|
*
|
2017-05-26 04:48:44 +08:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2018-02-22 02:25:11 +08:00
|
|
|
*
|
2017-05-26 04:48:44 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2018-02-22 02:25:11 +08:00
|
|
|
*
|
2017-05-26 04:48:44 +08:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2020-09-29 01:58:49 +08:00
|
|
|
#include <cstdint>
|
2017-05-26 04:48:44 +08:00
|
|
|
#include <fstream>
|
2020-08-07 16:02:07 +08:00
|
|
|
#include <ostream>
|
2021-04-08 03:59:51 +08:00
|
|
|
#include <sstream>
|
2021-07-17 00:51:38 +08:00
|
|
|
#include <string_view>
|
2021-05-21 03:48:41 +08:00
|
|
|
#include <toml.hpp>
|
2020-10-06 01:07:51 +08:00
|
|
|
#include "fdbrpc/Locality.h"
|
2017-05-26 04:48:44 +08:00
|
|
|
#include "fdbrpc/simulator.h"
|
2021-10-11 11:44:56 +08:00
|
|
|
#include "fdbclient/ClusterConnectionFile.h"
|
|
|
|
#include "fdbclient/ClusterConnectionMemoryRecord.h"
|
2017-05-26 04:48:44 +08:00
|
|
|
#include "fdbclient/DatabaseContext.h"
|
2019-02-18 11:25:16 +08:00
|
|
|
#include "fdbserver/TesterInterface.actor.h"
|
2019-02-18 11:13:26 +08:00
|
|
|
#include "fdbserver/WorkerInterface.actor.h"
|
2017-05-26 04:48:44 +08:00
|
|
|
#include "fdbclient/ClusterInterface.h"
|
2018-10-20 01:30:13 +08:00
|
|
|
#include "fdbserver/Knobs.h"
|
2017-05-26 04:48:44 +08:00
|
|
|
#include "fdbserver/CoordinationInterface.h"
|
2022-02-04 07:33:58 +08:00
|
|
|
#include "fdbclient/SimpleIni.h"
|
2017-05-26 04:48:44 +08:00
|
|
|
#include "fdbrpc/AsyncFileNonDurable.actor.h"
|
2019-02-18 09:38:13 +08:00
|
|
|
#include "fdbclient/ManagementAPI.actor.h"
|
2019-02-18 07:41:16 +08:00
|
|
|
#include "fdbclient/NativeAPI.actor.h"
|
2019-02-18 07:19:05 +08:00
|
|
|
#include "fdbclient/BackupAgent.actor.h"
|
2020-05-21 04:23:02 +08:00
|
|
|
#include "fdbclient/versions.h"
|
2021-09-21 00:46:34 +08:00
|
|
|
#include "fdbclient/WellKnownEndpoints.h"
|
2020-09-29 01:58:49 +08:00
|
|
|
#include "flow/ProtocolVersion.h"
|
2020-10-06 01:07:51 +08:00
|
|
|
#include "flow/network.h"
|
2021-06-17 00:46:21 +08:00
|
|
|
#include "flow/TypeTraits.h"
|
2021-07-24 07:28:20 +08:00
|
|
|
#include "flow/FaultInjection.h"
|
2021-05-21 03:48:41 +08:00
|
|
|
#include "flow/actorcompiler.h" // This must be the last #include.
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
#undef max
|
|
|
|
#undef min
|
|
|
|
|
|
|
|
extern "C" int g_expect_full_pointermap;
|
2019-11-16 04:26:51 +08:00
|
|
|
extern const char* getSourceVersion();
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-05-21 03:48:41 +08:00
|
|
|
using namespace std::literals;
|
|
|
|
|
2021-07-17 00:51:38 +08:00
|
|
|
// TODO: Defining these here is just asking for ODR violations.
|
|
|
|
template <>
|
|
|
|
std::string describe(bool const& val) {
|
|
|
|
return val ? "true" : "false";
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
std::string describe(int const& val) {
|
|
|
|
return format("%d", val);
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
const int MACHINE_REBOOT_TIME = 10;
|
|
|
|
|
|
|
|
bool destructed = false;
|
|
|
|
|
2021-05-21 03:48:41 +08:00
|
|
|
// Configuration details specified in workload test files that change the simulation
|
|
|
|
// environment details
|
|
|
|
class TestConfig {
|
|
|
|
class ConfigBuilder {
|
|
|
|
using value_type = toml::basic_value<toml::discard_comments>;
|
2021-08-07 15:14:06 +08:00
|
|
|
using base_variant = std::variant<int, bool, std::string, std::vector<int>, ConfigDBType>;
|
2021-06-17 00:46:21 +08:00
|
|
|
using types =
|
|
|
|
variant_map<variant_concat<base_variant, variant_map<base_variant, Optional>>, std::add_pointer_t>;
|
2021-06-16 06:00:19 +08:00
|
|
|
std::unordered_map<std::string_view, types> confMap;
|
|
|
|
|
|
|
|
struct visitor {
|
|
|
|
const value_type& value;
|
|
|
|
visitor(const value_type& v) : value(v) {}
|
|
|
|
void operator()(int* val) const { *val = value.as_integer(); }
|
|
|
|
void operator()(Optional<int>* val) const { *val = value.as_integer(); }
|
|
|
|
void operator()(bool* val) const { *val = value.as_boolean(); }
|
|
|
|
void operator()(Optional<bool>* val) const { *val = value.as_boolean(); }
|
|
|
|
void operator()(std::string* val) const { *val = value.as_string(); }
|
|
|
|
void operator()(Optional<std::string>* val) const { *val = value.as_string(); }
|
|
|
|
void operator()(std::vector<int>* val) const {
|
|
|
|
auto arr = value.as_array();
|
|
|
|
for (const auto& i : arr) {
|
|
|
|
val->emplace_back(i.as_integer());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void operator()(Optional<std::vector<int>>* val) const {
|
|
|
|
std::vector<int> res;
|
|
|
|
(*this)(&res);
|
|
|
|
*val = std::move(res);
|
|
|
|
}
|
2021-08-07 15:14:06 +08:00
|
|
|
void operator()(ConfigDBType* val) const {
|
|
|
|
if (value.as_string() == "random") {
|
|
|
|
*val = deterministicRandom()->coinflip() ? ConfigDBType::SIMPLE : ConfigDBType::PAXOS;
|
|
|
|
} else {
|
|
|
|
*val = configDBTypeFromString(value.as_string());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void operator()(Optional<ConfigDBType>* val) const {
|
|
|
|
ConfigDBType res;
|
|
|
|
(*this)(&res);
|
|
|
|
*val = std::move(res);
|
|
|
|
}
|
2021-06-16 06:00:19 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct trace_visitor {
|
|
|
|
std::string key;
|
|
|
|
TraceEvent& evt;
|
|
|
|
trace_visitor(std::string const& key, TraceEvent& e) : key("Key" + key), evt(e) {}
|
2021-08-07 15:22:53 +08:00
|
|
|
template <class T>
|
|
|
|
void operator()(T const* val) const {
|
|
|
|
evt.detail(key.c_str(), *val);
|
|
|
|
}
|
|
|
|
void operator()(std::vector<int> const* val) const {
|
2021-06-16 06:00:19 +08:00
|
|
|
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());
|
|
|
|
}
|
2021-08-07 15:22:53 +08:00
|
|
|
void operator()(Optional<std::vector<int>> const* val) const {
|
|
|
|
if (!val->present()) {
|
|
|
|
evt.detail(key.c_str(), *val);
|
|
|
|
} else {
|
|
|
|
(*this)(&(val->get()));
|
|
|
|
}
|
2021-06-16 06:00:19 +08:00
|
|
|
}
|
2021-08-07 15:22:53 +08:00
|
|
|
void operator()(ConfigDBType const* val) const { evt.detail(key.c_str(), *val); }
|
|
|
|
void operator()(Optional<ConfigDBType> const* val) const {
|
2021-08-07 15:14:06 +08:00
|
|
|
Optional<std::string> optStr;
|
|
|
|
if (val->present()) {
|
|
|
|
optStr = configDBTypeToString(val->get());
|
|
|
|
}
|
|
|
|
evt.detail(key.c_str(), optStr);
|
2021-06-16 06:00:19 +08:00
|
|
|
}
|
|
|
|
};
|
2021-05-21 03:48:41 +08:00
|
|
|
|
|
|
|
public:
|
2021-06-16 06:00:19 +08:00
|
|
|
~ConfigBuilder() {
|
|
|
|
TraceEvent evt("SimulatorConfigFromToml");
|
|
|
|
for (const auto& p : confMap) {
|
|
|
|
std::visit(trace_visitor(std::string(p.first), evt), p.second);
|
|
|
|
}
|
2021-05-21 03:48:41 +08:00
|
|
|
}
|
2021-06-16 06:00:19 +08:00
|
|
|
|
|
|
|
template <class V>
|
|
|
|
ConfigBuilder& add(std::string_view key, V value) {
|
|
|
|
confMap.emplace(key, value);
|
2021-05-21 03:48:41 +08:00
|
|
|
return *this;
|
|
|
|
}
|
2021-06-16 06:00:19 +08:00
|
|
|
|
|
|
|
void set(std::string_view key, const value_type& value) {
|
2021-05-21 03:48:41 +08:00
|
|
|
auto iter = confMap.find(key);
|
|
|
|
if (iter == confMap.end()) {
|
|
|
|
std::cerr << "Unknown configuration attribute " << key << std::endl;
|
2021-06-16 06:00:19 +08:00
|
|
|
TraceEvent("UnknownConfigurationAttribute").detail("Name", std::string(key));
|
2021-05-21 03:48:41 +08:00
|
|
|
throw unknown_error();
|
|
|
|
}
|
2021-06-16 06:00:19 +08:00
|
|
|
std::visit(visitor(value), iter->second);
|
2021-05-21 03:48:41 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
bool isIniFile(const char* fileName) {
|
|
|
|
std::string name = fileName;
|
|
|
|
auto pos = name.find_last_of('.');
|
|
|
|
ASSERT(pos != std::string::npos && pos + 1 < name.size());
|
|
|
|
auto extension = name.substr(pos + 1);
|
|
|
|
return extension == "txt"sv;
|
|
|
|
}
|
|
|
|
|
|
|
|
void loadIniFile(const char* testFile) {
|
|
|
|
std::ifstream ifs;
|
|
|
|
ifs.open(testFile, std::ifstream::in);
|
|
|
|
if (!ifs.good())
|
|
|
|
return;
|
|
|
|
|
|
|
|
std::string cline;
|
|
|
|
|
|
|
|
while (ifs.good()) {
|
|
|
|
getline(ifs, cline);
|
|
|
|
std::string line = removeWhitespace(std::string(cline));
|
|
|
|
if (!line.size() || line.find(';') == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
size_t found = line.find('=');
|
|
|
|
if (found == std::string::npos)
|
|
|
|
// hmmm, not good
|
|
|
|
continue;
|
|
|
|
std::string attrib = removeWhitespace(line.substr(0, found));
|
|
|
|
std::string value = removeWhitespace(line.substr(found + 1));
|
|
|
|
|
|
|
|
if (attrib == "extraDB") {
|
|
|
|
sscanf(value.c_str(), "%d", &extraDB);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attrib == "minimumReplication") {
|
|
|
|
sscanf(value.c_str(), "%d", &minimumReplication);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attrib == "minimumRegions") {
|
|
|
|
sscanf(value.c_str(), "%d", &minimumRegions);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attrib == "configureLocked") {
|
2021-10-31 12:07:38 +08:00
|
|
|
int configureLockedInt;
|
|
|
|
sscanf(value.c_str(), "%d", &configureLockedInt);
|
|
|
|
configureLocked = (configureLockedInt != 0);
|
2021-05-21 03:48:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (attrib == "startIncompatibleProcess") {
|
|
|
|
startIncompatibleProcess = strcmp(value.c_str(), "true") == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attrib == "logAntiQuorum") {
|
|
|
|
sscanf(value.c_str(), "%d", &logAntiQuorum);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attrib == "storageEngineExcludeTypes") {
|
|
|
|
std::stringstream ss(value);
|
|
|
|
for (int i; ss >> i;) {
|
|
|
|
storageEngineExcludeTypes.push_back(i);
|
|
|
|
if (ss.peek() == ',') {
|
|
|
|
ss.ignore();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (attrib == "maxTLogVersion") {
|
|
|
|
sscanf(value.c_str(), "%d", &maxTLogVersion);
|
|
|
|
}
|
2021-06-11 02:46:44 +08:00
|
|
|
if (attrib == "disableTss") {
|
2021-09-04 03:47:02 +08:00
|
|
|
disableTss = strcmp(value.c_str(), "true") == 0;
|
2021-06-11 02:46:44 +08:00
|
|
|
}
|
2022-01-21 05:26:49 +08:00
|
|
|
if (attrib == "disableHostname") {
|
|
|
|
disableHostname = strcmp(value.c_str(), "true") == 0;
|
|
|
|
}
|
2021-06-03 04:40:00 +08:00
|
|
|
if (attrib == "restartInfoLocation") {
|
2021-05-13 02:53:20 +08:00
|
|
|
isFirstTestInRestart = true;
|
|
|
|
}
|
2021-08-07 14:18:10 +08:00
|
|
|
if (attrib == "configDBType") {
|
2021-08-07 15:14:06 +08:00
|
|
|
if (value == "random") {
|
|
|
|
configDBType = deterministicRandom()->coinflip() ? ConfigDBType::SIMPLE : ConfigDBType::PAXOS;
|
|
|
|
} else {
|
|
|
|
configDBType = configDBTypeFromString(value);
|
|
|
|
}
|
2021-08-07 12:19:53 +08:00
|
|
|
}
|
2021-05-21 03:48:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ifs.close();
|
|
|
|
}
|
|
|
|
|
2021-08-07 15:14:06 +08:00
|
|
|
ConfigDBType configDBType{ ConfigDBType::DISABLED };
|
2021-08-07 12:19:53 +08:00
|
|
|
|
2021-05-21 03:48:41 +08:00
|
|
|
public:
|
|
|
|
int extraDB = 0;
|
|
|
|
int minimumReplication = 0;
|
|
|
|
int minimumRegions = 0;
|
|
|
|
bool configureLocked = false;
|
|
|
|
bool startIncompatibleProcess = false;
|
|
|
|
int logAntiQuorum = -1;
|
2021-05-26 04:06:32 +08:00
|
|
|
bool isFirstTestInRestart = false;
|
2021-06-11 02:46:44 +08:00
|
|
|
// 7.0 cannot be downgraded to 6.3 after enabling TSS, so disable TSS for 6.3 downgrade tests
|
|
|
|
bool disableTss = false;
|
2022-01-21 05:26:49 +08:00
|
|
|
// 7.1 cannot be downgraded to 7.0 and below after enabling hostname, so disable hostname for 7.0 downgrade tests
|
|
|
|
bool disableHostname = false;
|
2021-05-21 03:48:41 +08:00
|
|
|
// Storage Engine Types: Verify match with SimulationConfig::generateNormalConfig
|
|
|
|
// 0 = "ssd"
|
|
|
|
// 1 = "memory"
|
|
|
|
// 2 = "memory-radixtree-beta"
|
2021-11-16 18:15:22 +08:00
|
|
|
// 3 = "ssd-redwood-1-experimental"
|
2021-07-17 00:01:01 +08:00
|
|
|
// 4 = "ssd-rocksdb-experimental"
|
2021-05-21 03:48:41 +08:00
|
|
|
// Requires a comma-separated list of numbers WITHOUT whitespaces
|
|
|
|
std::vector<int> storageEngineExcludeTypes;
|
|
|
|
// Set the maximum TLog version that can be selected for a test
|
|
|
|
// Refer to FDBTypes.h::TLogVersion. Defaults to the maximum supported version.
|
|
|
|
int maxTLogVersion = TLogVersion::MAX_SUPPORTED;
|
|
|
|
// Set true to simplify simulation configs for easier debugging
|
2021-10-15 03:58:37 +08:00
|
|
|
bool simpleConfig = false;
|
2021-09-22 07:49:55 +08:00
|
|
|
int extraMachineCountDC = 0;
|
2021-05-21 03:48:41 +08:00
|
|
|
Optional<bool> generateFearless, buggify;
|
|
|
|
Optional<int> datacenters, desiredTLogCount, commitProxyCount, grvProxyCount, resolverCount, storageEngineType,
|
|
|
|
stderrSeverity, machineCount, processesPerMachine, coordinators;
|
|
|
|
Optional<std::string> config;
|
|
|
|
|
2021-08-07 15:14:06 +08:00
|
|
|
ConfigDBType getConfigDBType() const { return configDBType; }
|
2021-08-07 12:19:53 +08:00
|
|
|
|
2021-06-03 04:40:00 +08:00
|
|
|
bool tomlKeyPresent(const toml::value& data, std::string key) {
|
|
|
|
if (data.is_table()) {
|
|
|
|
for (const auto& [k, v] : data.as_table()) {
|
|
|
|
if (k == key || tomlKeyPresent(v, key)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (data.is_array()) {
|
|
|
|
for (const auto& v : data.as_array()) {
|
|
|
|
if (tomlKeyPresent(v, key)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-05-21 03:48:41 +08:00
|
|
|
void readFromConfig(const char* testFile) {
|
|
|
|
if (isIniFile(testFile)) {
|
|
|
|
loadIniFile(testFile);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ConfigBuilder builder;
|
|
|
|
builder.add("extraDB", &extraDB)
|
|
|
|
.add("minimumReplication", &minimumReplication)
|
|
|
|
.add("minimumRegions", &minimumRegions)
|
|
|
|
.add("configureLocked", &configureLocked)
|
|
|
|
.add("startIncompatibleProcess", &startIncompatibleProcess)
|
|
|
|
.add("logAntiQuorum", &logAntiQuorum)
|
|
|
|
.add("storageEngineExcludeTypes", &storageEngineExcludeTypes)
|
|
|
|
.add("maxTLogVersion", &maxTLogVersion)
|
2021-06-11 02:46:44 +08:00
|
|
|
.add("disableTss", &disableTss)
|
2022-01-21 05:26:49 +08:00
|
|
|
.add("disableHostname", &disableHostname)
|
2021-05-21 03:48:41 +08:00
|
|
|
.add("simpleConfig", &simpleConfig)
|
|
|
|
.add("generateFearless", &generateFearless)
|
|
|
|
.add("datacenters", &datacenters)
|
|
|
|
.add("desiredTLogCount", &desiredTLogCount)
|
|
|
|
.add("commitProxyCount", &commitProxyCount)
|
|
|
|
.add("grvProxyCount", &grvProxyCount)
|
|
|
|
.add("resolverCount", &resolverCount)
|
|
|
|
.add("storageEngineType", &storageEngineType)
|
|
|
|
.add("config", &config)
|
|
|
|
.add("buggify", &buggify)
|
|
|
|
.add("StderrSeverity", &stderrSeverity)
|
|
|
|
.add("machineCount", &machineCount)
|
|
|
|
.add("processesPerMachine", &processesPerMachine)
|
2021-08-07 12:19:53 +08:00
|
|
|
.add("coordinators", &coordinators)
|
2021-09-22 07:49:55 +08:00
|
|
|
.add("configDB", &configDBType)
|
|
|
|
.add("extraMachineCountDC", &extraMachineCountDC);
|
2021-05-21 03:48:41 +08:00
|
|
|
try {
|
|
|
|
auto file = toml::parse(testFile);
|
|
|
|
if (file.contains("configuration") && toml::find(file, "configuration").is_table()) {
|
|
|
|
auto conf = toml::find(file, "configuration").as_table();
|
|
|
|
for (const auto& [key, value] : conf) {
|
|
|
|
if (key == "ClientInfoLogging") {
|
|
|
|
setNetworkOption(FDBNetworkOptions::DISABLE_CLIENT_STATISTICS_LOGGING);
|
2021-05-13 02:53:20 +08:00
|
|
|
} else if (key == "restartInfoLocation") {
|
|
|
|
isFirstTestInRestart = true;
|
2021-05-21 03:48:41 +08:00
|
|
|
} else {
|
|
|
|
builder.set(key, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (stderrSeverity.present()) {
|
|
|
|
TraceEvent("StderrSeverity").detail("NewSeverity", stderrSeverity.get());
|
|
|
|
}
|
|
|
|
}
|
2021-06-03 04:40:00 +08:00
|
|
|
// look for restartInfoLocation to mark isFirstTestInRestart
|
|
|
|
if (!isFirstTestInRestart) {
|
|
|
|
isFirstTestInRestart = tomlKeyPresent(file, "restartInfoLocation");
|
|
|
|
}
|
2021-05-21 03:48:41 +08:00
|
|
|
} catch (std::exception& e) {
|
|
|
|
std::cerr << e.what() << std::endl;
|
|
|
|
TraceEvent("TOMLParseError").detail("Error", printable(e.what()));
|
|
|
|
throw unknown_error();
|
|
|
|
}
|
2021-06-16 06:00:19 +08:00
|
|
|
// Verify that we can use the passed config
|
|
|
|
if (simpleConfig) {
|
|
|
|
if (minimumRegions > 1) {
|
|
|
|
TraceEvent("ElapsedTime").detail("SimTime", now()).detail("RealTime", 0).detail("RandomUnseed", 0);
|
|
|
|
flushAndExit(0);
|
|
|
|
}
|
|
|
|
}
|
2021-05-21 03:48:41 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
template <class T>
|
2021-03-11 02:06:03 +08:00
|
|
|
T simulate(const T& in) {
|
2020-09-29 01:58:49 +08:00
|
|
|
BinaryWriter writer(AssumeVersion(g_network->protocolVersion()));
|
2017-05-26 04:48:44 +08:00
|
|
|
writer << in;
|
2021-03-11 02:06:03 +08:00
|
|
|
BinaryReader reader(writer.getData(), writer.getLength(), AssumeVersion(g_network->protocolVersion()));
|
2017-05-26 04:48:44 +08:00
|
|
|
T out;
|
|
|
|
reader >> out;
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2021-10-11 11:44:56 +08:00
|
|
|
ACTOR Future<Void> runBackup(Reference<IClusterConnectionRecord> connRecord) {
|
2017-05-26 04:48:44 +08:00
|
|
|
state std::vector<Future<Void>> agentFutures;
|
2020-09-29 04:32:20 +08:00
|
|
|
|
2020-11-23 11:49:16 +08:00
|
|
|
while (g_simulator.backupAgents == ISimulator::BackupAgentType::WaitForType) {
|
2018-08-11 04:57:10 +08:00
|
|
|
wait(delay(1.0));
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
2020-11-23 11:49:16 +08:00
|
|
|
if (g_simulator.backupAgents == ISimulator::BackupAgentType::BackupToFile) {
|
2021-10-11 11:44:56 +08:00
|
|
|
Database cx = Database::createDatabase(connRecord, -1);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
state FileBackupAgent fileAgent;
|
2021-07-06 04:20:43 +08:00
|
|
|
agentFutures.push_back(fileAgent.run(
|
|
|
|
cx, 1.0 / CLIENT_KNOBS->BACKUP_AGGREGATE_POLL_RATE, CLIENT_KNOBS->SIM_BACKUP_TASKS_PER_AGENT));
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2020-11-23 11:49:16 +08:00
|
|
|
while (g_simulator.backupAgents == ISimulator::BackupAgentType::BackupToFile) {
|
2018-08-11 04:57:10 +08:00
|
|
|
wait(delay(1.0));
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
for (auto it : agentFutures) {
|
2017-05-26 04:48:44 +08:00
|
|
|
it.cancel();
|
|
|
|
}
|
|
|
|
}
|
2018-02-21 05:22:31 +08:00
|
|
|
|
2018-08-11 08:25:43 +08:00
|
|
|
wait(Future<Void>(Never()));
|
2018-02-21 05:22:31 +08:00
|
|
|
throw internal_error();
|
|
|
|
}
|
|
|
|
|
2021-10-11 11:44:56 +08:00
|
|
|
ACTOR Future<Void> runDr(Reference<IClusterConnectionRecord> connRecord) {
|
2018-02-21 05:22:31 +08:00
|
|
|
state std::vector<Future<Void>> agentFutures;
|
|
|
|
|
2020-11-23 11:49:16 +08:00
|
|
|
while (g_simulator.drAgents == ISimulator::BackupAgentType::WaitForType) {
|
2018-08-11 04:57:10 +08:00
|
|
|
wait(delay(1.0));
|
2018-02-21 05:22:31 +08:00
|
|
|
}
|
|
|
|
|
2020-11-23 11:49:16 +08:00
|
|
|
if (g_simulator.drAgents == ISimulator::BackupAgentType::BackupToDB) {
|
2021-10-11 11:44:56 +08:00
|
|
|
Database cx = Database::createDatabase(connRecord, -1);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-10-11 11:44:56 +08:00
|
|
|
auto extraFile = makeReference<ClusterConnectionMemoryRecord>(*g_simulator.extraDB);
|
2018-09-22 06:58:14 +08:00
|
|
|
state Database extraDB = Database::createDatabase(extraFile, -1);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
TraceEvent("StartingDrAgents")
|
2021-10-11 11:44:56 +08:00
|
|
|
.detail("ConnectionString", connRecord->getConnectionString().toString())
|
2021-03-11 02:06:03 +08:00
|
|
|
.detail("ExtraString", extraFile->getConnectionString().toString());
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
state DatabaseBackupAgent dbAgent = DatabaseBackupAgent(cx);
|
|
|
|
state DatabaseBackupAgent extraAgent = DatabaseBackupAgent(extraDB);
|
|
|
|
|
2021-07-06 04:20:43 +08:00
|
|
|
auto drPollDelay = 1.0 / CLIENT_KNOBS->BACKUP_AGGREGATE_POLL_RATE;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-07-06 04:20:43 +08:00
|
|
|
agentFutures.push_back(extraAgent.run(cx, drPollDelay, CLIENT_KNOBS->SIM_BACKUP_TASKS_PER_AGENT));
|
|
|
|
agentFutures.push_back(dbAgent.run(extraDB, drPollDelay, CLIENT_KNOBS->SIM_BACKUP_TASKS_PER_AGENT));
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2020-11-23 11:49:16 +08:00
|
|
|
while (g_simulator.drAgents == ISimulator::BackupAgentType::BackupToDB) {
|
2018-08-11 04:57:10 +08:00
|
|
|
wait(delay(1.0));
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
2021-07-27 10:55:10 +08:00
|
|
|
TraceEvent("StoppingDrAgents").log();
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
for (auto it : agentFutures) {
|
2017-05-26 04:48:44 +08:00
|
|
|
it.cancel();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-11 08:25:43 +08:00
|
|
|
wait(Future<Void>(Never()));
|
2017-05-26 04:48:44 +08:00
|
|
|
throw internal_error();
|
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
enum AgentMode { AgentNone = 0, AgentOnly = 1, AgentAddition = 2 };
|
2019-07-24 10:24:07 +08:00
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
// SOMEDAY: when a process can be rebooted in isolation from the other on that machine,
|
|
|
|
// a loop{} will be needed around the waiting on simulatedFDBD(). For now this simply
|
|
|
|
// takes care of house-keeping such as context switching and file closing.
|
2021-10-11 11:44:56 +08:00
|
|
|
ACTOR Future<ISimulator::KillType> simulatedFDBDRebooter(Reference<IClusterConnectionRecord> connRecord,
|
2021-03-11 02:06:03 +08:00
|
|
|
IPAddress ip,
|
2020-02-07 11:29:31 +08:00
|
|
|
bool sslEnabled,
|
2021-03-11 02:06:03 +08:00
|
|
|
uint16_t port,
|
|
|
|
uint16_t listenPerProcess,
|
|
|
|
LocalityData localities,
|
|
|
|
ProcessClass processClass,
|
|
|
|
std::string* dataFolder,
|
|
|
|
std::string* coordFolder,
|
|
|
|
std::string baseFolder,
|
|
|
|
ClusterConnectionString connStr,
|
|
|
|
bool useSeedFile,
|
|
|
|
AgentMode runBackupAgents,
|
|
|
|
std::string whitelistBinPaths,
|
2021-08-07 12:19:53 +08:00
|
|
|
ProtocolVersion protocolVersion,
|
2021-08-07 14:18:10 +08:00
|
|
|
ConfigDBType configDBType) {
|
2021-03-11 02:06:03 +08:00
|
|
|
state ISimulator::ProcessInfo* simProcess = g_simulator.getCurrentProcess();
|
2019-05-11 05:01:52 +08:00
|
|
|
state UID randomId = nondeterministicRandom()->randomUniqueID();
|
2017-06-20 07:48:15 +08:00
|
|
|
state int cycles = 0;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
loop {
|
2021-03-11 02:06:03 +08:00
|
|
|
auto waitTime =
|
|
|
|
SERVER_KNOBS->MIN_REBOOT_TIME +
|
|
|
|
(SERVER_KNOBS->MAX_REBOOT_TIME - SERVER_KNOBS->MIN_REBOOT_TIME) * deterministicRandom()->random01();
|
|
|
|
cycles++;
|
|
|
|
TraceEvent("SimulatedFDBDPreWait")
|
|
|
|
.detail("Cycles", cycles)
|
|
|
|
.detail("RandomId", randomId)
|
|
|
|
.detail("Address", NetworkAddress(ip, port, true, false))
|
|
|
|
.detail("ZoneId", localities.zoneId())
|
|
|
|
.detail("WaitTime", waitTime)
|
|
|
|
.detail("Port", port);
|
|
|
|
|
|
|
|
wait(delay(waitTime));
|
|
|
|
|
|
|
|
state ISimulator::ProcessInfo* process = g_simulator.newProcess("Server",
|
|
|
|
ip,
|
|
|
|
port,
|
|
|
|
sslEnabled,
|
|
|
|
listenPerProcess,
|
|
|
|
localities,
|
|
|
|
processClass,
|
|
|
|
dataFolder->c_str(),
|
|
|
|
coordFolder->c_str(),
|
|
|
|
protocolVersion);
|
|
|
|
wait(g_simulator.onProcess(
|
|
|
|
process,
|
|
|
|
TaskPriority::DefaultYield)); // Now switch execution to the process on which we will run
|
2017-05-26 04:48:44 +08:00
|
|
|
state Future<ISimulator::KillType> onShutdown = process->onShutdown();
|
|
|
|
|
|
|
|
try {
|
2021-03-11 02:06:03 +08:00
|
|
|
TraceEvent("SimulatedRebooterStarting")
|
|
|
|
.detail("Cycles", cycles)
|
|
|
|
.detail("RandomId", randomId)
|
|
|
|
.detail("ZoneId", localities.zoneId())
|
|
|
|
.detail("DataHall", localities.dataHallId())
|
|
|
|
.detail("Address", process->address.toString())
|
|
|
|
.detail("Excluded", process->excluded)
|
|
|
|
.detail("UsingSSL", sslEnabled);
|
|
|
|
TraceEvent("ProgramStart")
|
|
|
|
.detail("Cycles", cycles)
|
|
|
|
.detail("RandomId", randomId)
|
|
|
|
.detail("SourceVersion", getSourceVersion())
|
|
|
|
.detail("Version", FDB_VT_VERSION)
|
|
|
|
.detail("PackageName", FDB_VT_PACKAGE_NAME)
|
|
|
|
.detail("DataFolder", *dataFolder)
|
2021-10-11 11:44:56 +08:00
|
|
|
.detail("ConnectionString", connRecord ? connRecord->getConnectionString().toString() : "")
|
2021-03-11 02:06:03 +08:00
|
|
|
.detailf("ActualTime", "%lld", DEBUG_DETERMINISM ? 0 : time(nullptr))
|
|
|
|
.detail("CommandLine", "fdbserver -r simulation")
|
|
|
|
.detail("BuggifyEnabled", isBuggifyEnabled(BuggifyType::General))
|
|
|
|
.detail("Simulated", true)
|
|
|
|
.trackLatest("ProgramStart");
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
try {
|
2021-03-11 02:06:03 +08:00
|
|
|
// SOMEDAY: test lower memory limits, without making them too small and causing the database to stop
|
|
|
|
// making progress
|
|
|
|
FlowTransport::createInstance(processClass == ProcessClass::TesterClass || runBackupAgents == AgentOnly,
|
2021-09-21 00:46:34 +08:00
|
|
|
1,
|
|
|
|
WLTOKEN_RESERVED_COUNT);
|
2017-05-26 04:48:44 +08:00
|
|
|
Sim2FileSystem::newFileSystem();
|
2018-12-07 03:48:50 +08:00
|
|
|
|
2021-09-17 08:42:34 +08:00
|
|
|
std::vector<Future<Void>> futures;
|
2018-12-07 03:48:50 +08:00
|
|
|
for (int listenPort = port; listenPort < port + listenPerProcess; ++listenPort) {
|
2019-02-01 10:20:14 +08:00
|
|
|
NetworkAddress n(ip, listenPort, true, sslEnabled && listenPort == port);
|
2021-03-11 02:06:03 +08:00
|
|
|
futures.push_back(FlowTransport::transport().bind(n, n));
|
2018-12-07 03:48:50 +08:00
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
if (runBackupAgents != AgentOnly) {
|
2021-10-11 11:44:56 +08:00
|
|
|
futures.push_back(fdbd(connRecord,
|
2021-03-11 02:06:03 +08:00
|
|
|
localities,
|
|
|
|
processClass,
|
|
|
|
*dataFolder,
|
|
|
|
*coordFolder,
|
|
|
|
500e6,
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
-1,
|
2021-05-12 09:23:33 +08:00
|
|
|
whitelistBinPaths,
|
2021-05-18 10:14:32 +08:00
|
|
|
"",
|
|
|
|
{},
|
2021-08-07 14:18:10 +08:00
|
|
|
configDBType));
|
2019-07-24 10:24:07 +08:00
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
if (runBackupAgents != AgentNone) {
|
2021-10-11 11:44:56 +08:00
|
|
|
futures.push_back(runBackup(connRecord));
|
|
|
|
futures.push_back(runDr(connRecord));
|
2019-07-24 10:24:07 +08:00
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2018-12-07 03:48:50 +08:00
|
|
|
futures.push_back(success(onShutdown));
|
2021-03-11 02:06:03 +08:00
|
|
|
wait(waitForAny(futures));
|
2017-05-26 04:48:44 +08:00
|
|
|
} catch (Error& e) {
|
2021-03-11 02:06:03 +08:00
|
|
|
// If in simulation, if we make it here with an error other than io_timeout but enASIOTimedOut is set
|
|
|
|
// then somewhere an io_timeout was converted to a different error.
|
|
|
|
if (g_network->isSimulated() && e.code() != error_code_io_timeout &&
|
|
|
|
(bool)g_network->global(INetwork::enASIOTimedOut))
|
|
|
|
TraceEvent(SevError, "IOTimeoutErrorSuppressed")
|
|
|
|
.detail("ErrorCode", e.code())
|
|
|
|
.detail("RandomId", randomId)
|
|
|
|
.backtrace();
|
2017-05-27 08:43:28 +08:00
|
|
|
|
2021-02-17 16:47:32 +08:00
|
|
|
if (e.code() == error_code_io_timeout && !onShutdown.isReady()) {
|
|
|
|
onShutdown = ISimulator::RebootProcess;
|
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
if (onShutdown.isReady() && onShutdown.isError())
|
|
|
|
throw onShutdown.getError();
|
|
|
|
if (e.code() != error_code_actor_cancelled)
|
2017-05-26 04:48:44 +08:00
|
|
|
printf("SimulatedFDBDTerminated: %s\n", e.what());
|
2021-03-11 02:06:03 +08:00
|
|
|
ASSERT(destructed ||
|
|
|
|
g_simulator.getCurrentProcess() == process); // simulatedFDBD catch called on different process
|
|
|
|
TraceEvent(e.code() == error_code_actor_cancelled || e.code() == error_code_file_not_found || destructed
|
|
|
|
? SevInfo
|
|
|
|
: SevError,
|
|
|
|
"SimulatedFDBDTerminated")
|
|
|
|
.error(e, true)
|
|
|
|
.detail("ZoneId", localities.zoneId());
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
TraceEvent("SimulatedFDBDDone")
|
|
|
|
.detail("Cycles", cycles)
|
|
|
|
.detail("RandomId", randomId)
|
|
|
|
.detail("Address", process->address)
|
|
|
|
.detail("Excluded", process->excluded)
|
|
|
|
.detail("ZoneId", localities.zoneId())
|
|
|
|
.detail("KillType", onShutdown.isReady() ? onShutdown.get() : ISimulator::None);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
if (!onShutdown.isReady())
|
|
|
|
onShutdown = ISimulator::InjectFaults;
|
|
|
|
} catch (Error& e) {
|
2021-03-11 02:06:03 +08:00
|
|
|
TraceEvent(destructed ? SevInfo : SevError, "SimulatedFDBDRebooterError")
|
|
|
|
.error(e, true)
|
|
|
|
.detail("ZoneId", localities.zoneId())
|
|
|
|
.detail("RandomId", randomId);
|
2017-05-26 04:48:44 +08:00
|
|
|
onShutdown = e;
|
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
ASSERT(destructed || g_simulator.getCurrentProcess() == process);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
if (!process->shutdownSignal.isSet() && !destructed) {
|
2017-05-26 04:48:44 +08:00
|
|
|
process->rebooting = true;
|
|
|
|
process->shutdownSignal.send(ISimulator::None);
|
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
TraceEvent("SimulatedFDBDWait")
|
|
|
|
.detail("Cycles", cycles)
|
|
|
|
.detail("RandomId", randomId)
|
|
|
|
.detail("Address", process->address)
|
|
|
|
.detail("Excluded", process->excluded)
|
|
|
|
.detail("Rebooting", process->rebooting)
|
|
|
|
.detail("ZoneId", localities.zoneId());
|
|
|
|
wait(g_simulator.onProcess(simProcess));
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-06-23 05:50:01 +08:00
|
|
|
wait(delay(0.00001 + FLOW_KNOBS->MAX_BUGGIFIED_DELAY)); // One last chance for the process to clean up?
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
g_simulator.destroyProcess(
|
|
|
|
process); // Leak memory here; the process may be used in other parts of the simulation
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
auto shutdownResult = onShutdown.get();
|
2021-03-11 02:06:03 +08:00
|
|
|
TraceEvent("SimulatedFDBDShutdown")
|
|
|
|
.detail("Cycles", cycles)
|
|
|
|
.detail("RandomId", randomId)
|
|
|
|
.detail("Address", process->address)
|
|
|
|
.detail("Excluded", process->excluded)
|
|
|
|
.detail("ZoneId", localities.zoneId())
|
|
|
|
.detail("KillType", shutdownResult);
|
|
|
|
|
|
|
|
if (shutdownResult < ISimulator::RebootProcessAndDelete) {
|
|
|
|
TraceEvent("SimulatedFDBDLowerReboot")
|
|
|
|
.detail("Cycles", cycles)
|
|
|
|
.detail("RandomId", randomId)
|
|
|
|
.detail("Address", process->address)
|
|
|
|
.detail("Excluded", process->excluded)
|
|
|
|
.detail("ZoneId", localities.zoneId())
|
|
|
|
.detail("KillType", shutdownResult);
|
2017-05-26 04:48:44 +08:00
|
|
|
return onShutdown.get();
|
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
if (onShutdown.get() == ISimulator::RebootProcessAndDelete) {
|
|
|
|
TraceEvent("SimulatedFDBDRebootAndDelete")
|
|
|
|
.detail("Cycles", cycles)
|
|
|
|
.detail("RandomId", randomId)
|
|
|
|
.detail("Address", process->address)
|
|
|
|
.detail("ZoneId", localities.zoneId())
|
|
|
|
.detail("KillType", shutdownResult);
|
2019-05-11 05:01:52 +08:00
|
|
|
*coordFolder = joinPath(baseFolder, deterministicRandom()->randomUniqueID().toString());
|
|
|
|
*dataFolder = joinPath(baseFolder, deterministicRandom()->randomUniqueID().toString());
|
2021-03-11 02:06:03 +08:00
|
|
|
platform::createDirectory(*dataFolder);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
if (!useSeedFile) {
|
2017-05-26 04:48:44 +08:00
|
|
|
writeFile(joinPath(*dataFolder, "fdb.cluster"), connStr.toString());
|
2021-10-11 11:44:56 +08:00
|
|
|
connRecord = makeReference<ClusterConnectionFile>(joinPath(*dataFolder, "fdb.cluster"));
|
2021-03-11 02:06:03 +08:00
|
|
|
} else {
|
2021-10-11 11:44:56 +08:00
|
|
|
connRecord =
|
2020-11-07 15:50:55 +08:00
|
|
|
makeReference<ClusterConnectionFile>(joinPath(*dataFolder, "fdb.cluster"), connStr.toString());
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
} else {
|
|
|
|
TraceEvent("SimulatedFDBDJustRepeat")
|
|
|
|
.detail("Cycles", cycles)
|
|
|
|
.detail("RandomId", randomId)
|
|
|
|
.detail("Address", process->address)
|
|
|
|
.detail("ZoneId", localities.zoneId())
|
|
|
|
.detail("KillType", shutdownResult);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Since a datacenter kill is considered to be the same as killing a machine, files cannot be swapped across datacenters
|
2021-03-11 02:06:03 +08:00
|
|
|
std::map<Optional<Standalone<StringRef>>, std::vector<std::vector<std::string>>> availableFolders;
|
|
|
|
// process count is no longer needed because it is now the length of the vector of ip's, because it was one ip per
|
|
|
|
// process
|
|
|
|
ACTOR Future<Void> simulatedMachine(ClusterConnectionString connStr,
|
|
|
|
std::vector<IPAddress> ips,
|
|
|
|
bool sslEnabled,
|
|
|
|
LocalityData localities,
|
|
|
|
ProcessClass processClass,
|
|
|
|
std::string baseFolder,
|
|
|
|
bool restarting,
|
|
|
|
bool useSeedFile,
|
|
|
|
AgentMode runBackupAgents,
|
|
|
|
bool sslOnly,
|
|
|
|
std::string whitelistBinPaths,
|
2021-08-07 12:19:53 +08:00
|
|
|
ProtocolVersion protocolVersion,
|
2021-08-07 14:18:10 +08:00
|
|
|
ConfigDBType configDBType) {
|
2017-05-26 04:48:44 +08:00
|
|
|
state int bootCount = 0;
|
|
|
|
state std::vector<std::string> myFolders;
|
|
|
|
state std::vector<std::string> coordFolders;
|
2019-05-11 05:01:52 +08:00
|
|
|
state UID randomId = nondeterministicRandom()->randomUniqueID();
|
2019-02-01 10:20:14 +08:00
|
|
|
state int listenPerProcess = (sslEnabled && !sslOnly) ? 2 : 1;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
try {
|
|
|
|
CSimpleIni ini;
|
|
|
|
ini.SetUnicode();
|
|
|
|
ini.LoadFile(joinPath(baseFolder, "restartInfo.ini").c_str());
|
|
|
|
|
|
|
|
for (int i = 0; i < ips.size(); i++) {
|
|
|
|
if (restarting) {
|
2021-03-11 02:06:03 +08:00
|
|
|
myFolders.push_back(
|
|
|
|
ini.GetValue(printable(localities.machineId()).c_str(),
|
|
|
|
format("%d", i * listenPerProcess).c_str(),
|
|
|
|
joinPath(baseFolder, deterministicRandom()->randomUniqueID().toString()).c_str()));
|
|
|
|
|
|
|
|
if (i == 0) {
|
|
|
|
std::string coordinationFolder =
|
|
|
|
ini.GetValue(printable(localities.machineId()).c_str(), "coordinationFolder", "");
|
|
|
|
if (!coordinationFolder.size())
|
|
|
|
coordinationFolder = ini.GetValue(
|
|
|
|
printable(localities.machineId()).c_str(),
|
|
|
|
format("c%d", i * listenPerProcess).c_str(),
|
|
|
|
joinPath(baseFolder, deterministicRandom()->randomUniqueID().toString()).c_str());
|
2017-05-26 04:48:44 +08:00
|
|
|
coordFolders.push_back(coordinationFolder);
|
|
|
|
} else {
|
2021-03-11 02:06:03 +08:00
|
|
|
coordFolders.push_back(
|
|
|
|
ini.GetValue(printable(localities.machineId()).c_str(),
|
|
|
|
format("c%d", i * listenPerProcess).c_str(),
|
|
|
|
joinPath(baseFolder, deterministicRandom()->randomUniqueID().toString()).c_str()));
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
} else {
|
|
|
|
coordFolders.push_back(joinPath(baseFolder, deterministicRandom()->randomUniqueID().toString()));
|
2019-05-11 05:01:52 +08:00
|
|
|
std::string thisFolder = deterministicRandom()->randomUniqueID().toString();
|
2021-03-11 02:06:03 +08:00
|
|
|
myFolders.push_back(joinPath(baseFolder, thisFolder));
|
|
|
|
platform::createDirectory(myFolders[i]);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
if (!useSeedFile)
|
|
|
|
writeFile(joinPath(myFolders[i], "fdb.cluster"), connStr.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
loop {
|
2021-03-11 02:06:03 +08:00
|
|
|
state std::vector<Future<ISimulator::KillType>> processes;
|
|
|
|
for (int i = 0; i < ips.size(); i++) {
|
2017-05-26 04:48:44 +08:00
|
|
|
std::string path = joinPath(myFolders[i], "fdb.cluster");
|
2021-10-11 11:44:56 +08:00
|
|
|
Reference<IClusterConnectionRecord> clusterFile(
|
|
|
|
useSeedFile ? new ClusterConnectionFile(path, connStr.toString())
|
|
|
|
: new ClusterConnectionFile(path));
|
2021-03-11 02:06:03 +08:00
|
|
|
const int listenPort = i * listenPerProcess + 1;
|
|
|
|
AgentMode agentMode =
|
|
|
|
runBackupAgents == AgentOnly ? (i == ips.size() - 1 ? AgentOnly : AgentNone) : runBackupAgents;
|
|
|
|
if (g_simulator.hasDiffProtocolProcess && !g_simulator.setDiffProtocol && agentMode == AgentNone) {
|
|
|
|
processes.push_back(simulatedFDBDRebooter(clusterFile,
|
|
|
|
ips[i],
|
|
|
|
sslEnabled,
|
|
|
|
listenPort,
|
|
|
|
listenPerProcess,
|
|
|
|
localities,
|
|
|
|
processClass,
|
|
|
|
&myFolders[i],
|
|
|
|
&coordFolders[i],
|
|
|
|
baseFolder,
|
|
|
|
connStr,
|
|
|
|
useSeedFile,
|
|
|
|
agentMode,
|
|
|
|
whitelistBinPaths,
|
2021-08-07 12:19:53 +08:00
|
|
|
protocolVersion,
|
2021-08-07 14:18:10 +08:00
|
|
|
configDBType));
|
2020-10-06 08:08:48 +08:00
|
|
|
g_simulator.setDiffProtocol = true;
|
2021-03-11 02:06:03 +08:00
|
|
|
} else {
|
|
|
|
processes.push_back(simulatedFDBDRebooter(clusterFile,
|
|
|
|
ips[i],
|
|
|
|
sslEnabled,
|
|
|
|
listenPort,
|
|
|
|
listenPerProcess,
|
|
|
|
localities,
|
|
|
|
processClass,
|
|
|
|
&myFolders[i],
|
|
|
|
&coordFolders[i],
|
|
|
|
baseFolder,
|
|
|
|
connStr,
|
|
|
|
useSeedFile,
|
|
|
|
agentMode,
|
|
|
|
whitelistBinPaths,
|
2021-08-07 12:19:53 +08:00
|
|
|
g_network->protocolVersion(),
|
2021-08-07 14:18:10 +08:00
|
|
|
configDBType));
|
2020-10-06 08:08:48 +08:00
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
TraceEvent("SimulatedMachineProcess", randomId)
|
|
|
|
.detail("Address", NetworkAddress(ips[i], listenPort, true, false))
|
|
|
|
.detail("ZoneId", localities.zoneId())
|
|
|
|
.detail("DataHall", localities.dataHallId())
|
|
|
|
.detail("Folder", myFolders[i]);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
TEST(bootCount >= 1); // Simulated machine rebooted
|
|
|
|
TEST(bootCount >= 2); // Simulated machine rebooted twice
|
|
|
|
TEST(bootCount >= 3); // Simulated machine rebooted three times
|
2017-05-26 04:48:44 +08:00
|
|
|
++bootCount;
|
|
|
|
|
2017-08-29 02:25:37 +08:00
|
|
|
TraceEvent("SimulatedMachineStart", randomId)
|
2021-03-11 02:06:03 +08:00
|
|
|
.detail("Folder0", myFolders[0])
|
|
|
|
.detail("CFolder0", coordFolders[0])
|
|
|
|
.detail("MachineIPs", toIPVectorString(ips))
|
|
|
|
.detail("SSL", sslEnabled)
|
|
|
|
.detail("Processes", processes.size())
|
|
|
|
.detail("BootCount", bootCount)
|
|
|
|
.detail("ProcessClass", processClass.toString())
|
|
|
|
.detail("Restarting", restarting)
|
|
|
|
.detail("UseSeedFile", useSeedFile)
|
|
|
|
.detail("ZoneId", localities.zoneId())
|
|
|
|
.detail("DataHall", localities.dataHallId())
|
|
|
|
.detail("Locality", localities.toString());
|
|
|
|
|
|
|
|
wait(waitForAll(processes));
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2017-08-29 02:25:37 +08:00
|
|
|
TraceEvent("SimulatedMachineRebootStart", randomId)
|
2021-03-11 02:06:03 +08:00
|
|
|
.detail("Folder0", myFolders[0])
|
|
|
|
.detail("CFolder0", coordFolders[0])
|
|
|
|
.detail("MachineIPs", toIPVectorString(ips))
|
|
|
|
.detail("ZoneId", localities.zoneId())
|
|
|
|
.detail("DataHall", localities.dataHallId());
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2019-02-18 10:46:59 +08:00
|
|
|
{
|
2021-03-11 02:06:03 +08:00
|
|
|
// Kill all open files, which may cause them to write invalid data.
|
2019-02-18 10:46:59 +08:00
|
|
|
auto& machineCache = g_simulator.getMachineById(localities.machineId())->openFiles;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
// Copy the file pointers to a vector because the map may be modified while we are killing files
|
2019-02-18 10:46:59 +08:00
|
|
|
std::vector<AsyncFileNonDurable*> files;
|
2021-03-11 02:06:03 +08:00
|
|
|
for (auto fileItr = machineCache.begin(); fileItr != machineCache.end(); ++fileItr) {
|
2021-05-27 04:38:24 +08:00
|
|
|
ASSERT(fileItr->second.get().isReady());
|
|
|
|
files.push_back((AsyncFileNonDurable*)fileItr->second.get().get().getPtr());
|
2019-02-18 10:46:59 +08:00
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2019-02-18 10:46:59 +08:00
|
|
|
std::vector<Future<Void>> killFutures;
|
2021-03-11 02:06:03 +08:00
|
|
|
for (auto fileItr = files.begin(); fileItr != files.end(); ++fileItr)
|
2019-02-18 10:46:59 +08:00
|
|
|
killFutures.push_back((*fileItr)->kill());
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
wait(waitForAll(killFutures));
|
2019-02-18 10:46:59 +08:00
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
state std::set<std::string> filenames;
|
|
|
|
state std::string closingStr;
|
2019-01-19 07:42:48 +08:00
|
|
|
auto& machineCache = g_simulator.getMachineById(localities.machineId())->openFiles;
|
2021-03-11 02:06:03 +08:00
|
|
|
for (auto it : machineCache) {
|
|
|
|
filenames.insert(it.first);
|
2017-05-26 04:48:44 +08:00
|
|
|
closingStr += it.first + ", ";
|
2021-05-27 04:38:24 +08:00
|
|
|
ASSERT(it.second.get().canGet());
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
for (auto it : g_simulator.getMachineById(localities.machineId())->deletingFiles) {
|
|
|
|
filenames.insert(it);
|
2017-08-26 01:12:58 +08:00
|
|
|
closingStr += it + ", ";
|
|
|
|
}
|
|
|
|
|
2017-08-29 02:25:37 +08:00
|
|
|
TraceEvent("SimulatedMachineRebootAfterKills", randomId)
|
2021-03-11 02:06:03 +08:00
|
|
|
.detail("Folder0", myFolders[0])
|
|
|
|
.detail("CFolder0", coordFolders[0])
|
|
|
|
.detail("MachineIPs", toIPVectorString(ips))
|
|
|
|
.detail("Closing", closingStr)
|
|
|
|
.detail("ZoneId", localities.zoneId())
|
|
|
|
.detail("DataHall", localities.dataHallId());
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2019-01-19 07:42:48 +08:00
|
|
|
ISimulator::MachineInfo* machine = g_simulator.getMachineById(localities.machineId());
|
2017-05-26 04:48:44 +08:00
|
|
|
machine->closingFiles = filenames;
|
2019-01-19 07:42:48 +08:00
|
|
|
g_simulator.getMachineById(localities.machineId())->openFiles.clear();
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
// During a reboot:
|
|
|
|
// The process is expected to close all files and be inactive in zero time, but not necessarily
|
|
|
|
// without delay(0)-equivalents, so delay(0) a few times waiting for it to achieve that goal.
|
|
|
|
// After an injected fault:
|
|
|
|
// The process is expected to shut down eventually, but not necessarily instantly. Wait up to 60 seconds.
|
|
|
|
state int shutdownDelayCount = 0;
|
|
|
|
state double backoff = 0;
|
|
|
|
loop {
|
2019-01-19 07:42:48 +08:00
|
|
|
auto& machineCache = g_simulator.getMachineById(localities.machineId())->closingFiles;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
if (!machineCache.empty()) {
|
2017-05-26 04:48:44 +08:00
|
|
|
std::string openFiles;
|
|
|
|
int i = 0;
|
2021-03-11 02:06:03 +08:00
|
|
|
for (auto it = machineCache.begin(); it != machineCache.end() && i < 5; ++it) {
|
2017-05-26 04:48:44 +08:00
|
|
|
openFiles += *it + ", ";
|
|
|
|
i++;
|
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
TraceEvent("MachineFilesOpen", randomId)
|
|
|
|
.detail("PAddr", toIPVectorString(ips))
|
|
|
|
.detail("OpenFiles", openFiles);
|
2017-05-26 04:48:44 +08:00
|
|
|
} else
|
|
|
|
break;
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
if (shutdownDelayCount++ >= 50) { // Worker doesn't shut down instantly on reboot
|
2017-08-29 02:25:37 +08:00
|
|
|
TraceEvent(SevError, "SimulatedFDBDFilesCheck", randomId)
|
2021-03-11 02:06:03 +08:00
|
|
|
.detail("PAddrs", toIPVectorString(ips))
|
|
|
|
.detail("ZoneId", localities.zoneId())
|
|
|
|
.detail("DataHall", localities.dataHallId());
|
|
|
|
ASSERT(false);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
wait(delay(backoff));
|
|
|
|
backoff = std::min(backoff + 1.0, 6.0);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
2017-08-29 02:25:37 +08:00
|
|
|
TraceEvent("SimulatedFDBDFilesClosed", randomId)
|
2021-03-11 02:06:03 +08:00
|
|
|
.detail("Address", toIPVectorString(ips))
|
|
|
|
.detail("ZoneId", localities.zoneId())
|
|
|
|
.detail("DataHall", localities.dataHallId());
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2019-01-19 07:42:48 +08:00
|
|
|
g_simulator.destroyMachine(localities.machineId());
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
// SOMEDAY: when processes can be rebooted, this check will be needed
|
2021-03-11 02:06:03 +08:00
|
|
|
// ASSERT( this machine is rebooting );
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
// Since processes can end with different codes, take the highest (least severe) to detmine what to do
|
|
|
|
state ISimulator::KillType killType = processes[0].get();
|
2021-03-11 02:06:03 +08:00
|
|
|
for (int i = 1; i < ips.size(); i++)
|
|
|
|
killType = std::max(processes[i].get(), killType);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
TEST(true); // Simulated machine has been rebooted
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
state bool swap = killType == ISimulator::Reboot && BUGGIFY_WITH_PROB(0.75) &&
|
|
|
|
g_simulator.canSwapToMachine(localities.zoneId());
|
|
|
|
if (swap)
|
|
|
|
availableFolders[localities.dcId()].push_back(myFolders);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2019-05-11 05:01:52 +08:00
|
|
|
auto rebootTime = deterministicRandom()->random01() * MACHINE_REBOOT_TIME;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2017-08-29 02:25:37 +08:00
|
|
|
TraceEvent("SimulatedMachineShutdown", randomId)
|
2021-03-11 02:06:03 +08:00
|
|
|
.detail("Swap", swap)
|
|
|
|
.detail("KillType", killType)
|
|
|
|
.detail("RebootTime", rebootTime)
|
|
|
|
.detail("ZoneId", localities.zoneId())
|
|
|
|
.detail("DataHall", localities.dataHallId())
|
|
|
|
.detail("MachineIPs", toIPVectorString(ips));
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
wait(delay(rebootTime));
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
if (swap) {
|
2017-05-26 04:48:44 +08:00
|
|
|
auto& avail = availableFolders[localities.dcId()];
|
2019-05-11 05:01:52 +08:00
|
|
|
int i = deterministicRandom()->randomInt(0, avail.size());
|
2021-03-11 02:06:03 +08:00
|
|
|
if (i != avail.size() - 1)
|
|
|
|
std::swap(avail[i], avail.back());
|
2017-05-26 04:48:44 +08:00
|
|
|
auto toRebootFrom = avail.back();
|
|
|
|
avail.pop_back();
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
if (myFolders != toRebootFrom) {
|
|
|
|
TEST(true); // Simulated machine swapped data folders
|
2017-08-29 02:25:37 +08:00
|
|
|
TraceEvent("SimulatedMachineFolderSwap", randomId)
|
2021-03-11 02:06:03 +08:00
|
|
|
.detail("OldFolder0", myFolders[0])
|
|
|
|
.detail("NewFolder0", toRebootFrom[0])
|
|
|
|
.detail("MachineIPs", toIPVectorString(ips));
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
myFolders = toRebootFrom;
|
2021-03-11 02:06:03 +08:00
|
|
|
if (!useSeedFile) {
|
|
|
|
for (auto f : toRebootFrom) {
|
|
|
|
if (!fileExists(joinPath(f, "fdb.cluster"))) {
|
2017-05-26 04:48:44 +08:00
|
|
|
writeFile(joinPath(f, "fdb.cluster"), connStr.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
} else if (killType == ISimulator::RebootAndDelete) {
|
|
|
|
for (int i = 0; i < ips.size(); i++) {
|
2019-05-11 05:01:52 +08:00
|
|
|
coordFolders[i] = joinPath(baseFolder, deterministicRandom()->randomUniqueID().toString());
|
|
|
|
myFolders[i] = joinPath(baseFolder, deterministicRandom()->randomUniqueID().toString());
|
2021-03-11 02:06:03 +08:00
|
|
|
platform::createDirectory(myFolders[i]);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
if (!useSeedFile) {
|
2017-05-26 04:48:44 +08:00
|
|
|
writeFile(joinPath(myFolders[i], "fdb.cluster"), connStr.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
TEST(true); // Simulated machine rebooted with data loss
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
// this machine is rebooting = false;
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
} catch (Error& e) {
|
2019-01-19 07:42:48 +08:00
|
|
|
g_simulator.getMachineById(localities.machineId())->openFiles.clear();
|
2017-05-26 04:48:44 +08:00
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-28 16:09:53 +08:00
|
|
|
IPAddress makeIPAddressForSim(bool isIPv6, std::array<int, 4> parts) {
|
|
|
|
if (isIPv6) {
|
|
|
|
IPAddress::IPAddressStore addrStore{ 0xAB, 0xCD };
|
|
|
|
uint16_t* ptr = (uint16_t*)addrStore.data();
|
|
|
|
ptr[4] = (uint16_t)(parts[0] << 8);
|
|
|
|
ptr[5] = (uint16_t)(parts[1] << 8);
|
|
|
|
ptr[6] = (uint16_t)(parts[2] << 8);
|
|
|
|
ptr[7] = (uint16_t)(parts[3] << 8);
|
|
|
|
return IPAddress(addrStore);
|
|
|
|
} else {
|
|
|
|
return IPAddress(parts[0] << 24 | parts[1] << 16 | parts[2] << 8 | parts[3]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
#include "fdbclient/MonitorLeader.h"
|
|
|
|
|
2021-03-23 03:24:46 +08:00
|
|
|
// Configures the system according to the given specifications in order to run
|
|
|
|
// simulation, but with the additional consideration that it is meant to act
|
|
|
|
// like a "rebooted" machine, mostly used for restarting tests.
|
2021-09-17 08:42:34 +08:00
|
|
|
ACTOR Future<Void> restartSimulatedSystem(std::vector<Future<Void>>* systemActors,
|
2021-03-11 02:06:03 +08:00
|
|
|
std::string baseFolder,
|
|
|
|
int* pTesterCount,
|
2019-01-30 00:43:57 +08:00
|
|
|
Optional<ClusterConnectionString>* pConnString,
|
|
|
|
Standalone<StringRef>* pStartingConfiguration,
|
2021-03-23 02:30:22 +08:00
|
|
|
TestConfig testConfig,
|
2021-03-11 02:06:03 +08:00
|
|
|
std::string whitelistBinPaths,
|
|
|
|
ProtocolVersion protocolVersion) {
|
2017-05-26 04:48:44 +08:00
|
|
|
CSimpleIni ini;
|
|
|
|
ini.SetUnicode();
|
|
|
|
ini.LoadFile(joinPath(baseFolder, "restartInfo.ini").c_str());
|
|
|
|
|
2021-08-07 14:18:10 +08:00
|
|
|
auto configDBType = testConfig.getConfigDBType();
|
2021-08-07 12:19:53 +08:00
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
// allows multiple ipAddr entries
|
|
|
|
ini.SetMultiKey();
|
|
|
|
|
|
|
|
try {
|
|
|
|
int machineCount = atoi(ini.GetValue("META", "machineCount"));
|
|
|
|
int processesPerMachine = atoi(ini.GetValue("META", "processesPerMachine"));
|
2019-02-01 10:20:14 +08:00
|
|
|
int listenersPerProcess = 1;
|
|
|
|
auto listenersPerProcessStr = ini.GetValue("META", "listenersPerProcess");
|
2021-03-11 02:06:03 +08:00
|
|
|
if (listenersPerProcessStr != nullptr) {
|
2019-02-01 10:20:14 +08:00
|
|
|
listenersPerProcess = atoi(listenersPerProcessStr);
|
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
int desiredCoordinators = atoi(ini.GetValue("META", "desiredCoordinators"));
|
|
|
|
int testerCount = atoi(ini.GetValue("META", "testerCount"));
|
2021-09-17 01:52:33 +08:00
|
|
|
auto tssModeStr = ini.GetValue("META", "tssMode");
|
|
|
|
if (tssModeStr != nullptr) {
|
|
|
|
g_simulator.tssMode = (ISimulator::TSSMode)atoi(tssModeStr);
|
|
|
|
}
|
2021-03-23 02:30:22 +08:00
|
|
|
bool enableExtraDB = (testConfig.extraDB == 3);
|
2017-05-26 04:48:44 +08:00
|
|
|
ClusterConnectionString conn(ini.GetValue("META", "connectionString"));
|
2018-04-28 04:54:34 +08:00
|
|
|
if (enableExtraDB) {
|
|
|
|
g_simulator.extraDB = new ClusterConnectionString(ini.GetValue("META", "connectionString"));
|
|
|
|
}
|
2022-01-21 05:26:49 +08:00
|
|
|
if (!testConfig.disableHostname) {
|
|
|
|
auto mockDNSStr = ini.GetValue("META", "mockDNS");
|
|
|
|
if (mockDNSStr != nullptr) {
|
|
|
|
INetworkConnections::net()->parseMockDNSFromString(mockDNSStr);
|
|
|
|
}
|
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
*pConnString = conn;
|
|
|
|
*pTesterCount = testerCount;
|
2019-02-01 10:20:14 +08:00
|
|
|
bool usingSSL = conn.toString().find(":tls") != std::string::npos || listenersPerProcess > 1;
|
2019-05-11 05:01:52 +08:00
|
|
|
int useSeedForMachine = deterministicRandom()->randomInt(0, machineCount);
|
2018-11-03 05:16:47 +08:00
|
|
|
std::vector<std::string> dcIds;
|
2021-03-11 02:06:03 +08:00
|
|
|
for (int i = 0; i < machineCount; i++) {
|
2017-05-26 04:48:44 +08:00
|
|
|
Optional<Standalone<StringRef>> dcUID;
|
2019-01-19 07:42:48 +08:00
|
|
|
Optional<Standalone<StringRef>> zoneId;
|
|
|
|
std::string machineIdString = ini.GetValue("META", format("%d", i).c_str());
|
|
|
|
Standalone<StringRef> machineId = StringRef(machineIdString);
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
std::string dcUIDini = ini.GetValue(machineIdString.c_str(), "dcUID");
|
2018-11-03 05:16:47 +08:00
|
|
|
if (!dcUIDini.empty()) {
|
|
|
|
dcUID = StringRef(dcUIDini);
|
|
|
|
}
|
2019-01-19 07:42:48 +08:00
|
|
|
|
|
|
|
auto zoneIDini = ini.GetValue(machineIdString.c_str(), "zoneId");
|
2021-03-11 02:06:03 +08:00
|
|
|
if (zoneIDini == nullptr) {
|
2019-01-19 07:42:48 +08:00
|
|
|
zoneId = machineId;
|
|
|
|
} else {
|
|
|
|
zoneId = StringRef(zoneIDini);
|
|
|
|
}
|
|
|
|
|
2021-04-27 00:49:26 +08:00
|
|
|
ProcessClass::ClassType cType =
|
|
|
|
(ProcessClass::ClassType)(atoi(ini.GetValue(machineIdString.c_str(), "mClass")));
|
|
|
|
// using specialized class types can lead to nondeterministic recruitment
|
2021-04-27 09:45:44 +08:00
|
|
|
if (cType == ProcessClass::MasterClass || cType == ProcessClass::ResolutionClass) {
|
2021-04-27 00:49:26 +08:00
|
|
|
cType = ProcessClass::StatelessClass;
|
|
|
|
}
|
|
|
|
ProcessClass processClass = ProcessClass(cType, ProcessClass::CommandLineSource);
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
if (processClass != ProcessClass::TesterClass) {
|
2018-11-03 05:16:47 +08:00
|
|
|
dcIds.push_back(dcUIDini);
|
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2019-02-28 16:09:53 +08:00
|
|
|
std::vector<IPAddress> ipAddrs;
|
2019-01-19 07:42:48 +08:00
|
|
|
int processes = atoi(ini.GetValue(machineIdString.c_str(), "processes"));
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2019-01-19 07:42:48 +08:00
|
|
|
auto ip = ini.GetValue(machineIdString.c_str(), "ipAddr");
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2019-03-01 04:24:56 +08:00
|
|
|
// Helper to translate the IP address stored in INI file to out IPAddress representation.
|
|
|
|
// After IPv6 work, we store the actual string representation of IP address, however earlier, it was
|
|
|
|
// instead the 32 bit integer value.
|
2019-02-28 16:09:53 +08:00
|
|
|
auto parseIp = [](const char* ipStr) -> IPAddress {
|
|
|
|
Optional<IPAddress> parsedIp = IPAddress::parse(ipStr);
|
|
|
|
if (parsedIp.present()) {
|
|
|
|
return parsedIp.get();
|
|
|
|
} else {
|
2020-08-19 05:18:50 +08:00
|
|
|
return IPAddress(strtoul(ipStr, nullptr, 10));
|
2019-02-28 16:09:53 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
if (ip == nullptr) {
|
2019-02-28 16:09:53 +08:00
|
|
|
for (int i = 0; i < processes; i++) {
|
|
|
|
const char* val =
|
|
|
|
ini.GetValue(machineIdString.c_str(), format("ipAddr%d", i * listenersPerProcess).c_str());
|
|
|
|
ipAddrs.push_back(parseIp(val));
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
} else {
|
2017-05-26 04:48:44 +08:00
|
|
|
// old way
|
2019-02-28 16:09:53 +08:00
|
|
|
ipAddrs.push_back(parseIp(ip));
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
for (int i = 1; i < processes; i++) {
|
2019-02-28 16:09:53 +08:00
|
|
|
if (ipAddrs.back().isV6()) {
|
|
|
|
IPAddress::IPAddressStore store = ipAddrs.back().toV6();
|
|
|
|
uint16_t* ptr = (uint16_t*)store.data();
|
|
|
|
ptr[7] += 1;
|
|
|
|
ipAddrs.push_back(IPAddress(store));
|
|
|
|
} else {
|
|
|
|
ipAddrs.push_back(IPAddress(ipAddrs.back().toV4() + 1));
|
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
LocalityData localities(Optional<Standalone<StringRef>>(), zoneId, machineId, dcUID);
|
2017-05-26 04:48:44 +08:00
|
|
|
localities.set(LiteralStringRef("data_hall"), dcUID);
|
|
|
|
|
2018-04-28 04:54:34 +08:00
|
|
|
// SOMEDAY: parse backup agent from test file
|
2019-01-30 00:43:57 +08:00
|
|
|
systemActors->push_back(reportErrors(
|
2021-03-11 02:06:03 +08:00
|
|
|
simulatedMachine(conn,
|
|
|
|
ipAddrs,
|
|
|
|
usingSSL,
|
|
|
|
localities,
|
|
|
|
processClass,
|
|
|
|
baseFolder,
|
|
|
|
true,
|
|
|
|
i == useSeedForMachine,
|
|
|
|
AgentAddition,
|
2020-10-01 02:24:52 +08:00
|
|
|
usingSSL && (listenersPerProcess == 1 || processClass == ProcessClass::TesterClass),
|
2021-03-11 02:06:03 +08:00
|
|
|
whitelistBinPaths,
|
2021-08-07 12:19:53 +08:00
|
|
|
protocolVersion,
|
2021-08-07 14:18:10 +08:00
|
|
|
configDBType),
|
2019-01-30 00:43:57 +08:00
|
|
|
processClass == ProcessClass::TesterClass ? "SimulatedTesterMachine" : "SimulatedMachine"));
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
g_simulator.desiredCoordinators = desiredCoordinators;
|
|
|
|
g_simulator.processesPerMachine = processesPerMachine;
|
2018-11-03 05:16:47 +08:00
|
|
|
|
|
|
|
uniquify(dcIds);
|
2021-03-11 02:06:03 +08:00
|
|
|
if (!BUGGIFY && dcIds.size() == 2 && dcIds[0] != "" && dcIds[1] != "") {
|
2018-11-03 05:16:47 +08:00
|
|
|
StatusObject primaryObj;
|
|
|
|
StatusObject primaryDcObj;
|
|
|
|
primaryDcObj["id"] = dcIds[0];
|
|
|
|
primaryDcObj["priority"] = 2;
|
|
|
|
StatusArray primaryDcArr;
|
|
|
|
primaryDcArr.push_back(primaryDcObj);
|
|
|
|
|
|
|
|
StatusObject remoteObj;
|
|
|
|
StatusObject remoteDcObj;
|
|
|
|
remoteDcObj["id"] = dcIds[1];
|
|
|
|
remoteDcObj["priority"] = 1;
|
|
|
|
StatusArray remoteDcArr;
|
|
|
|
remoteDcArr.push_back(remoteDcObj);
|
|
|
|
|
|
|
|
primaryObj["datacenters"] = primaryDcArr;
|
|
|
|
remoteObj["datacenters"] = remoteDcArr;
|
|
|
|
|
|
|
|
StatusArray regionArr;
|
|
|
|
regionArr.push_back(primaryObj);
|
|
|
|
regionArr.push_back(remoteObj);
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
*pStartingConfiguration =
|
|
|
|
"single usable_regions=2 regions=" +
|
|
|
|
json_spirit::write_string(json_spirit::mValue(regionArr), json_spirit::Output_options::none);
|
2018-11-03 05:16:47 +08:00
|
|
|
}
|
2019-02-05 03:39:06 +08:00
|
|
|
|
|
|
|
TraceEvent("RestartSimulatorSettings")
|
2021-03-11 02:06:03 +08:00
|
|
|
.detail("DesiredCoordinators", g_simulator.desiredCoordinators)
|
|
|
|
.detail("ProcessesPerMachine", g_simulator.processesPerMachine)
|
|
|
|
.detail("ListenersPerProcess", listenersPerProcess);
|
|
|
|
} catch (Error& e) {
|
2018-06-09 02:11:08 +08:00
|
|
|
TraceEvent(SevError, "RestartSimulationError").error(e);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
2018-08-11 04:57:10 +08:00
|
|
|
wait(delay(1.0));
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
2021-03-24 05:24:00 +08:00
|
|
|
// Configuration details compiled in a structure used when setting up a simulated cluster
|
2017-08-12 06:06:36 +08:00
|
|
|
struct SimulationConfig {
|
2021-03-23 04:10:26 +08:00
|
|
|
explicit SimulationConfig(const TestConfig& testConfig);
|
2017-08-22 13:29:56 +08:00
|
|
|
int extraDB;
|
2021-06-19 02:35:51 +08:00
|
|
|
bool generateFearless;
|
2017-08-12 06:06:36 +08:00
|
|
|
|
2017-08-22 13:29:56 +08:00
|
|
|
DatabaseConfiguration db;
|
2017-08-12 06:06:36 +08:00
|
|
|
|
2017-08-22 13:29:56 +08:00
|
|
|
void set_config(std::string config);
|
2017-08-12 06:06:36 +08:00
|
|
|
|
2017-08-22 13:29:56 +08:00
|
|
|
// Simulation layout
|
|
|
|
int datacenters;
|
2021-06-19 02:54:33 +08:00
|
|
|
int replication_type;
|
2021-03-11 02:06:03 +08:00
|
|
|
int machine_count; // Total, not per DC.
|
2017-08-22 13:29:56 +08:00
|
|
|
int processes_per_machine;
|
|
|
|
int coordinators;
|
2021-03-11 02:06:03 +08:00
|
|
|
|
2017-08-12 06:06:36 +08:00
|
|
|
private:
|
2021-06-17 04:58:32 +08:00
|
|
|
void setRandomConfig();
|
|
|
|
void setSimpleConfig();
|
|
|
|
void setSpecificConfig(const TestConfig& testConfig);
|
2021-06-19 02:54:33 +08:00
|
|
|
void setDatacenters(const TestConfig& testConfig);
|
2021-06-19 02:35:51 +08:00
|
|
|
void setStorageEngine(const TestConfig& testConfig);
|
2021-06-19 02:54:33 +08:00
|
|
|
void setRegions(const TestConfig& testConfig);
|
2021-06-19 02:35:51 +08:00
|
|
|
void setReplicationType(const TestConfig& testConfig);
|
|
|
|
void setMachineCount(const TestConfig& testConfig);
|
|
|
|
void setCoordinators(const TestConfig& testConfig);
|
|
|
|
void setProcessesPerMachine(const TestConfig& testConfig);
|
|
|
|
void setTss(const TestConfig& testConfig);
|
2021-03-23 04:10:26 +08:00
|
|
|
void generateNormalConfig(const TestConfig& testConfig);
|
2017-08-12 06:06:36 +08:00
|
|
|
};
|
|
|
|
|
2021-03-24 02:58:00 +08:00
|
|
|
SimulationConfig::SimulationConfig(const TestConfig& testConfig) : extraDB(testConfig.extraDB) {
|
2021-03-23 02:30:22 +08:00
|
|
|
generateNormalConfig(testConfig);
|
2017-08-22 13:29:56 +08:00
|
|
|
}
|
2017-08-12 06:06:36 +08:00
|
|
|
|
2017-08-22 13:29:56 +08:00
|
|
|
void SimulationConfig::set_config(std::string config) {
|
|
|
|
// The only mechanism we have for turning "single" into what single means
|
|
|
|
// is buildConfiguration()... :/
|
|
|
|
std::map<std::string, std::string> hack_map;
|
2020-09-28 02:52:18 +08:00
|
|
|
ASSERT(buildConfiguration(config, hack_map) != ConfigurationResult::NO_OPTIONS_PROVIDED);
|
2021-03-11 02:06:03 +08:00
|
|
|
for (auto kv : hack_map)
|
|
|
|
db.set(kv.first, kv.second);
|
2017-08-22 13:29:56 +08:00
|
|
|
}
|
2017-08-12 06:06:36 +08:00
|
|
|
|
2021-10-29 03:42:24 +08:00
|
|
|
[[maybe_unused]] StringRef StringRefOf(const char* s) {
|
2021-03-11 02:06:03 +08:00
|
|
|
return StringRef((uint8_t*)s, strlen(s));
|
2017-08-12 06:06:36 +08:00
|
|
|
}
|
2021-06-17 04:58:32 +08:00
|
|
|
|
2021-06-19 02:35:51 +08:00
|
|
|
// Set the randomly generated options of the config. Compiled here to easily observe and trace random options
|
|
|
|
void SimulationConfig::setRandomConfig() {
|
|
|
|
if (deterministicRandom()->random01() < 0.25) {
|
|
|
|
db.desiredTLogCount = deterministicRandom()->randomInt(1, 7);
|
2021-05-21 03:48:41 +08:00
|
|
|
}
|
2021-06-19 02:35:51 +08:00
|
|
|
if (deterministicRandom()->random01() < 0.25) {
|
|
|
|
db.commitProxyCount = deterministicRandom()->randomInt(1, 7);
|
|
|
|
}
|
|
|
|
if (deterministicRandom()->random01() < 0.25) {
|
|
|
|
db.grvProxyCount = deterministicRandom()->randomInt(1, 4);
|
|
|
|
}
|
|
|
|
if (deterministicRandom()->random01() < 0.25) {
|
|
|
|
db.resolverCount = deterministicRandom()->randomInt(1, 7);
|
2021-05-21 03:48:41 +08:00
|
|
|
}
|
2021-06-19 02:35:51 +08:00
|
|
|
// TraceEvent("SimulatedConfigRandom")
|
|
|
|
// .detail("DesiredTLogCount", db.desiredTLogCount)
|
|
|
|
// .detail("CommitProxyCount", db.commitProxyCount)
|
|
|
|
// .detail("GRVProxyCount", db.grvProxyCount)
|
|
|
|
// .detail("ResolverCount", db.resolverCount);
|
|
|
|
|
|
|
|
if (deterministicRandom()->random01() < 0.5) {
|
|
|
|
// TraceEvent("SimulatedConfigRandom").detail("PerpetualWiggle", 0);
|
|
|
|
set_config("perpetual_storage_wiggle=0");
|
|
|
|
} else {
|
|
|
|
// TraceEvent("SimulatedConfigRandom").detail("PerpetualWiggle", 1);
|
|
|
|
set_config("perpetual_storage_wiggle=1");
|
2021-05-21 03:48:41 +08:00
|
|
|
}
|
2021-06-19 02:35:51 +08:00
|
|
|
|
|
|
|
if (deterministicRandom()->random01() < 0.5) {
|
|
|
|
set_config("backup_worker_enabled:=1");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Overwrite DB with simple options, used when simpleConfig is true in the TestConfig
|
|
|
|
void SimulationConfig::setSimpleConfig() {
|
|
|
|
db.desiredTLogCount = 1;
|
|
|
|
db.commitProxyCount = 1;
|
|
|
|
db.grvProxyCount = 1;
|
|
|
|
db.resolverCount = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Overwrite previous options with ones specified by TestConfig
|
|
|
|
void SimulationConfig::setSpecificConfig(const TestConfig& testConfig) {
|
2021-05-21 03:48:41 +08:00
|
|
|
if (testConfig.desiredTLogCount.present()) {
|
|
|
|
db.desiredTLogCount = testConfig.desiredTLogCount.get();
|
|
|
|
}
|
|
|
|
if (testConfig.commitProxyCount.present()) {
|
|
|
|
db.commitProxyCount = testConfig.commitProxyCount.get();
|
|
|
|
}
|
|
|
|
if (testConfig.grvProxyCount.present()) {
|
|
|
|
db.grvProxyCount = testConfig.grvProxyCount.get();
|
|
|
|
}
|
|
|
|
if (testConfig.resolverCount.present()) {
|
|
|
|
db.resolverCount = testConfig.resolverCount.get();
|
|
|
|
}
|
2021-06-19 02:35:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Sets generateFearless and number of dataCenters based on testConfig details
|
|
|
|
// The number of datacenters may be overwritten in setRegions
|
2021-06-17 04:58:32 +08:00
|
|
|
void SimulationConfig::setDatacenters(const TestConfig& testConfig) {
|
|
|
|
generateFearless =
|
2021-05-21 03:48:41 +08:00
|
|
|
testConfig.simpleConfig ? false : (testConfig.minimumRegions > 1 || deterministicRandom()->random01() < 0.5);
|
|
|
|
if (testConfig.generateFearless.present()) {
|
|
|
|
// overwrite whatever decision we made before
|
|
|
|
generateFearless = testConfig.generateFearless.get();
|
|
|
|
}
|
|
|
|
datacenters =
|
|
|
|
testConfig.simpleConfig
|
|
|
|
? 1
|
|
|
|
: (generateFearless ? (testConfig.minimumReplication > 0 || deterministicRandom()->random01() < 0.5 ? 4 : 6)
|
2021-03-23 02:30:22 +08:00
|
|
|
: deterministicRandom()->randomInt(1, 4));
|
2021-06-17 04:58:32 +08:00
|
|
|
|
|
|
|
// Overwrite with specific option if present
|
2021-05-21 03:48:41 +08:00
|
|
|
if (testConfig.datacenters.present()) {
|
|
|
|
datacenters = testConfig.datacenters.get();
|
|
|
|
}
|
2021-06-17 04:58:32 +08:00
|
|
|
}
|
2021-05-21 03:48:41 +08:00
|
|
|
|
2021-06-17 04:58:32 +08:00
|
|
|
// Sets storage engine based on testConfig details
|
|
|
|
void SimulationConfig::setStorageEngine(const TestConfig& testConfig) {
|
2021-08-24 02:56:13 +08:00
|
|
|
// Using [0, 4) to disable the RocksDB storage engine.
|
|
|
|
// TODO: Figure out what is broken with the RocksDB engine in simulation.
|
|
|
|
int storage_engine_type = deterministicRandom()->randomInt(0, 4);
|
2021-05-21 03:48:41 +08:00
|
|
|
if (testConfig.storageEngineType.present()) {
|
|
|
|
storage_engine_type = testConfig.storageEngineType.get();
|
|
|
|
} else {
|
|
|
|
// Continuously re-pick the storage engine type if it's the one we want to exclude
|
|
|
|
while (std::find(testConfig.storageEngineExcludeTypes.begin(),
|
|
|
|
testConfig.storageEngineExcludeTypes.end(),
|
|
|
|
storage_engine_type) != testConfig.storageEngineExcludeTypes.end()) {
|
2021-07-17 00:01:01 +08:00
|
|
|
storage_engine_type = deterministicRandom()->randomInt(0, 5);
|
2021-05-21 03:48:41 +08:00
|
|
|
}
|
2021-03-23 02:30:22 +08:00
|
|
|
}
|
2021-03-06 03:28:15 +08:00
|
|
|
|
2020-01-24 08:52:42 +08:00
|
|
|
switch (storage_engine_type) {
|
|
|
|
case 0: {
|
|
|
|
TEST(true); // Simulated cluster using ssd storage engine
|
2017-08-22 13:29:56 +08:00
|
|
|
set_config("ssd");
|
2020-01-24 08:52:42 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1: {
|
|
|
|
TEST(true); // Simulated cluster using default memory storage engine
|
2017-08-22 13:29:56 +08:00
|
|
|
set_config("memory");
|
2020-01-24 08:52:42 +08:00
|
|
|
break;
|
2017-08-22 13:29:56 +08:00
|
|
|
}
|
2020-01-24 08:52:42 +08:00
|
|
|
case 2: {
|
|
|
|
TEST(true); // Simulated cluster using radix-tree storage engine
|
|
|
|
set_config("memory-radixtree-beta");
|
|
|
|
break;
|
|
|
|
}
|
2020-03-30 21:57:35 +08:00
|
|
|
case 3: {
|
2020-11-11 05:01:07 +08:00
|
|
|
TEST(true); // Simulated cluster using redwood storage engine
|
2021-11-16 18:15:22 +08:00
|
|
|
set_config("ssd-redwood-1-experimental");
|
2020-03-30 21:57:35 +08:00
|
|
|
break;
|
2021-03-11 02:06:03 +08:00
|
|
|
}
|
2021-07-17 00:01:01 +08:00
|
|
|
case 4: {
|
|
|
|
TEST(true); // Simulated cluster using RocksDB storage engine
|
|
|
|
set_config("ssd-rocksdb-experimental");
|
|
|
|
// Tests using the RocksDB engine are necessarily non-deterministic because of RocksDB
|
|
|
|
// background threads.
|
2021-09-02 23:38:23 +08:00
|
|
|
TraceEvent(SevWarnAlways, "RocksDBNonDeterminism")
|
2021-07-17 00:01:01 +08:00
|
|
|
.detail("Explanation", "The RocksDB storage engine is threaded and non-deterministic");
|
|
|
|
noUnseed = true;
|
|
|
|
break;
|
|
|
|
}
|
2020-01-24 08:52:42 +08:00
|
|
|
default:
|
|
|
|
ASSERT(false); // Programmer forgot to adjust cases.
|
|
|
|
}
|
2021-06-17 04:58:32 +08:00
|
|
|
}
|
2021-03-06 03:28:15 +08:00
|
|
|
|
2021-06-19 02:35:51 +08:00
|
|
|
// Sets replication type and TLogSpillType and Version
|
|
|
|
void SimulationConfig::setReplicationType(const TestConfig& testConfig) {
|
2021-06-19 02:54:33 +08:00
|
|
|
replication_type = testConfig.simpleConfig
|
|
|
|
? 1
|
|
|
|
: (std::max(testConfig.minimumReplication,
|
|
|
|
datacenters > 4 ? deterministicRandom()->randomInt(1, 3)
|
|
|
|
: std::min(deterministicRandom()->randomInt(0, 6), 3)));
|
2021-05-21 03:48:41 +08:00
|
|
|
if (testConfig.config.present()) {
|
|
|
|
set_config(testConfig.config.get());
|
|
|
|
} else {
|
|
|
|
switch (replication_type) {
|
|
|
|
case 0: {
|
|
|
|
TEST(true); // Simulated cluster using custom redundancy mode
|
|
|
|
int storage_servers = deterministicRandom()->randomInt(1, generateFearless ? 4 : 5);
|
|
|
|
// FIXME: log replicas must be more than storage replicas because otherwise better master exists will not
|
|
|
|
// recognize it needs to change dcs
|
|
|
|
int replication_factor = deterministicRandom()->randomInt(storage_servers, generateFearless ? 4 : 5);
|
|
|
|
int anti_quorum = deterministicRandom()->randomInt(
|
|
|
|
0,
|
|
|
|
(replication_factor / 2) +
|
|
|
|
1); // The anti quorum cannot be more than half of the replication factor, or the
|
|
|
|
// log system will continue to accept commits when a recovery is impossible
|
|
|
|
// Go through buildConfiguration, as it sets tLogPolicy/storagePolicy.
|
|
|
|
set_config(format("storage_replicas:=%d log_replicas:=%d log_anti_quorum:=%d "
|
|
|
|
"replica_datacenters:=1 min_replica_datacenters:=1",
|
|
|
|
storage_servers,
|
|
|
|
replication_factor,
|
|
|
|
anti_quorum));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1: {
|
|
|
|
TEST(true); // Simulated cluster running in single redundancy mode
|
|
|
|
set_config("single");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2: {
|
|
|
|
TEST(true); // Simulated cluster running in double redundancy mode
|
|
|
|
set_config("double");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 3: {
|
|
|
|
if (datacenters <= 2 || generateFearless) {
|
|
|
|
TEST(true); // Simulated cluster running in triple redundancy mode
|
|
|
|
set_config("triple");
|
|
|
|
} else if (datacenters == 3) {
|
|
|
|
TEST(true); // Simulated cluster running in 3 data-hall mode
|
|
|
|
set_config("three_data_hall");
|
|
|
|
} else {
|
|
|
|
ASSERT(false);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
ASSERT(false); // Programmer forgot to adjust cases.
|
|
|
|
}
|
|
|
|
if (deterministicRandom()->random01() < 0.5) {
|
|
|
|
int logSpill = deterministicRandom()->randomInt(TLogSpillType::VALUE, TLogSpillType::END);
|
|
|
|
set_config(format("log_spill:=%d", logSpill));
|
|
|
|
int logVersion =
|
|
|
|
deterministicRandom()->randomInt(TLogVersion::MIN_RECRUITABLE, testConfig.maxTLogVersion + 1);
|
|
|
|
set_config(format("log_version:=%d", logVersion));
|
2021-03-11 02:06:03 +08:00
|
|
|
} else {
|
2021-05-21 03:48:41 +08:00
|
|
|
if (deterministicRandom()->random01() < 0.7)
|
|
|
|
set_config(format("log_version:=%d", testConfig.maxTLogVersion));
|
|
|
|
if (deterministicRandom()->random01() < 0.5)
|
|
|
|
set_config(format("log_spill:=%d", TLogSpillType::DEFAULT));
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
2020-02-06 06:23:54 +08:00
|
|
|
}
|
2021-06-19 02:35:51 +08:00
|
|
|
}
|
2020-02-06 06:23:54 +08:00
|
|
|
|
2021-06-19 02:35:51 +08:00
|
|
|
// Set the regions of the config, including the primary and remote options
|
|
|
|
// This will also determine the replication types used for satellite and remote.
|
|
|
|
void SimulationConfig::setRegions(const TestConfig& testConfig) {
|
|
|
|
// The kill region workload relies on the fact that all "0", "2", and "4" are all of the possible primary dcids.
|
|
|
|
StatusObject primaryObj;
|
|
|
|
StatusObject primaryDcObj;
|
|
|
|
primaryDcObj["id"] = "0";
|
|
|
|
primaryDcObj["priority"] = 2;
|
|
|
|
StatusArray primaryDcArr;
|
|
|
|
primaryDcArr.push_back(primaryDcObj);
|
|
|
|
|
|
|
|
StatusObject remoteObj;
|
|
|
|
StatusObject remoteDcObj;
|
|
|
|
remoteDcObj["id"] = "1";
|
|
|
|
remoteDcObj["priority"] = 1;
|
|
|
|
StatusArray remoteDcArr;
|
|
|
|
remoteDcArr.push_back(remoteDcObj);
|
|
|
|
|
|
|
|
bool needsRemote = generateFearless;
|
|
|
|
if (generateFearless) {
|
|
|
|
if (datacenters > 4) {
|
|
|
|
// FIXME: we cannot use one satellite replication with more than one satellite per region because
|
|
|
|
// canKillProcesses does not respect usable_dcs
|
|
|
|
int satellite_replication_type = deterministicRandom()->randomInt(0, 3);
|
|
|
|
switch (satellite_replication_type) {
|
|
|
|
case 0: {
|
|
|
|
TEST(true); // Simulated cluster using no satellite redundancy mode (>4 datacenters)
|
|
|
|
break;
|
2018-03-06 11:27:46 +08:00
|
|
|
}
|
2021-06-19 02:35:51 +08:00
|
|
|
case 1: {
|
|
|
|
TEST(true); // Simulated cluster using two satellite fast redundancy mode
|
|
|
|
primaryObj["satellite_redundancy_mode"] = "two_satellite_fast";
|
|
|
|
remoteObj["satellite_redundancy_mode"] = "two_satellite_fast";
|
|
|
|
break;
|
2018-06-18 10:31:15 +08:00
|
|
|
}
|
2021-06-19 02:35:51 +08:00
|
|
|
case 2: {
|
|
|
|
TEST(true); // Simulated cluster using two satellite safe redundancy mode
|
|
|
|
primaryObj["satellite_redundancy_mode"] = "two_satellite_safe";
|
|
|
|
remoteObj["satellite_redundancy_mode"] = "two_satellite_safe";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
ASSERT(false); // Programmer forgot to adjust cases.
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
int satellite_replication_type = deterministicRandom()->randomInt(0, 5);
|
|
|
|
switch (satellite_replication_type) {
|
2018-03-06 11:27:46 +08:00
|
|
|
case 0: {
|
2021-03-11 02:06:03 +08:00
|
|
|
// FIXME: implement
|
2021-06-19 02:35:51 +08:00
|
|
|
TEST(true); // Simulated cluster using custom satellite redundancy mode
|
2018-03-06 11:27:46 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1: {
|
2021-06-19 02:35:51 +08:00
|
|
|
TEST(true); // Simulated cluster using no satellite redundancy mode (<4 datacenters)
|
2018-03-06 11:27:46 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2: {
|
2021-06-19 02:35:51 +08:00
|
|
|
TEST(true); // Simulated cluster using single satellite redundancy mode
|
|
|
|
primaryObj["satellite_redundancy_mode"] = "one_satellite_single";
|
|
|
|
remoteObj["satellite_redundancy_mode"] = "one_satellite_single";
|
2018-03-06 11:27:46 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 3: {
|
2021-06-19 02:35:51 +08:00
|
|
|
TEST(true); // Simulated cluster using double satellite redundancy mode
|
|
|
|
primaryObj["satellite_redundancy_mode"] = "one_satellite_double";
|
|
|
|
remoteObj["satellite_redundancy_mode"] = "one_satellite_double";
|
2018-03-06 11:27:46 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 4: {
|
2021-06-19 02:35:51 +08:00
|
|
|
TEST(true); // Simulated cluster using triple satellite redundancy mode
|
|
|
|
primaryObj["satellite_redundancy_mode"] = "one_satellite_triple";
|
|
|
|
remoteObj["satellite_redundancy_mode"] = "one_satellite_triple";
|
2018-03-06 11:27:46 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2021-03-11 02:06:03 +08:00
|
|
|
ASSERT(false); // Programmer forgot to adjust cases.
|
2018-03-06 11:27:46 +08:00
|
|
|
}
|
2021-06-19 02:35:51 +08:00
|
|
|
}
|
2018-06-19 01:22:34 +08:00
|
|
|
|
2021-06-19 02:35:51 +08:00
|
|
|
if (deterministicRandom()->random01() < 0.25)
|
|
|
|
primaryObj["satellite_logs"] = deterministicRandom()->randomInt(1, 7);
|
|
|
|
if (deterministicRandom()->random01() < 0.25)
|
|
|
|
remoteObj["satellite_logs"] = deterministicRandom()->randomInt(1, 7);
|
|
|
|
|
|
|
|
// We cannot run with a remote DC when MAX_READ_TRANSACTION_LIFE_VERSIONS is too small, because the log
|
|
|
|
// routers will not be able to keep up.
|
|
|
|
if (testConfig.minimumRegions <= 1 &&
|
|
|
|
(deterministicRandom()->random01() < 0.25 ||
|
|
|
|
SERVER_KNOBS->MAX_READ_TRANSACTION_LIFE_VERSIONS < SERVER_KNOBS->VERSIONS_PER_SECOND)) {
|
|
|
|
TEST(true); // Simulated cluster using one region
|
|
|
|
needsRemote = false;
|
|
|
|
} else {
|
|
|
|
TEST(true); // Simulated cluster using two regions
|
|
|
|
db.usableRegions = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
int remote_replication_type = deterministicRandom()->randomInt(0, datacenters > 4 ? 4 : 5);
|
|
|
|
switch (remote_replication_type) {
|
|
|
|
case 0: {
|
|
|
|
// FIXME: implement
|
|
|
|
TEST(true); // Simulated cluster using custom remote redundancy mode
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1: {
|
|
|
|
TEST(true); // Simulated cluster using default remote redundancy mode
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2: {
|
|
|
|
TEST(true); // Simulated cluster using single remote redundancy mode
|
|
|
|
set_config("remote_single");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 3: {
|
|
|
|
TEST(true); // Simulated cluster using double remote redundancy mode
|
|
|
|
set_config("remote_double");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 4: {
|
|
|
|
TEST(true); // Simulated cluster using triple remote redundancy mode
|
|
|
|
set_config("remote_triple");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
ASSERT(false); // Programmer forgot to adjust cases.
|
|
|
|
}
|
|
|
|
|
|
|
|
if (deterministicRandom()->random01() < 0.25)
|
|
|
|
db.desiredLogRouterCount = deterministicRandom()->randomInt(1, 7);
|
|
|
|
if (deterministicRandom()->random01() < 0.25)
|
|
|
|
db.remoteDesiredTLogCount = deterministicRandom()->randomInt(1, 7);
|
|
|
|
|
|
|
|
bool useNormalDCsAsSatellites =
|
|
|
|
datacenters > 4 && testConfig.minimumRegions < 2 && deterministicRandom()->random01() < 0.3;
|
|
|
|
StatusObject primarySatelliteObj;
|
|
|
|
primarySatelliteObj["id"] = useNormalDCsAsSatellites ? "1" : "2";
|
|
|
|
primarySatelliteObj["priority"] = 1;
|
|
|
|
primarySatelliteObj["satellite"] = 1;
|
|
|
|
if (deterministicRandom()->random01() < 0.25)
|
|
|
|
primarySatelliteObj["satellite_logs"] = deterministicRandom()->randomInt(1, 7);
|
|
|
|
primaryDcArr.push_back(primarySatelliteObj);
|
|
|
|
|
|
|
|
StatusObject remoteSatelliteObj;
|
|
|
|
remoteSatelliteObj["id"] = useNormalDCsAsSatellites ? "0" : "3";
|
|
|
|
remoteSatelliteObj["priority"] = 1;
|
|
|
|
remoteSatelliteObj["satellite"] = 1;
|
|
|
|
if (deterministicRandom()->random01() < 0.25)
|
|
|
|
remoteSatelliteObj["satellite_logs"] = deterministicRandom()->randomInt(1, 7);
|
|
|
|
remoteDcArr.push_back(remoteSatelliteObj);
|
|
|
|
|
|
|
|
if (datacenters > 4) {
|
|
|
|
StatusObject primarySatelliteObjB;
|
|
|
|
primarySatelliteObjB["id"] = useNormalDCsAsSatellites ? "2" : "4";
|
|
|
|
primarySatelliteObjB["priority"] = 1;
|
|
|
|
primarySatelliteObjB["satellite"] = 1;
|
2021-03-11 02:06:03 +08:00
|
|
|
if (deterministicRandom()->random01() < 0.25)
|
2021-06-19 02:35:51 +08:00
|
|
|
primarySatelliteObjB["satellite_logs"] = deterministicRandom()->randomInt(1, 7);
|
|
|
|
primaryDcArr.push_back(primarySatelliteObjB);
|
2019-03-19 03:17:59 +08:00
|
|
|
|
2021-06-19 02:35:51 +08:00
|
|
|
StatusObject remoteSatelliteObjB;
|
|
|
|
remoteSatelliteObjB["id"] = useNormalDCsAsSatellites ? "2" : "5";
|
|
|
|
remoteSatelliteObjB["priority"] = 1;
|
|
|
|
remoteSatelliteObjB["satellite"] = 1;
|
2021-03-11 02:06:03 +08:00
|
|
|
if (deterministicRandom()->random01() < 0.25)
|
2021-06-19 02:35:51 +08:00
|
|
|
remoteSatelliteObjB["satellite_logs"] = deterministicRandom()->randomInt(1, 7);
|
|
|
|
remoteDcArr.push_back(remoteSatelliteObjB);
|
2018-03-06 11:27:46 +08:00
|
|
|
}
|
2021-06-19 02:35:51 +08:00
|
|
|
if (useNormalDCsAsSatellites) {
|
|
|
|
datacenters = 3;
|
2018-03-06 11:27:46 +08:00
|
|
|
}
|
2021-06-19 02:35:51 +08:00
|
|
|
}
|
2018-03-06 11:27:46 +08:00
|
|
|
|
2021-06-19 02:35:51 +08:00
|
|
|
primaryObj["datacenters"] = primaryDcArr;
|
|
|
|
remoteObj["datacenters"] = remoteDcArr;
|
2018-06-14 08:55:55 +08:00
|
|
|
|
2021-06-19 02:35:51 +08:00
|
|
|
StatusArray regionArr;
|
|
|
|
regionArr.push_back(primaryObj);
|
|
|
|
if (needsRemote || deterministicRandom()->random01() < 0.5) {
|
|
|
|
regionArr.push_back(remoteObj);
|
|
|
|
}
|
2018-03-06 11:27:46 +08:00
|
|
|
|
2021-06-19 02:35:51 +08:00
|
|
|
if (needsRemote) {
|
|
|
|
g_simulator.originalRegions =
|
|
|
|
"regions=" + json_spirit::write_string(json_spirit::mValue(regionArr), json_spirit::Output_options::none);
|
2018-09-18 09:32:39 +08:00
|
|
|
|
2021-06-19 02:35:51 +08:00
|
|
|
StatusArray disablePrimary = regionArr;
|
|
|
|
disablePrimary[0].get_obj()["datacenters"].get_array()[0].get_obj()["priority"] = -1;
|
|
|
|
g_simulator.disablePrimary = "regions=" + json_spirit::write_string(json_spirit::mValue(disablePrimary),
|
|
|
|
json_spirit::Output_options::none);
|
2018-07-17 01:06:57 +08:00
|
|
|
|
2021-06-19 02:35:51 +08:00
|
|
|
StatusArray disableRemote = regionArr;
|
|
|
|
disableRemote[1].get_obj()["datacenters"].get_array()[0].get_obj()["priority"] = -1;
|
|
|
|
g_simulator.disableRemote = "regions=" + json_spirit::write_string(json_spirit::mValue(disableRemote),
|
|
|
|
json_spirit::Output_options::none);
|
|
|
|
} else {
|
|
|
|
// In order to generate a starting configuration with the remote disabled, do not apply the region
|
|
|
|
// configuration to the DatabaseConfiguration until after creating the starting conf string.
|
|
|
|
set_config("regions=" +
|
|
|
|
json_spirit::write_string(json_spirit::mValue(regionArr), json_spirit::Output_options::none));
|
2018-02-19 04:59:43 +08:00
|
|
|
}
|
2021-06-19 02:35:51 +08:00
|
|
|
}
|
2018-06-14 08:55:55 +08:00
|
|
|
|
2021-06-19 02:35:51 +08:00
|
|
|
// Sets the machine count based on the testConfig. May be overwritten later
|
|
|
|
// if the end result is not a viable config.
|
|
|
|
void SimulationConfig::setMachineCount(const TestConfig& testConfig) {
|
2021-05-21 03:48:41 +08:00
|
|
|
if (testConfig.machineCount.present()) {
|
|
|
|
machine_count = testConfig.machineCount.get();
|
2021-10-15 03:58:37 +08:00
|
|
|
} else if (generateFearless && testConfig.minimumReplication > 1) {
|
2021-03-11 02:06:03 +08:00
|
|
|
// low latency tests in fearless configurations need 4 machines per datacenter (3 for triple replication, 1 that
|
|
|
|
// is down during failures).
|
2020-08-08 02:44:01 +08:00
|
|
|
machine_count = 16;
|
2021-03-11 02:06:03 +08:00
|
|
|
} else if (generateFearless) {
|
2020-08-17 06:10:36 +08:00
|
|
|
machine_count = 12;
|
2021-03-11 02:06:03 +08:00
|
|
|
} else if (db.tLogPolicy && db.tLogPolicy->info() == "data_hall^2 x zoneid^2 x 1") {
|
2020-08-08 02:44:01 +08:00
|
|
|
machine_count = 9;
|
2018-02-11 05:27:51 +08:00
|
|
|
} else {
|
2021-03-11 02:06:03 +08:00
|
|
|
// datacenters+2 so that the configure database workload can configure into three_data_hall
|
|
|
|
machine_count = std::max(datacenters + 2,
|
|
|
|
((db.minDatacentersRequired() > 0) ? datacenters : 1) *
|
|
|
|
std::max(3, db.minZonesRequiredPerDatacenter()));
|
|
|
|
machine_count = deterministicRandom()->randomInt(machine_count, std::max(machine_count + 1, extraDB ? 6 : 10));
|
2021-06-19 02:35:51 +08:00
|
|
|
// generateMachineTeamTestConfig set up the number of servers per machine and the number of machines such that
|
|
|
|
// if we do not remove the surplus server and machine teams, the simulation test will report error.
|
|
|
|
// This is needed to make sure the number of server (and machine) teams is no larger than the desired number.
|
|
|
|
bool generateMachineTeamTestConfig = BUGGIFY_WITH_PROB(0.1) ? true : false;
|
2019-02-16 07:10:58 +08:00
|
|
|
if (generateMachineTeamTestConfig) {
|
|
|
|
// When DESIRED_TEAMS_PER_SERVER is set to 1, the desired machine team number is 5
|
|
|
|
// while the max possible machine team number is 10.
|
|
|
|
// If machine_count > 5, we can still test the effectivenss of machine teams
|
|
|
|
// Note: machine_count may be much larger than 5 because we may have a big replication factor
|
2019-05-11 05:01:52 +08:00
|
|
|
machine_count = std::max(machine_count, deterministicRandom()->randomInt(5, extraDB ? 6 : 10));
|
2019-02-16 07:10:58 +08:00
|
|
|
}
|
2018-02-11 05:27:51 +08:00
|
|
|
}
|
2021-09-22 07:49:55 +08:00
|
|
|
machine_count += datacenters * testConfig.extraMachineCountDC;
|
2021-06-19 02:35:51 +08:00
|
|
|
}
|
2018-02-11 05:27:51 +08:00
|
|
|
|
2021-06-19 02:35:51 +08:00
|
|
|
// Sets the coordinator count based on the testConfig. May be overwritten later
|
|
|
|
// if the end result is not a viable config.
|
|
|
|
void SimulationConfig::setCoordinators(const TestConfig& testConfig) {
|
2021-05-21 03:48:41 +08:00
|
|
|
if (testConfig.coordinators.present()) {
|
|
|
|
coordinators = testConfig.coordinators.get();
|
|
|
|
} else {
|
|
|
|
// because we protect a majority of coordinators from being killed, it is better to run with low numbers of
|
|
|
|
// coordinators to prevent too many processes from being protected
|
|
|
|
coordinators = (testConfig.minimumRegions <= 1 && BUGGIFY)
|
|
|
|
? deterministicRandom()->randomInt(1, std::max(machine_count, 2))
|
|
|
|
: 1;
|
|
|
|
}
|
2021-06-19 02:35:51 +08:00
|
|
|
}
|
2018-02-16 10:32:39 +08:00
|
|
|
|
2021-06-19 02:35:51 +08:00
|
|
|
// Sets the processes per machine based on the testConfig.
|
|
|
|
void SimulationConfig::setProcessesPerMachine(const TestConfig& testConfig) {
|
2021-05-21 03:48:41 +08:00
|
|
|
if (testConfig.processesPerMachine.present()) {
|
|
|
|
processes_per_machine = testConfig.processesPerMachine.get();
|
2021-10-15 03:58:37 +08:00
|
|
|
} else if (generateFearless) {
|
2018-02-19 04:59:43 +08:00
|
|
|
processes_per_machine = 1;
|
|
|
|
} else {
|
2021-03-11 02:06:03 +08:00
|
|
|
processes_per_machine = deterministicRandom()->randomInt(1, (extraDB ? 14 : 28) / machine_count + 2);
|
2018-02-19 04:59:43 +08:00
|
|
|
}
|
2021-06-19 02:35:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Sets the TSS configuration based on the testConfig.
|
|
|
|
// Also configures the cluster behaviour through setting some flags on the simulator.
|
|
|
|
void SimulationConfig::setTss(const TestConfig& testConfig) {
|
|
|
|
int tssCount = 0;
|
|
|
|
if (!testConfig.simpleConfig && !testConfig.disableTss && deterministicRandom()->random01() < 0.25) {
|
|
|
|
// 1 or 2 tss
|
|
|
|
tssCount = deterministicRandom()->randomInt(1, 3);
|
|
|
|
}
|
2021-03-06 03:28:15 +08:00
|
|
|
|
|
|
|
// reduce tss to half of extra non-seed servers that can be recruited in usable regions.
|
|
|
|
tssCount =
|
2021-09-22 07:49:55 +08:00
|
|
|
std::max(0, std::min(tssCount, db.usableRegions * ((machine_count / datacenters) - db.storageTeamSize) / 2));
|
2021-03-06 03:28:15 +08:00
|
|
|
|
2021-09-15 21:20:00 +08:00
|
|
|
if (!testConfig.config.present() && tssCount > 0) {
|
2021-03-06 03:28:15 +08:00
|
|
|
std::string confStr = format("tss_count:=%d tss_storage_engine:=%d", tssCount, db.storageServerStoreType);
|
|
|
|
set_config(confStr);
|
|
|
|
double tssRandom = deterministicRandom()->random01();
|
2021-09-15 21:20:00 +08:00
|
|
|
if (tssRandom > 0.5 || !faultInjectionActivated) {
|
2021-03-06 03:28:15 +08:00
|
|
|
// normal tss mode
|
|
|
|
g_simulator.tssMode = ISimulator::TSSMode::EnabledNormal;
|
2021-05-13 02:53:20 +08:00
|
|
|
} else if (tssRandom < 0.25 && !testConfig.isFirstTestInRestart) {
|
|
|
|
// fault injection - don't enable in first test in restart because second test won't know it intentionally
|
|
|
|
// lost data
|
|
|
|
g_simulator.tssMode = ISimulator::TSSMode::EnabledDropMutations;
|
|
|
|
} else {
|
2021-03-06 03:28:15 +08:00
|
|
|
// delay injection
|
|
|
|
g_simulator.tssMode = ISimulator::TSSMode::EnabledAddDelay;
|
|
|
|
}
|
|
|
|
printf("enabling tss for simulation in mode %d: %s\n", g_simulator.tssMode, confStr.c_str());
|
|
|
|
}
|
2017-08-12 06:06:36 +08:00
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-08-07 12:19:53 +08:00
|
|
|
void setConfigDB(TestConfig const& testConfig) {
|
2021-08-07 14:18:10 +08:00
|
|
|
g_simulator.configDBType = testConfig.getConfigDBType();
|
2021-08-07 12:19:53 +08:00
|
|
|
}
|
|
|
|
|
2021-06-19 02:35:51 +08:00
|
|
|
// 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
|
|
|
|
void SimulationConfig::generateNormalConfig(const TestConfig& testConfig) {
|
|
|
|
set_config("new");
|
|
|
|
// Some of these options will overwrite one another so the ordering is important.
|
|
|
|
// This is a bit inefficient but separates the different types of option setting paths for better readability.
|
|
|
|
setDatacenters(testConfig);
|
|
|
|
|
|
|
|
// These 3 sets will only change the settings with trivial logic and low coupling with
|
|
|
|
// other portions of the configuration. The parameters that are more involved and use
|
|
|
|
// complex logic will be found in their respective "set----" methods following after.
|
|
|
|
setRandomConfig();
|
|
|
|
if (testConfig.simpleConfig) {
|
|
|
|
setSimpleConfig();
|
|
|
|
}
|
|
|
|
setSpecificConfig(testConfig);
|
|
|
|
|
|
|
|
setStorageEngine(testConfig);
|
|
|
|
setReplicationType(testConfig);
|
|
|
|
if (generateFearless || (datacenters == 2 && deterministicRandom()->random01() < 0.5)) {
|
|
|
|
setRegions(testConfig);
|
|
|
|
}
|
|
|
|
setMachineCount(testConfig);
|
|
|
|
setCoordinators(testConfig);
|
|
|
|
|
|
|
|
if (testConfig.minimumReplication > 1 && datacenters == 3) {
|
|
|
|
// low latency tests in 3 data hall mode need 2 other data centers with 2 machines each to avoid waiting for
|
|
|
|
// logs to recover.
|
|
|
|
machine_count = std::max(machine_count, 6);
|
|
|
|
coordinators = 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
setProcessesPerMachine(testConfig);
|
|
|
|
setTss(testConfig);
|
2021-08-07 12:19:53 +08:00
|
|
|
setConfigDB(testConfig);
|
2021-06-19 02:35:51 +08:00
|
|
|
}
|
|
|
|
|
2021-03-23 03:24:46 +08:00
|
|
|
// Configures the system according to the given specifications in order to run
|
|
|
|
// simulation under the correct conditions
|
2021-09-17 08:42:34 +08:00
|
|
|
void setupSimulatedSystem(std::vector<Future<Void>>* systemActors,
|
2021-03-11 02:06:03 +08:00
|
|
|
std::string baseFolder,
|
|
|
|
int* pTesterCount,
|
|
|
|
Optional<ClusterConnectionString>* pConnString,
|
|
|
|
Standalone<StringRef>* pStartingConfiguration,
|
|
|
|
std::string whitelistBinPaths,
|
2021-03-23 02:30:22 +08:00
|
|
|
TestConfig testConfig,
|
2021-03-11 02:06:03 +08:00
|
|
|
ProtocolVersion protocolVersion) {
|
2017-05-26 04:48:44 +08:00
|
|
|
// SOMEDAY: this does not test multi-interface configurations
|
2021-03-23 02:30:22 +08:00
|
|
|
SimulationConfig simconfig(testConfig);
|
|
|
|
if (testConfig.logAntiQuorum != -1) {
|
|
|
|
simconfig.db.tLogWriteAntiQuorum = testConfig.logAntiQuorum;
|
2020-10-07 02:33:32 +08:00
|
|
|
}
|
2018-03-06 11:27:46 +08:00
|
|
|
StatusObject startingConfigJSON = simconfig.db.toJSON(true);
|
|
|
|
std::string startingConfigString = "new";
|
2021-03-23 02:30:22 +08:00
|
|
|
if (testConfig.configureLocked) {
|
2020-02-12 03:10:09 +08:00
|
|
|
startingConfigString += " locked";
|
|
|
|
}
|
2021-08-07 14:18:10 +08:00
|
|
|
auto configDBType = testConfig.getConfigDBType();
|
2021-03-11 02:06:03 +08:00
|
|
|
for (auto kv : startingConfigJSON) {
|
2021-03-06 03:28:15 +08:00
|
|
|
if ("tss_storage_engine" == kv.first) {
|
|
|
|
continue;
|
|
|
|
}
|
2021-09-18 01:16:26 +08:00
|
|
|
if ("perpetual_storage_wiggle_locality" == kv.first) {
|
|
|
|
if (deterministicRandom()->random01() < 0.25) {
|
|
|
|
int dcId = deterministicRandom()->randomInt(0, simconfig.datacenters);
|
|
|
|
startingConfigString += " " + kv.first + "=" + "data_hall:" + std::to_string(dcId);
|
|
|
|
}
|
2021-03-06 03:28:15 +08:00
|
|
|
continue;
|
|
|
|
}
|
2018-03-06 11:27:46 +08:00
|
|
|
startingConfigString += " ";
|
2021-03-11 02:06:03 +08:00
|
|
|
if (kv.second.type() == json_spirit::int_type) {
|
2019-01-19 07:42:48 +08:00
|
|
|
startingConfigString += kv.first + ":=" + format("%d", kv.second.get_int());
|
2021-03-11 02:06:03 +08:00
|
|
|
} else if (kv.second.type() == json_spirit::str_type) {
|
2021-09-08 07:26:43 +08:00
|
|
|
if ("storage_migration_type" == kv.first) {
|
|
|
|
startingConfigString += kv.first + "=" + kv.second.get_str();
|
|
|
|
} else {
|
|
|
|
startingConfigString += kv.second.get_str();
|
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
} else if (kv.second.type() == json_spirit::array_type) {
|
|
|
|
startingConfigString += kv.first + "=" +
|
|
|
|
json_spirit::write_string(json_spirit::mValue(kv.second.get_array()),
|
|
|
|
json_spirit::Output_options::none);
|
2018-03-06 11:27:46 +08:00
|
|
|
} else {
|
|
|
|
ASSERT(false);
|
|
|
|
}
|
|
|
|
}
|
2017-08-22 13:29:56 +08:00
|
|
|
|
2021-03-06 03:28:15 +08:00
|
|
|
// handle tss_storage_engine separately because the passthrough needs the enum ordinal, but it's serialized to json
|
|
|
|
// as the string name
|
|
|
|
if (simconfig.db.desiredTSSCount > 0) {
|
|
|
|
startingConfigString += format(" tss_storage_engine:=%d", simconfig.db.testingStorageServerStoreType);
|
|
|
|
}
|
|
|
|
|
2021-03-31 12:11:26 +08:00
|
|
|
if (g_simulator.originalRegions != "") {
|
|
|
|
simconfig.set_config(g_simulator.originalRegions);
|
|
|
|
g_simulator.startingDisabledConfiguration = startingConfigString + " " + g_simulator.disableRemote;
|
|
|
|
startingConfigString += " " + g_simulator.originalRegions;
|
|
|
|
}
|
|
|
|
|
2017-08-22 13:29:56 +08:00
|
|
|
g_simulator.storagePolicy = simconfig.db.storagePolicy;
|
|
|
|
g_simulator.tLogPolicy = simconfig.db.tLogPolicy;
|
|
|
|
g_simulator.tLogWriteAntiQuorum = simconfig.db.tLogWriteAntiQuorum;
|
2018-06-18 10:31:15 +08:00
|
|
|
g_simulator.remoteTLogPolicy = simconfig.db.getRemoteTLogPolicy();
|
|
|
|
g_simulator.usableRegions = simconfig.db.usableRegions;
|
2017-10-20 06:49:54 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
if (simconfig.db.regions.size() > 0) {
|
2018-03-06 11:27:46 +08:00
|
|
|
g_simulator.primaryDcId = simconfig.db.regions[0].dcId;
|
2018-06-11 11:20:41 +08:00
|
|
|
g_simulator.hasSatelliteReplication = simconfig.db.regions[0].satelliteTLogReplicationFactor > 0;
|
2021-03-11 02:06:03 +08:00
|
|
|
if (simconfig.db.regions[0].satelliteTLogUsableDcsFallback > 0) {
|
2018-07-10 13:01:46 +08:00
|
|
|
g_simulator.satelliteTLogPolicyFallback = simconfig.db.regions[0].satelliteTLogPolicyFallback;
|
2021-03-11 02:06:03 +08:00
|
|
|
g_simulator.satelliteTLogWriteAntiQuorumFallback =
|
|
|
|
simconfig.db.regions[0].satelliteTLogWriteAntiQuorumFallback;
|
2018-06-29 14:15:32 +08:00
|
|
|
} else {
|
2018-07-10 13:01:46 +08:00
|
|
|
g_simulator.satelliteTLogPolicyFallback = simconfig.db.regions[0].satelliteTLogPolicy;
|
|
|
|
g_simulator.satelliteTLogWriteAntiQuorumFallback = simconfig.db.regions[0].satelliteTLogWriteAntiQuorum;
|
2018-03-06 11:27:46 +08:00
|
|
|
}
|
2018-07-10 13:01:46 +08:00
|
|
|
g_simulator.satelliteTLogPolicy = simconfig.db.regions[0].satelliteTLogPolicy;
|
|
|
|
g_simulator.satelliteTLogWriteAntiQuorum = simconfig.db.regions[0].satelliteTLogWriteAntiQuorum;
|
2018-03-16 01:59:30 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
for (auto s : simconfig.db.regions[0].satellites) {
|
2018-03-16 01:59:30 +08:00
|
|
|
g_simulator.primarySatelliteDcIds.push_back(s.dcId);
|
|
|
|
}
|
2018-03-06 11:27:46 +08:00
|
|
|
} else {
|
|
|
|
g_simulator.hasSatelliteReplication = false;
|
|
|
|
g_simulator.satelliteTLogWriteAntiQuorum = 0;
|
|
|
|
}
|
2018-06-29 14:15:32 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
if (simconfig.db.regions.size() == 2) {
|
2018-06-29 14:15:32 +08:00
|
|
|
g_simulator.remoteDcId = simconfig.db.regions[1].dcId;
|
2021-03-11 02:06:03 +08:00
|
|
|
ASSERT((!simconfig.db.regions[0].satelliteTLogPolicy && !simconfig.db.regions[1].satelliteTLogPolicy) ||
|
|
|
|
simconfig.db.regions[0].satelliteTLogPolicy->info() ==
|
|
|
|
simconfig.db.regions[1].satelliteTLogPolicy->info());
|
2018-06-29 14:15:32 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
for (auto s : simconfig.db.regions[1].satellites) {
|
2018-06-29 14:15:32 +08:00
|
|
|
g_simulator.remoteSatelliteDcIds.push_back(s.dcId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
if (g_simulator.usableRegions < 2 || !g_simulator.hasSatelliteReplication) {
|
2018-07-10 13:24:43 +08:00
|
|
|
g_simulator.allowLogSetKills = false;
|
|
|
|
}
|
|
|
|
|
2017-10-20 06:49:54 +08:00
|
|
|
ASSERT(g_simulator.storagePolicy && g_simulator.tLogPolicy);
|
|
|
|
ASSERT(!g_simulator.hasSatelliteReplication || g_simulator.satelliteTLogPolicy);
|
2019-03-19 06:03:43 +08:00
|
|
|
TraceEvent("SimulatorConfig").detail("ConfigString", StringRef(startingConfigString));
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2017-08-22 13:29:56 +08:00
|
|
|
const int dataCenters = simconfig.datacenters;
|
|
|
|
const int machineCount = simconfig.machine_count;
|
|
|
|
const int coordinatorCount = simconfig.coordinators;
|
|
|
|
const int processesPerMachine = simconfig.processes_per_machine;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
// half the time, when we have more than 4 machines that are not the first in their dataCenter, assign classes
|
2019-05-11 05:01:52 +08:00
|
|
|
bool assignClasses = machineCount - dataCenters > 4 && deterministicRandom()->random01() < 0.5;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2017-10-30 23:31:01 +08:00
|
|
|
// Use SSL 5% of the time
|
2020-02-07 11:29:31 +08:00
|
|
|
bool sslEnabled = deterministicRandom()->random01() < 0.10;
|
2019-05-11 05:01:52 +08:00
|
|
|
bool sslOnly = sslEnabled && deterministicRandom()->coinflip();
|
2022-01-21 05:26:49 +08:00
|
|
|
bool isTLS = sslEnabled && sslOnly;
|
2019-02-01 10:20:14 +08:00
|
|
|
g_simulator.listenersPerProcess = sslEnabled && !sslOnly ? 2 : 1;
|
2021-03-11 02:06:03 +08:00
|
|
|
TEST(sslEnabled); // SSL enabled
|
|
|
|
TEST(!sslEnabled); // SSL disabled
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2019-02-28 16:09:53 +08:00
|
|
|
// Use IPv6 25% of the time
|
2019-05-11 05:01:52 +08:00
|
|
|
bool useIPv6 = deterministicRandom()->random01() < 0.25;
|
2021-03-11 02:06:03 +08:00
|
|
|
TEST(useIPv6); // Use IPv6
|
|
|
|
TEST(!useIPv6); // Use IPv4
|
2019-02-28 16:09:53 +08:00
|
|
|
|
2022-01-21 05:26:49 +08:00
|
|
|
// TODO(renxuan): Use hostname 25% of the time, unless it is disabled
|
|
|
|
bool useHostname = false; // !testConfig.disableHostname && deterministicRandom()->random01() < 0.25;
|
|
|
|
TEST(useHostname); // Use hostname
|
|
|
|
TEST(!useHostname); // Use IP address
|
|
|
|
NetworkAddressFromHostname fromHostname =
|
|
|
|
useHostname ? NetworkAddressFromHostname::True : NetworkAddressFromHostname::False;
|
|
|
|
|
2021-09-17 08:42:34 +08:00
|
|
|
std::vector<NetworkAddress> coordinatorAddresses;
|
2022-01-21 05:26:49 +08:00
|
|
|
std::vector<Hostname> coordinatorHostnames;
|
2021-09-17 08:42:34 +08:00
|
|
|
std::vector<NetworkAddress> extraCoordinatorAddresses; // Used by extra DB if the DR db is a new one
|
2022-01-21 05:26:49 +08:00
|
|
|
std::vector<Hostname> extraCoordinatorHostnames;
|
|
|
|
|
2021-03-23 02:30:22 +08:00
|
|
|
if (testConfig.minimumRegions > 1) {
|
2021-03-11 02:06:03 +08:00
|
|
|
// do not put coordinators in the primary region so that we can kill that region safely
|
|
|
|
int nonPrimaryDcs = dataCenters / 2;
|
|
|
|
for (int dc = 1; dc < dataCenters; dc += 2) {
|
|
|
|
int dcCoordinators = coordinatorCount / nonPrimaryDcs + ((dc - 1) / 2 < coordinatorCount % nonPrimaryDcs);
|
|
|
|
for (int m = 0; m < dcCoordinators; m++) {
|
2019-02-28 16:09:53 +08:00
|
|
|
auto ip = makeIPAddressForSim(useIPv6, { 2, dc, 1, m });
|
2022-01-21 05:26:49 +08:00
|
|
|
uint16_t port = sslEnabled && !sslOnly ? 2 : 1;
|
|
|
|
NetworkAddress coordinator(ip, port, true, isTLS, fromHostname);
|
|
|
|
coordinatorAddresses.push_back(coordinator);
|
2021-03-31 00:31:10 +08:00
|
|
|
auto extraIp = makeIPAddressForSim(useIPv6, { 4, dc, 1, m });
|
2022-01-21 05:26:49 +08:00
|
|
|
NetworkAddress extraCoordinator(extraIp, port, true, isTLS, fromHostname);
|
|
|
|
extraCoordinatorAddresses.push_back(extraCoordinator);
|
|
|
|
|
|
|
|
if (useHostname) {
|
|
|
|
std::string hostname = "fakeCoordinatorDC" + std::to_string(dc) + "M" + std::to_string(m);
|
|
|
|
Hostname coordinatorHostname(hostname, std::to_string(port), isTLS);
|
|
|
|
coordinatorHostnames.push_back(coordinatorHostname);
|
|
|
|
INetworkConnections::net()->addMockTCPEndpoint(hostname, std::to_string(port), { coordinator });
|
|
|
|
hostname = "fakeExtraCoordinatorDC" + std::to_string(dc) + "M" + std::to_string(m);
|
|
|
|
Hostname extraCoordinatorHostname(hostname, std::to_string(port), isTLS);
|
|
|
|
extraCoordinatorHostnames.push_back(extraCoordinatorHostname);
|
|
|
|
INetworkConnections::net()->addMockTCPEndpoint(
|
|
|
|
hostname, std::to_string(port), { extraCoordinator });
|
|
|
|
}
|
|
|
|
TraceEvent("SelectedCoordinator")
|
|
|
|
.detail("Hostname", useHostname ? coordinatorHostnames.back().toString().c_str() : "N/A")
|
|
|
|
.detail("Address", coordinatorAddresses.back());
|
2018-09-18 09:32:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2019-01-19 07:42:48 +08:00
|
|
|
int assignedMachines = 0;
|
|
|
|
int coordCount = coordinatorCount;
|
2021-03-11 02:06:03 +08:00
|
|
|
if (coordinatorCount > 4) {
|
2019-01-19 07:42:48 +08:00
|
|
|
++coordCount;
|
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
for (int dc = 0; dc < dataCenters; dc++) {
|
|
|
|
int dcCoordinators = coordCount / dataCenters + (dc < coordCount % dataCenters);
|
2019-01-19 07:42:48 +08:00
|
|
|
int machines = machineCount / dataCenters + (dc < machineCount % dataCenters);
|
2021-03-11 02:06:03 +08:00
|
|
|
for (int m = 0; m < dcCoordinators; m++) {
|
|
|
|
if (coordinatorCount > 4 &&
|
|
|
|
(assignedMachines == 4 || (m + 1 == dcCoordinators && assignedMachines < 4 &&
|
|
|
|
assignedMachines + machines - dcCoordinators >= 4))) {
|
2019-02-28 16:09:53 +08:00
|
|
|
auto ip = makeIPAddressForSim(useIPv6, { 2, dc, 1, m });
|
|
|
|
TraceEvent("SkippedCoordinator")
|
|
|
|
.detail("Address", ip.toString())
|
|
|
|
.detail("M", m)
|
|
|
|
.detail("Machines", machines)
|
|
|
|
.detail("Assigned", assignedMachines)
|
|
|
|
.detail("DcCoord", dcCoordinators)
|
|
|
|
.detail("CoordinatorCount", coordinatorCount);
|
2019-01-19 07:42:48 +08:00
|
|
|
} else {
|
2019-02-28 16:09:53 +08:00
|
|
|
auto ip = makeIPAddressForSim(useIPv6, { 2, dc, 1, m });
|
2022-01-21 05:26:49 +08:00
|
|
|
uint16_t port = sslEnabled && !sslOnly ? 2 : 1;
|
|
|
|
NetworkAddress coordinator(ip, port, true, isTLS, fromHostname);
|
|
|
|
coordinatorAddresses.push_back(coordinator);
|
2021-03-31 00:31:10 +08:00
|
|
|
auto extraIp = makeIPAddressForSim(useIPv6, { 4, dc, 1, m });
|
2022-01-21 05:26:49 +08:00
|
|
|
NetworkAddress extraCoordinator(extraIp, port, true, isTLS, fromHostname);
|
|
|
|
extraCoordinatorAddresses.push_back(extraCoordinator);
|
|
|
|
if (useHostname) {
|
|
|
|
std::string hostname = "fakeCoordinatorDC" + std::to_string(dc) + "M" + std::to_string(m);
|
|
|
|
Hostname coordinatorHostname(hostname, std::to_string(port), isTLS);
|
|
|
|
coordinatorHostnames.push_back(coordinatorHostname);
|
|
|
|
INetworkConnections::net()->addMockTCPEndpoint(hostname, std::to_string(port), { coordinator });
|
|
|
|
hostname = "fakeExtraCoordinatorDC" + std::to_string(dc) + "M" + std::to_string(m);
|
|
|
|
Hostname extraCoordinatorHostname(hostname, std::to_string(port), isTLS);
|
|
|
|
extraCoordinatorHostnames.push_back(extraCoordinatorHostname);
|
|
|
|
INetworkConnections::net()->addMockTCPEndpoint(
|
|
|
|
hostname, std::to_string(port), { extraCoordinator });
|
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
TraceEvent("SelectedCoordinator")
|
2022-01-21 05:26:49 +08:00
|
|
|
.detail("Hostname", useHostname ? coordinatorHostnames.back().toString().c_str() : "N/A")
|
2021-03-11 02:06:03 +08:00
|
|
|
.detail("Address", coordinatorAddresses.back())
|
|
|
|
.detail("M", m)
|
|
|
|
.detail("Machines", machines)
|
|
|
|
.detail("Assigned", assignedMachines)
|
|
|
|
.detail("DcCoord", dcCoordinators)
|
|
|
|
.detail("P1", (m + 1 == dcCoordinators))
|
|
|
|
.detail("P2", (assignedMachines < 4))
|
|
|
|
.detail("P3", (assignedMachines + machines - dcCoordinators >= 4))
|
|
|
|
.detail("CoordinatorCount", coordinatorCount);
|
2019-01-19 07:42:48 +08:00
|
|
|
}
|
|
|
|
assignedMachines++;
|
2018-09-18 09:32:39 +08:00
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
assignedMachines += machines - dcCoordinators;
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
}
|
2017-05-27 05:20:11 +08:00
|
|
|
|
2021-06-16 06:00:19 +08:00
|
|
|
ASSERT(coordinatorAddresses.size() > 0);
|
2019-05-11 05:01:52 +08:00
|
|
|
deterministicRandom()->randomShuffle(coordinatorAddresses);
|
2021-03-11 02:06:03 +08:00
|
|
|
for (int i = 0; i < (coordinatorAddresses.size() / 2) + 1; i++) {
|
2019-02-28 16:09:53 +08:00
|
|
|
TraceEvent("ProtectCoordinator")
|
|
|
|
.detail("Address", coordinatorAddresses[i])
|
|
|
|
.detail("Coordinators", describe(coordinatorAddresses));
|
2021-03-11 02:06:03 +08:00
|
|
|
g_simulator.protectedAddresses.insert(NetworkAddress(
|
|
|
|
coordinatorAddresses[i].ip, coordinatorAddresses[i].port, true, coordinatorAddresses[i].isTLS()));
|
|
|
|
if (coordinatorAddresses[i].port == 2) {
|
2020-02-13 07:12:43 +08:00
|
|
|
g_simulator.protectedAddresses.insert(NetworkAddress(coordinatorAddresses[i].ip, 1, true, true));
|
2019-02-01 10:20:14 +08:00
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
2019-05-11 05:01:52 +08:00
|
|
|
deterministicRandom()->randomShuffle(coordinatorAddresses);
|
2017-05-27 05:20:11 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
ASSERT_EQ(coordinatorAddresses.size(), coordinatorCount);
|
2017-05-26 04:48:44 +08:00
|
|
|
ClusterConnectionString conn(coordinatorAddresses, LiteralStringRef("TestCluster:0"));
|
2022-01-21 05:26:49 +08:00
|
|
|
if (useHostname) {
|
|
|
|
conn = ClusterConnectionString(coordinatorHostnames, LiteralStringRef("TestCluster:0"));
|
|
|
|
}
|
2018-04-27 08:24:40 +08:00
|
|
|
|
2018-04-19 10:34:35 +08:00
|
|
|
// If extraDB==0, leave g_simulator.extraDB as null because the test does not use DR.
|
2021-03-23 02:30:22 +08:00
|
|
|
if (testConfig.extraDB == 1) {
|
2018-04-19 10:34:35 +08:00
|
|
|
// The DR database can be either a new database or itself
|
2021-03-31 00:31:10 +08:00
|
|
|
g_simulator.extraDB =
|
2022-01-21 05:26:49 +08:00
|
|
|
BUGGIFY
|
|
|
|
? (useHostname ? new ClusterConnectionString(coordinatorHostnames, LiteralStringRef("TestCluster:0"))
|
|
|
|
: new ClusterConnectionString(coordinatorAddresses, LiteralStringRef("TestCluster:0")))
|
|
|
|
: (useHostname
|
|
|
|
? new ClusterConnectionString(extraCoordinatorHostnames, LiteralStringRef("ExtraCluster:0"))
|
|
|
|
: new ClusterConnectionString(extraCoordinatorAddresses, LiteralStringRef("ExtraCluster:0")));
|
2021-03-23 02:30:22 +08:00
|
|
|
} else if (testConfig.extraDB == 2) {
|
2018-04-19 10:34:35 +08:00
|
|
|
// The DR database is a new database
|
2021-03-31 00:31:10 +08:00
|
|
|
g_simulator.extraDB =
|
2022-01-21 05:26:49 +08:00
|
|
|
useHostname ? new ClusterConnectionString(extraCoordinatorHostnames, LiteralStringRef("ExtraCluster:0"))
|
|
|
|
: new ClusterConnectionString(extraCoordinatorAddresses, LiteralStringRef("ExtraCluster:0"));
|
2021-03-23 02:30:22 +08:00
|
|
|
} else if (testConfig.extraDB == 3) {
|
2018-04-19 10:34:35 +08:00
|
|
|
// The DR database is the same database
|
2022-01-21 05:26:49 +08:00
|
|
|
g_simulator.extraDB =
|
|
|
|
useHostname ? new ClusterConnectionString(coordinatorHostnames, LiteralStringRef("TestCluster:0"))
|
|
|
|
: new ClusterConnectionString(coordinatorAddresses, LiteralStringRef("TestCluster:0"));
|
2018-04-19 10:34:35 +08:00
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
*pConnString = conn;
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
TraceEvent("SimulatedConnectionString")
|
|
|
|
.detail("String", conn.toString())
|
|
|
|
.detail("ConfigString", startingConfigString);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-23 02:30:22 +08:00
|
|
|
bool requiresExtraDBMachines = testConfig.extraDB && g_simulator.extraDB->toString() != conn.toString();
|
2017-05-26 04:48:44 +08:00
|
|
|
int assignedMachines = 0, nonVersatileMachines = 0;
|
2021-09-22 07:49:55 +08:00
|
|
|
bool gradualMigrationPossible = true;
|
2021-03-11 02:06:03 +08:00
|
|
|
std::vector<ProcessClass::ClassType> processClassesSubSet = { ProcessClass::UnsetClass,
|
2021-04-27 00:49:26 +08:00
|
|
|
ProcessClass::StatelessClass };
|
2021-03-11 02:06:03 +08:00
|
|
|
for (int dc = 0; dc < dataCenters; dc++) {
|
|
|
|
// FIXME: test unset dcID
|
2017-10-20 06:49:54 +08:00
|
|
|
Optional<Standalone<StringRef>> dcUID = StringRef(format("%d", dc));
|
2017-05-26 04:48:44 +08:00
|
|
|
std::vector<UID> machineIdentities;
|
2021-03-11 02:06:03 +08:00
|
|
|
int machines = machineCount / dataCenters +
|
|
|
|
(dc < machineCount % dataCenters); // add remainder of machines to first datacenter
|
2021-09-22 07:49:55 +08:00
|
|
|
int possible_ss = 0;
|
2021-03-11 02:06:03 +08:00
|
|
|
int dcCoordinators = coordinatorCount / dataCenters + (dc < coordinatorCount % dataCenters);
|
|
|
|
printf("Datacenter %d: %d/%d machines, %d/%d coordinators\n",
|
|
|
|
dc,
|
|
|
|
machines,
|
|
|
|
machineCount,
|
|
|
|
dcCoordinators,
|
|
|
|
coordinatorCount);
|
2020-07-21 05:13:52 +08:00
|
|
|
ASSERT_LE(dcCoordinators, machines);
|
2020-01-24 08:52:42 +08:00
|
|
|
|
2021-10-15 03:58:37 +08:00
|
|
|
// FIXME: temporarily code to test storage cache
|
2021-03-11 02:06:03 +08:00
|
|
|
// TODO: caching disabled for this merge
|
2021-10-15 03:58:37 +08:00
|
|
|
if (dc == 0) {
|
|
|
|
machines++;
|
2021-10-13 21:46:38 +08:00
|
|
|
}
|
2019-11-13 05:01:29 +08:00
|
|
|
|
2021-10-15 03:58:37 +08:00
|
|
|
int useSeedForMachine = deterministicRandom()->randomInt(0, machines);
|
2019-01-19 07:42:48 +08:00
|
|
|
Standalone<StringRef> zoneId;
|
|
|
|
Standalone<StringRef> newZoneId;
|
2021-10-15 03:58:37 +08:00
|
|
|
for (int machine = 0; machine < machines; machine++) {
|
2019-05-11 05:01:52 +08:00
|
|
|
Standalone<StringRef> machineId(deterministicRandom()->randomUniqueID().toString());
|
2021-03-11 02:06:03 +08:00
|
|
|
if (machine == 0 || machineCount - dataCenters <= 4 || assignedMachines != 4 ||
|
|
|
|
simconfig.db.regions.size() || deterministicRandom()->random01() < 0.5) {
|
2019-05-11 05:01:52 +08:00
|
|
|
zoneId = deterministicRandom()->randomUniqueID().toString();
|
|
|
|
newZoneId = deterministicRandom()->randomUniqueID().toString();
|
2019-01-19 07:42:48 +08:00
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
// Choose a machine class
|
2017-05-26 04:48:44 +08:00
|
|
|
ProcessClass processClass = ProcessClass(ProcessClass::UnsetClass, ProcessClass::CommandLineSource);
|
2021-03-11 02:06:03 +08:00
|
|
|
if (assignClasses) {
|
|
|
|
if (assignedMachines < 4)
|
|
|
|
processClass = ProcessClass((ProcessClass::ClassType)deterministicRandom()->randomInt(0, 2),
|
|
|
|
ProcessClass::CommandLineSource); // Unset or Storage
|
|
|
|
else if (assignedMachines == 4 && !simconfig.db.regions.size())
|
|
|
|
processClass = ProcessClass(
|
|
|
|
processClassesSubSet[deterministicRandom()->randomInt(0, processClassesSubSet.size())],
|
2021-04-27 00:49:26 +08:00
|
|
|
ProcessClass::CommandLineSource); // Unset or Stateless
|
2017-05-26 04:48:44 +08:00
|
|
|
else
|
2021-03-11 02:06:03 +08:00
|
|
|
processClass = ProcessClass((ProcessClass::ClassType)deterministicRandom()->randomInt(0, 3),
|
|
|
|
ProcessClass::CommandLineSource); // Unset, Storage, or Transaction
|
|
|
|
if (processClass ==
|
2021-09-22 07:49:55 +08:00
|
|
|
ProcessClass::StatelessClass) { // *can't* be assigned to other roles, even in an emergency
|
2017-05-26 04:48:44 +08:00
|
|
|
nonVersatileMachines++;
|
2021-09-22 07:49:55 +08:00
|
|
|
}
|
|
|
|
if (processClass == ProcessClass::UnsetClass || processClass == ProcessClass::StorageClass) {
|
|
|
|
possible_ss++;
|
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
2021-10-15 03:58:37 +08:00
|
|
|
// FIXME: temporarily code to test storage cache
|
2021-03-11 02:06:03 +08:00
|
|
|
// TODO: caching disabled for this merge
|
2021-10-15 03:58:37 +08:00
|
|
|
if (machine == machines - 1 && dc == 0) {
|
|
|
|
processClass = ProcessClass(ProcessClass::StorageCacheClass, ProcessClass::CommandLineSource);
|
|
|
|
nonVersatileMachines++;
|
2021-09-19 05:35:56 +08:00
|
|
|
}
|
|
|
|
|
2019-02-28 16:09:53 +08:00
|
|
|
std::vector<IPAddress> ips;
|
2021-03-04 11:36:21 +08:00
|
|
|
ips.reserve(processesPerMachine);
|
2019-02-28 16:09:53 +08:00
|
|
|
for (int i = 0; i < processesPerMachine; i++) {
|
2021-03-11 02:06:03 +08:00
|
|
|
ips.push_back(
|
|
|
|
makeIPAddressForSim(useIPv6, { 2, dc, deterministicRandom()->randomInt(1, i + 2), machine }));
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
if (requiresExtraDBMachines) {
|
2019-07-24 10:24:07 +08:00
|
|
|
ips.push_back(makeIPAddressForSim(useIPv6, { 2, dc, 1, machine }));
|
|
|
|
}
|
|
|
|
|
2020-07-13 09:30:02 +08:00
|
|
|
// check the sslEnablementMap using only one ip
|
2021-03-11 02:06:03 +08:00
|
|
|
LocalityData localities(Optional<Standalone<StringRef>>(), zoneId, machineId, dcUID);
|
2017-05-26 04:48:44 +08:00
|
|
|
localities.set(LiteralStringRef("data_hall"), dcUID);
|
2021-03-11 02:06:03 +08:00
|
|
|
systemActors->push_back(reportErrors(simulatedMachine(conn,
|
|
|
|
ips,
|
|
|
|
sslEnabled,
|
|
|
|
localities,
|
|
|
|
processClass,
|
|
|
|
baseFolder,
|
|
|
|
false,
|
|
|
|
machine == useSeedForMachine,
|
|
|
|
requiresExtraDBMachines ? AgentOnly : AgentAddition,
|
|
|
|
sslOnly,
|
|
|
|
whitelistBinPaths,
|
2021-08-07 12:19:53 +08:00
|
|
|
protocolVersion,
|
2021-08-07 14:18:10 +08:00
|
|
|
configDBType),
|
2021-03-11 02:06:03 +08:00
|
|
|
"SimulatedMachine"));
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2019-07-24 10:24:07 +08:00
|
|
|
if (requiresExtraDBMachines) {
|
2019-02-28 16:09:53 +08:00
|
|
|
std::vector<IPAddress> extraIps;
|
2021-03-04 11:36:21 +08:00
|
|
|
extraIps.reserve(processesPerMachine);
|
|
|
|
for (int i = 0; i < processesPerMachine; i++) {
|
2021-03-11 02:06:03 +08:00
|
|
|
extraIps.push_back(
|
|
|
|
makeIPAddressForSim(useIPv6, { 4, dc, deterministicRandom()->randomInt(1, i + 2), machine }));
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
2019-05-11 05:01:52 +08:00
|
|
|
Standalone<StringRef> newMachineId(deterministicRandom()->randomUniqueID().toString());
|
2019-01-19 07:42:48 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
LocalityData localities(Optional<Standalone<StringRef>>(), newZoneId, newMachineId, dcUID);
|
2017-05-26 04:48:44 +08:00
|
|
|
localities.set(LiteralStringRef("data_hall"), dcUID);
|
2021-03-11 02:06:03 +08:00
|
|
|
systemActors->push_back(reportErrors(simulatedMachine(*g_simulator.extraDB,
|
|
|
|
extraIps,
|
|
|
|
sslEnabled,
|
|
|
|
localities,
|
|
|
|
processClass,
|
|
|
|
baseFolder,
|
|
|
|
false,
|
|
|
|
machine == useSeedForMachine,
|
|
|
|
AgentNone,
|
|
|
|
sslOnly,
|
|
|
|
whitelistBinPaths,
|
2021-08-07 12:19:53 +08:00
|
|
|
protocolVersion,
|
2021-08-07 14:18:10 +08:00
|
|
|
configDBType),
|
2021-03-11 02:06:03 +08:00
|
|
|
"SimulatedMachine"));
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
assignedMachines++;
|
|
|
|
}
|
2021-09-22 07:49:55 +08:00
|
|
|
|
|
|
|
if (possible_ss - simconfig.db.desiredTSSCount / simconfig.db.usableRegions <= simconfig.db.storageTeamSize) {
|
|
|
|
gradualMigrationPossible = false;
|
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
g_simulator.desiredCoordinators = coordinatorCount;
|
|
|
|
g_simulator.physicalDatacenters = dataCenters;
|
|
|
|
g_simulator.processesPerMachine = processesPerMachine;
|
|
|
|
|
|
|
|
TraceEvent("SetupSimulatorSettings")
|
2021-03-11 02:06:03 +08:00
|
|
|
.detail("DesiredCoordinators", g_simulator.desiredCoordinators)
|
|
|
|
.detail("PhysicalDatacenters", g_simulator.physicalDatacenters)
|
|
|
|
.detail("ProcessesPerMachine", g_simulator.processesPerMachine);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
// SOMEDAY: add locality for testers to simulate network topology
|
|
|
|
// FIXME: Start workers with tester class instead, at least sometimes run tests with the testers-only flag
|
2019-05-11 05:01:52 +08:00
|
|
|
int testerCount = *pTesterCount = deterministicRandom()->randomInt(4, 9);
|
|
|
|
int useSeedForMachine = deterministicRandom()->randomInt(0, testerCount);
|
2021-03-11 02:06:03 +08:00
|
|
|
for (int i = 0; i < testerCount; i++) {
|
2019-02-28 16:09:53 +08:00
|
|
|
std::vector<IPAddress> ips;
|
|
|
|
ips.push_back(makeIPAddressForSim(useIPv6, { 3, 4, 3, i + 1 }));
|
2019-05-11 05:01:52 +08:00
|
|
|
Standalone<StringRef> newZoneId = Standalone<StringRef>(deterministicRandom()->randomUniqueID().toString());
|
2021-03-11 02:06:03 +08:00
|
|
|
LocalityData localities(
|
|
|
|
Optional<Standalone<StringRef>>(), newZoneId, newZoneId, Optional<Standalone<StringRef>>());
|
|
|
|
systemActors->push_back(
|
|
|
|
reportErrors(simulatedMachine(conn,
|
|
|
|
ips,
|
2021-11-17 03:49:59 +08:00
|
|
|
sslEnabled,
|
2021-03-11 02:06:03 +08:00
|
|
|
localities,
|
|
|
|
ProcessClass(ProcessClass::TesterClass, ProcessClass::CommandLineSource),
|
|
|
|
baseFolder,
|
|
|
|
false,
|
|
|
|
i == useSeedForMachine,
|
|
|
|
AgentNone,
|
2021-11-17 03:49:59 +08:00
|
|
|
sslOnly,
|
2021-03-11 02:06:03 +08:00
|
|
|
whitelistBinPaths,
|
2021-08-07 12:19:53 +08:00
|
|
|
protocolVersion,
|
2021-08-07 14:18:10 +08:00
|
|
|
configDBType),
|
2021-03-11 02:06:03 +08:00
|
|
|
"SimulatedTesterMachine"));
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
2020-10-06 08:08:48 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
if (g_simulator.setDiffProtocol) {
|
2020-10-06 08:08:48 +08:00
|
|
|
--(*pTesterCount);
|
|
|
|
}
|
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
*pStartingConfiguration = startingConfigString;
|
|
|
|
|
|
|
|
// save some state that we only need when restarting the simulator.
|
|
|
|
g_simulator.connectionString = conn.toString();
|
|
|
|
g_simulator.testerCount = testerCount;
|
2021-09-22 07:49:55 +08:00
|
|
|
g_simulator.allowStorageMigrationTypeChange = gradualMigrationPossible;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
TraceEvent("SimulatedClusterStarted")
|
2021-03-11 02:06:03 +08:00
|
|
|
.detail("DataCenters", dataCenters)
|
|
|
|
.detail("ServerMachineCount", machineCount)
|
|
|
|
.detail("ProcessesPerServer", processesPerMachine)
|
|
|
|
.detail("SSLEnabled", sslEnabled)
|
|
|
|
.detail("SSLOnly", sslOnly)
|
|
|
|
.detail("ClassesAssigned", assignClasses)
|
2021-09-22 07:49:55 +08:00
|
|
|
.detail("GradualMigrationPossible", gradualMigrationPossible)
|
2021-03-11 02:06:03 +08:00
|
|
|
.detail("StartingConfiguration", pStartingConfiguration->toString());
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
2021-05-21 03:48:41 +08:00
|
|
|
using namespace std::literals;
|
2018-09-18 09:32:39 +08:00
|
|
|
|
2021-08-03 04:47:37 +08:00
|
|
|
#if defined(SSD_ROCKSDB_EXPERIMENTAL) && !VALGRIND
|
2021-07-17 00:51:38 +08:00
|
|
|
bool rocksDBEnabled = true;
|
|
|
|
#else
|
|
|
|
bool rocksDBEnabled = false;
|
|
|
|
#endif
|
|
|
|
|
2021-05-21 03:48:41 +08:00
|
|
|
// Populates the TestConfig fields according to what is found in the test file.
|
2021-10-29 03:42:24 +08:00
|
|
|
[[maybe_unused]] void checkTestConf(const char* testFile, TestConfig* testConfig) {}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-07-17 00:51:38 +08:00
|
|
|
} // namespace
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
ACTOR void setupAndRun(std::string dataFolder,
|
|
|
|
const char* testFile,
|
|
|
|
bool rebooting,
|
|
|
|
bool restoring,
|
|
|
|
std::string whitelistBinPaths) {
|
2021-09-17 08:42:34 +08:00
|
|
|
state std::vector<Future<Void>> systemActors;
|
2021-10-11 11:44:56 +08:00
|
|
|
state Optional<ClusterConnectionString> connectionString;
|
2017-05-26 04:48:44 +08:00
|
|
|
state Standalone<StringRef> startingConfiguration;
|
|
|
|
state int testerCount = 1;
|
2021-03-23 02:30:22 +08:00
|
|
|
state TestConfig testConfig;
|
2021-05-21 03:48:41 +08:00
|
|
|
testConfig.readFromConfig(testFile);
|
2021-03-23 02:30:22 +08:00
|
|
|
g_simulator.hasDiffProtocolProcess = testConfig.startIncompatibleProcess;
|
2020-10-06 08:08:48 +08:00
|
|
|
g_simulator.setDiffProtocol = false;
|
2020-10-27 06:59:18 +08:00
|
|
|
|
2021-07-17 00:51:38 +08:00
|
|
|
// The RocksDB storage engine does not support the restarting tests because you cannot consistently get a clean
|
|
|
|
// snapshot of the storage engine without a snapshotting file system.
|
|
|
|
// https://github.com/apple/foundationdb/issues/5155
|
|
|
|
if (std::string_view(testFile).find("restarting") != std::string_view::npos) {
|
|
|
|
testConfig.storageEngineExcludeTypes.push_back(4);
|
|
|
|
}
|
|
|
|
|
2021-09-02 23:38:23 +08:00
|
|
|
// TODO: Currently backup and restore related simulation tests are failing when run with rocksDB storage engine
|
|
|
|
// possibly due to running the rocksdb in single thread in simulation.
|
|
|
|
// Re-enable the backup and restore related simulation tests when the tests are passing again.
|
|
|
|
if (std::string_view(testFile).find("Backup") != std::string_view::npos) {
|
|
|
|
testConfig.storageEngineExcludeTypes.push_back(4);
|
|
|
|
}
|
|
|
|
|
2021-07-17 00:51:38 +08:00
|
|
|
// The RocksDB engine is not always built with the rest of fdbserver. Don't try to use it if it is not included
|
|
|
|
// in the build.
|
|
|
|
if (!rocksDBEnabled) {
|
|
|
|
testConfig.storageEngineExcludeTypes.push_back(4);
|
|
|
|
}
|
|
|
|
|
2020-10-27 06:59:18 +08:00
|
|
|
state ProtocolVersion protocolVersion = currentProtocolVersion;
|
2021-03-23 02:30:22 +08:00
|
|
|
if (testConfig.startIncompatibleProcess) {
|
2020-10-27 06:59:18 +08:00
|
|
|
// isolates right most 1 bit of compatibleProtocolVersionMask to make this protocolVersion incompatible
|
2021-03-11 02:06:03 +08:00
|
|
|
uint64_t minAddToMakeIncompatible =
|
|
|
|
ProtocolVersion::compatibleProtocolVersionMask & ~(ProtocolVersion::compatibleProtocolVersionMask - 1);
|
2020-10-27 06:59:18 +08:00
|
|
|
protocolVersion = ProtocolVersion(currentProtocolVersion.version() + minAddToMakeIncompatible);
|
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2019-02-28 16:09:53 +08:00
|
|
|
// TODO (IPv6) Use IPv6?
|
|
|
|
wait(g_simulator.onProcess(
|
2021-03-11 02:06:03 +08:00
|
|
|
g_simulator.newProcess("TestSystem",
|
|
|
|
IPAddress(0x01010101),
|
|
|
|
1,
|
|
|
|
false,
|
|
|
|
1,
|
2019-02-28 16:09:53 +08:00
|
|
|
LocalityData(Optional<Standalone<StringRef>>(),
|
2019-05-11 05:01:52 +08:00
|
|
|
Standalone<StringRef>(deterministicRandom()->randomUniqueID().toString()),
|
|
|
|
Standalone<StringRef>(deterministicRandom()->randomUniqueID().toString()),
|
2019-02-28 16:09:53 +08:00
|
|
|
Optional<Standalone<StringRef>>()),
|
2021-03-11 02:06:03 +08:00
|
|
|
ProcessClass(ProcessClass::TesterClass, ProcessClass::CommandLineSource),
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
currentProtocolVersion),
|
2019-06-25 17:47:35 +08:00
|
|
|
TaskPriority::DefaultYield));
|
2017-05-26 04:48:44 +08:00
|
|
|
Sim2FileSystem::newFileSystem();
|
2021-09-21 00:46:34 +08:00
|
|
|
FlowTransport::createInstance(true, 1, WLTOKEN_RESERVED_COUNT);
|
2021-03-11 02:06:03 +08:00
|
|
|
TEST(true); // Simulation start
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
try {
|
2021-03-11 02:06:03 +08:00
|
|
|
// systemActors.push_back( startSystemMonitor(dataFolder) );
|
2017-05-26 04:48:44 +08:00
|
|
|
if (rebooting) {
|
2021-03-11 02:06:03 +08:00
|
|
|
wait(timeoutError(restartSimulatedSystem(&systemActors,
|
|
|
|
dataFolder,
|
|
|
|
&testerCount,
|
2021-10-11 11:44:56 +08:00
|
|
|
&connectionString,
|
2021-03-11 02:06:03 +08:00
|
|
|
&startingConfiguration,
|
2021-03-23 02:30:22 +08:00
|
|
|
testConfig,
|
2021-03-11 02:06:03 +08:00
|
|
|
whitelistBinPaths,
|
|
|
|
protocolVersion),
|
|
|
|
100.0));
|
2019-04-03 20:47:19 +08:00
|
|
|
// FIXME: snapshot restore does not support multi-region restore, hence restore it as single region always
|
2019-03-26 09:31:08 +08:00
|
|
|
if (restoring) {
|
2019-04-13 04:23:02 +08:00
|
|
|
startingConfiguration = LiteralStringRef("usable_regions=1");
|
2019-03-26 09:31:08 +08:00
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
} else {
|
2017-05-26 04:48:44 +08:00
|
|
|
g_expect_full_pointermap = 1;
|
2021-03-11 02:06:03 +08:00
|
|
|
setupSimulatedSystem(&systemActors,
|
|
|
|
dataFolder,
|
|
|
|
&testerCount,
|
2021-10-11 11:44:56 +08:00
|
|
|
&connectionString,
|
2021-03-11 02:06:03 +08:00
|
|
|
&startingConfiguration,
|
|
|
|
whitelistBinPaths,
|
2021-03-23 02:30:22 +08:00
|
|
|
testConfig,
|
2021-03-11 02:06:03 +08:00
|
|
|
protocolVersion);
|
|
|
|
wait(delay(1.0)); // FIXME: WHY!!! //wait for machines to boot
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
std::string clusterFileDir = joinPath(dataFolder, deterministicRandom()->randomUniqueID().toString());
|
|
|
|
platform::createDirectory(clusterFileDir);
|
2021-10-11 11:44:56 +08:00
|
|
|
writeFile(joinPath(clusterFileDir, "fdb.cluster"), connectionString.get().toString());
|
2020-11-07 15:50:55 +08:00
|
|
|
wait(timeoutError(runTests(makeReference<ClusterConnectionFile>(joinPath(clusterFileDir, "fdb.cluster")),
|
2021-03-11 02:06:03 +08:00
|
|
|
TEST_TYPE_FROM_FILE,
|
|
|
|
TEST_ON_TESTERS,
|
|
|
|
testerCount,
|
|
|
|
testFile,
|
|
|
|
startingConfiguration),
|
2020-11-07 15:50:55 +08:00
|
|
|
isBuggifyEnabled(BuggifyType::General) ? 36000.0 : 5400.0));
|
2017-05-26 04:48:44 +08:00
|
|
|
} catch (Error& e) {
|
2018-06-09 04:57:00 +08:00
|
|
|
TraceEvent(SevError, "SetupAndRunError").error(e);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
2021-07-27 10:55:10 +08:00
|
|
|
TraceEvent("SimulatedSystemDestruct").log();
|
2019-06-26 07:25:42 +08:00
|
|
|
g_simulator.stop();
|
2017-05-26 04:48:44 +08:00
|
|
|
destructed = true;
|
2019-07-10 05:01:05 +08:00
|
|
|
wait(Never());
|
|
|
|
ASSERT(false);
|
2021-10-31 12:07:38 +08:00
|
|
|
}
|