Skip to content

Commit

Permalink
Fix test: create enough nodes to make cluster always be able to go gr…
Browse files Browse the repository at this point in the history
…een (elastic#113824)

* Fix test: create enough nodes to make cluster always be able to go green
* Skip test when feature is disabled

(cherry picked from commit 852c960)

# Conflicts:
#	muted-tests.yml
  • Loading branch information
smalyshev committed Oct 1, 2024
1 parent 8a8ad1b commit d54678c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.elasticsearch.client.internal.Client;
import org.elasticsearch.cluster.health.ClusterHealthStatus;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.FeatureFlag;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.query.MatchAllQueryBuilder;
import org.elasticsearch.search.builder.SearchSourceBuilder;
Expand All @@ -22,6 +23,7 @@
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.InternalTestCluster;
import org.junit.Assert;
import org.junit.BeforeClass;

import java.util.Collection;
import java.util.List;
Expand All @@ -44,6 +46,7 @@ public class ClusterStatsRemoteIT extends AbstractMultiClustersTestCase {
private static final String REMOTE2 = "cluster-b";

private static final String INDEX_NAME = "demo";
private static final FeatureFlag CCS_TELEMETRY_FEATURE_FLAG = new FeatureFlag("ccs_telemetry");

@Override
protected boolean reuseClusters() {
Expand All @@ -60,6 +63,11 @@ protected Map<String, Boolean> skipUnavailableForRemoteClusters() {
return Map.of(REMOTE1, false, REMOTE2, true);
}

@BeforeClass
protected static void skipIfTelemetryDisabled() {
assumeTrue("Skipping test as CCS_TELEMETRY_FEATURE_FLAG is disabled", CCS_TELEMETRY_FEATURE_FLAG.isEnabled());
}

public void testRemoteClusterStats() throws ExecutionException, InterruptedException {
setupClusters();
final Client client = client(LOCAL_CLUSTER);
Expand Down Expand Up @@ -117,7 +125,7 @@ private void setupClusters() {
int numShardsRemote = randomIntBetween(2, 10);
for (String clusterAlias : remoteClusterAlias()) {
final InternalTestCluster remoteCluster = cluster(clusterAlias);
remoteCluster.ensureAtLeastNumDataNodes(randomIntBetween(1, 3));
remoteCluster.ensureAtLeastNumDataNodes(randomIntBetween(2, 3));
assertAcked(
client(clusterAlias).admin()
.indices()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ private Map<String, Object> setupClusters() {
int numShardsRemote = randomIntBetween(2, 10);
for (String clusterAlias : remoteClusterAlias()) {
final InternalTestCluster remoteCluster = cluster(clusterAlias);
remoteCluster.ensureAtLeastNumDataNodes(randomIntBetween(1, 3));
remoteCluster.ensureAtLeastNumDataNodes(randomIntBetween(2, 3));
assertAcked(
client(clusterAlias).admin()
.indices()
Expand Down

0 comments on commit d54678c

Please sign in to comment.