Skip to content

Commit

Permalink
Merge pull request #243 from Panikabor/fix_confluent_kafka_7_1_3
Browse files Browse the repository at this point in the history
Make kafka testcontainer compatible with confluentinc/cp-kafka:7.1.3
  • Loading branch information
tillahoffmann authored Aug 30, 2022
2 parents 7346345 + 8a46c63 commit b65c8a0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion testcontainers/kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_bootstrap_server(self):
def _connect(self):
bootstrap_server = self.get_bootstrap_server()
consumer = KafkaConsumer(group_id='test', bootstrap_servers=[bootstrap_server])
if not consumer.topics():
if not consumer.bootstrap_connected():
raise KafkaError("Unable to connect with kafka container!")

def tc_start(self):
Expand Down
5 changes: 5 additions & 0 deletions tests/test_kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ def test_kafka_producer_consumer_custom_port():
produce_and_consume_kafka_message(container)


def test_kafka_confluent_7_1_3():
with KafkaContainer(image='confluentinc/cp-kafka:7.1.3') as container:
produce_and_consume_kafka_message(container)


def produce_and_consume_kafka_message(container):
topic = 'test-topic'
bootstrap_server = container.get_bootstrap_server()
Expand Down

0 comments on commit b65c8a0

Please sign in to comment.