From 96d80597c442997491ec6d42121485c56f61f6e3 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Mon, 2 Mar 2015 14:17:37 +0100 Subject: [PATCH] Test: fixed test timing issue Original commit: elastic/x-pack-elasticsearch@ccdac702f4453510f8cd9ba01110ca5f1f78526c --- .../alerts/test/integration/BasicAlertsTests.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/test/java/org/elasticsearch/alerts/test/integration/BasicAlertsTests.java b/src/test/java/org/elasticsearch/alerts/test/integration/BasicAlertsTests.java index 52384cfc113..6aa3433aa33 100644 --- a/src/test/java/org/elasticsearch/alerts/test/integration/BasicAlertsTests.java +++ b/src/test/java/org/elasticsearch/alerts/test/integration/BasicAlertsTests.java @@ -108,6 +108,13 @@ public class BasicAlertsTests extends AbstractAlertsIntegrationTests { .get(); assertThat(indexResponse.indexResponse().isCreated(), is(true)); + // TODO: when MockScheduler can be used this workaround can be removed: + // Although there is no added benefit in this test for waiting for the alert to fire, however + // we need to wait here because of a test timing issue. When we tear down a test we delete the alert and delete all + // indices, but there may still be inflight fired alerts, which may trigger the alert history to be created again, before + // we finished the tear down phase. + assertAlertWithNoActionNeeded("my-first-alert", 1); + DeleteAlertRequest deleteAlertRequest = new DeleteAlertRequest("my-first-alert"); DeleteAlertResponse deleteAlertResponse = alertsClient.deleteAlert(deleteAlertRequest).actionGet(); assertNotNull(deleteAlertResponse.deleteResponse());