[TEST] Stabilize MovAvgTests with more lenient floating point checks

It appears the previous failure (-Dtests.seed=D9EF60095522804F) is just accumulation of
floating point error differences between expected and actual results.  Making the tests less
stringent by requiring closeTo(0.1) instead of the previous 0.00001
This commit is contained in:
Zachary Tong 2015-05-04 13:16:08 -04:00
parent f6d5167d41
commit babfd8a181
1 changed files with 4 additions and 9 deletions

View File

@ -59,9 +59,7 @@ import static org.elasticsearch.search.aggregations.AggregationBuilders.min;
import static org.elasticsearch.search.aggregations.AggregationBuilders.range; import static org.elasticsearch.search.aggregations.AggregationBuilders.range;
import static org.elasticsearch.search.aggregations.reducers.ReducerBuilders.movingAvg; import static org.elasticsearch.search.aggregations.reducers.ReducerBuilders.movingAvg;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
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;
@ -308,7 +306,6 @@ public class MovAvgTests extends ElasticsearchIntegrationTest {
* test simple moving average on single value field * test simple moving average on single value field
*/ */
@Test @Test
@AwaitsFix(bugUrl = "Fails with certain seeds including -Dtests.seed=D9EF60095522804F")
public void simpleSingleValuedField() { public void simpleSingleValuedField() {
SearchResponse response = client() SearchResponse response = client()
@ -361,7 +358,6 @@ public class MovAvgTests extends ElasticsearchIntegrationTest {
} }
@Test @Test
@AwaitsFix(bugUrl = "Fails with certain seeds including -Dtests.seed=D9EF60095522804F")
public void linearSingleValuedField() { public void linearSingleValuedField() {
SearchResponse response = client() SearchResponse response = client()
@ -414,7 +410,6 @@ public class MovAvgTests extends ElasticsearchIntegrationTest {
} }
@Test @Test
@AwaitsFix(bugUrl = "Fails with certain seeds including -Dtests.seed=D9EF60095522804F")
public void singleSingleValuedField() { public void singleSingleValuedField() {
SearchResponse response = client() SearchResponse response = client()
@ -467,7 +462,6 @@ public class MovAvgTests extends ElasticsearchIntegrationTest {
} }
@Test @Test
@AwaitsFix(bugUrl = "Fails with certain seeds including -Dtests.seed=D9EF60095522804F")
public void doubleSingleValuedField() { public void doubleSingleValuedField() {
SearchResponse response = client() SearchResponse response = client()
@ -1038,7 +1032,7 @@ public class MovAvgTests extends ElasticsearchIntegrationTest {
} else { } else {
assertThat("[_count] movavg is null", countMovAvg, notNullValue()); assertThat("[_count] movavg is null", countMovAvg, notNullValue());
assertThat("[_count] movavg does not match expected ["+countMovAvg.value()+" vs "+expectedCount+"]", assertThat("[_count] movavg does not match expected ["+countMovAvg.value()+" vs "+expectedCount+"]",
Math.abs(countMovAvg.value() - expectedCount) <= 0.000001, equalTo(true)); countMovAvg.value(), closeTo(expectedCount, 0.1));
} }
// This is a gap bucket // This is a gap bucket
@ -1047,7 +1041,8 @@ public class MovAvgTests extends ElasticsearchIntegrationTest {
assertThat("[value] movavg is not null", valuesMovAvg, Matchers.nullValue()); assertThat("[value] movavg is not null", valuesMovAvg, Matchers.nullValue());
} else { } else {
assertThat("[value] movavg is null", valuesMovAvg, notNullValue()); assertThat("[value] movavg is null", valuesMovAvg, notNullValue());
assertThat("[value] movavg does not match expected ["+valuesMovAvg.value()+" vs "+expectedValue+"]", Math.abs(valuesMovAvg.value() - expectedValue) <= 0.000001, equalTo(true)); assertThat("[value] movavg does not match expected ["+valuesMovAvg.value()+" vs "+expectedValue+"]",
valuesMovAvg.value(), closeTo(expectedValue, 0.1));
} }
} }