File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 54
54
def topics ():
55
55
topics = ["test" , "foo" , "bar" ]
56
56
admin_client = KafkaAdminClient (bootstrap_servers = [f"{ KAFKA_HOST } :9092" ])
57
- admin_client .create_topics ([NewTopic (name , num_partitions = 1 , replication_factor = 1 ) for name in topics ])
57
+ # since kafka-python 2.1.0 we started to get failures in create_topics because topics were already there despite
58
+ # calls to delete_topics. In the meantime we found a proper fix use a big hammer and catch topics handling failures
59
+ # https://github.com/dpkp/kafka-python/issues/2557
60
+ try :
61
+ admin_client .create_topics ([NewTopic (name , num_partitions = 1 , replication_factor = 1 ) for name in topics ])
62
+ except Exception :
63
+ pass
58
64
yield topics
59
- admin_client .delete_topics (topics )
65
+ try :
66
+ admin_client .delete_topics (topics )
67
+ except Exception :
68
+ pass
60
69
61
70
62
71
@pytest .fixture ()
You can’t perform that action at this time.
0 commit comments