Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions tests/instrumentation/kafka_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,18 @@
def topics():
topics = ["test", "foo", "bar"]
admin_client = KafkaAdminClient(bootstrap_servers=[f"{KAFKA_HOST}:9092"])
admin_client.create_topics([NewTopic(name, num_partitions=1, replication_factor=1) for name in topics])
# since kafka-python 2.1.0 we started to get failures in create_topics because topics were already there despite
# calls to delete_topics. In the meantime we found a proper fix use a big hammer and catch topics handling failures
# https://github.com/dpkp/kafka-python/issues/2557
try:
admin_client.create_topics([NewTopic(name, num_partitions=1, replication_factor=1) for name in topics])
except Exception:
pass
yield topics
admin_client.delete_topics(topics)
try:
admin_client.delete_topics(topics)
except Exception:
pass


@pytest.fixture()
Expand Down
Loading