Skip to content

Commit d6dbed8

Browse files
Enable encryption in BackupAndParallelRestoreCorrectness workload
1 parent 99a5193 commit d6dbed8

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

fdbserver/workloads/BackupAndParallelRestoreCorrectness.actor.cpp

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "fdbrpc/simulator.h"
2222
#include "fdbclient/BackupAgent.actor.h"
2323
#include "fdbclient/BackupContainer.h"
24+
#include "fdbclient/BackupContainerFileSystem.h"
2425
#include "fdbclient/ManagementAPI.actor.h"
2526
#include "fdbserver/RestoreWorkerInterface.actor.h"
2627
#include "fdbclient/RunRYWTransaction.actor.h"
@@ -47,6 +48,7 @@ struct BackupAndParallelRestoreCorrectnessWorkload : TestWorkload {
4748
UsePartitionedLog usePartitionedLogs{ false };
4849
Key addPrefix, removePrefix; // Original key will be first applied removePrefix and then applied addPrefix
4950
// CAVEAT: When removePrefix is used, we must ensure every key in backup have the removePrefix
51+
Optional<std::string> encryptionKeyFileName;
5052

5153
std::map<Standalone<KeyRef>, Standalone<ValueRef>> dbKVs;
5254

@@ -85,6 +87,10 @@ struct BackupAndParallelRestoreCorrectnessWorkload : TestWorkload {
8587
addPrefix = getOption(options, "addPrefix"_sr, ""_sr);
8688
removePrefix = getOption(options, "removePrefix"_sr, ""_sr);
8789

90+
if (getOption(options, "encrypted"_sr, true)) {
91+
encryptionKeyFileName = "simfdb/" + getTestEncryptionFileName();
92+
}
93+
8894
KeyRef beginRange;
8995
KeyRef endRange;
9096
UID randomID = nondeterministicRandom()->randomUniqueID();
@@ -159,6 +165,7 @@ struct BackupAndParallelRestoreCorrectnessWorkload : TestWorkload {
159165
TraceEvent(SevInfo, "BARW_Param").detail("DifferentialBackup", differentialBackup);
160166
TraceEvent(SevInfo, "BARW_Param").detail("StopDifferentialAfter", stopDifferentialAfter);
161167
TraceEvent(SevInfo, "BARW_Param").detail("AgentRequest", agentRequest);
168+
TraceEvent(SevInfo, "BARW_Param").detail("Encrypted", encryptionKeyFileName.present());
162169

163170
return _start(cx, this);
164171
}
@@ -230,7 +237,9 @@ struct BackupAndParallelRestoreCorrectnessWorkload : TestWorkload {
230237
backupRanges,
231238
true,
232239
StopWhenDone{ !stopDifferentialDelay },
233-
self->usePartitionedLogs));
240+
self->usePartitionedLogs,
241+
IncrementalBackupOnly::False,
242+
self->encryptionKeyFileName));
234243
} catch (Error& e) {
235244
TraceEvent("BARW_DoBackupSubmitBackupException", randomID).error(e).detail("Tag", printable(tag));
236245
if (e.code() != error_code_backup_unneeded && e.code() != error_code_backup_duplicate)
@@ -388,7 +397,11 @@ struct BackupAndParallelRestoreCorrectnessWorkload : TestWorkload {
388397
normalKeys,
389398
Key(),
390399
Key(),
391-
self->locked)));
400+
self->locked,
401+
OnlyApplyMutationLogs::False,
402+
InconsistentSnapshotOnly::False,
403+
::invalidVersion,
404+
self->encryptionKeyFileName)));
392405
TraceEvent(SevError, "BARW_RestoreAllowedOverwrittingDatabase", randomID).log();
393406
ASSERT(false);
394407
} catch (Error& e) {
@@ -425,6 +438,10 @@ struct BackupAndParallelRestoreCorrectnessWorkload : TestWorkload {
425438
BackupAndParallelRestoreCorrectnessWorkload::backupAgentRequests++;
426439
}
427440

441+
if (self->encryptionKeyFileName.present()) {
442+
wait(BackupContainerFileSystem::createTestEncryptionKeyFile(self->encryptionKeyFileName.get()));
443+
}
444+
428445
try {
429446
state Future<Void> startRestore = delay(self->restoreAfter);
430447

@@ -489,7 +506,9 @@ struct BackupAndParallelRestoreCorrectnessWorkload : TestWorkload {
489506
self->backupRanges,
490507
true,
491508
StopWhenDone::True,
492-
UsePartitionedLog::False);
509+
UsePartitionedLog::False,
510+
IncrementalBackupOnly::False,
511+
self->encryptionKeyFileName);
493512
} catch (Error& e) {
494513
TraceEvent("BARW_SubmitBackup2Exception", randomID)
495514
.error(e)
@@ -529,8 +548,9 @@ struct BackupAndParallelRestoreCorrectnessWorkload : TestWorkload {
529548
.detail("BackupTag", printable(self->backupTag));
530549
// start restoring
531550

532-
auto container =
533-
IBackupContainer::openContainer(lastBackupContainer->getURL(), lastBackupContainer->getProxy(), {});
551+
auto container = IBackupContainer::openContainer(lastBackupContainer->getURL(),
552+
lastBackupContainer->getProxy(),
553+
lastBackupContainer->getEncryptionKeyFileName());
534554
BackupDescription desc = wait(container->describeBackup());
535555
ASSERT(self->usePartitionedLogs == desc.partitioned);
536556
ASSERT(desc.minRestorableVersion.present()); // We must have a valid backup now.

0 commit comments

Comments
 (0)