This is an automated email from the ASF dual-hosted git repository.
jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 12b106b Fix SegmentGenerationWithTimeColumnTest (#7537)
12b106b is described below
commit 12b106bb27013c3d845930e2c7a5c629b662f778
Author: Richard Startin <[email protected]>
AuthorDate: Fri Oct 8 00:17:51 2021 +0100
Fix SegmentGenerationWithTimeColumnTest (#7537)
This test would fail when timestamps were generated in the first or last
day and the simple date mode was used. There isn't enough information to get a
number of milliseconds in UTC. We don't know which timezone the simple date is
in, but also don't know that there isn't a timezone in the format string
either, so the second change ensures that we don't test within a day of the
minimum or maximum allowed number of milliseconds. This has no functional
impact, it only relates to interval [...]
I added a couple of tests to fix the seed for degenerate cases.
---
.../SegmentGenerationWithTimeColumnTest.java | 30 ++++++++++++++++++----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git
a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/creator/SegmentGenerationWithTimeColumnTest.java
b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/creator/SegmentGenerationWithTimeColumnTest.java
index 819fe0e..884b77e 100644
---
a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/creator/SegmentGenerationWithTimeColumnTest.java
+++
b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/creator/SegmentGenerationWithTimeColumnTest.java
@@ -79,6 +79,8 @@ public class SegmentGenerationWithTimeColumnTest {
_minTime = Long.MAX_VALUE;
_maxTime = Long.MIN_VALUE;
FileUtils.deleteQuietly(new File(SEGMENT_DIR_NAME));
+ // allow tests to fix the seed by restoring it here
+ _random.setSeed(_seed);
}
@Test
@@ -114,6 +116,20 @@ public class SegmentGenerationWithTimeColumnTest {
Assert.assertEquals(metadata.getEndTime(), _maxTime);
}
+ @Test
+ public void testSimpleDateSegmentGenerationNewWithDegenerateSeed()
+ throws Exception {
+ _random.setSeed(255672780506968L);
+ testSimpleDateSegmentGenerationNew();
+ }
+
+ @Test
+ public void testEpochDateSegmentGenerationWithDegenerateSeed()
+ throws Exception {
+ _random.setSeed(255672780506968L);
+ testEpochDateSegmentGeneration();
+ }
+
/**
* Tests using DateTimeFieldSpec as time column
*/
@@ -225,12 +241,16 @@ public class SegmentGenerationWithTimeColumnTest {
}
private Object getRandomValueForTimeColumn(boolean isSimpleDate, boolean
isInvalidDate) {
- long randomMs = _validMinTime + (long) (_random.nextDouble() * (_startTime
- _validMinTime));
+ // avoid testing within a day after the start of the epoch because
timezones aren't (and can't)
+ // be handled properly
+ long oneDayInMillis = 24 * 60 * 60 * 1000;
+ long randomMs = _validMinTime + oneDayInMillis
+ + (long) (_random.nextDouble() * (_startTime - _validMinTime -
oneDayInMillis));
Preconditions.checkArgument(TimeUtils.timeValueInValidRange(randomMs),
"Value " + randomMs + " out of range");
long dateColVal = randomMs;
Object result;
if (isInvalidDate) {
- result = new Long(new DateTime(2072, 1, 1, 0, 0, 0, 0,
DateTimeZone.UTC).getMillis());
+ result = new DateTime(2072, 1, 1, 0, 0, 0, 0,
DateTimeZone.UTC).getMillis();
return result;
} else if (isSimpleDate) {
DateTime dateTime = new DateTime(randomMs, DateTimeZone.UTC);
@@ -239,10 +259,10 @@ public class SegmentGenerationWithTimeColumnTest {
int month = localDateTime.getMonthOfYear();
int day = localDateTime.getDayOfMonth();
String dateColStr = String.format("%04d%02d%02d", year, month, day);
- dateColVal = Integer.valueOf(dateColStr);
- result = new Integer(Integer.valueOf(dateColStr));
+ dateColVal = Integer.parseInt(dateColStr);
+ result = (int) dateColVal;
} else {
- result = new Long(dateColVal);
+ result = dateColVal;
}
if (dateColVal < _minTime) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]