code: def test_kafka_group_io_dataset_primary_cg():
      """Test the functionality of the KafkaGroupIODataset when the consumer group
      is being newly created.
  
      NOTE: After the kafka cluster is setup during the testing phase, 10 messages
      are written to the 'key-partition-test' topic with 5 in each partition
      (topic created with 2 partitions, the messages are split based on the keys).
      And the same 10 messages are written into the 'key-test' topic (topic created
      with 1 partition, so no splitting of the messages based on the keys).
  
      K0:D0, K1:D1, K0:D2, K1:D3, K0:D4, K1:D5, K0:D6, K1:D7, K0:D8, K1:D9.
  
      Here, messages D0, D2, D4, D6 and D8 are written into partition 0 and the rest are written
      into partition 1.
  
      Also, since the messages are read from different partitions, the order of retrieval may not be
      the same as storage. Thus, we sort and compare.
      """
      dataset = tfio.experimental.streaming.KafkaGroupIODataset(
          topics=["key-partition-test"],
          group_id="cgtestprimary",
          servers="localhost:9092",
          configuration=[
              "session.timeout.ms=7000",
              "max.poll.interval.ms=8000",
              "auto.offset.reset=earliest",
          ],
      )
      assert np.all(
          sorted(k.numpy() for (k, _) in dataset)
          == sorted(("D" + str(i)).encode() for i in range(10))
      )
  
imports: import sys
  import time
  import pytest
  import numpy
  import threading
  import tensorflow
  import tensorflow_io
label_desc: Use image node_id 7 for calling a global function with example usage: test_kafka_group_io_dataset_primary_cg() without return types