2828import org .elasticsearch .common .Glob ;
2929import org .elasticsearch .common .Strings ;
3030import org .elasticsearch .common .lease .Releasable ;
31+ import org .elasticsearch .common .settings .Settings ;
3132import org .elasticsearch .common .util .concurrent .RunOnce ;
3233import org .elasticsearch .plugins .Plugin ;
3334import org .elasticsearch .test .ESIntegTestCase ;
5051import static org .hamcrest .Matchers .is ;
5152import static org .hamcrest .Matchers .notNullValue ;
5253
53- @ ESIntegTestCase .ClusterScope (scope = ESIntegTestCase .Scope .TEST , minNumDataNodes = 2 )
54+ @ ESIntegTestCase .ClusterScope (scope = ESIntegTestCase .Scope .TEST )
5455public class ReopenWhileClosingIT extends ESIntegTestCase {
5556
5657 @ Override
@@ -64,8 +65,9 @@ protected int minimumNumberOfShards() {
6465 }
6566
6667 public void testReopenDuringClose () throws Exception {
68+ List <String > dataOnlyNodes = internalCluster ().startDataOnlyNodes (randomIntBetween (2 , 3 ));
6769 final String indexName = "test" ;
68- createIndexWithDocs (indexName );
70+ createIndexWithDocs (indexName , dataOnlyNodes );
6971
7072 ensureYellowAndNoInitializingShards (indexName );
7173
@@ -85,10 +87,11 @@ public void testReopenDuringClose() throws Exception {
8587 }
8688
8789 public void testReopenDuringCloseOnMultipleIndices () throws Exception {
90+ List <String > dataOnlyNodes = internalCluster ().startDataOnlyNodes (randomIntBetween (2 , 3 ));
8891 final List <String > indices = new ArrayList <>();
8992 for (int i = 0 ; i < randomIntBetween (2 , 10 ); i ++) {
9093 indices .add ("index-" + i );
91- createIndexWithDocs (indices .get (i ));
94+ createIndexWithDocs (indices .get (i ), dataOnlyNodes );
9295 }
9396
9497 ensureYellowAndNoInitializingShards (indices .toArray (Strings .EMPTY_ARRAY ));
@@ -116,8 +119,9 @@ public void testReopenDuringCloseOnMultipleIndices() throws Exception {
116119 });
117120 }
118121
119- private void createIndexWithDocs (final String indexName ) {
120- createIndex (indexName );
122+ private void createIndexWithDocs (final String indexName , final Collection <String > dataOnlyNodes ) {
123+ createIndex (indexName ,
124+ Settings .builder ().put (indexSettings ()).put ("index.routing.allocation.include._name" , String .join ("," , dataOnlyNodes )).build ());
121125 final int nbDocs = scaledRandomIntBetween (1 , 100 );
122126 for (int i = 0 ; i < nbDocs ; i ++) {
123127 index (indexName , "_doc" , String .valueOf (i ), "num" , i );
0 commit comments