Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17765#discussion_r113825493
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/streaming/StreamSuite.scala ---
    @@ -500,6 +502,69 @@ class StreamSuite extends StreamTest {
           }
         }
       }
    +
    +  test("calling stop() on a query cancels related jobs") {
    +    val input = MemoryStream[Int]
    +    val query = input
    +      .toDS()
    +      .map { i =>
    +        while (!org.apache.spark.TaskContext.get().isInterrupted()) {
    +          // keep looping till interrupted by query.stop()
    +          Thread.sleep(100)
    +        }
    +        i
    +      }
    +      .writeStream
    +      .format("console")
    +      .start()
    +
    +    input.addData(1)
    +    // wait for jobs to start
    +    eventually(timeout(streamingTimeout)) {
    +      assert(sparkContext.statusTracker.getActiveJobIds().nonEmpty)
    +    }
    +
    +    query.stop()
    +    // make sure jobs are stopped
    +    eventually(timeout(streamingTimeout)) {
    +      assert(sparkContext.statusTracker.getActiveJobIds().isEmpty)
    +    }
    +  }
    +
    +  test("batch id is updated correctly in the job description") {
    +    val queryName = "memStream"
    +    @volatile var jobDescription: String = null
    +    def assertContainsNameAndBatch(batch: Integer): Unit = {
    +      // wait for listener event to be processed
    +      
spark.sparkContext.listenerBus.waitUntilEmpty(streamingTimeout.toMillis)
    +      assert(jobDescription.contains(queryName) && 
jobDescription.contains(s"batch = $batch"))
    +    }
    +
    +    spark.sparkContext.addSparkListener(new SparkListener {
    +      override def onJobStart(jobStart: SparkListenerJobStart): Unit = {
    +        jobDescription = 
jobStart.properties.getProperty(SparkContext.SPARK_JOB_DESCRIPTION)
    +      }
    +    })
    +
    +    val input = MemoryStream[Int]
    +    val query = input
    --- End diff --
    
    The query is not stopped.


---
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