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
This commit is contained in:
Nhat Nguyen 2019-05-27 17:30:21 -04:00
parent a94d24ae5a
commit de6be819d6
1 changed files with 9 additions and 5 deletions

View File

@ -28,6 +28,7 @@ import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.Glob;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.lease.Releasable;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.RunOnce;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
@ -50,7 +51,7 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, minNumDataNodes = 2)
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class ReopenWhileClosingIT extends ESIntegTestCase {
@Override
@ -64,8 +65,9 @@ public class ReopenWhileClosingIT extends ESIntegTestCase {
}
public void testReopenDuringClose() throws Exception {
List<String> dataOnlyNodes = internalCluster().startDataOnlyNodes(randomIntBetween(2, 3));
final String indexName = "test";
createIndexWithDocs(indexName);
createIndexWithDocs(indexName, dataOnlyNodes);
ensureYellowAndNoInitializingShards(indexName);
@ -85,10 +87,11 @@ public class ReopenWhileClosingIT extends ESIntegTestCase {
}
public void testReopenDuringCloseOnMultipleIndices() throws Exception {
List<String> dataOnlyNodes = internalCluster().startDataOnlyNodes(randomIntBetween(2, 3));
final List<String> indices = new ArrayList<>();
for (int i = 0; i < randomIntBetween(2, 10); i++) {
indices.add("index-" + i);
createIndexWithDocs(indices.get(i));
createIndexWithDocs(indices.get(i), dataOnlyNodes);
}
ensureYellowAndNoInitializingShards(indices.toArray(Strings.EMPTY_ARRAY));
@ -116,8 +119,9 @@ public class ReopenWhileClosingIT extends ESIntegTestCase {
});
}
private void createIndexWithDocs(final String indexName) {
createIndex(indexName);
private void createIndexWithDocs(final String indexName, final Collection<String> dataOnlyNodes) {
createIndex(indexName,
Settings.builder().put(indexSettings()).put("index.routing.allocation.include._name", String.join(",", dataOnlyNodes)).build());
final int nbDocs = scaledRandomIntBetween(1, 100);
for (int i = 0; i < nbDocs; i++) {
index(indexName, "_doc", String.valueOf(i), "num", i);