21
21
#include " fdbrpc/simulator.h"
22
22
#include " fdbclient/BackupAgent.actor.h"
23
23
#include " fdbclient/BackupContainer.h"
24
+ #include " fdbclient/BackupContainerFileSystem.h"
24
25
#include " fdbclient/ManagementAPI.actor.h"
25
26
#include " fdbserver/RestoreWorkerInterface.actor.h"
26
27
#include " fdbclient/RunRYWTransaction.actor.h"
@@ -47,6 +48,7 @@ struct BackupAndParallelRestoreCorrectnessWorkload : TestWorkload {
47
48
UsePartitionedLog usePartitionedLogs{ false };
48
49
Key addPrefix, removePrefix; // Original key will be first applied removePrefix and then applied addPrefix
49
50
// CAVEAT: When removePrefix is used, we must ensure every key in backup have the removePrefix
51
+ Optional<std::string> encryptionKeyFileName;
50
52
51
53
std::map<Standalone<KeyRef>, Standalone<ValueRef>> dbKVs;
52
54
@@ -85,6 +87,10 @@ struct BackupAndParallelRestoreCorrectnessWorkload : TestWorkload {
85
87
addPrefix = getOption (options, " addPrefix" _sr, " " _sr);
86
88
removePrefix = getOption (options, " removePrefix" _sr, " " _sr);
87
89
90
+ if (getOption (options, " encrypted" _sr, true )) {
91
+ encryptionKeyFileName = " simfdb/" + getTestEncryptionFileName ();
92
+ }
93
+
88
94
KeyRef beginRange;
89
95
KeyRef endRange;
90
96
UID randomID = nondeterministicRandom ()->randomUniqueID ();
@@ -159,6 +165,7 @@ struct BackupAndParallelRestoreCorrectnessWorkload : TestWorkload {
159
165
TraceEvent (SevInfo, " BARW_Param" ).detail (" DifferentialBackup" , differentialBackup);
160
166
TraceEvent (SevInfo, " BARW_Param" ).detail (" StopDifferentialAfter" , stopDifferentialAfter);
161
167
TraceEvent (SevInfo, " BARW_Param" ).detail (" AgentRequest" , agentRequest);
168
+ TraceEvent (SevInfo, " BARW_Param" ).detail (" Encrypted" , encryptionKeyFileName.present ());
162
169
163
170
return _start (cx, this );
164
171
}
@@ -230,7 +237,9 @@ struct BackupAndParallelRestoreCorrectnessWorkload : TestWorkload {
230
237
backupRanges,
231
238
true ,
232
239
StopWhenDone{ !stopDifferentialDelay },
233
- self->usePartitionedLogs ));
240
+ self->usePartitionedLogs ,
241
+ IncrementalBackupOnly::False,
242
+ self->encryptionKeyFileName ));
234
243
} catch (Error& e) {
235
244
TraceEvent (" BARW_DoBackupSubmitBackupException" , randomID).error (e).detail (" Tag" , printable (tag));
236
245
if (e.code () != error_code_backup_unneeded && e.code () != error_code_backup_duplicate)
@@ -388,7 +397,11 @@ struct BackupAndParallelRestoreCorrectnessWorkload : TestWorkload {
388
397
normalKeys,
389
398
Key (),
390
399
Key (),
391
- self->locked )));
400
+ self->locked ,
401
+ OnlyApplyMutationLogs::False,
402
+ InconsistentSnapshotOnly::False,
403
+ ::invalidVersion,
404
+ self->encryptionKeyFileName )));
392
405
TraceEvent (SevError, " BARW_RestoreAllowedOverwrittingDatabase" , randomID).log ();
393
406
ASSERT (false );
394
407
} catch (Error& e) {
@@ -425,6 +438,10 @@ struct BackupAndParallelRestoreCorrectnessWorkload : TestWorkload {
425
438
BackupAndParallelRestoreCorrectnessWorkload::backupAgentRequests++;
426
439
}
427
440
441
+ if (self->encryptionKeyFileName .present ()) {
442
+ wait (BackupContainerFileSystem::createTestEncryptionKeyFile (self->encryptionKeyFileName .get ()));
443
+ }
444
+
428
445
try {
429
446
state Future<Void> startRestore = delay (self->restoreAfter );
430
447
@@ -489,7 +506,9 @@ struct BackupAndParallelRestoreCorrectnessWorkload : TestWorkload {
489
506
self->backupRanges ,
490
507
true ,
491
508
StopWhenDone::True,
492
- UsePartitionedLog::False);
509
+ UsePartitionedLog::False,
510
+ IncrementalBackupOnly::False,
511
+ self->encryptionKeyFileName );
493
512
} catch (Error& e) {
494
513
TraceEvent (" BARW_SubmitBackup2Exception" , randomID)
495
514
.error (e)
@@ -529,8 +548,9 @@ struct BackupAndParallelRestoreCorrectnessWorkload : TestWorkload {
529
548
.detail (" BackupTag" , printable (self->backupTag ));
530
549
// start restoring
531
550
532
- auto container =
533
- IBackupContainer::openContainer (lastBackupContainer->getURL (), lastBackupContainer->getProxy (), {});
551
+ auto container = IBackupContainer::openContainer (lastBackupContainer->getURL (),
552
+ lastBackupContainer->getProxy (),
553
+ lastBackupContainer->getEncryptionKeyFileName ());
534
554
BackupDescription desc = wait (container->describeBackup ());
535
555
ASSERT (self->usePartitionedLogs == desc.partitioned );
536
556
ASSERT (desc.minRestorableVersion .present ()); // We must have a valid backup now.
0 commit comments