Github user brkyvz commented on a diff in the pull request:
https://github.com/apache/spark/pull/16343#discussion_r93543971
--- Diff:
streaming/src/test/scala/org/apache/spark/streaming/InputStreamsSuite.scala ---
@@ -67,42 +67,33 @@ class InputStreamsSuite extends TestSuiteBase with
BeforeAndAfter {
val expectedOutput = input.map(_.toString)
for (i <- input.indices) {
testServer.send(input(i).toString + "\n")
- Thread.sleep(500)
clock.advance(batchDuration.milliseconds)
}
- // Make sure we finish all batches before "stop"
- if (!batchCounter.waitUntilBatchesCompleted(input.size, 30000)) {
- fail("Timeout: cannot finish all batches in 30 seconds")
+
+ eventually(eventuallyTimeout) {
+ clock.advance(batchDuration.milliseconds)
+ // Verify whether data received was as expected
+ logInfo("--------------------------------")
+ logInfo("output.size = " + outputQueue.size)
+ logInfo("output")
+ outputQueue.asScala.foreach(x => logInfo("[" + x.mkString(",") +
"]"))
+ logInfo("expected output.size = " + expectedOutput.size)
+ logInfo("expected output")
+ expectedOutput.foreach(x => logInfo("[" + x.mkString(",") + "]"))
+ logInfo("--------------------------------")
+
+ // Verify whether all the elements received are as expected
+ // (whether the elements were received one in each interval is
not verified)
+ val output: Array[String] = outputQueue.asScala.flatMap(x =>
x).toArray
+ assert(output.length === expectedOutput.size)
+ for (i <- output.indices) {
+ assert(output(i) === expectedOutput(i))
+ }
}
- // Ensure progress listener has been notified of all events
- ssc.sparkContext.listenerBus.waitUntilEmpty(500)
-
- // Verify all "InputInfo"s have been reported
- assert(ssc.progressListener.numTotalReceivedRecords === input.size)
- assert(ssc.progressListener.numTotalProcessedRecords ===
input.size)
-
- logInfo("Stopping server")
- testServer.stop()
- logInfo("Stopping context")
- ssc.stop()
-
- // Verify whether data received was as expected
- logInfo("--------------------------------")
- logInfo("output.size = " + outputQueue.size)
- logInfo("output")
- outputQueue.asScala.foreach(x => logInfo("[" + x.mkString(",") +
"]"))
- logInfo("expected output.size = " + expectedOutput.size)
- logInfo("expected output")
- expectedOutput.foreach(x => logInfo("[" + x.mkString(",") + "]"))
- logInfo("--------------------------------")
-
- // Verify whether all the elements received are as expected
- // (whether the elements were received one in each interval is not
verified)
- val output: Array[String] = outputQueue.asScala.flatMap(x =>
x).toArray
- assert(output.length === expectedOutput.size)
- for (i <- output.indices) {
- assert(output(i) === expectedOutput(i))
+ eventually(eventuallyTimeout) {
--- End diff --
since these are reported asynchronously, they may be reported after the
results have already been processed. Since the whole code inside eventually
executes each time, I didn't want to execute the whole batch of code above
(increase time in manual clock, log a bunch of stuff)
---
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]