Github user tdas commented on a diff in the pull request:
https://github.com/apache/spark/pull/1195#discussion_r15199936
--- Diff:
streaming/src/test/scala/org/apache/spark/streaming/InputStreamsSuite.scala ---
@@ -236,6 +236,36 @@ class InputStreamsSuite extends TestSuiteBase with
BeforeAndAfter {
assert(output.sum === numTotalRecords)
}
+ /**
+ * Test to ensure callbacks are called when the store which has a
callback specified is called.
+ */
+ test("receiver with callbacks") {
+ val limit = 100
+ val testReceiver = new CallbackReceiver(limit)
+ // set up the network stream using the test receiver
+ val ssc = new StreamingContext(conf, batchDuration)
+ val networkStream = ssc.receiverStream[AnyVal](testReceiver)
+ val outputBuffer = new ArrayBuffer[Seq[AnyVal]]
+ val outputStream = new TestOutputStream(networkStream, outputBuffer)
+ def output = outputBuffer.flatten
+ outputStream.register()
+ ssc.start()
+
+ // Let the data from the receiver be received
+ val clock = ssc.scheduler.clock.asInstanceOf[ManualClock]
+ val startTime = System.currentTimeMillis()
+ while((output.size < limit * 2) &&
+ System.currentTimeMillis() - startTime < 5000) {
+ Thread.sleep(50)
+ clock.addToTime(batchDuration.milliseconds)
+ }
+ Thread.sleep(1000)
+ logInfo("Stopping context")
+ assert(output.size === limit * 2)
+ // Sum would be (sum(1..limit)) * 2 since each number appears twice.
+ assert(output.asInstanceOf[ArrayBuffer[Int]].sum === limit * (limit +
1))
+ ssc.stop()
+ }
test("queue input stream - oneAtATime=true") {
--- End diff --
add extra line here.
---
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.
---