def test_offset_reset_manual(self): yield from self.send_messages(0, list(range(0, 10))) consumer = AIOKafkaConsumer( self.topic, loop=self.loop, bootstrap_servers=self.hosts, metadata_max_age_ms=200, group_id="offset_reset_group", auto_offset_reset="none") yield from consumer.start() self.add_cleanup(consumer.stop) with self.assertRaises(OffsetOutOfRangeError): yield from consumer.getmany(timeout_ms=1000) with self.assertRaises(OffsetOutOfRangeError): yield from consumer.getone()
def test_ssl_consume(self): # Produce by PLAINTEXT, Consume by SSL # Send 3 messages yield from self.send_messages(0, [1, 2, 3]) context = self.create_ssl_context() group = "group-{}".format(self.id()) consumer = AIOKafkaConsumer( self.topic, loop=self.loop, group_id=group, bootstrap_servers=[ "{}:{}".format(self.kafka_host, self.kafka_ssl_port)], enable_auto_commit=True, auto_offset_reset="earliest", security_protocol="SSL", ssl_context=context) yield from consumer.start() results = yield from consumer.getmany(timeout_ms=1000) [msgs] = results.values() # only 1 partition anyway msgs = [msg.value for msg in msgs] self.assertEqual(msgs, [b"1", b"2", b"3"]) yield from consumer.stop()