35
35
import com .apple .foundationdb .record .lucene .directory .FDBDirectoryLockFactory ;
36
36
import com .apple .foundationdb .record .lucene .directory .FDBDirectoryWrapper ;
37
37
import com .apple .foundationdb .record .metadata .Index ;
38
+ import com .apple .foundationdb .record .provider .common .RollingTestKeyManager ;
38
39
import com .apple .foundationdb .record .provider .common .StoreTimer ;
39
40
import com .apple .foundationdb .record .provider .foundationdb .FDBExceptions ;
40
41
import com .apple .foundationdb .record .provider .foundationdb .FDBRecordContext ;
70
71
import javax .annotation .Nonnull ;
71
72
import javax .annotation .Nullable ;
72
73
import java .io .IOException ;
74
+ import java .security .GeneralSecurityException ;
73
75
import java .time .Duration ;
74
76
import java .util .ArrayDeque ;
75
77
import java .util .HashMap ;
@@ -250,11 +252,13 @@ void savingInReverseDoesNotRequireRepartitioning(boolean isGrouped,
250
252
251
253
static Stream <Arguments > manyDocumentsArgumentsSlow () {
252
254
return Stream .concat (
253
- Stream .of (Arguments .of (true , true , true , 80 , 2 , 200 , 234809 ),
255
+ Stream .of (Arguments .of (true , true , true , true , false , 80 , 2 , 200 , 234809 ),
254
256
// I don't know why, but this took over an hour, I'm hoping my laptop slept, but I don't see it
255
- Arguments .of (false , true , false , 50 , 8 , 212 , 3125111852333110588L )),
257
+ Arguments .of (false , true , false , true , false , 50 , 8 , 212 , 3125111852333110588L )),
256
258
RandomizedTestUtils .randomArguments (random ->
257
259
Arguments .of (random .nextBoolean (),
260
+ random .nextBoolean (),
261
+ random .nextBoolean (),
258
262
random .nextBoolean (),
259
263
random .nextBoolean (),
260
264
// We want to have a high partitionHighWatermark so that the underlying lucene indexes
@@ -271,27 +275,31 @@ static Stream<Arguments> manyDocumentsArgumentsSlow() {
271
275
void manyDocumentSlow (boolean isGrouped ,
272
276
boolean isSynthetic ,
273
277
boolean primaryKeySegmentIndexEnabled ,
278
+ boolean compressed ,
279
+ boolean encrypted ,
274
280
int partitionHighWatermark ,
275
281
int repartitionCount ,
276
282
int loopCount ,
277
- long seed ) throws IOException {
278
- manyDocument (isGrouped , isSynthetic , primaryKeySegmentIndexEnabled , partitionHighWatermark ,
283
+ long seed ) throws IOException , GeneralSecurityException {
284
+ manyDocuments (isGrouped , isSynthetic , primaryKeySegmentIndexEnabled , compressed , encrypted , partitionHighWatermark ,
279
285
repartitionCount , loopCount , 10 , seed );
280
286
}
281
287
282
288
283
289
static Stream <Arguments > manyDocumentsArguments () {
284
290
return Stream .concat (
285
291
Stream .concat (
286
- Stream .of (Arguments .of (true , true , true , 20 , 4 , 50 , 3 , -644766138635622644L )),
292
+ Stream .of (Arguments .of (true , true , true , true , false , 20 , 4 , 50 , 3 , -644766138635622644L )),
287
293
TestConfigurationUtils .onlyNightly (
288
294
Stream .of (
289
- Arguments .of (true , false , false , 21 , 3 , 55 , 3 , 9237590782644L ),
290
- Arguments .of (false , true , true , 18 , 3 , 46 , 3 , -1089113174774589435L ),
291
- Arguments .of (false , false , false , 24 , 6 , 59 , 3 , 6223372946177329440L ),
292
- Arguments .of (true , false , false , 27 , 9 , 48 , 3 , 2451719304283565963L )))),
295
+ Arguments .of (true , false , false , true , false , 21 , 3 , 55 , 3 , 9237590782644L ),
296
+ Arguments .of (false , true , true , true , false , 18 , 3 , 46 , 3 , -1089113174774589435L ),
297
+ Arguments .of (false , false , false , true , false , 24 , 6 , 59 , 3 , 6223372946177329440L ),
298
+ Arguments .of (true , false , false , true , false , 27 , 9 , 48 , 3 , 2451719304283565963L )))),
293
299
RandomizedTestUtils .randomArguments (random ->
294
300
Arguments .of (random .nextBoolean (),
301
+ random .nextBoolean (),
302
+ random .nextBoolean (),
295
303
random .nextBoolean (),
296
304
random .nextBoolean (),
297
305
// We want to have a high partitionHighWatermark so that the underlying lucene indexes
@@ -305,14 +313,16 @@ static Stream<Arguments> manyDocumentsArguments() {
305
313
306
314
@ ParameterizedTest
307
315
@ MethodSource ("manyDocumentsArguments" )
308
- void manyDocument (boolean isGrouped ,
309
- boolean isSynthetic ,
310
- boolean primaryKeySegmentIndexEnabled ,
311
- int partitionHighWatermark ,
312
- int repartitionCount ,
313
- int loopCount ,
314
- int maxTransactionsPerLoop ,
315
- long seed ) throws IOException {
316
+ void manyDocuments (boolean isGrouped ,
317
+ boolean isSynthetic ,
318
+ boolean primaryKeySegmentIndexEnabled ,
319
+ boolean compressed ,
320
+ boolean encrypted ,
321
+ int partitionHighWatermark ,
322
+ int repartitionCount ,
323
+ int loopCount ,
324
+ int maxTransactionsPerLoop ,
325
+ long seed ) throws IOException , GeneralSecurityException {
316
326
final LuceneIndexTestDataModel dataModel = new LuceneIndexTestDataModel .Builder (seed , this ::getStoreBuilder , pathManager )
317
327
.setIsGrouped (isGrouped )
318
328
.setIsSynthetic (isSynthetic )
@@ -326,11 +336,16 @@ void manyDocument(boolean isGrouped,
326
336
"seed" , seed ,
327
337
"loopCount" , loopCount ));
328
338
329
- final RecordLayerPropertyStorage contextProps = RecordLayerPropertyStorage .newBuilder ()
339
+ final RecordLayerPropertyStorage . Builder contextPropsBuilder = RecordLayerPropertyStorage .newBuilder ()
330
340
.addProp (LuceneRecordContextProperties .LUCENE_REPARTITION_DOCUMENT_COUNT , repartitionCount )
331
341
.addProp (LuceneRecordContextProperties .LUCENE_MAX_DOCUMENTS_TO_MOVE_DURING_REPARTITIONING , dataModel .nextInt (1000 ) + repartitionCount )
332
342
.addProp (LuceneRecordContextProperties .LUCENE_MERGE_SEGMENTS_PER_TIER , (double )dataModel .nextInt (10 ) + 2 ) // it must be at least 2.0
333
- .build ();
343
+ .addProp (LuceneRecordContextProperties .LUCENE_INDEX_COMPRESSION_ENABLED , compressed )
344
+ .addProp (LuceneRecordContextProperties .LUCENE_INDEX_ENCRYPTION_ENABLED , encrypted );
345
+ if (encrypted ) {
346
+ contextPropsBuilder .addProp (LuceneRecordContextProperties .LUCENE_INDEX_KEY_MANAGER , new RollingTestKeyManager (seed ));
347
+ }
348
+ final RecordLayerPropertyStorage contextProps = contextPropsBuilder .build ();
334
349
for (int i = 0 ; i < loopCount ; i ++) {
335
350
LOGGER .info (KeyValueLogMessage .of ("ManyDocument loop" ,
336
351
"iteration" , i ,
@@ -1279,6 +1294,9 @@ private void explicitMergeIndex(Index index,
1279
1294
}
1280
1295
1281
1296
protected RecordLayerPropertyStorage .Builder addDefaultProps (final RecordLayerPropertyStorage .Builder props ) {
1297
+ if (props .hasProp (LuceneRecordContextProperties .LUCENE_INDEX_COMPRESSION_ENABLED )) {
1298
+ return props ;
1299
+ }
1282
1300
return super .addDefaultProps (props ).addProp (LuceneRecordContextProperties .LUCENE_INDEX_COMPRESSION_ENABLED , true );
1283
1301
}
1284
1302
}
0 commit comments