Skip to content

Commit 643eb35

Browse files
authored
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 337cef1 commit 643eb35

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

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

+9-6
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

@@ -84,12 +86,12 @@ public void testReopenDuringClose() throws Exception {
8486
assertIndexIsOpened(indexName);
8587
}
8688

87-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/39757")
8889
public void testReopenDuringCloseOnMultipleIndices() throws Exception {
90+
List<String> dataOnlyNodes = internalCluster().startDataOnlyNodes(randomIntBetween(2, 3));
8991
final List<String> indices = new ArrayList<>();
9092
for (int i = 0; i < randomIntBetween(2, 10); i++) {
9193
indices.add("index-" + i);
92-
createIndexWithDocs(indices.get(i));
94+
createIndexWithDocs(indices.get(i), dataOnlyNodes);
9395
}
9496

9597
ensureYellowAndNoInitializingShards(indices.toArray(Strings.EMPTY_ARRAY));
@@ -117,8 +119,9 @@ public void testReopenDuringCloseOnMultipleIndices() throws Exception {
117119
});
118120
}
119121

120-
private void createIndexWithDocs(final String indexName) {
121-
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());
122125
final int nbDocs = scaledRandomIntBetween(1, 100);
123126
for (int i = 0; i < nbDocs; i++) {
124127
index(indexName, "_doc", String.valueOf(i), "num", i);

0 commit comments

Comments
 (0)