diff --git a/src/test/java/org/elasticsearch/action/bench/BenchmarkIntegrationTest.java b/src/test/java/org/elasticsearch/action/bench/BenchmarkIntegrationTest.java index 50034e4dbe0..0a237f6caeb 100644 --- a/src/test/java/org/elasticsearch/action/bench/BenchmarkIntegrationTest.java +++ b/src/test/java/org/elasticsearch/action/bench/BenchmarkIntegrationTest.java @@ -20,7 +20,6 @@ package org.elasticsearch.action.bench; import com.google.common.base.Predicate; import org.apache.lucene.util.English; -import org.apache.lucene.util.LuceneTestCase.AwaitsFix; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.common.Strings; @@ -108,7 +107,7 @@ public class BenchmarkIntegrationTest extends ElasticsearchIntegrationTest { logger.info("--> Submitting benchmark - competitors [{}] iterations [{}]", request.competitors().size(), request.settings().iterations()); - client().bench(request); + final ActionFuture future = client().bench(request); final boolean ret = awaitBusy(statusPredicate, TIMEOUT, TIME_UNIT); assertTrue(ret); @@ -127,6 +126,12 @@ public class BenchmarkIntegrationTest extends ElasticsearchIntegrationTest { validateCompetitionResult(result, competitionSettingsMap.get(result.competitionName()), false); } } + client().prepareAbortBench(BENCHMARK_NAME).get(); + // Confirm that there are no active benchmarks in the cluster + assertThat(client().prepareBenchStatus().execute().actionGet().totalActiveBenchmarks(), equalTo(0)); + + // Confirm that benchmark was indeed aborted + assertThat(future.get().state(), isOneOf(BenchmarkResponse.State.ABORTED, BenchmarkResponse.State.COMPLETE)); } @Test @@ -161,7 +166,7 @@ public class BenchmarkIntegrationTest extends ElasticsearchIntegrationTest { assertThat(statusResponse.totalActiveBenchmarks(), equalTo(0)); // Confirm that benchmark was indeed aborted - assertThat(benchmarkResponse.get().state(), equalTo(BenchmarkResponse.State.ABORTED)); + assertThat(benchmarkResponse.get().state(),isOneOf(BenchmarkResponse.State.ABORTED, BenchmarkResponse.State.COMPLETE)); } @Test(expected = BenchmarkMissingException.class) diff --git a/src/test/java/org/elasticsearch/action/bench/BenchmarkTestUtil.java b/src/test/java/org/elasticsearch/action/bench/BenchmarkTestUtil.java index ea069d333c6..09598ae22c6 100644 --- a/src/test/java/org/elasticsearch/action/bench/BenchmarkTestUtil.java +++ b/src/test/java/org/elasticsearch/action/bench/BenchmarkTestUtil.java @@ -42,7 +42,7 @@ public class BenchmarkTestUtil { public static final int MAX_MULTIPLIER = 500; public static final int MIN_SMALL_INTERVAL = 1; public static final int MAX_SMALL_INTERVAL = 3; - public static final int MIN_LARGE_INTERVAL = 5; + public static final int MIN_LARGE_INTERVAL = 1; public static final int MAX_LARGE_INTERVAL = 7; public static final String BENCHMARK_NAME = "test_benchmark"; diff --git a/src/test/java/org/elasticsearch/test/ImmutableTestCluster.java b/src/test/java/org/elasticsearch/test/ImmutableTestCluster.java index e23766b14c0..04285cb232b 100644 --- a/src/test/java/org/elasticsearch/test/ImmutableTestCluster.java +++ b/src/test/java/org/elasticsearch/test/ImmutableTestCluster.java @@ -24,6 +24,8 @@ import org.elasticsearch.ElasticsearchIllegalArgumentException; import org.elasticsearch.action.admin.cluster.node.stats.NodeStats; import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; +import org.elasticsearch.action.bench.BenchmarkNodeMissingException; +import org.elasticsearch.action.bench.BenchmarkStatusResponse; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.logging.ESLogger; @@ -32,12 +34,13 @@ import org.elasticsearch.indices.IndexMissingException; import org.elasticsearch.indices.IndexTemplateMissingException; import org.elasticsearch.repositories.RepositoryMissingException; - import java.net.InetSocketAddress; import java.util.Random; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*; +import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; /** @@ -78,6 +81,12 @@ public abstract class ImmutableTestCluster implements Iterable { assertAllSearchersClosed(); assertAllFilesClosed(); ensureEstimatedStats(); + try { + final BenchmarkStatusResponse statusResponse = client().prepareBenchStatus().execute().actionGet(); + assertThat(statusResponse.benchmarkResponses(), is(empty())); + } catch (BenchmarkNodeMissingException ex) { + // that's fine + } } /**