28
28
import org .elasticsearch .cluster .metadata .MetaDataIndexStateService ;
29
29
import org .elasticsearch .cluster .routing .allocation .decider .EnableAllocationDecider ;
30
30
import org .elasticsearch .common .Booleans ;
31
+ import org .elasticsearch .common .Strings ;
31
32
import org .elasticsearch .common .settings .Settings ;
32
33
import org .elasticsearch .common .util .concurrent .AbstractRunnable ;
33
34
import org .elasticsearch .common .xcontent .support .XContentMapValues ;
@@ -281,7 +282,7 @@ public void testRelocationWithConcurrentIndexing() throws Exception {
281
282
}
282
283
}
283
284
284
- public void testRecoveryWithSoftDeletes () throws Exception {
285
+ public void testRecovery () throws Exception {
285
286
final String index = "recover_with_soft_deletes" ;
286
287
if (CLUSTER_TYPE == ClusterType .OLD ) {
287
288
Settings .Builder settings = Settings .builder ()
@@ -294,7 +295,7 @@ public void testRecoveryWithSoftDeletes() throws Exception {
294
295
.put (INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING .getKey (), "100ms" )
295
296
.put (SETTING_ALLOCATION_MAX_RETRY .getKey (), "0" ); // fail faster
296
297
if (randomBoolean ()) {
297
- settings .put (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), true );
298
+ settings .put (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), randomBoolean () );
298
299
}
299
300
createIndex (index , settings .build ());
300
301
int numDocs = randomInt (10 );
@@ -325,7 +326,7 @@ public void testRetentionLeasesEstablishedWhenPromotingPrimary() throws Exceptio
325
326
.put (IndexMetaData .INDEX_NUMBER_OF_REPLICAS_SETTING .getKey (), between (1 , 2 )) // triggers nontrivial promotion
326
327
.put (INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING .getKey (), "100ms" )
327
328
.put (SETTING_ALLOCATION_MAX_RETRY .getKey (), "0" ) // fail faster
328
- .put (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), true );
329
+ .put (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), randomBoolean () );
329
330
createIndex (index , settings .build ());
330
331
int numDocs = randomInt (10 );
331
332
indexDocs (index , 0 , numDocs );
@@ -348,7 +349,7 @@ public void testRetentionLeasesEstablishedWhenRelocatingPrimary() throws Excepti
348
349
.put (IndexMetaData .INDEX_NUMBER_OF_REPLICAS_SETTING .getKey (), between (0 , 1 ))
349
350
.put (INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING .getKey (), "100ms" )
350
351
.put (SETTING_ALLOCATION_MAX_RETRY .getKey (), "0" ) // fail faster
351
- .put (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), true );
352
+ .put (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), randomBoolean () );
352
353
createIndex (index , settings .build ());
353
354
int numDocs = randomInt (10 );
354
355
indexDocs (index , 0 , numDocs );
@@ -740,6 +741,26 @@ public void testAutoExpandIndicesDuringRollingUpgrade() throws Exception {
740
741
}
741
742
}
742
743
744
+ public void testSoftDeletesDisabledWarning () throws Exception {
745
+ final String indexName = "test_soft_deletes_disabled_warning" ;
746
+ if (CLUSTER_TYPE == ClusterType .OLD ) {
747
+ boolean softDeletesEnabled = true ;
748
+ Settings .Builder settings = Settings .builder ();
749
+ if (randomBoolean ()) {
750
+ softDeletesEnabled = randomBoolean ();
751
+ settings .put (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), softDeletesEnabled );
752
+ }
753
+ Request request = new Request ("PUT" , "/" + indexName );
754
+ request .setJsonEntity ("{\" settings\" : " + Strings .toString (settings .build ()) + "}" );
755
+ if (softDeletesEnabled == false ) {
756
+ expectSoftDeletesWarning (request , indexName );
757
+ }
758
+ client ().performRequest (request );
759
+ }
760
+ ensureGreen (indexName );
761
+ indexDocs (indexName , randomInt (100 ), randomInt (100 ));
762
+ }
763
+
743
764
@ SuppressWarnings ("unchecked" )
744
765
private Map <String , Object > getIndexSettingsAsMap (String index ) throws IOException {
745
766
Map <String , Object > indexSettings = getIndexSettings (index );
0 commit comments