Fix bug in GiantGapWithPrediction, due to "slow start" of double exp

This commit is contained in:
Zachary Tong 2015-04-23 19:13:27 -04:00
parent a218d59ce1
commit 8435d9226f
1 changed files with 3 additions and 5 deletions

View File

@ -20,9 +20,9 @@
package org.elasticsearch.search.aggregations.reducers.moving.avg; package org.elasticsearch.search.aggregations.reducers.moving.avg;
import com.carrotsearch.randomizedtesting.annotations.Seed;
import com.google.common.collect.EvictingQueue; import com.google.common.collect.EvictingQueue;
import org.apache.lucene.util.LuceneTestCase.AwaitsFix;
import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.search.SearchPhaseExecutionException; import org.elasticsearch.action.search.SearchPhaseExecutionException;
import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchResponse;
@ -58,12 +58,10 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSear
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThanOrEqualTo; import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.lessThanOrEqualTo; import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.core.IsNull.notNullValue; import static org.hamcrest.core.IsNull.notNullValue;
import static org.hamcrest.core.IsNull.nullValue; import static org.hamcrest.core.IsNull.nullValue;
@ElasticsearchIntegrationTest.SuiteScopeTest @ElasticsearchIntegrationTest.SuiteScopeTest
@AwaitsFix(bugUrl = "Gap test logic seems to fail a lot of the time on CI build")
public class MovAvgTests extends ElasticsearchIntegrationTest { public class MovAvgTests extends ElasticsearchIntegrationTest {
private static final String INTERVAL_FIELD = "l_value"; private static final String INTERVAL_FIELD = "l_value";
@ -789,8 +787,8 @@ public class MovAvgTests extends ElasticsearchIntegrationTest {
currentValue = current.value(); currentValue = current.value();
if (gapPolicy.equals(BucketHelpers.GapPolicy.IGNORE)) { if (gapPolicy.equals(BucketHelpers.GapPolicy.IGNORE)) {
// If we ignore missing, there will only be two values in this histo, so movavg will stay the same // if we are ignoring, movavg could go up (double_exp) or stay the same (simple, linear, single_exp)
assertThat(Double.compare(lastValue, currentValue), equalTo(0)); assertThat(Double.compare(lastValue, currentValue), lessThanOrEqualTo(0));
} else if (gapPolicy.equals(BucketHelpers.GapPolicy.INSERT_ZEROS)) { } else if (gapPolicy.equals(BucketHelpers.GapPolicy.INSERT_ZEROS)) {
// If we insert zeros, this should always increase the moving avg since the last bucket has a real value // If we insert zeros, this should always increase the moving avg since the last bucket has a real value
assertThat(Double.compare(lastValue, currentValue), equalTo(-1)); assertThat(Double.compare(lastValue, currentValue), equalTo(-1));