'--restoring' cmd line arg removed for fdbserver

'--restoring' command line option was introduced to indicate
simulated fdbserver to restore from snapshot and restart the cluster.
As part of this change that option is removed and restore
information is stored in the restartInfo.ini.
This commit is contained in:
sramamoorthy 2019-03-20 16:51:14 -07:00 committed by Alex Miller
parent 6431513ad0
commit 281c785f94
8 changed files with 61 additions and 67 deletions

View File

@ -75,10 +75,6 @@ function(add_fdb_test)
if(ADD_FDB_TEST_UNIT) if(ADD_FDB_TEST_UNIT)
set(test_type "test") set(test_type "test")
endif() endif()
set(TEST_RESTORING "NO")
if (ADD_FDB_TEST_RESTORE)
set(TEST_RESTORING "YES")
endif()
list(GET ADD_FDB_TEST_TEST_FILES 0 first_file) list(GET ADD_FDB_TEST_TEST_FILES 0 first_file)
string(REGEX REPLACE "^(.*)\\.txt$" "\\1" test_name ${first_file}) string(REGEX REPLACE "^(.*)\\.txt$" "\\1" test_name ${first_file})
if("${test_name}" MATCHES "(-\\d)$") if("${test_name}" MATCHES "(-\\d)$")
@ -121,7 +117,6 @@ function(add_fdb_test)
--log-format ${TEST_LOG_FORMAT} --log-format ${TEST_LOG_FORMAT}
--keep-logs ${TEST_KEEP_LOGS} --keep-logs ${TEST_KEEP_LOGS}
--keep-simdirs ${TEST_KEEP_SIMDIR} --keep-simdirs ${TEST_KEEP_SIMDIR}
--restoring ${TEST_RESTORING}
--seed ${SEED} --seed ${SEED}
--test-number ${assigned_id} --test-number ${assigned_id}
${BUGGIFY_OPTION} ${BUGGIFY_OPTION}

View File

@ -120,7 +120,6 @@ CSimpleOpt::SOption g_rgOptions[] = {
{ OPT_TESTFILE, "--testfile", SO_REQ_SEP }, { OPT_TESTFILE, "--testfile", SO_REQ_SEP },
{ OPT_RESTARTING, "-R", SO_NONE }, { OPT_RESTARTING, "-R", SO_NONE },
{ OPT_RESTARTING, "--restarting", SO_NONE }, { OPT_RESTARTING, "--restarting", SO_NONE },
{ OPT_RESTORING, "--restoring", SO_NONE },
{ OPT_RANDOMSEED, "-s", SO_REQ_SEP }, { OPT_RANDOMSEED, "-s", SO_REQ_SEP },
{ OPT_RANDOMSEED, "--seed", SO_REQ_SEP }, { OPT_RANDOMSEED, "--seed", SO_REQ_SEP },
{ OPT_KEY, "-k", SO_REQ_SEP }, { OPT_KEY, "-k", SO_REQ_SEP },
@ -935,7 +934,7 @@ int main(int argc, char* argv[]) {
LocalityData localities; LocalityData localities;
int minTesterCount = 1; int minTesterCount = 1;
bool testOnServers = false; bool testOnServers = false;
bool restoring = false; bool isRestoring = false;
Reference<TLSOptions> tlsOptions = Reference<TLSOptions>( new TLSOptions ); Reference<TLSOptions> tlsOptions = Reference<TLSOptions>( new TLSOptions );
std::string tlsCertPath, tlsKeyPath, tlsCAPath, tlsPassword; std::string tlsCertPath, tlsKeyPath, tlsCAPath, tlsPassword;
@ -1197,10 +1196,6 @@ int main(int argc, char* argv[]) {
case OPT_RESTARTING: case OPT_RESTARTING:
restarting = true; restarting = true;
break; break;
case OPT_RESTORING: {
restoring = true;
break;
}
case OPT_RANDOMSEED: { case OPT_RANDOMSEED: {
char* end; char* end;
randomSeed = (uint32_t)strtoul( args.OptionArg(), &end, 0 ); randomSeed = (uint32_t)strtoul( args.OptionArg(), &end, 0 );
@ -1670,64 +1665,66 @@ int main(int argc, char* argv[]) {
if (!restarting) { if (!restarting) {
platform::eraseDirectoryRecursive( dataFolder ); platform::eraseDirectoryRecursive( dataFolder );
platform::createDirectory( dataFolder ); platform::createDirectory( dataFolder );
} else if (restoring) { } else {
std::vector<std::string> returnList;
std::string ext = "";
std::string tmpFolder = abspath(dataFolder);
returnList = platform::listDirectories(tmpFolder);
TraceEvent("RestoringDataFolder").detail("DataFolder", tmpFolder);
CSimpleIni ini; CSimpleIni ini;
ini.SetUnicode(); ini.SetUnicode();
std::string tmpFolder = abspath(dataFolder);
ini.LoadFile(joinPath(tmpFolder, "restartInfo.ini").c_str()); ini.LoadFile(joinPath(tmpFolder, "restartInfo.ini").c_str());
std::string snapStr = ini.GetValue("RESTORE", "RestoreSnapUID"); int isRestoring = atoi(ini.GetValue("RESTORE", "isRestoring"));
TraceEvent("RestoreSnapUID").detail("UID", snapStr); if (isRestoring) {
std::vector<std::string> returnList;
std::string ext = "";
returnList = platform::listDirectories(tmpFolder);
std::string snapStr = ini.GetValue("RESTORE", "RestoreSnapUID");
// delete all files (except fdb.cluster) in non-snap directories TraceEvent("RestoringDataFolder").detail("DataFolder", tmpFolder);
for (int i = 0; i < returnList.size(); i++) { TraceEvent("RestoreSnapUID").detail("UID", snapStr);
if (returnList[i] == "." || returnList[i] == "..") {
continue;
}
if (returnList[i].find(snapStr) != std::string::npos) {
continue;
}
std::string childf = tmpFolder + "/" + returnList[i]; // delete all files (except fdb.cluster) in non-snap directories
std::vector<std::string> returnFiles = platform::listFiles(childf, ext); for (int i = 0; i < returnList.size(); i++) {
for (int j = 0; j < returnFiles.size(); j++) { if (returnList[i] == "." || returnList[i] == "..") {
fprintf(stderr, "file : %s\n", returnFiles[j].c_str()); continue;
if (returnFiles[j] != "fdb.cluster") { }
TraceEvent("DeletingNonSnapfiles") if (returnList[i].find(snapStr) != std::string::npos) {
.detail("FileBeingDeleted", childf + "/" + returnFiles[j]); continue;
deleteFile(childf + "/" + returnFiles[j]); }
std::string childf = tmpFolder + "/" + returnList[i];
std::vector<std::string> returnFiles = platform::listFiles(childf, ext);
for (int j = 0; j < returnFiles.size(); j++) {
fprintf(stderr, "file : %s\n", returnFiles[j].c_str());
if (returnFiles[j] != "fdb.cluster") {
TraceEvent("DeletingNonSnapfiles")
.detail("FileBeingDeleted", childf + "/" + returnFiles[j]);
deleteFile(childf + "/" + returnFiles[j]);
}
} }
} }
} // move the contents from snap folder to the original folder,
// move the contents from snap folder to the original folder, // delete snap folders
// delete snap folders for (int i = 0; i < returnList.size(); i++) {
for (int i = 0; i < returnList.size(); i++) { fprintf(stderr, "Dir : %s\n", returnList[i].c_str());
fprintf(stderr, "Dir : %s\n", returnList[i].c_str()); if (returnList[i] == "." || returnList[i] == "..") {
if (returnList[i] == "." || returnList[i] == "..") { continue;
continue;
}
if (returnList[i].find(snapStr) == std::string::npos) {
if (returnList[i].find("snap") != std::string::npos) {
platform::eraseDirectoryRecursive(tmpFolder + returnList[i]);
} }
continue; if (returnList[i].find(snapStr) == std::string::npos) {
if (returnList[i].find("snap") != std::string::npos) {
platform::eraseDirectoryRecursive(tmpFolder + returnList[i]);
}
continue;
}
std::string origDir = returnList[i].substr(0, 32);
std::string dirToRemove = tmpFolder + "/" + origDir;
std::string dirSrc = tmpFolder + "/" + returnList[i];
TraceEvent("DeletingOriginalNonSnapDirectory").detail("FileBeingDeleted", dirToRemove);
platform::eraseDirectoryRecursive(dirToRemove);
renameFile(dirSrc, dirToRemove);
TraceEvent("RenamingSnapToOriginalDirectory")
.detail("Oldname", dirSrc)
.detail("Newname", dirToRemove);
} }
std::string origDir = returnList[i].substr(0, 32);
std::string dirToRemove = tmpFolder + "/" + origDir;
std::string dirSrc = tmpFolder + "/" + returnList[i];
TraceEvent("DeletingOriginalNonSnapDirectory").detail("FileBeingDeleted", dirToRemove);
platform::eraseDirectoryRecursive(dirToRemove);
renameFile(dirSrc, dirToRemove);
TraceEvent("RenamingSnapToOriginalDirectory")
.detail("Oldname", dirSrc)
.detail("Newname", dirToRemove);
} }
} }
setupAndRun( dataFolder, testFile, restarting, tlsOptions ); setupAndRun( dataFolder, testFile, restarting, tlsOptions );
g_simulator.run(); g_simulator.run();
} else if (role == FDBD) { } else if (role == FDBD) {

View File

@ -34,12 +34,14 @@ struct SaveAndKillWorkload : TestWorkload {
std::string restartInfo; std::string restartInfo;
double testDuration; double testDuration;
int isRestoring;
SaveAndKillWorkload(WorkloadContext const& wcx) SaveAndKillWorkload(WorkloadContext const& wcx)
: TestWorkload(wcx) : TestWorkload(wcx)
{ {
restartInfo = getOption( options, LiteralStringRef("restartInfoLocation"), LiteralStringRef("simfdb/restartInfo.ini") ).toString(); restartInfo = getOption( options, LiteralStringRef("restartInfoLocation"), LiteralStringRef("simfdb/restartInfo.ini") ).toString();
testDuration = getOption( options, LiteralStringRef("testDuration"), 10.0 ); testDuration = getOption( options, LiteralStringRef("testDuration"), 10.0 );
isRestoring = getOption( options, LiteralStringRef("isRestoring"), 0 );
} }
virtual std::string description() { return "SaveAndKillWorkload"; } virtual std::string description() { return "SaveAndKillWorkload"; }
@ -59,6 +61,7 @@ struct SaveAndKillWorkload : TestWorkload {
ini.SetUnicode(); ini.SetUnicode();
ini.LoadFile(self->restartInfo.c_str()); ini.LoadFile(self->restartInfo.c_str());
ini.SetValue("RESTORE", "isRestoring", format("%d", self->isRestoring).c_str());
ini.SetValue("META", "processesPerMachine", format("%d", g_simulator.processesPerMachine).c_str()); ini.SetValue("META", "processesPerMachine", format("%d", g_simulator.processesPerMachine).c_str());
ini.SetValue("META", "listenersPerProcess", format("%d", g_simulator.listenersPerProcess).c_str()); ini.SetValue("META", "listenersPerProcess", format("%d", g_simulator.listenersPerProcess).c_str());
ini.SetValue("META", "desiredCoordinators", format("%d", g_simulator.desiredCoordinators).c_str()); ini.SetValue("META", "desiredCoordinators", format("%d", g_simulator.desiredCoordinators).c_str());

View File

@ -142,20 +142,16 @@ add_fdb_test(
restarting/StorefrontTestRestart-2.txt) restarting/StorefrontTestRestart-2.txt)
add_fdb_test( add_fdb_test(
TEST_FILES restarting/SnapTestSimpleRestart-1.txt TEST_FILES restarting/SnapTestSimpleRestart-1.txt
restarting/SnapTestSimpleRestart-2.txt restarting/SnapTestSimpleRestart-2.txt)
RESTORE)
add_fdb_test( add_fdb_test(
TEST_FILES restarting/SnapTestRestart-1.txt TEST_FILES restarting/SnapTestRestart-1.txt
restarting/SnapTestRestart-2.txt restarting/SnapTestRestart-2.txt)
RESTORE)
add_fdb_test( add_fdb_test(
TEST_FILES restarting/SnapCycleRestart-1.txt TEST_FILES restarting/SnapCycleRestart-1.txt
restarting/SnapCycleRestart-2.txt restarting/SnapCycleRestart-2.txt)
RESTORE)
add_fdb_test( add_fdb_test(
TEST_FILES restarting/SnapTestAttrition-1.txt TEST_FILES restarting/SnapTestAttrition-1.txt
restarting/SnapTestAttrition-2.txt restarting/SnapTestAttrition-2.txt)
RESTORE)
add_fdb_test( add_fdb_test(
TEST_FILES restarting/from_5.1.7/DrUpgradeRestart-1.txt TEST_FILES restarting/from_5.1.7/DrUpgradeRestart-1.txt
restarting/from_5.1.7/DrUpgradeRestart-2.txt IGNORE) restarting/from_5.1.7/DrUpgradeRestart-2.txt IGNORE)

View File

@ -20,3 +20,4 @@ testTitle=SnapCycleShutdown
testName=SaveAndKill testName=SaveAndKill
restartInfoLocation=simfdb/restartInfo.ini restartInfoLocation=simfdb/restartInfo.ini
testDuration=10.0 testDuration=10.0
isRestoring=1

View File

@ -49,3 +49,4 @@ testTitle=SnapSimpleShutdown
testName=SaveAndKill testName=SaveAndKill
restartInfoLocation=simfdb/restartInfo.ini restartInfoLocation=simfdb/restartInfo.ini
testDuration=10.0 testDuration=10.0
isRestoring=1

View File

@ -46,3 +46,4 @@ testTitle=SnapTestShutdown
testName=SaveAndKill testName=SaveAndKill
restartInfoLocation=simfdb/restartInfo.ini restartInfoLocation=simfdb/restartInfo.ini
testDuration=10.0 testDuration=10.0
isRestoring=1

View File

@ -30,7 +30,7 @@ testTitle=SnapSimplePost
; save and shutdown ; save and shutdown
testTitle=SnapSimpleShutdown testTitle=SnapSimpleShutdown
testName=SaveAndKill testName=SaveAndKill
restartInfoLocation=simfdb/restartInfo.ini restartInfoLocation=simfdb/restartInfo.ini
testDuration=10.0 testDuration=10.0
isRestoring=1