Test: Also clear the alert actions te be processed between tests.
Original commit: elastic/x-pack-elasticsearch@f6da5717aa
This commit is contained in:
parent
53ef534567
commit
7eb1ec8ba0
|
@ -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() {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue