Github user lw-lin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12797#discussion_r61663787
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/ProcessingTimeExecutorSuite.scala
 ---
    @@ -21,19 +21,41 @@ import java.util.concurrent.{CountDownLatch, TimeUnit}
     
     import org.apache.spark.SparkFunSuite
     import org.apache.spark.sql.ProcessingTime
    -import org.apache.spark.util.ManualClock
    +import org.apache.spark.util.{Clock, ManualClock, SystemClock}
     
     class ProcessingTimeExecutorSuite extends SparkFunSuite {
     
       test("nextBatchTime") {
         val processingTimeExecutor = 
ProcessingTimeExecutor(ProcessingTime(100))
    +    assert(processingTimeExecutor.nextBatchTime(0) === 100)
         assert(processingTimeExecutor.nextBatchTime(1) === 100)
         assert(processingTimeExecutor.nextBatchTime(99) === 100)
    -    assert(processingTimeExecutor.nextBatchTime(100) === 100)
    +    assert(processingTimeExecutor.nextBatchTime(100) === 200)
         assert(processingTimeExecutor.nextBatchTime(101) === 200)
         assert(processingTimeExecutor.nextBatchTime(150) === 200)
       }
     
    +  private def testNextBatchTimeAgainstClock(clock: Clock) {
    +    val IntervalMS = 100
    +    val processingTimeExecutor = 
ProcessingTimeExecutor(ProcessingTime(IntervalMS), clock)
    +
    +    val ITERATION = 10
    +    var nextBatchTime: Long = 0
    +    for (it <- 1 to ITERATION)
    +      nextBatchTime = processingTimeExecutor.nextBatchTime(nextBatchTime)
    +
    +    // nextBatchTime should be 1000
    +    assert(nextBatchTime === IntervalMS * ITERATION)
    +  }
    +
    +  test("nextBatchTime against SystemClock") {
    +    testNextBatchTimeAgainstClock(new SystemClock)
    +  }
    +
    +  test("nextBatchTime against ManualClock") {
    --- End diff --
    
    Please note the `ProcessingTimeExecutor` issue would fail this test without 
this patch, but would pass with this patch.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to