mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-06 04:58:50 +00:00
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:
parent
a94d24ae5a
commit
de6be819d6
@ -28,6 +28,7 @@ import org.elasticsearch.cluster.node.DiscoveryNode;
|
|||||||
import org.elasticsearch.common.Glob;
|
import org.elasticsearch.common.Glob;
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.lease.Releasable;
|
import org.elasticsearch.common.lease.Releasable;
|
||||||
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.util.concurrent.RunOnce;
|
import org.elasticsearch.common.util.concurrent.RunOnce;
|
||||||
import org.elasticsearch.plugins.Plugin;
|
import org.elasticsearch.plugins.Plugin;
|
||||||
import org.elasticsearch.test.ESIntegTestCase;
|
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.is;
|
||||||
import static org.hamcrest.Matchers.notNullValue;
|
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 {
|
public class ReopenWhileClosingIT extends ESIntegTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -64,8 +65,9 @@ public class ReopenWhileClosingIT extends ESIntegTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testReopenDuringClose() throws Exception {
|
public void testReopenDuringClose() throws Exception {
|
||||||
|
List<String> dataOnlyNodes = internalCluster().startDataOnlyNodes(randomIntBetween(2, 3));
|
||||||
final String indexName = "test";
|
final String indexName = "test";
|
||||||
createIndexWithDocs(indexName);
|
createIndexWithDocs(indexName, dataOnlyNodes);
|
||||||
|
|
||||||
ensureYellowAndNoInitializingShards(indexName);
|
ensureYellowAndNoInitializingShards(indexName);
|
||||||
|
|
||||||
@ -85,10 +87,11 @@ public class ReopenWhileClosingIT extends ESIntegTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testReopenDuringCloseOnMultipleIndices() throws Exception {
|
public void testReopenDuringCloseOnMultipleIndices() throws Exception {
|
||||||
|
List<String> dataOnlyNodes = internalCluster().startDataOnlyNodes(randomIntBetween(2, 3));
|
||||||
final List<String> indices = new ArrayList<>();
|
final List<String> indices = new ArrayList<>();
|
||||||
for (int i = 0; i < randomIntBetween(2, 10); i++) {
|
for (int i = 0; i < randomIntBetween(2, 10); i++) {
|
||||||
indices.add("index-" + i);
|
indices.add("index-" + i);
|
||||||
createIndexWithDocs(indices.get(i));
|
createIndexWithDocs(indices.get(i), dataOnlyNodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureYellowAndNoInitializingShards(indices.toArray(Strings.EMPTY_ARRAY));
|
ensureYellowAndNoInitializingShards(indices.toArray(Strings.EMPTY_ARRAY));
|
||||||
@ -116,8 +119,9 @@ public class ReopenWhileClosingIT extends ESIntegTestCase {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createIndexWithDocs(final String indexName) {
|
private void createIndexWithDocs(final String indexName, final Collection<String> dataOnlyNodes) {
|
||||||
createIndex(indexName);
|
createIndex(indexName,
|
||||||
|
Settings.builder().put(indexSettings()).put("index.routing.allocation.include._name", String.join(",", dataOnlyNodes)).build());
|
||||||
final int nbDocs = scaledRandomIntBetween(1, 100);
|
final int nbDocs = scaledRandomIntBetween(1, 100);
|
||||||
for (int i = 0; i < nbDocs; i++) {
|
for (int i = 0; i < nbDocs; i++) {
|
||||||
index(indexName, "_doc", String.valueOf(i), "num", i);
|
index(indexName, "_doc", String.valueOf(i), "num", i);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user