This page is meant as a template for writing a KIP. To create a KIP choose Tools->Copy on this page and modify with your content and replace the heading with the next KIP number and a description of your issue. Replace anything in italics with your own description.
Status
Current state: KIP DRAFT [One of "Under Discussion", "Accepted", "Rejected"]
Discussion thread: here [Change the link from the KIP proposal email archive to your own email thread]
JIRA:
-
KAFKA-8233Getting issue details...
STATUS
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
Motivation
When using TopologyTestDriver you need to call ConsumerRecordFactory to create ConsumerRecord passed into pipeInput method to write to topic. Also when calling readOutput to consume from topic, you need to provide correct Deserializers each time.
You easily end up writing helper methods in your test classes, but this can be avoided when adding generic input and output topic classes wrapping existing functionality.
Public Interfaces
package org.apache.kafka.streams.test; public class TestInputTopic<K, V> { //TODO Constructors //Methods to pipe single record void pipeInput(V value); void pipeInput(K key, V value); void pipeInput(V value, long timestampMs); void pipeInput(K key, V value, long timestampMs); void pipeInput(K key, V value, Headers headers); void pipeInput(K key, V value, Headers headers, long timestampMs); void pipeKeyValueList(List<KeyValue<K, V>> keyValues); void pipeValueList(List<V> values); void pipeKeyValueList(List<KeyValue<K, V>> keyValues, long startTimestamp, long advanceMs); void pipeValueList(List<V> values, long startTimestamp, long advanceMs); }
package org.apache.kafka.streams.test; public class TestOutputTopic<K, V> { //TODO Constructors //Methods to readOutput V readValue(); K readKey(); KeyValue<K, V> readKeyValue(); ProducerRecord<K, V> readRecord(); Map<K, V> readRecordsToMap(); List<KeyValue<K, V>> readRecordsToList(); }
Proposed Changes
This improvement adds TestInputTopic class which wraps TopologyTestDriver and ConsumerRecordFactory methods as one class to be used to write to Input Topics and TestOutputTopic class which collects TopologyTestDriver reading methods and provide typesafe read methods.
- Examples ??
- New Classes need to updated to Testing Kafka Streams https://kafka.apache.org/22/documentation/streams/developer-guide/testing.html
Compatibility, Deprecation, and Migration Plan
This is only adding new classes. The tests utilizing directly TopologyTestDriver can still be used. There are no compatibility issues.
Rejected Alternatives
If there are alternative ways of accomplishing the same thing, what were they? The purpose of this section is to motivate why the design is the way it is and not some other way.