Test: handle case where multiple state_uuids are found in monitoring shards docs

Original commit: elastic/x-pack-elasticsearch@8d95776081
This commit is contained in:
jaymode 2017-02-16 11:34:17 -05:00
parent c5506b7440
commit 6ec6db8544
1 changed files with 8 additions and 3 deletions

View File

@ -63,7 +63,7 @@ public class ShardsTests extends MonitoringIntegTestCase {
flush(); flush();
refresh(); refresh();
updateMonitoringInterval(3L, TimeUnit.SECONDS); updateMonitoringInterval(1L, TimeUnit.SECONDS);
waitForMonitoringIndices(); waitForMonitoringIndices();
awaitMonitoringDocsCount(greaterThan(0L), ShardsResolver.TYPE); awaitMonitoringDocsCount(greaterThan(0L), ShardsResolver.TYPE);
@ -93,7 +93,7 @@ public class ShardsTests extends MonitoringIntegTestCase {
assertAcked(prepareCreate(indexName) assertAcked(prepareCreate(indexName)
.setSettings(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1, IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)); .setSettings(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1, IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0));
updateMonitoringInterval(3L, TimeUnit.SECONDS); updateMonitoringInterval(1L, TimeUnit.SECONDS);
waitForMonitoringIndices(); waitForMonitoringIndices();
awaitMonitoringDocsCount(greaterThan(0L), ShardsResolver.TYPE); awaitMonitoringDocsCount(greaterThan(0L), ShardsResolver.TYPE);
@ -113,7 +113,12 @@ public class ShardsTests extends MonitoringIntegTestCase {
for (Aggregation aggregation : response.getAggregations()) { for (Aggregation aggregation : response.getAggregations()) {
assertThat(aggregation, instanceOf(StringTerms.class)); 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));
}
} }
} }
} }