Tests: wait for alerting to be stopped and added a TODO about using a start/stop lock
Original commit: elastic/x-pack-elasticsearch@7404bb56b0
This commit is contained in:
parent
42716a5adb
commit
de681481d1
|
@ -64,6 +64,14 @@ public class AlertsService extends AbstractComponent {
|
||||||
manuallyStopped = !settings.getAsBoolean("alerts.start_immediately", true);
|
manuallyStopped = !settings.getAsBoolean("alerts.start_immediately", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: consider making this adding start/stop lock
|
||||||
|
// The currently mechanism isn't broken, but in tests it is annoying that if stop has been invoked concurrently
|
||||||
|
// and the first invocation sets the state to STOPPING then the second invocation will just return, because the
|
||||||
|
// first invocation will do the work to stop alerts plugin. If the second invocation was caused by a test teardown
|
||||||
|
// then the thread lead detection will fail, because it assumes that everything should have been stopped & closed.
|
||||||
|
// This isn't the case in the situation, although this will happen, but to late for the thread leak detection to
|
||||||
|
// not see it as a failure.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manually starts alerting if not already started
|
* Manually starts alerting if not already started
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||||
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
|
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
|
||||||
import org.elasticsearch.action.index.IndexResponse;
|
import org.elasticsearch.action.index.IndexResponse;
|
||||||
|
import org.elasticsearch.alerts.AlertsService;
|
||||||
import org.elasticsearch.alerts.support.init.proxy.ClientProxy;
|
import org.elasticsearch.alerts.support.init.proxy.ClientProxy;
|
||||||
import org.elasticsearch.alerts.support.init.proxy.ScriptServiceProxy;
|
import org.elasticsearch.alerts.support.init.proxy.ScriptServiceProxy;
|
||||||
import org.elasticsearch.client.Requests;
|
import org.elasticsearch.client.Requests;
|
||||||
|
@ -31,6 +32,12 @@ public abstract class AbstractAlertsSingleNodeTests extends ElasticsearchSingleN
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void cleanupSuite() throws Exception {
|
public static void cleanupSuite() throws Exception {
|
||||||
node().stop();
|
node().stop();
|
||||||
|
assertBusy(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
assertThat(getInstanceFromNode(AlertsService.class).state(), equalTo(AlertsService.State.STOPPED));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue