Skip to content

Test suite fails on Python 3.11

As seen in !21 (merged), the test suite is failing on Python 3.11.

The first failure is as follows [log]:

___________________________ test_listen_no_callback ____________________________
no_callback_message = 'New message from topic {topic}: {msg}'
    def test_listen_no_callback(no_callback_message):
    
        tc = test_client(noauth=True,
                         server='kafka://test.server',
                         port=1234,
                         group='test')
        topic = 'test.topic1'
        metadata = MagicMock()
        metadata.topic = topic
        alert_contents = {"test_key": "test_value"}
        message = json.dumps(alert_contents).encode('utf-8')
    
        alert_received = [(message, metadata)]
        with patch('igwn_alert.client.open') as client_open:
    
            with client_open() as stream:
                stream.read.side_effect = [alert_received]
    
            f = io.StringIO()
            with redirect_stdout(f):
>               tc.listen(topic=topic)
igwn_alert/tests/test_igwn_alert.py:232: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
igwn_alert/client.py:241: in listen
    with self.open(url, "r", group_id=self.consumer_group) as s:
/usr/local/lib/python3.11/site-packages/hop/io.py:120: in open
    return Consumer(
/usr/local/lib/python3.11/site-packages/hop/io.py:320: in __init__
    self._consumer.subscribe(topics)
/usr/local/lib/python3.11/site-packages/adc/consumer.py:48: in subscribe
    topic_meta = self.describe_topic(topic, timeout)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <adc.consumer.Consumer object at 0x7fdfefcb17d0>
topic = 'test.test.topic1', timeout = datetime.timedelta(seconds=10)
    def describe_topic(
            self,
            topic: str,
            timeout: timedelta = timedelta(seconds=5.0)) -> confluent_kafka.admin.TopicMetadata:
        """Fetch confluent_kafka.admin.TopicMetadata describing a topic.
        """
        self.logger.debug(f"fetching cluster metadata to describe topic name={topic}")
>       cluster_meta = self._consumer.list_topics(timeout=timeout.total_seconds())
E       cimpl.KafkaException: KafkaError{code=_TRANSPORT,val=-195,str="Failed to get metadata: Local: Broker transport failure"}
/usr/local/lib/python3.11/site-packages/adc/consumer.py:70: KafkaException
----------------------------- Captured stderr call -----------------------------
%3|1696697909.094|FAIL|rdkafka#consumer-1| [thrd:test.server:1234/bootstrap]: test.server:1234/bootstrap: Failed to resolve 'test.server:1234': Name or service not known (after 7ms in state CONNECT)
%3|1696697911.087|FAIL|rdkafka#consumer-1| [thrd:test.server:1234/bootstrap]: test.server:1234/bootstrap: Failed to resolve 'test.server:1234': Name or service not known (after 1ms in state CONNECT, 1 identical error(s) suppressed)