Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,6 @@ tests:
- class: org.elasticsearch.smoketest.MlWithSecurityIT
method: test {yaml=ml/start_data_frame_analytics/Test start classification analysis when the dependent variable is missing}
issue: https://github.com/elastic/elasticsearch/issues/124168
- class: org.elasticsearch.search.fieldcaps.FieldCapabilitiesIT
method: testRelocation
issue: https://github.com/elastic/elasticsearch/issues/124227
- class: org.elasticsearch.smoketest.MlWithSecurityIT
method: test {yaml=ml/3rd_party_deployment/Test start and stop multiple deployments}
issue: https://github.com/elastic/elasticsearch/issues/124315
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.IntStream;

import static java.util.Collections.singletonList;
Expand Down Expand Up @@ -557,11 +558,14 @@ public void testNoActiveCopy() throws Exception {
}
}

private void moveOrCloseShardsOnNodes(String nodeName) throws Exception {
private void moveOrCloseShardsOnNodes(String nodeName, Predicate<String> indexName) throws Exception {
final IndicesService indicesService = internalCluster().getInstance(IndicesService.class, nodeName);
final ClusterState clusterState = clusterService().state();
for (IndexService indexService : indicesService) {
for (IndexShard indexShard : indexService) {
if (indexName.test(indexShard.shardId().getIndexName()) == false) {
continue;
}
if (randomBoolean()) {
closeShardNoCheck(indexShard, randomBoolean());
} else if (randomBoolean()) {
Expand Down Expand Up @@ -603,13 +607,21 @@ private void moveOrCloseShardsOnNodes(String nodeName) throws Exception {

public void testRelocation() throws Exception {
populateTimeRangeIndices();
assertAcked(
client().admin()
.indices()
.prepareUpdateSettings("log-index-*")
.setSettings(Settings.builder().put("index.routing.rebalance.enable", "none").build())
.get()
);
ensureGreen("log-index-*");
try {
final AtomicBoolean relocated = new AtomicBoolean();
for (String node : internalCluster().getNodeNames()) {
MockTransportService.getInstance(node)
.addRequestHandlingBehavior(TransportFieldCapabilitiesAction.ACTION_NODE_NAME, (handler, request, channel, task) -> {
if (relocated.compareAndSet(false, true)) {
moveOrCloseShardsOnNodes(node);
moveOrCloseShardsOnNodes(node, indexName -> indexName.startsWith("log-index-"));
}
handler.messageReceived(request, channel, task);
});
Expand Down
Loading