From 78d92622da64895a7c502f70c2392d14f737c7c7 Mon Sep 17 00:00:00 2001 From: Joshua Powers Date: Thu, 19 May 2022 14:15:41 -0600 Subject: [PATCH] test: force elasticsearch to index batch data (#11153) --- .../elasticsearch_query/elasticsearch_query_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/inputs/elasticsearch_query/elasticsearch_query_test.go b/plugins/inputs/elasticsearch_query/elasticsearch_query_test.go index cccebc3ba3253..fb1055eed5037 100644 --- a/plugins/inputs/elasticsearch_query/elasticsearch_query_test.go +++ b/plugins/inputs/elasticsearch_query/elasticsearch_query_test.go @@ -568,8 +568,13 @@ func setupIntegrationTest() error { return err } - // wait 5s (default) for Elasticsearch to index, so results are consistent - time.Sleep(time.Second * 5) + // force elastic to refresh indexes to get new batch data + ctx := context.Background() + _, err = e.esClient.Refresh().Do(ctx) + if err != nil { + return err + } + return nil }