@@ -268,12 +268,12 @@ public void testMultipleIndices() throws Exception {
268
268
internalCluster ().startClusterManagerOnlyNode ();
269
269
final String index_2 = "tst-index-2" ;
270
270
List <String > nodes = new ArrayList <>();
271
- final String primaryNode = internalCluster ().startNode ();
271
+ final String primaryNode = internalCluster ().startDataOnlyNode ();
272
272
nodes .add (primaryNode );
273
273
createIndex (INDEX_NAME , index_2 );
274
274
275
275
ensureYellowAndNoInitializingShards (INDEX_NAME , index_2 );
276
- nodes .add (internalCluster ().startNode ());
276
+ nodes .add (internalCluster ().startDataOnlyNode ());
277
277
ensureGreen (INDEX_NAME , index_2 );
278
278
279
279
final long numDocs = scaledRandomIntBetween (50 , 100 );
@@ -284,44 +284,47 @@ public void testMultipleIndices() throws Exception {
284
284
refresh (INDEX_NAME , index_2 );
285
285
waitForSearchableDocs (INDEX_NAME , numDocs , nodes );
286
286
waitForSearchableDocs (index_2 , numDocs , nodes );
287
+ ensureSearchable (INDEX_NAME , index_2 );
287
288
288
289
final IndexShard index_1_primary = getIndexShard (primaryNode , INDEX_NAME );
289
290
final IndexShard index_2_primary = getIndexShard (primaryNode , index_2 );
290
291
291
292
assertTrue (index_1_primary .routingEntry ().primary ());
292
293
assertTrue (index_2_primary .routingEntry ().primary ());
293
294
294
- // test both indices are returned in the response.
295
- SegmentReplicationStatsResponse segmentReplicationStatsResponse = client ().admin ()
296
- .indices ()
297
- .prepareSegmentReplicationStats ()
298
- .execute ()
299
- .actionGet ();
295
+ assertBusy (() -> {
296
+ // test both indices are returned in the response.
297
+ SegmentReplicationStatsResponse segmentReplicationStatsResponse = dataNodeClient ().admin ()
298
+ .indices ()
299
+ .prepareSegmentReplicationStats ()
300
+ .execute ()
301
+ .actionGet ();
300
302
301
- Map <String , List <SegmentReplicationPerGroupStats >> replicationStats = segmentReplicationStatsResponse .getReplicationStats ();
302
- assertEquals (2 , replicationStats .size ());
303
- List <SegmentReplicationPerGroupStats > replicationPerGroupStats = replicationStats .get (INDEX_NAME );
304
- assertEquals (1 , replicationPerGroupStats .size ());
305
- SegmentReplicationPerGroupStats perGroupStats = replicationPerGroupStats .get (0 );
306
- assertEquals (perGroupStats .getShardId (), index_1_primary .shardId ());
307
- Set <SegmentReplicationShardStats > replicaStats = perGroupStats .getReplicaStats ();
308
- assertEquals (1 , replicaStats .size ());
309
- for (SegmentReplicationShardStats replica : replicaStats ) {
310
- assertNotNull (replica .getCurrentReplicationState ());
311
- }
303
+ Map <String , List <SegmentReplicationPerGroupStats >> replicationStats = segmentReplicationStatsResponse .getReplicationStats ();
304
+ assertEquals (2 , replicationStats .size ());
305
+ List <SegmentReplicationPerGroupStats > replicationPerGroupStats = replicationStats .get (INDEX_NAME );
306
+ assertEquals (1 , replicationPerGroupStats .size ());
307
+ SegmentReplicationPerGroupStats perGroupStats = replicationPerGroupStats .get (0 );
308
+ assertEquals (perGroupStats .getShardId (), index_1_primary .shardId ());
309
+ Set <SegmentReplicationShardStats > replicaStats = perGroupStats .getReplicaStats ();
310
+ assertEquals (1 , replicaStats .size ());
311
+ for (SegmentReplicationShardStats replica : replicaStats ) {
312
+ assertNotNull (replica .getCurrentReplicationState ());
313
+ }
312
314
313
- replicationPerGroupStats = replicationStats .get (index_2 );
314
- assertEquals (1 , replicationPerGroupStats .size ());
315
- perGroupStats = replicationPerGroupStats .get (0 );
316
- assertEquals (perGroupStats .getShardId (), index_2_primary .shardId ());
317
- replicaStats = perGroupStats .getReplicaStats ();
318
- assertEquals (1 , replicaStats .size ());
319
- for (SegmentReplicationShardStats replica : replicaStats ) {
320
- assertNotNull (replica .getCurrentReplicationState ());
321
- }
315
+ replicationPerGroupStats = replicationStats .get (index_2 );
316
+ assertEquals (1 , replicationPerGroupStats .size ());
317
+ perGroupStats = replicationPerGroupStats .get (0 );
318
+ assertEquals (perGroupStats .getShardId (), index_2_primary .shardId ());
319
+ replicaStats = perGroupStats .getReplicaStats ();
320
+ assertEquals (1 , replicaStats .size ());
321
+ for (SegmentReplicationShardStats replica : replicaStats ) {
322
+ assertNotNull (replica .getCurrentReplicationState ());
323
+ }
324
+ }, 30 , TimeUnit .SECONDS );
322
325
323
326
// test only single index queried.
324
- segmentReplicationStatsResponse = client ().admin ()
327
+ SegmentReplicationStatsResponse segmentReplicationStatsResponse = dataNodeClient ().admin ()
325
328
.indices ()
326
329
.prepareSegmentReplicationStats ()
327
330
.setIndices (index_2 )
0 commit comments