summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDana Powers <dana.powers@rd.io>2015-06-05 10:28:17 -0700
committerDana Powers <dana.powers@rd.io>2015-06-06 16:47:26 -0700
commit522395f83711b2b8eca08135a6054de80c75d55e (patch)
tree1b8e3a5cd19f608bca981d4321aa574db935cad9
parent7b86964dd7c0cb71ba1a3ab150240d7b20e1f2be (diff)
downloadkafka-python-522395f83711b2b8eca08135a6054de80c75d55e.tar.gz
test_batched_simple_producer__triggers_by_message should wait for producer queue to drain before testing messages were sent
-rw-r--r--test/test_producer_integration.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/test_producer_integration.py b/test/test_producer_integration.py
index e3f7767..329e4bc 100644
--- a/test/test_producer_integration.py
+++ b/test/test_producer_integration.py
@@ -251,6 +251,16 @@ class TestKafkaProducerIntegration(KafkaIntegrationTestCase):
# Batch mode is async. No ack
self.assertEqual(len(resp), 0)
+ # Wait until producer has pulled all messages from internal queue
+ # this should signal that the first batch was sent, and the producer
+ # is now waiting for enough messages to batch again (or a timeout)
+ timeout = 5
+ start = time.time()
+ while not producer.queue.empty():
+ if time.time() - start > timeout:
+ self.fail('timeout waiting for producer queue to empty')
+ time.sleep(0.1)
+
# send messages groups all *msgs in a single call to the same partition
# so we should see all messages from the first call in one partition
self.assert_fetch_offset(partitions[0], start_offsets[0], [