@@ -3849,13 +3849,15 @@ protected long doGenerateSeqNoForOperation(Operation operation) {
3849
3849
assertThat (noOp .seqNo (), equalTo ((long ) (maxSeqNo + 2 )));
3850
3850
assertThat (noOp .primaryTerm (), equalTo (primaryTerm .get ()));
3851
3851
assertThat (noOp .reason (), equalTo (reason ));
3852
- MapperService mapperService = createMapperService ("test" );
3853
- List <Translog .Operation > operationsFromLucene = readAllOperationsInLucene (noOpEngine , mapperService );
3854
- assertThat (operationsFromLucene , hasSize (maxSeqNo + 2 - localCheckpoint )); // fills n gap and 2 manual noop.
3855
- for (int i = 0 ; i < operationsFromLucene .size (); i ++) {
3856
- assertThat (operationsFromLucene .get (i ), equalTo (new Translog .NoOp (localCheckpoint + 1 + i , primaryTerm .get (), "filling gaps" )));
3852
+ if (engine .engineConfig .getIndexSettings ().isSoftDeleteEnabled ()) {
3853
+ MapperService mapperService = createMapperService ("test" );
3854
+ List <Translog .Operation > operationsFromLucene = readAllOperationsInLucene (noOpEngine , mapperService );
3855
+ assertThat (operationsFromLucene , hasSize (maxSeqNo + 2 - localCheckpoint )); // fills n gap and 2 manual noop.
3856
+ for (int i = 0 ; i < operationsFromLucene .size (); i ++) {
3857
+ assertThat (operationsFromLucene .get (i ), equalTo (new Translog .NoOp (localCheckpoint + 1 + i , primaryTerm .get (), "filling gaps" )));
3858
+ }
3859
+ assertConsistentHistoryBetweenTranslogAndLuceneIndex (noOpEngine , mapperService );
3857
3860
}
3858
- assertConsistentHistoryBetweenTranslogAndLuceneIndex (noOpEngine , mapperService );
3859
3861
} finally {
3860
3862
IOUtils .close (noOpEngine );
3861
3863
}
@@ -3912,8 +3914,10 @@ public void testRandomOperations() throws Exception {
3912
3914
engine .forceMerge (randomBoolean (), between (1 , 10 ), randomBoolean (), false , false );
3913
3915
}
3914
3916
}
3915
- List <Translog .Operation > operations = readAllOperationsInLucene (engine , createMapperService ("test" ));
3916
- assertThat (operations , hasSize (numOps ));
3917
+ if (engine .engineConfig .getIndexSettings ().isSoftDeleteEnabled ()) {
3918
+ List <Translog .Operation > operations = readAllOperationsInLucene (engine , createMapperService ("test" ));
3919
+ assertThat (operations , hasSize (numOps ));
3920
+ }
3917
3921
}
3918
3922
3919
3923
public void testMinGenerationForSeqNo () throws IOException , BrokenBarrierException , InterruptedException {
@@ -4854,9 +4858,15 @@ public void testLuceneHistoryOnReplica() throws Exception {
4854
4858
private void assertOperationHistoryInLucene (List <Engine .Operation > operations ) throws IOException {
4855
4859
final MergePolicy keepSoftDeleteDocsMP = new SoftDeletesRetentionMergePolicy (
4856
4860
Lucene .SOFT_DELETE_FIELD , () -> new MatchAllDocsQuery (), engine .config ().getMergePolicy ());
4861
+ Settings .Builder settings = Settings .builder ()
4862
+ .put (defaultSettings .getSettings ())
4863
+ .put (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), true )
4864
+ .put (IndexSettings .INDEX_SOFT_DELETES_RETENTION_OPERATIONS_SETTING .getKey (), randomLongBetween (0 , 10 ));
4865
+ final IndexMetaData indexMetaData = IndexMetaData .builder (defaultSettings .getIndexMetaData ()).settings (settings ).build ();
4866
+ final IndexSettings indexSettings = IndexSettingsModule .newIndexSettings (indexMetaData );
4857
4867
Set <Long > expectedSeqNos = new HashSet <>();
4858
4868
try (Store store = createStore ();
4859
- Engine engine = createEngine (config (defaultSettings , store , createTempDir (), keepSoftDeleteDocsMP , null ))) {
4869
+ Engine engine = createEngine (config (indexSettings , store , createTempDir (), keepSoftDeleteDocsMP , null ))) {
4860
4870
for (Engine .Operation op : operations ) {
4861
4871
if (op instanceof Engine .Index ) {
4862
4872
Engine .IndexResult indexResult = engine .index ((Engine .Index ) op );
0 commit comments