[TEST] Only sanitly check time values in stats

Testing the actual time value even with lowerbounds is very tricky
and fails very often. We should really just sanity check the values.
This commit is contained in:
Simon Willnauer 2015-07-08 10:02:21 +02:00
parent 26fd4ba95b
commit b5452074a3
1 changed files with 4 additions and 9 deletions

View File

@ -186,7 +186,6 @@ public class SearchStatsTests extends ElasticsearchIntegrationTest {
// force the scan to complete measuring the time taken // force the scan to complete measuring the time taken
// the total time the scroll is open should be greater than this // 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 // 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; int count = 0;
while (true) { while (true) {
count++; count++;
@ -197,15 +196,11 @@ public class SearchStatsTests extends ElasticsearchIntegrationTest {
break; break;
} }
} }
long total = System.nanoTime() - time;
indicesStats = client().admin().indices().prepareStats().execute().actionGet(); indicesStats = client().admin().indices().prepareStats().execute().actionGet();
assertThat(indicesStats.getTotal().getSearch().getTotal().getQueryCount(), equalTo(count * (long)numAssignedShards("test1"))); Stats stats = indicesStats.getTotal().getSearch().getTotal();
assertThat(indicesStats.getTotal().getSearch().getTotal().getScrollCount(), equalTo((long)numAssignedShards("test1"))); assertThat(stats.getQueryCount(), equalTo(count * (long)numAssignedShards("test1")));
assertThat( assertThat(stats.getScrollCount(), equalTo((long)numAssignedShards("test1")));
indicesStats.getTotal().getSearch().getTotal().getScrollTimeInMillis(), assertThat(stats.getScrollTimeInMillis(), greaterThan(0l));
greaterThan(TimeUnit.NANOSECONDS.toMillis(total * numAssignedShards("test1")))
);
// scroll, but with no timeout (so no context) // scroll, but with no timeout (so no context)
searchResponse = client().prepareSearchScroll(searchResponse.getScrollId()).execute().actionGet(); searchResponse = client().prepareSearchScroll(searchResponse.getScrollId()).execute().actionGet();