diff --git a/x-pack/plugin/async-search/src/test/java/org/elasticsearch/xpack/search/AsyncSearchIntegTestCase.java b/x-pack/plugin/async-search/src/test/java/org/elasticsearch/xpack/search/AsyncSearchIntegTestCase.java index f579b834b723e..1b215068faa09 100644 --- a/x-pack/plugin/async-search/src/test/java/org/elasticsearch/xpack/search/AsyncSearchIntegTestCase.java +++ b/x-pack/plugin/async-search/src/test/java/org/elasticsearch/xpack/search/AsyncSearchIntegTestCase.java @@ -12,7 +12,10 @@ import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.support.master.AcknowledgedResponse; +import org.elasticsearch.cluster.ClusterChangedEvent; +import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.node.DiscoveryNode; +import org.elasticsearch.common.component.Lifecycle; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.ContextParser; @@ -34,6 +37,7 @@ import org.elasticsearch.xpack.core.search.action.SubmitAsyncSearchRequest; import org.elasticsearch.xpack.ilm.IndexLifecycle; import org.junit.After; +import org.junit.Before; import java.io.Closeable; import java.util.Arrays; @@ -71,6 +75,25 @@ public List getAggregations() { } } + @Before + public void startMaintenanceService() { + for (AsyncSearchMaintenanceService service : internalCluster().getDataNodeInstances(AsyncSearchMaintenanceService.class)) { + if (service.lifecycleState() == Lifecycle.State.STOPPED) { + // force the service to start again + service.start(); + ClusterState state = internalCluster().clusterService().state(); + service.clusterChanged(new ClusterChangedEvent("noop", state, state)); + } + } + } + + @After + public void stopMaintenanceService() { + for (AsyncSearchMaintenanceService service : internalCluster().getDataNodeInstances(AsyncSearchMaintenanceService.class)) { + service.stop(); + } + } + @After public void releaseQueryLatch() { BlockingQueryBuilder.releaseQueryLatch();