Stop/Start async search maintenance service in tests(#56673)
This change ensures that the maintenance service that is responsible for deleting the expired response is stopped between each test. This is needed since we check that no search context are in-flight after each test method. Fixes #55988
This commit is contained in:
parent
97bf47f5b9
commit
fb5e6329b7
|
@ -12,7 +12,10 @@ import org.elasticsearch.action.admin.cluster.node.tasks.get.GetTaskResponse;
|
|||
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;
|
||||
|
@ -36,6 +39,7 @@ import org.elasticsearch.xpack.core.XPackClientPlugin;
|
|||
import org.elasticsearch.xpack.core.XPackSettings;
|
||||
import org.elasticsearch.xpack.ilm.IndexLifecycle;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.util.Arrays;
|
||||
|
@ -73,6 +77,25 @@ public abstract class AsyncSearchIntegTestCase extends ESIntegTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@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();
|
||||
|
|
Loading…
Reference in New Issue