From 58ea3924c4724a2406eec755f6da23717b4c54c3 Mon Sep 17 00:00:00 2001 From: Shixiong Zhu Date: Wed, 18 Jan 2017 10:50:51 -0800 Subject: [PATCH] [SPARK-19113][SS][TESTS] Ignore StreamingQueryException thrown from awaitInitialization to avoid breaking tests ## What changes were proposed in this pull request? #16492 missed one race condition: `StreamExecution.awaitInitialization` may throw fatal errors and fail the test. This PR just ignores `StreamingQueryException` thrown from `awaitInitialization` so that we can verify the exception in the `ExpectFailure` action later. It's fine since `StopStream` or `ExpectFailure` will catch `StreamingQueryException` as well. ## How was this patch tested? Jenkins Author: Shixiong Zhu Closes #16567 from zsxwing/SPARK-19113-2. --- .../scala/org/apache/spark/sql/streaming/StreamTest.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sql/core/src/test/scala/org/apache/spark/sql/streaming/StreamTest.scala b/sql/core/src/test/scala/org/apache/spark/sql/streaming/StreamTest.scala index 4aa4100522cde..af2f31a34d8da 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/streaming/StreamTest.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/streaming/StreamTest.scala @@ -385,7 +385,12 @@ trait StreamTest extends QueryTest with SharedSQLContext with Timeouts { .streamingQuery // Wait until the initialization finishes, because some tests need to use `logicalPlan` // after starting the query. - currentStream.awaitInitialization(streamingTimeout.toMillis) + try { + currentStream.awaitInitialization(streamingTimeout.toMillis) + } catch { + case _: StreamingQueryException => + // Ignore the exception. `StopStream` or `ExpectFailure` will catch it as well. + } case AdvanceManualClock(timeToAdd) => verify(currentStream != null,