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