Ignore test encryption file when re-running simulation test

This commit is contained in:
sfc-gh-tclinkenbeard 2022-08-25 16:40:05 -07:00
parent a27ee0f18a
commit bad14b67fb
3 changed files with 33 additions and 12 deletions

View File

@ -1836,6 +1836,30 @@ private:
localities.set(LocalityData::keyDcId, dcId);
}
};
// Returns true iff validation is successful
bool validateSimulationDataFiles(std::string const& dataFolder, bool isRestarting) {
std::vector<std::string> files = platform::listFiles(dataFolder);
if (!isRestarting) {
for (const auto& file : files) {
if (file != "restartInfo.ini" && file != getTestEncryptionFileName()) {
TraceEvent(SevError, "IncompatibleFileFound").detail("DataFolder", dataFolder).detail("FileName", file);
fprintf(stderr,
"ERROR: Data folder `%s' is non-empty; please use clean, fdb-only folder\n",
dataFolder.c_str());
return false;
}
}
} else if (isRestarting && files.empty()) {
TraceEvent(SevWarnAlways, "FileNotFound").detail("DataFolder", dataFolder);
printf("ERROR: Data folder `%s' is empty, but restarting option selected. Run Phase 1 test first\n",
dataFolder.c_str());
return false;
}
return true;
}
} // namespace
int main(int argc, char* argv[]) {
@ -2082,17 +2106,8 @@ int main(int argc, char* argv[]) {
flushAndExit(FDB_EXIT_ERROR);
}
}
std::vector<std::string> files = platform::listFiles(dataFolder);
if ((files.size() > 1 || (files.size() == 1 && files[0] != "restartInfo.ini")) && !opts.restarting) {
TraceEvent(SevError, "IncompatibleFileFound").detail("DataFolder", dataFolder);
fprintf(stderr,
"ERROR: Data folder `%s' is non-empty; please use clean, fdb-only folder\n",
dataFolder.c_str());
flushAndExit(FDB_EXIT_ERROR);
} else if (files.empty() && opts.restarting) {
TraceEvent(SevWarnAlways, "FileNotFound").detail("DataFolder", dataFolder);
printf("ERROR: Data folder `%s' is empty, but restarting option selected. Run Phase 1 test first\n",
dataFolder.c_str());
if (!validateSimulationDataFiles(dataFolder, opts.restarting)) {
flushAndExit(FDB_EXIT_ERROR);
}

View File

@ -296,6 +296,8 @@ Future<Void> testExpectedError(Future<Void> test,
Optional<Error> throwOnError = Optional<Error>(),
UID id = UID());
std::string getTestEncryptionFileName();
#include "flow/unactorcompiler.h"
#endif

View File

@ -73,7 +73,7 @@ struct BackupAndRestoreCorrectnessWorkload : TestWorkload {
restorePrefixesToInclude = getOption(options, "restorePrefixesToInclude"_sr, std::vector<std::string>());
shouldSkipRestoreRanges = deterministicRandom()->random01() < 0.3 ? true : false;
if (getOption(options, "encrypted"_sr, deterministicRandom()->random01() < 0.1)) {
encryptionKeyFileName = "simfdb/test_encryption_key_file";
encryptionKeyFileName = "simfdb/" + getTestEncryptionFileName();
}
TraceEvent("BARW_ClientId").detail("Id", wcx.clientId);
@ -883,5 +883,9 @@ struct BackupAndRestoreCorrectnessWorkload : TestWorkload {
int BackupAndRestoreCorrectnessWorkload::backupAgentRequests = 0;
std::string getTestEncryptionFileName() {
return "test_encryption_key_file";
}
WorkloadFactory<BackupAndRestoreCorrectnessWorkload> BackupAndRestoreCorrectnessWorkloadFactory(
"BackupAndRestoreCorrectness");