template installation is async, so use assertBusy

This commit is contained in:
Martijn van Groningen 2016-01-07 14:00:24 +01:00
parent 0bfe6de75c
commit 0b06648205
1 changed files with 3 additions and 18 deletions

View File

@ -37,34 +37,19 @@ import static org.mockito.Mockito.when;
public class IngestTemplateTests extends ESSingleNodeTestCase {
private IngestBootstrapper bootstrapper;
@Override
protected boolean resetNodeAfterTest() {
return true;
}
@Before
public void init() {
ThreadPool threadPool = mock(ThreadPool.class);
when(threadPool.executor(anyString())).thenReturn(Runnable::run);
Environment environment = mock(Environment.class);
ClusterService clusterService = mock(ClusterService.class);
TransportService transportService = mock(TransportService.class);
bootstrapper = new IngestBootstrapper(
Settings.EMPTY, threadPool, environment, clusterService, transportService, new ProcessorsRegistry()
);
bootstrapper.setClient(client());
}
public void testIngestIndexTemplateIsInstalled() throws Exception {
verifyIngestIndexTemplateExist();
assertBusy(IngestTemplateTests::verifyIngestIndexTemplateExist);
}
public void testInstallTemplateAfterItHasBeenRemoved() throws Exception {
verifyIngestIndexTemplateExist();
assertBusy(IngestTemplateTests::verifyIngestIndexTemplateExist);
client().admin().indices().prepareDeleteTemplate(IngestBootstrapper.INGEST_INDEX_TEMPLATE_NAME).get();
verifyIngestIndexTemplateExist();
assertBusy(IngestTemplateTests::verifyIngestIndexTemplateExist);
}
private static void verifyIngestIndexTemplateExist() {