From 714bf929aff10486a7dd1f6927a2f8dc626a30db Mon Sep 17 00:00:00 2001 From: jaymode Date: Wed, 7 Dec 2016 09:22:05 -0500 Subject: [PATCH] test: LocalExporterTests should wait for exporters to be started Original commit: elastic/x-pack-elasticsearch@978933f9d621b6b366236d832b53a810752aadf8 --- .../xpack/monitoring/exporter/local/LocalExporterTests.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/elasticsearch/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterTests.java b/elasticsearch/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterTests.java index effaa7fdf15..cfc9ae5609b 100644 --- a/elasticsearch/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterTests.java +++ b/elasticsearch/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterTests.java @@ -12,6 +12,7 @@ import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.health.ClusterHealthStatus; import org.elasticsearch.cluster.node.DiscoveryNode; +import org.elasticsearch.common.component.Lifecycle.State; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.search.SearchHit; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; @@ -178,6 +179,8 @@ public class LocalExporterTests extends MonitoringIntegTestCase { private void export(Collection docs) throws Exception { Exporters exporters = internalCluster().getInstance(Exporters.class); assertThat(exporters, notNullValue()); + // make sure exporters has been started, otherwise we might miss some of the exporters + assertBusy(() -> assertEquals(State.STARTED, exporters.lifecycleState())); // Wait for exporting bulks to be ready to export assertBusy(() -> exporters.forEach(exporter -> assertThat(exporter.openBulk(), notNullValue())));