From c456c6e28894e4fe2fc6f1ea8228375765820cb4 Mon Sep 17 00:00:00 2001 From: Shixiong Zhu Date: Sun, 1 Jan 2017 11:55:17 -0800 Subject: [PATCH] Fix EventTimeWatermarkSuite 'delay in months and years handled correctly' --- .../apache/spark/sql/streaming/EventTimeWatermarkSuite.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 23f51ff11d903..c34d119734cc0 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") } ) }