diff --git a/core/src/test/java/org/elasticsearch/search/stats/SearchStatsTests.java b/core/src/test/java/org/elasticsearch/search/stats/SearchStatsTests.java index fd100a64b9b..d4446fef52a 100644 --- a/core/src/test/java/org/elasticsearch/search/stats/SearchStatsTests.java +++ b/core/src/test/java/org/elasticsearch/search/stats/SearchStatsTests.java @@ -186,7 +186,6 @@ public class SearchStatsTests extends ElasticsearchIntegrationTest { // force the scan to complete measuring the time taken // the total time the scroll is open should be greater than this // the number of queries should equal the number of pages in the scan times the number of shards - long time = System.nanoTime(); int count = 0; while (true) { count++; @@ -197,15 +196,11 @@ public class SearchStatsTests extends ElasticsearchIntegrationTest { break; } } - long total = System.nanoTime() - time; - indicesStats = client().admin().indices().prepareStats().execute().actionGet(); - assertThat(indicesStats.getTotal().getSearch().getTotal().getQueryCount(), equalTo(count * (long)numAssignedShards("test1"))); - assertThat(indicesStats.getTotal().getSearch().getTotal().getScrollCount(), equalTo((long)numAssignedShards("test1"))); - assertThat( - indicesStats.getTotal().getSearch().getTotal().getScrollTimeInMillis(), - greaterThan(TimeUnit.NANOSECONDS.toMillis(total * numAssignedShards("test1"))) - ); + Stats stats = indicesStats.getTotal().getSearch().getTotal(); + assertThat(stats.getQueryCount(), equalTo(count * (long)numAssignedShards("test1"))); + assertThat(stats.getScrollCount(), equalTo((long)numAssignedShards("test1"))); + assertThat(stats.getScrollTimeInMillis(), greaterThan(0l)); // scroll, but with no timeout (so no context) searchResponse = client().prepareSearchScroll(searchResponse.getScrollId()).execute().actionGet();