Github user djalova commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9186#discussion_r42926305
  
    --- Diff: python/pyspark/streaming/tests.py ---
    @@ -398,6 +399,69 @@ 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(self.getEventInfo(batchSubmitted))
    +
    +        def onBatchStarted(self, batchStarted):
    +            self.batchInfosStarted.append(self.getEventInfo(batchStarted))
    +
    +        def onBatchCompleted(self, batchCompleted):
    +            
self.batchInfosCompleted.append(self.getEventInfo(batchCompleted))
    +
    +    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)
    +
    +        # Test occasionally fails without a delay
    +        time.sleep(.1)
    --- End diff --
    
    The listener sometimes receives 3 batchCompleted events instead of 4 when I 
run the test, even though it always gets the correct job output. However, when 
I add a minor delay the test passes consistently. Can I get someone's opinion 
on this?


---
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]

Reply via email to