spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djalova <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-6328] [Python] Python API for Streaming...
Date Thu, 12 Nov 2015 18:27:38 GMT
Github user djalova commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9186#discussion_r44694463
  
    --- Diff: python/pyspark/streaming/tests.py ---
    @@ -403,6 +404,80 @@ def func(dstream):
             self._test_func(input, func, expected)
     
     
    +class StreamingListenerTests(PySparkStreamingTestCase):
    +
    +    duration = .5
    +
    +    class BatchInfoCollector(StreamingListener):
    +
    +        def __init__(self):
    +            super(StreamingListener, self).__init__()
    +            self.batchInfosCompleted = []
    +            self.batchInfosStarted = []
    +            self.batchInfosSubmitted = []
    +
    +        def onBatchSubmitted(self, batchSubmitted):
    +            self.batchInfosSubmitted.append(batchSubmitted.batchInfo())
    +
    +        def onBatchStarted(self, batchStarted):
    +            self.batchInfosStarted.append(batchStarted.batchInfo())
    +
    +        def onBatchCompleted(self, batchCompleted):
    +            self.batchInfosCompleted.append(batchCompleted.batchInfo())
    +
    +    def test_batch_info_reports(self):
    +        batch_collector = self.BatchInfoCollector()
    +        self.ssc.addStreamingListener(batch_collector)
    +        input = [[1], [2], [3], [4]]
    +
    +        def func(dstream):
    +            return dstream.map(int)
    +        expected = [[1], [2], [3], [4]]
    +        self._test_func(input, func, expected)
    +
    +        batchInfosSubmitted = batch_collector.batchInfosSubmitted
    +        batchInfosStarted = batch_collector.batchInfosStarted
    +        batchInfosCompleted = batch_collector.batchInfosCompleted
    +
    +        self.wait_for(batchInfosCompleted, 4)
    +
    +        self.assertEqual(len(batchInfosSubmitted), 4)
    --- End diff --
    
    Ok, I'll change the assert to check if it receives at least 1 batch.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message