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() {
|
public void clear() {
|
||||||
scheduler.clearAlerts();
|
scheduler.clearAlerts();
|
||||||
alertsStore.clear();
|
alertsStore.clear();
|
||||||
|
actionManager.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void internalStop() {
|
private void internalStop() {
|
||||||
|
|
|
@ -135,6 +135,10 @@ public class AlertActionManager extends AbstractComponent {
|
||||||
return started.get();
|
return started.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
actionsToBeProcessed.clear();
|
||||||
|
}
|
||||||
|
|
||||||
private void doStart() {
|
private void doStart() {
|
||||||
logger.info("Starting job queue");
|
logger.info("Starting job queue");
|
||||||
if (started.compareAndSet(false, true)) {
|
if (started.compareAndSet(false, true)) {
|
||||||
|
@ -323,12 +327,12 @@ public class AlertActionManager extends AbstractComponent {
|
||||||
updateHistoryEntry(entry);
|
updateHistoryEntry(entry);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (started()) {
|
if (started()) {
|
||||||
logger.error("Failed to execute alert action", e);
|
logger.warn("Failed to execute alert action", e);
|
||||||
try {
|
try {
|
||||||
entry.setErrorMsg(e.getMessage());
|
entry.setErrorMsg(e.getMessage());
|
||||||
updateHistoryEntry(entry, AlertActionState.ERROR);
|
updateHistoryEntry(entry, AlertActionState.ERROR);
|
||||||
} catch (IOException ioe) {
|
} 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 {
|
} else {
|
||||||
logger.debug("Failed to execute alert action after shutdown", e);
|
logger.debug("Failed to execute alert action after shutdown", e);
|
||||||
|
|
|
@ -64,7 +64,7 @@ public abstract class AbstractAlertingTests extends ElasticsearchIntegrationTest
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void clearAlerts() {
|
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)) {
|
for (AlertManager manager : internalTestCluster().getInstances(AlertManager.class)) {
|
||||||
manager.clear();
|
manager.clear();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue