Github user tdas commented on a diff in the pull request:
https://github.com/apache/spark/pull/11030#discussion_r51823321
--- Diff: sql/core/src/test/scala/org/apache/spark/sql/StreamTest.scala ---
@@ -211,37 +264,69 @@ trait StreamTest extends QueryTest with Timeouts {
})
case StopStream =>
- checkState(currentStream != null, "can not stop a stream that
is not running")
- currentStream.stop()
- currentStream = null
+ assert(currentStream != null, "can not stop a stream that is
not running")
+ try failAfter(streamingTimout) {
+ currentStream.stop()
+ assert(!currentStream.microBatchThread.isAlive,
+ s"microbatch thread not stopped")
+ assert(!currentStream.isActive,
+ "query.isActive() is false even after stopping")
+ assert(currentStream.exception.isEmpty,
+ "query.exception() is not empty after clean stop")
+ } catch {
+ case _: InterruptedException =>
+ case _:
org.scalatest.exceptions.TestFailedDueToTimeoutException =>
+ failTest("Timed out while stopping and waiting for
microbatchthread to terminate.")
+ case t: Throwable =>
+ failTest("Error while checking stream failure.", t)
+ } finally {
+ lastStream = currentStream
+ currentStream = null
+ }
--- End diff --
isnt it just safer to be in finally?
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]