summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDana Powers <dana.powers@gmail.com>2017-06-17 07:18:54 -0700
committerDana Powers <dana.powers@gmail.com>2017-06-18 22:43:21 -0700
commitb4f71229d000b01c5d7b8054ce5eca5b69177bb1 (patch)
treec8274294e6b581f6f570d1923142d206a75196f1
parentd127928e44113f645649775174f751ebc470cd88 (diff)
downloadkafka-python-b4f71229d000b01c5d7b8054ce5eca5b69177bb1.tar.gz
Fix fetch_max_bytes=1 consumer integration test
-rw-r--r--test/test_consumer_integration.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/test/test_consumer_integration.py b/test/test_consumer_integration.py
index f04a1d1..045e81e 100644
--- a/test/test_consumer_integration.py
+++ b/test/test_consumer_integration.py
@@ -604,20 +604,20 @@ class TestConsumerIntegration(KafkaIntegrationTestCase):
self.send_messages(0, range(100, 200))
# Start a consumer. FetchResponse_v3 should always include at least 1
- # full msg, so by setting fetch_max_bytes=1 we must get 1 msg at a time
+ # full msg, so by setting fetch_max_bytes=1 we should get 1 msg at a time
+ # But 0.11.0.0 returns 1 MessageSet at a time when the messages are
+ # stored in the new v2 format by the broker.
+ #
+ # DP Note: This is a strange test. The consumer shouldn't care
+ # how many messages are included in a FetchResponse, as long as it is
+ # non-zero. I would not mind if we deleted this test. It caused
+ # a minor headache when testing 0.11.0.0.
group = 'test-kafka-consumer-max-bytes-one-msg-' + random_string(5)
consumer = self.kafka_consumer(
group_id=group,
auto_offset_reset='earliest',
+ consumer_timeout_ms=5000,
fetch_max_bytes=1)
- fetched_msgs = []
- # A bit hacky, but we need this in order for message count to be exact
- consumer._coordinator.ensure_active_group()
- for i in range(10):
- poll_res = consumer.poll(timeout_ms=2000)
- print(poll_res)
- for partition, msgs in six.iteritems(poll_res):
- for msg in msgs:
- fetched_msgs.append(msg)
+ fetched_msgs = [next(consumer) for i in range(10)]
self.assertEqual(len(fetched_msgs), 10)