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@ee94b740a8
This commit is contained in:
Martijn van Groningen 2016-12-01 11:04:11 +01:00
parent 792a821d1a
commit 0701f7bb18
1 changed files with 8 additions and 6 deletions

View File

@ -574,12 +574,14 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase
}); });
// Verify that the index templates exist: // Verify that the index templates exist:
GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates(HISTORY_TEMPLATE_NAME).get(); assertBusy(() -> {
assertThat("[" + HISTORY_TEMPLATE_NAME + "] is missing", response.getIndexTemplates().size(), equalTo(1)); GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates(HISTORY_TEMPLATE_NAME).get();
response = client().admin().indices().prepareGetTemplates(TRIGGERED_TEMPLATE_NAME).get(); assertThat("[" + HISTORY_TEMPLATE_NAME + "] is missing", response.getIndexTemplates().size(), equalTo(1));
assertThat("[" + TRIGGERED_TEMPLATE_NAME + "] is missing", response.getIndexTemplates().size(), equalTo(1)); response = client().admin().indices().prepareGetTemplates(TRIGGERED_TEMPLATE_NAME).get();
response = client().admin().indices().prepareGetTemplates(WATCHES_TEMPLATE_NAME).get(); assertThat("[" + TRIGGERED_TEMPLATE_NAME + "] is missing", response.getIndexTemplates().size(), equalTo(1));
assertThat("[" + WATCHES_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 { protected void ensureLicenseEnabled() throws Exception {