'--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)
set(test_type "test")
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)
string(REGEX REPLACE "^(.*)\\.txt$" "\\1" test_name ${first_file})
if("${test_name}" MATCHES "(-\\d)$")
@ -121,7 +117,6 @@ function(add_fdb_test)
--log-format ${TEST_LOG_FORMAT}
--keep-logs ${TEST_KEEP_LOGS}
--keep-simdirs ${TEST_KEEP_SIMDIR}
--restoring ${TEST_RESTORING}
--seed ${SEED}
--test-number ${assigned_id}
${BUGGIFY_OPTION}

View File

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

View File

@ -34,12 +34,14 @@ struct SaveAndKillWorkload : TestWorkload {
std::string restartInfo;
double testDuration;
int isRestoring;
SaveAndKillWorkload(WorkloadContext const& wcx)
: TestWorkload(wcx)
{
restartInfo = getOption( options, LiteralStringRef("restartInfoLocation"), LiteralStringRef("simfdb/restartInfo.ini") ).toString();
testDuration = getOption( options, LiteralStringRef("testDuration"), 10.0 );
isRestoring = getOption( options, LiteralStringRef("isRestoring"), 0 );
}
virtual std::string description() { return "SaveAndKillWorkload"; }
@ -59,6 +61,7 @@ struct SaveAndKillWorkload : TestWorkload {
ini.SetUnicode();
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", "listenersPerProcess", format("%d", g_simulator.listenersPerProcess).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)
add_fdb_test(
TEST_FILES restarting/SnapTestSimpleRestart-1.txt
restarting/SnapTestSimpleRestart-2.txt
RESTORE)
restarting/SnapTestSimpleRestart-2.txt)
add_fdb_test(
TEST_FILES restarting/SnapTestRestart-1.txt
restarting/SnapTestRestart-2.txt
RESTORE)
restarting/SnapTestRestart-2.txt)
add_fdb_test(
TEST_FILES restarting/SnapCycleRestart-1.txt
restarting/SnapCycleRestart-2.txt
RESTORE)
restarting/SnapCycleRestart-2.txt)
add_fdb_test(
TEST_FILES restarting/SnapTestAttrition-1.txt
restarting/SnapTestAttrition-2.txt
RESTORE)
restarting/SnapTestAttrition-2.txt)
add_fdb_test(
TEST_FILES restarting/from_5.1.7/DrUpgradeRestart-1.txt
restarting/from_5.1.7/DrUpgradeRestart-2.txt IGNORE)

View File

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

View File

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

View File

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

View File

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