code: def test_consumer(kafka_broker, topic):
      # The `topic` fixture is included because
      # 0.8.2 brokers need a topic to function well
      consumer = KafkaConsumer(
          bootstrap_servers=get_connect_str(kafka_broker)
      )
      consumer.poll(500)
      assert len(consumer._client._conns) > 0
      node_id = list(consumer._client._conns.keys())[0]
      assert (
          consumer._client._conns[node_id].state
          is ConnectionStates.CONNECTED
      )
      consumer.close()
  
file_path: kafka-python/test/test_consumer_group.py
imports: import collections
  import logging
  import threading
  import time
  import pytest
  from kafka.vendor import six
  from kafka.conn import ConnectionStates
  from kafka.consumer.group import KafkaConsumer
  from kafka.coordinator.base import MemberState
  from kafka.structs import TopicPartition
  from test.testutil import env_kafka_version, random_string
label_desc: Use image node_id 2 for calling a global function with example usage: test_consumer(kafka_broker, topic) without return types