mirror of https://github.com/apache/druid.git
Fix flaky tests in ParserTest.java (#15318)
Fixed the following flaky tests: org.apache.druid.math.expr.ParserTest#testApplyFunctions org.apache.druid.math.expr.ParserTest#testSimpleMultiplicativeOp1 org.apache.druid.math.expr.ParserTest#testFunctions org.apache.druid.math.expr.ParserTest#testSimpleLogicalOps1 org.apache.druid.math.expr.ParserTest#testSimpleAdditivityOp1 org.apache.druid.math.expr.ParserTest#testSimpleAdditivityOp2 The above mentioned tests have been reported as flaky (tests assuming deterministic implementation of a non-deterministic specification ) when ran against the NonDex tool. The tests contain assertions (Assertion 1 & Assertion 2) that compare an ArrayList created from a HashSet using the ArrayList() constructor with another List. However, HashSet does not guarantee the ordering of elements and thus resulting in these flaky tests that assume deterministic implementation of HashSet. Thus, when the NonDex tool shuffles the HashSet elements, it results in the test failures: Co-authored-by: ythorat2 <ythorat2@illinois.edu>
This commit is contained in:
parent
77828bead4
commit
7b5790c72c
|
@ -38,6 +38,7 @@ import org.junit.rules.ExpectedException;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -820,7 +821,7 @@ public class ParserTest extends InitializedNullHandlingTest
|
||||||
}
|
}
|
||||||
final Expr.BindingAnalysis deets = parsed.analyzeInputs();
|
final Expr.BindingAnalysis deets = parsed.analyzeInputs();
|
||||||
Assert.assertEquals(expression, expected, parsed.toString());
|
Assert.assertEquals(expression, expected, parsed.toString());
|
||||||
Assert.assertEquals(expression, identifiers, deets.getRequiredBindingsList());
|
Assert.assertEquals(expression, new HashSet<>(identifiers), deets.getRequiredBindings());
|
||||||
Assert.assertEquals(expression, scalars, deets.getScalarVariables());
|
Assert.assertEquals(expression, scalars, deets.getScalarVariables());
|
||||||
Assert.assertEquals(expression, arrays, deets.getArrayVariables());
|
Assert.assertEquals(expression, arrays, deets.getArrayVariables());
|
||||||
|
|
||||||
|
@ -828,7 +829,7 @@ public class ParserTest extends InitializedNullHandlingTest
|
||||||
final Expr roundTrip = Parser.parse(parsedNoFlatten.stringify(), ExprMacroTable.nil());
|
final Expr roundTrip = Parser.parse(parsedNoFlatten.stringify(), ExprMacroTable.nil());
|
||||||
Assert.assertEquals(parsed.stringify(), roundTrip.stringify());
|
Assert.assertEquals(parsed.stringify(), roundTrip.stringify());
|
||||||
final Expr.BindingAnalysis roundTripDeets = roundTrip.analyzeInputs();
|
final Expr.BindingAnalysis roundTripDeets = roundTrip.analyzeInputs();
|
||||||
Assert.assertEquals(expression, identifiers, roundTripDeets.getRequiredBindingsList());
|
Assert.assertEquals(expression, new HashSet<>(identifiers), roundTripDeets.getRequiredBindings());
|
||||||
Assert.assertEquals(expression, scalars, roundTripDeets.getScalarVariables());
|
Assert.assertEquals(expression, scalars, roundTripDeets.getScalarVariables());
|
||||||
Assert.assertEquals(expression, arrays, roundTripDeets.getArrayVariables());
|
Assert.assertEquals(expression, arrays, roundTripDeets.getArrayVariables());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue