Skip to content

Commit 7ada41b

Browse files
committed
Allocate to data-only nodes in ReopenWhileClosingIT (#42560)
If all primary shards are allocated on the master node, then the verifying before close step will never interact with mock transport service. This change prefers to allocate shards on data-only nodes. Closes #39757
1 parent 86e63ee commit 7ada41b

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

server/src/test/java/org/elasticsearch/indices/state/ReopenWhileClosingIT.java

+9-5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.elasticsearch.common.Glob;
2929
import org.elasticsearch.common.Strings;
3030
import org.elasticsearch.common.lease.Releasable;
31+
import org.elasticsearch.common.settings.Settings;
3132
import org.elasticsearch.common.util.concurrent.RunOnce;
3233
import org.elasticsearch.plugins.Plugin;
3334
import org.elasticsearch.test.ESIntegTestCase;
@@ -50,7 +51,7 @@
5051
import static org.hamcrest.Matchers.is;
5152
import static org.hamcrest.Matchers.notNullValue;
5253

53-
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, minNumDataNodes = 2)
54+
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST)
5455
public 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

Comments
 (0)