Skip to content

Commit

Permalink
[SPARK-18617][SPARK-18560][TESTS] Fix flaky test: StreamingContextSui…
Browse files Browse the repository at this point in the history
…te. Receiver data should be deserialized properly

## What changes were proposed in this pull request?

Avoid to create multiple threads to stop StreamingContext. Otherwise, the latch added in apache#16091 can be passed too early.

## How was this patch tested?

Jenkins

Author: Shixiong Zhu <shixiong@databricks.com>

Closes apache#16105 from zsxwing/SPARK-18617-2.
  • Loading branch information
zsxwing authored and uzadude committed Jan 27, 2017
1 parent 0fd8014 commit 6994601
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -814,10 +814,12 @@ class StreamingContextSuite extends SparkFunSuite with BeforeAndAfter with Timeo
ssc = new StreamingContext(conf, Milliseconds(100))
val input = ssc.receiverStream(new TestReceiver)
val latch = new CountDownLatch(1)
@volatile var stopping = false
input.count().foreachRDD { rdd =>
// Make sure we can read from BlockRDD
if (rdd.collect().headOption.getOrElse(0L) > 0) {
if (rdd.collect().headOption.getOrElse(0L) > 0 && !stopping) {
// Stop StreamingContext to unblock "awaitTerminationOrTimeout"
stopping = true
new Thread() {
setDaemon(true)
override def run(): Unit = {
Expand Down

0 comments on commit 6994601

Please sign in to comment.