Skip to content

Commit addee3d

Browse files
authored
Use wait_for_metadata=True when creating topic fixtures with admin client (#2858)
1 parent cd15ddd commit addee3d

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

test/integration/fixtures.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ def _create_topics_via_admin(broker, topic_names, num_partitions, replication_fa
4242
admin = KafkaAdminClient(**params)
4343
try:
4444
topics = [NewTopic(name, num_partitions, replication_factor) for name in topic_names]
45-
admin.create_topics(topics)
45+
admin.create_topics(topics, wait_for_metadata=True)
4646
except InvalidReplicationFactorError:
4747
time.sleep(0.5)
4848
topics = [NewTopic(name, num_partitions, replication_factor) for name in topic_names]
49-
admin.create_topics(topics)
49+
admin.create_topics(topics, wait_for_metadata=True)
5050
finally:
5151
admin.close()
5252

test/integration/test_consumer_integration.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ def test_consumer(consumer):
2323

2424

2525
def test_consumer_topics(consumer, topic):
26+
# The `topic` fixture waits for the topic to be visible in broker
27+
# metadata before returning, so a single poll + fetch is sufficient here.
2628
consumer.poll(timeout_ms=500)
2729
assert topic in consumer.topics()
2830
assert len(consumer.partitions_for_topic(topic)) > 0

0 commit comments

Comments
 (0)