Skip to content

Commit f8f6c93

Browse files
committed
Remove (all but one) sleep calls from “socket input stream” test
1 parent 303e828 commit f8f6c93

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

streaming/src/test/scala/org/apache/spark/streaming/InputStreamsSuite.scala

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717

1818
package org.apache.spark.streaming
1919

20-
import akka.actor.Actor
21-
import akka.actor.Props
22-
import akka.util.ByteString
23-
2420
import java.io.{File, BufferedWriter, OutputStreamWriter}
2521
import java.net.{InetSocketAddress, SocketException, ServerSocket}
2622
import java.nio.charset.Charset
@@ -54,6 +50,7 @@ class InputStreamsSuite extends TestSuiteBase with BeforeAndAfter {
5450

5551
// Set up the streaming context and input streams
5652
val ssc = new StreamingContext(conf, batchDuration)
53+
val waiter = new StreamingTestWaiter(ssc)
5754
val networkStream = ssc.socketTextStream(
5855
"localhost", testServer.port, StorageLevel.MEMORY_AND_DISK)
5956
val outputBuffer = new ArrayBuffer[Seq[String]] with SynchronizedBuffer[Seq[String]]
@@ -66,13 +63,12 @@ class InputStreamsSuite extends TestSuiteBase with BeforeAndAfter {
6663
val clock = ssc.scheduler.clock.asInstanceOf[ManualClock]
6764
val input = Seq(1, 2, 3, 4, 5)
6865
val expectedOutput = input.map(_.toString)
69-
Thread.sleep(1000)
7066
for (i <- 0 until input.size) {
7167
testServer.send(input(i).toString + "\n")
72-
Thread.sleep(500)
68+
Thread.sleep(500) // This sleep is to wait for `testServer` to send the data to Spark
7369
clock.addToTime(batchDuration.milliseconds)
70+
waiter.waitForBatchToComplete()
7471
}
75-
Thread.sleep(1000)
7672
logInfo("Stopping server")
7773
testServer.stop()
7874
logInfo("Stopping context")

0 commit comments

Comments
 (0)