Skip to content

Commit

Permalink
Improve test/test_consumer_integration.py in GitHub runner (#194)
Browse files Browse the repository at this point in the history
test/test_consumer_integration.py::test_kafka_consumer__blocking failed
in
https://github.com/wbarnha/kafka-python-ng/actions/runs/10361086008/job/28680735389?pr=186
because it took 592ms to finish. Output from the GitHub runner attached

This commit increase TIMEOUT_MS so it is less likely to fail on GitHub
runner.

          # Ask for 5 messages, 10 in queue. Get 5 back, no blocking
          messages = []
          with Timer() as t:
              for i in range(5):
                  msg = next(consumer)
                  messages.append(msg)
          assert_message_count(messages, 5)
  >       assert t.interval < (TIMEOUT_MS / 1000.0)
  E       assert 0.5929090976715088 < (500 / 1000.0)
  E        +  where 0.5929090976715088 = <test.testutil.Timer object at 0x7f6c4b50e960>.interval

Co-authored-by: William Barnhart <[email protected]>
  • Loading branch information
orange-kao and wbarnha authored Oct 3, 2024
1 parent 9bee9fc commit 6104623
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/test_consumer_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_kafka_consumer_unsupported_encoding(

@pytest.mark.skipif(not env_kafka_version(), reason="No KAFKA_VERSION set")
def test_kafka_consumer__blocking(kafka_consumer_factory, topic, send_messages):
TIMEOUT_MS = 500
TIMEOUT_MS = 1000
consumer = kafka_consumer_factory(auto_offset_reset='earliest',
enable_auto_commit=False,
consumer_timeout_ms=TIMEOUT_MS)
Expand All @@ -70,7 +70,7 @@ def test_kafka_consumer__blocking(kafka_consumer_factory, topic, send_messages):
consumer.unsubscribe()
consumer.assign([TopicPartition(topic, 0)])

# Ask for 5 messages, nothing in queue, block 500ms
# Ask for 5 messages, nothing in queue, block 1000ms
with Timer() as t:
with pytest.raises(StopIteration):
msg = next(consumer)
Expand All @@ -87,7 +87,7 @@ def test_kafka_consumer__blocking(kafka_consumer_factory, topic, send_messages):
assert_message_count(messages, 5)
assert t.interval < (TIMEOUT_MS / 1000.0)

# Ask for 10 messages, get 5 back, block 500ms
# Ask for 10 messages, get 5 back, block 1000ms
messages = []
with Timer() as t:
with pytest.raises(StopIteration):
Expand Down

0 comments on commit 6104623

Please sign in to comment.