@@ -1287,8 +1287,8 @@ public void testDeleteAndCreateSameIndexShardOnSameNode() throws Exception {
1287
1287
final Index index = state .metadata ().index (indexName ).getIndex ();
1288
1288
1289
1289
assertBusy (() -> {
1290
- assertThat ( Files . exists (shardDirectory (node_1 , index , 0 )), equalTo ( false ));
1291
- assertThat ( Files . exists (shardDirectory (node_2 , index , 0 )), equalTo ( true ));
1290
+ assertFalse ( Arrays . stream (shardDirectory (node_1 , index , 0 )). anyMatch ( Files :: exists ));
1291
+ assertEquals ( 1 , Arrays . stream (shardDirectory (node_2 , index , 0 )). filter ( Files :: exists ). count ( ));
1292
1292
});
1293
1293
1294
1294
logger .info ("Moving the shard: {} again from node:{} to node:{}" , indexName + "#0" , node_2 , node_1 );
@@ -1301,11 +1301,10 @@ public void testDeleteAndCreateSameIndexShardOnSameNode() throws Exception {
1301
1301
.setWaitForNoInitializingShards (true )
1302
1302
.get ();
1303
1303
assertThat (clusterHealth .isTimedOut (), equalTo (false ));
1304
- assertThat (Files .exists (shardDirectory (node_1 , index , 0 )), equalTo (true ));
1305
1304
1306
1305
assertBusy (() -> {
1307
- assertThat ( Files . exists (shardDirectory (node_1 , index , 0 )), equalTo ( true ));
1308
- assertThat ( Files . exists (shardDirectory (node_2 , index , 0 )), equalTo ( false ));
1306
+ assertEquals ( 1 , Arrays . stream (shardDirectory (node_1 , index , 0 )). filter ( Files :: exists ). count ( ));
1307
+ assertFalse ( Arrays . stream (shardDirectory (node_2 , index , 0 )). anyMatch ( Files :: exists ));
1309
1308
});
1310
1309
1311
1310
logger .info ("Clearing the cache for index:{}. And verify the request stats doesn't go negative" , indexName );
@@ -1318,11 +1317,12 @@ public void testDeleteAndCreateSameIndexShardOnSameNode() throws Exception {
1318
1317
assertTrue (stats .getMemorySizeInBytes () == 0 );
1319
1318
}
1320
1319
1321
- private Path shardDirectory (String server , Index index , int shard ) {
1320
+ private Path [] shardDirectory (String server , Index index , int shard ) {
1322
1321
NodeEnvironment env = internalCluster ().getInstance (NodeEnvironment .class , server );
1323
1322
final Path [] paths = env .availableShardPaths (new ShardId (index , shard ));
1324
- assert paths .length == 1 ;
1325
- return paths [0 ];
1323
+ // the available paths of the shard may be bigger than the 1,
1324
+ // it depends on `InternalTestCluster.numDataPaths`.
1325
+ return paths ;
1326
1326
}
1327
1327
1328
1328
private void setupIndex (Client client , String index ) throws Exception {
0 commit comments