28
28
import org .elasticsearch .common .Glob ;
29
29
import org .elasticsearch .common .Strings ;
30
30
import org .elasticsearch .common .lease .Releasable ;
31
+ import org .elasticsearch .common .settings .Settings ;
31
32
import org .elasticsearch .common .util .concurrent .RunOnce ;
32
33
import org .elasticsearch .plugins .Plugin ;
33
34
import org .elasticsearch .test .ESIntegTestCase ;
50
51
import static org .hamcrest .Matchers .is ;
51
52
import static org .hamcrest .Matchers .notNullValue ;
52
53
53
- @ ESIntegTestCase .ClusterScope (scope = ESIntegTestCase .Scope .TEST , minNumDataNodes = 2 )
54
+ @ ESIntegTestCase .ClusterScope (scope = ESIntegTestCase .Scope .TEST )
54
55
public class ReopenWhileClosingIT extends ESIntegTestCase {
55
56
56
57
@ Override
@@ -64,8 +65,9 @@ protected int minimumNumberOfShards() {
64
65
}
65
66
66
67
public void testReopenDuringClose () throws Exception {
68
+ List <String > dataOnlyNodes = internalCluster ().startDataOnlyNodes (randomIntBetween (2 , 3 ));
67
69
final String indexName = "test" ;
68
- createIndexWithDocs (indexName );
70
+ createIndexWithDocs (indexName , dataOnlyNodes );
69
71
70
72
ensureYellowAndNoInitializingShards (indexName );
71
73
@@ -85,10 +87,11 @@ public void testReopenDuringClose() throws Exception {
85
87
}
86
88
87
89
public void testReopenDuringCloseOnMultipleIndices () throws Exception {
90
+ List <String > dataOnlyNodes = internalCluster ().startDataOnlyNodes (randomIntBetween (2 , 3 ));
88
91
final List <String > indices = new ArrayList <>();
89
92
for (int i = 0 ; i < randomIntBetween (2 , 10 ); i ++) {
90
93
indices .add ("index-" + i );
91
- createIndexWithDocs (indices .get (i ));
94
+ createIndexWithDocs (indices .get (i ), dataOnlyNodes );
92
95
}
93
96
94
97
ensureYellowAndNoInitializingShards (indices .toArray (Strings .EMPTY_ARRAY ));
@@ -116,8 +119,9 @@ public void testReopenDuringCloseOnMultipleIndices() throws Exception {
116
119
});
117
120
}
118
121
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 ());
121
125
final int nbDocs = scaledRandomIntBetween (1 , 100 );
122
126
for (int i = 0 ; i < nbDocs ; i ++) {
123
127
index (indexName , "_doc" , String .valueOf (i ), "num" , i );
0 commit comments