From 0701f7bb1812597879dd2774f74512c4c2198581 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Thu, 1 Dec 2016 11:04:11 +0100 Subject: [PATCH] test: verify whether templates exist in an assertBusy(...) It may take a few clicks before the templates are added. Waiting for started doesn't guarantee that the index templates have been added. Original commit: elastic/x-pack-elasticsearch@ee94b740a803f47e6dfbe4d474de4c1b46c7ad97 --- .../test/AbstractWatcherIntegrationTestCase.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/elasticsearch/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java b/elasticsearch/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java index f5bbaedfa99..f1741c97c22 100644 --- a/elasticsearch/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java +++ b/elasticsearch/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java @@ -574,12 +574,14 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase }); // Verify that the index templates exist: - GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates(HISTORY_TEMPLATE_NAME).get(); - assertThat("[" + HISTORY_TEMPLATE_NAME + "] is missing", response.getIndexTemplates().size(), equalTo(1)); - response = client().admin().indices().prepareGetTemplates(TRIGGERED_TEMPLATE_NAME).get(); - assertThat("[" + TRIGGERED_TEMPLATE_NAME + "] is missing", response.getIndexTemplates().size(), equalTo(1)); - response = client().admin().indices().prepareGetTemplates(WATCHES_TEMPLATE_NAME).get(); - assertThat("[" + WATCHES_TEMPLATE_NAME + "] is missing", response.getIndexTemplates().size(), equalTo(1)); + assertBusy(() -> { + GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates(HISTORY_TEMPLATE_NAME).get(); + assertThat("[" + HISTORY_TEMPLATE_NAME + "] is missing", response.getIndexTemplates().size(), equalTo(1)); + response = client().admin().indices().prepareGetTemplates(TRIGGERED_TEMPLATE_NAME).get(); + assertThat("[" + TRIGGERED_TEMPLATE_NAME + "] is missing", response.getIndexTemplates().size(), equalTo(1)); + response = client().admin().indices().prepareGetTemplates(WATCHES_TEMPLATE_NAME).get(); + assertThat("[" + WATCHES_TEMPLATE_NAME + "] is missing", response.getIndexTemplates().size(), equalTo(1)); + }); } protected void ensureLicenseEnabled() throws Exception {