Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@

import org.elasticsearch.Build;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.support.PlainActionFuture;
import org.elasticsearch.client.internal.Client;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.Priority;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.compute.lucene.DataPartitioning;
Expand Down Expand Up @@ -121,12 +125,36 @@ public void testMetadataIndex() {
}
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/106273")
void waitForNoInitializingShards(Client client, TimeValue timeout, String... indices) {
ClusterHealthResponse resp = client.admin()
.cluster()
.prepareHealth(indices)
.setWaitForEvents(Priority.LANGUID)
.setWaitForNoRelocatingShards(true)
.setWaitForNoInitializingShards(true)
.setTimeout(timeout)
.get();
assertFalse(Strings.toString(resp, true, true), resp.isTimedOut());
}

public void testProfile() {
assumeTrue("pragmas only enabled on snapshot builds", Build.current().isSnapshot());
final int localOnlyProfiles;
// uses shard partitioning as segments can be merged during these queries
var pragmas = new QueryPragmas(Settings.builder().put(QueryPragmas.DATA_PARTITIONING.getKey(), DataPartitioning.SHARD).build());
// Use single replicas for the target indices, to make sure we hit the same set of target nodes
client(LOCAL_CLUSTER).admin()
.indices()
.prepareUpdateSettings("logs-1")
.setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0).put("index.routing.rebalance.enable", "none"))
.get();
waitForNoInitializingShards(client(LOCAL_CLUSTER), TimeValue.timeValueSeconds(30), "logs-1");
client(REMOTE_CLUSTER).admin()
.indices()
.prepareUpdateSettings("logs-2")
.setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0).put("index.routing.rebalance.enable", "none"))
.get();
waitForNoInitializingShards(client(REMOTE_CLUSTER), TimeValue.timeValueSeconds(30), "logs-2");
final int localOnlyProfiles;
{
EsqlQueryRequest request = new EsqlQueryRequest();
request.query("FROM logs* | stats sum(v)");
Expand Down