forked from prestodb/presto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace random test values by discrete ones
The use of Random() function in the parquet.batchreader.decoders tests may cause flakiness. Adds TestMode.java to parameterize tests with an arbitrary value and an upper-/lower-bounded value. Resolves: prestodb#23840
- Loading branch information
Showing
4 changed files
with
123 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
presto-parquet/src/test/java/com/facebook/presto/parquet/batchreader/decoders/TestMode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.facebook.presto.parquet.batchreader.decoders; | ||
|
||
public enum TestMode | ||
{ | ||
UPPER_BOUND(Integer.MAX_VALUE, Long.MAX_VALUE), LOWER_BOUND(Integer.MIN_VALUE, 0), ARBITRARY(237, 237 * (1L << 31)); | ||
|
||
private final int testInt; | ||
private final long testLong; | ||
|
||
TestMode(int i, long l) | ||
{ | ||
this.testInt = i; | ||
this.testLong = l; | ||
} | ||
|
||
public int getInt() | ||
{ | ||
return testInt; | ||
} | ||
|
||
public long getLong() | ||
{ | ||
return testLong; | ||
} | ||
|
||
public int getPositiveUpperBoundedInt(int upper) | ||
{ | ||
if (this.name().equals(LOWER_BOUND.name()) || upper <= 0) { | ||
return 0; | ||
} | ||
|
||
if (this.name().equals(UPPER_BOUND.name())) { | ||
return upper; | ||
} | ||
|
||
return ARBITRARY.testInt % upper; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.