Test: Also clear the alert actions te be processed between tests.

Original commit: elastic/x-pack-elasticsearch@f6da5717aa
This commit is contained in:
Martijn van Groningen 2014-11-24 21:14:18 +01:00
parent 53ef534567
commit 7eb1ec8ba0
3 changed files with 9 additions and 4 deletions

View File

@ -213,11 +213,12 @@ public class AlertManager extends AbstractComponent {
}
/**
* For testing only to clear the alerts between tests.
* For testing only to clear the alerts and actions between tests.
*/
public void clear() {
scheduler.clearAlerts();
alertsStore.clear();
actionManager.clear();
}
private void internalStop() {

View File

@ -135,6 +135,10 @@ public class AlertActionManager extends AbstractComponent {
return started.get();
}
public void clear() {
actionsToBeProcessed.clear();
}
private void doStart() {
logger.info("Starting job queue");
if (started.compareAndSet(false, true)) {
@ -323,12 +327,12 @@ public class AlertActionManager extends AbstractComponent {
updateHistoryEntry(entry);
} catch (Exception e) {
if (started()) {
logger.error("Failed to execute alert action", e);
logger.warn("Failed to execute alert action", e);
try {
entry.setErrorMsg(e.getMessage());
updateHistoryEntry(entry, AlertActionState.ERROR);
} catch (IOException ioe) {
logger.error("Failed to update action history entry", ioe);
logger.error("Failed store error message to update action history entry", ioe);
}
} else {
logger.debug("Failed to execute alert action after shutdown", e);

View File

@ -64,7 +64,7 @@ public abstract class AbstractAlertingTests extends ElasticsearchIntegrationTest
@After
public void clearAlerts() {
// Clear all in-memory alerts on all nodes, perhaps there isn't an elected master at this point
// Clear all internal state. Use manager directly because perhaps there isn't an elected master at this point
for (AlertManager manager : internalTestCluster().getInstances(AlertManager.class)) {
manager.clear();
}