[TEST] test against scaled value instead of fixed epsilon in MovAvgIT
When comparing doubles, fixed epsilons can fail because the absolute difference in values may be quite large, even though the relative difference is tiny (e.g. with two very large numbers). Instead, we can scale epsilon by the absolute value of the expected value. This means we are looking for a diff that is epsilon-percent away from the value, rather than just epsilon. This is basically checking the relative error using junit's assertEqual. Closes #29456, unmutes the test
This commit is contained in:
parent
9c8ebb608f
commit
cfc9d12acc
|
@ -68,7 +68,6 @@ import static org.hamcrest.Matchers.is;
|
||||||
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;
|
||||||
|
|
||||||
@LuceneTestCase.AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/29456")
|
|
||||||
@ESIntegTestCase.SuiteScopeTestCase
|
@ESIntegTestCase.SuiteScopeTestCase
|
||||||
public class MovAvgIT extends ESIntegTestCase {
|
public class MovAvgIT extends ESIntegTestCase {
|
||||||
private static final String INTERVAL_FIELD = "l_value";
|
private static final String INTERVAL_FIELD = "l_value";
|
||||||
|
@ -1296,7 +1295,7 @@ public class MovAvgIT extends ESIntegTestCase {
|
||||||
} else {
|
} else {
|
||||||
assertThat("[_count] movavg is null", countMovAvg, notNullValue());
|
assertThat("[_count] movavg is null", countMovAvg, notNullValue());
|
||||||
assertEquals("[_count] movavg does not match expected [" + countMovAvg.value() + " vs " + expectedCount + "]",
|
assertEquals("[_count] movavg does not match expected [" + countMovAvg.value() + " vs " + expectedCount + "]",
|
||||||
countMovAvg.value(), expectedCount, 0.1);
|
countMovAvg.value(), expectedCount, 0.1 * Math.abs(countMovAvg.value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a gap bucket
|
// This is a gap bucket
|
||||||
|
@ -1308,7 +1307,7 @@ public class MovAvgIT extends ESIntegTestCase {
|
||||||
} else {
|
} else {
|
||||||
assertThat("[value] movavg is null", valuesMovAvg, notNullValue());
|
assertThat("[value] movavg is null", valuesMovAvg, notNullValue());
|
||||||
assertEquals("[value] movavg does not match expected [" + valuesMovAvg.value() + " vs " + expectedValue + "]",
|
assertEquals("[value] movavg does not match expected [" + valuesMovAvg.value() + " vs " + expectedValue + "]",
|
||||||
valuesMovAvg.value(), expectedValue, 0.1);
|
valuesMovAvg.value(), expectedValue, 0.1 * Math.abs(countMovAvg.value()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue