Skip to content

Commit 033f777

Browse files
committed
tests/kafka: wait for the cluster to delete topics
Since kafka-python 2.1.0 topic deletions have become more asynchronous so, so wait for the cluster to update its status.
1 parent 52fd979 commit 033f777

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tests/instrumentation/kafka_tests.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
kafka = pytest.importorskip("kafka")
4242

43-
from kafka import KafkaConsumer, KafkaProducer
43+
from kafka import KafkaClient, KafkaConsumer, KafkaProducer
4444
from kafka.admin import KafkaAdminClient, NewTopic
4545

4646
pytestmark = [pytest.mark.kafka]
@@ -57,6 +57,13 @@ def topics():
5757
admin_client.create_topics([NewTopic(name, num_partitions=1, replication_factor=1) for name in topics])
5858
yield topics
5959
admin_client.delete_topics(topics)
60+
client = KafkaClient(bootstrap_servers=[f"{KAFKA_HOST}:9092"])
61+
try:
62+
future = client.cluster.request_update()
63+
client.poll(future=future)
64+
except Exception as e:
65+
print(e)
66+
pass
6067

6168

6269
@pytest.fixture()

0 commit comments

Comments
 (0)