@@ -160,7 +160,7 @@ public void testGetOperationsBasedOnGlobalSequenceId() throws Exception {
160
160
161
161
public void testFollowIndex () throws Exception {
162
162
final int numberOfPrimaryShards = randomIntBetween (1 , 3 );
163
- final String leaderIndexSettings = getIndexSettings (numberOfPrimaryShards ,
163
+ final String leaderIndexSettings = getIndexSettings (numberOfPrimaryShards , between ( 0 , 1 ),
164
164
singletonMap (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), "true" ));
165
165
assertAcked (client ().admin ().indices ().prepareCreate ("index1" ).setSource (leaderIndexSettings , XContentType .JSON ));
166
166
ensureYellow ("index1" );
@@ -218,7 +218,7 @@ public void testFollowIndex() throws Exception {
218
218
}
219
219
220
220
public void testSyncMappings () throws Exception {
221
- final String leaderIndexSettings = getIndexSettings (2 ,
221
+ final String leaderIndexSettings = getIndexSettings (2 , between ( 0 , 1 ),
222
222
singletonMap (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), "true" ));
223
223
assertAcked (client ().admin ().indices ().prepareCreate ("index1" ).setSource (leaderIndexSettings , XContentType .JSON ));
224
224
ensureYellow ("index1" );
@@ -255,7 +255,8 @@ public void testSyncMappings() throws Exception {
255
255
}
256
256
257
257
public void testFollowIndex_backlog () throws Exception {
258
- String leaderIndexSettings = getIndexSettings (3 , singletonMap (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), "true" ));
258
+ String leaderIndexSettings = getIndexSettings (between (1 , 5 ), between (0 , 1 ),
259
+ singletonMap (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), "true" ));
259
260
assertAcked (client ().admin ().indices ().prepareCreate ("index1" ).setSource (leaderIndexSettings , XContentType .JSON ));
260
261
BulkProcessor .Listener listener = new BulkProcessor .Listener () {
261
262
@ Override
@@ -306,10 +307,10 @@ public void afterBulk(long executionId, BulkRequest request, Throwable failure)
306
307
307
308
public void testFollowIndexAndCloseNode () throws Exception {
308
309
internalCluster ().ensureAtLeastNumDataNodes (3 );
309
- String leaderIndexSettings = getIndexSettings (3 , singletonMap (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), "true" ));
310
+ String leaderIndexSettings = getIndexSettings (3 , 1 , singletonMap (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), "true" ));
310
311
assertAcked (client ().admin ().indices ().prepareCreate ("index1" ).setSource (leaderIndexSettings , XContentType .JSON ));
311
312
312
- String followerIndexSettings = getIndexSettings (3 , singletonMap (CcrSettings .CCR_FOLLOWING_INDEX_SETTING .getKey (), "true" ));
313
+ String followerIndexSettings = getIndexSettings (3 , 1 , singletonMap (CcrSettings .CCR_FOLLOWING_INDEX_SETTING .getKey (), "true" ));
313
314
assertAcked (client ().admin ().indices ().prepareCreate ("index2" ).setSource (followerIndexSettings , XContentType .JSON ));
314
315
ensureGreen ("index1" , "index2" );
315
316
@@ -366,13 +367,14 @@ public void testFollowIndexAndCloseNode() throws Exception {
366
367
367
368
public void testFollowIndexWithNestedField () throws Exception {
368
369
final String leaderIndexSettings =
369
- getIndexSettingsWithNestedMapping (1 , singletonMap (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), "true" ));
370
+ getIndexSettingsWithNestedMapping (1 , between ( 0 , 1 ), singletonMap (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), "true" ));
370
371
assertAcked (client ().admin ().indices ().prepareCreate ("index1" ).setSource (leaderIndexSettings , XContentType .JSON ));
371
372
372
373
final String followerIndexSettings =
373
- getIndexSettingsWithNestedMapping (1 , singletonMap (CcrSettings .CCR_FOLLOWING_INDEX_SETTING .getKey (), "true" ));
374
+ getIndexSettingsWithNestedMapping (1 , between ( 0 , 1 ), singletonMap (CcrSettings .CCR_FOLLOWING_INDEX_SETTING .getKey (), "true" ));
374
375
assertAcked (client ().admin ().indices ().prepareCreate ("index2" ).setSource (followerIndexSettings , XContentType .JSON ));
375
376
377
+ internalCluster ().ensureAtLeastNumDataNodes (2 );
376
378
ensureGreen ("index1" , "index2" );
377
379
378
380
final FollowIndexAction .Request followRequest = createFollowRequest ("index1" , "index2" );
@@ -455,7 +457,8 @@ public void testValidateFollowingIndexSettings() throws Exception {
455
457
}
456
458
457
459
public void testFollowIndex_lowMaxTranslogBytes () throws Exception {
458
- final String leaderIndexSettings = getIndexSettings (1 , singletonMap (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), "true" ));
460
+ final String leaderIndexSettings = getIndexSettings (1 , between (0 , 1 ),
461
+ singletonMap (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), "true" ));
459
462
assertAcked (client ().admin ().indices ().prepareCreate ("index1" ).setSource (leaderIndexSettings , XContentType .JSON ));
460
463
ensureYellow ("index1" );
461
464
@@ -554,15 +557,16 @@ private CheckedRunnable<Exception> assertExpectedDocumentRunnable(final int valu
554
557
};
555
558
}
556
559
557
- private String getIndexSettings (final int numberOfPrimaryShards , final Map <String , String > additionalIndexSettings ) throws IOException {
560
+ private String getIndexSettings (final int numberOfShards , final int numberOfReplicas ,
561
+ final Map <String , String > additionalIndexSettings ) throws IOException {
558
562
final String settings ;
559
563
try (XContentBuilder builder = jsonBuilder ()) {
560
564
builder .startObject ();
561
565
{
562
566
builder .startObject ("settings" );
563
567
{
564
- builder .field ("index.number_of_shards" , numberOfPrimaryShards );
565
- builder .field ("index.number_of_replicas" , 1 );
568
+ builder .field ("index.number_of_shards" , numberOfShards );
569
+ builder .field ("index.number_of_replicas" , numberOfReplicas );
566
570
for (final Map .Entry <String , String > additionalSetting : additionalIndexSettings .entrySet ()) {
567
571
builder .field (additionalSetting .getKey (), additionalSetting .getValue ());
568
572
}
@@ -592,15 +596,16 @@ private String getIndexSettings(final int numberOfPrimaryShards, final Map<Strin
592
596
return settings ;
593
597
}
594
598
595
- private String getIndexSettingsWithNestedMapping (final int numberOfPrimaryShards ,
599
+ private String getIndexSettingsWithNestedMapping (final int numberOfShards , final int numberOfReplicas ,
596
600
final Map <String , String > additionalIndexSettings ) throws IOException {
597
601
final String settings ;
598
602
try (XContentBuilder builder = jsonBuilder ()) {
599
603
builder .startObject ();
600
604
{
601
605
builder .startObject ("settings" );
602
606
{
603
- builder .field ("index.number_of_shards" , numberOfPrimaryShards );
607
+ builder .field ("index.number_of_shards" , numberOfShards );
608
+ builder .field ("index.number_of_replicas" , numberOfReplicas );
604
609
for (final Map .Entry <String , String > additionalSetting : additionalIndexSettings .entrySet ()) {
605
610
builder .field (additionalSetting .getKey (), additionalSetting .getValue ());
606
611
}
0 commit comments