From 2394047370d2d93bd8bc57b996fee47465c470af Mon Sep 17 00:00:00 2001 From: Shixiong Zhu Date: Sun, 1 Jan 2017 13:25:44 -0800 Subject: [SPARK-19050][SS][TESTS] Fix EventTimeWatermarkSuite 'delay in months and years handled correctly' ## What changes were proposed in this pull request? `monthsSinceEpoch` in this test is like `math.floor(num)`, so `monthDiff` has two possible values. ## How was this patch tested? Jenkins. Author: Shixiong Zhu Closes #16449 from zsxwing/watermark-test-hotfix. --- .../org/apache/spark/sql/streaming/EventTimeWatermarkSuite.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sql/core') diff --git a/sql/core/src/test/scala/org/apache/spark/sql/streaming/EventTimeWatermarkSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/streaming/EventTimeWatermarkSuite.scala index 23f51ff11d..c34d119734 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/streaming/EventTimeWatermarkSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/streaming/EventTimeWatermarkSuite.scala @@ -190,7 +190,10 @@ class EventTimeWatermarkSuite extends StreamTest with BeforeAndAfter with Loggin assertEventStats { e => assert(timestampFormat.parse(e.get("max")).getTime === (currentTimeMs / 1000) * 1000) val watermarkTime = timestampFormat.parse(e.get("watermark")) - assert(monthsSinceEpoch(currentTime) - monthsSinceEpoch(watermarkTime) === 29) + val monthDiff = monthsSinceEpoch(currentTime) - monthsSinceEpoch(watermarkTime) + // monthsSinceEpoch is like `math.floor(num)`, so monthDiff has two possible values. + assert(monthDiff === 29 || monthDiff === 30, + s"currentTime: $currentTime, watermarkTime: $watermarkTime") } ) } -- cgit v1.2.3