From 45c8f2dfcb87738f9f04e24a6f9ada1b95ad1c3e Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Fri, 2 Nov 2018 14:16:47 -0700 Subject: [PATCH] restarting tests will sometimes configure to a fearless configuration on startup if possible --- fdbserver/SimulatedCluster.actor.cpp | 39 +++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/fdbserver/SimulatedCluster.actor.cpp b/fdbserver/SimulatedCluster.actor.cpp index f7695043a0..38325b0249 100644 --- a/fdbserver/SimulatedCluster.actor.cpp +++ b/fdbserver/SimulatedCluster.actor.cpp @@ -597,7 +597,7 @@ ACTOR Future simulatedMachine( ACTOR Future restartSimulatedSystem( vector> *systemActors, std::string baseFolder, int* pTesterCount, - Optional *pConnString, Reference tlsOptions, int extraDB) { + Optional *pConnString, Standalone *pStartingConfiguration, Reference tlsOptions, int extraDB) { CSimpleIni ini; ini.SetUnicode(); ini.LoadFile(joinPath(baseFolder, "restartInfo.ini").c_str()); @@ -619,13 +619,20 @@ ACTOR Future restartSimulatedSystem( *pTesterCount = testerCount; bool usingSSL = conn.toString().find(":tls") != std::string::npos; int useSeedForMachine = g_random->randomInt(0, machineCount); + std::vector dcIds; for( int i = 0; i < machineCount; i++) { Optional> dcUID; std::string zoneIdString = ini.GetValue("META", format("%d", i).c_str()); Standalone zoneId = StringRef(zoneIdString); std::string dcUIDini = ini.GetValue(zoneIdString.c_str(), "dcUID"); - if (!dcUIDini.empty()) dcUID = StringRef(dcUIDini); + + if (!dcUIDini.empty()) { + dcUID = StringRef(dcUIDini); + } ProcessClass processClass = ProcessClass((ProcessClass::ClassType)atoi(ini.GetValue(zoneIdString.c_str(), "mClass")), ProcessClass::CommandLineSource); + if(processClass != ProcessClass::TesterClass) { + dcIds.push_back(dcUIDini); + } std::vector ipAddrs; int processes = atoi(ini.GetValue(zoneIdString.c_str(), "processes")); @@ -656,6 +663,32 @@ ACTOR Future restartSimulatedSystem( g_simulator.desiredCoordinators = desiredCoordinators; g_simulator.processesPerMachine = processesPerMachine; + + uniquify(dcIds); + if(!BUGGIFY && dcIds.size() == 2 && dcIds[0] != "" && dcIds[1] != "") { + 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); + + *pStartingConfiguration = "single usable_regions=2 regions=" + json_spirit::write_string(json_spirit::mValue(regionArr), json_spirit::Output_options::none); + } } catch (Error& e) { TraceEvent(SevError, "RestartSimulationError").error(e); @@ -1259,7 +1292,7 @@ ACTOR void setupAndRun(std::string dataFolder, const char *testFile, bool reboot try { //systemActors.push_back( startSystemMonitor(dataFolder) ); if (rebooting) { - Void _ = wait( timeoutError( restartSimulatedSystem( &systemActors, dataFolder, &testerCount, &connFile, tlsOptions, extraDB), 100.0 ) ); + Void _ = wait( timeoutError( restartSimulatedSystem( &systemActors, dataFolder, &testerCount, &connFile, &startingConfiguration, tlsOptions, extraDB), 100.0 ) ); } else { g_expect_full_pointermap = 1;