Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Added unit-test for error_cb
  • Loading branch information
edenhill committed Jul 13, 2016
commit fa80712a5c046e10073469276041edd8d8608fc6
30 changes: 30 additions & 0 deletions tests/test_KafkaError.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python

from confluent_kafka import Producer, KafkaError, KafkaException
import time

seen_all_brokers_down = False

def error_cb (err):
print('error_cb', err)
if err.code() == KafkaError._ALL_BROKERS_DOWN:
global seen_all_brokers_down
seen_all_brokers_down = True


def test_error_cb():
""" Test the error callback. """

global seen_all_brokers_down

# Configure an invalid broker and make sure the ALL_BROKERS_DOWN
# error is seen in the error callback.
p = Producer({'bootstrap.servers': '127.0.0.1:1', 'socket.timeout.ms':10,
'error_cb': error_cb})

t_end = time.time() + 5

while not seen_all_brokers_down and time.time() < t_end:
p.poll(1)

assert seen_all_brokers_down