From 6ec6db85441f3b129c8fb575ceee552455b3a00a Mon Sep 17 00:00:00 2001 From: jaymode Date: Thu, 16 Feb 2017 11:34:17 -0500 Subject: [PATCH] Test: handle case where multiple state_uuids are found in monitoring shards docs Original commit: elastic/x-pack-elasticsearch@8d95776081b208bf5f339088bcb6146296ffe341 --- .../xpack/monitoring/resolver/shards/ShardsTests.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/shards/ShardsTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/shards/ShardsTests.java index ab13c4304fb..8151c6a3edb 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/shards/ShardsTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/resolver/shards/ShardsTests.java @@ -63,7 +63,7 @@ public class ShardsTests extends MonitoringIntegTestCase { flush(); refresh(); - updateMonitoringInterval(3L, TimeUnit.SECONDS); + updateMonitoringInterval(1L, TimeUnit.SECONDS); waitForMonitoringIndices(); awaitMonitoringDocsCount(greaterThan(0L), ShardsResolver.TYPE); @@ -93,7 +93,7 @@ public class ShardsTests extends MonitoringIntegTestCase { assertAcked(prepareCreate(indexName) .setSettings(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1, IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)); - updateMonitoringInterval(3L, TimeUnit.SECONDS); + updateMonitoringInterval(1L, TimeUnit.SECONDS); waitForMonitoringIndices(); awaitMonitoringDocsCount(greaterThan(0L), ShardsResolver.TYPE); @@ -113,7 +113,12 @@ public class ShardsTests extends MonitoringIntegTestCase { for (Aggregation aggregation : response.getAggregations()) { assertThat(aggregation, instanceOf(StringTerms.class)); - assertThat(((StringTerms) aggregation).getBuckets().size(), equalTo(1)); + if (aggregation.getName().equals("agg_state_uuid")) { + // there is a chance that multiple documents are indexed and the cluster state uuid differs... + assertThat(((StringTerms) aggregation).getBuckets().size(), greaterThanOrEqualTo(1)); + } else { + assertThat(((StringTerms) aggregation).getBuckets().size(), equalTo(1)); + } } } }