Status
Current state: Under Discussion
Discussion thread: here
JIRA: https://issues.apache.org/jira/browse/KAFKA-10629
Motivation
For many use cases of TopologyTestDriver, we don't need to specify properties parameter. As of https://github.com/apache/kafka/pull/9477, many TopologyTestDriver usages will have no configurations at all to specify, so we should provide a constructor that doesn't take a Properties argument. Right now, such configuration-free usages have to provide an empty Properties object.
Public Interfaces
/** * Create a new test diver instance. * Default test properties are used to initialize the driver instance * * @param topology the topology to be tested */ public TopologyTestDriver(final Topology topology) { this(topology, DEFAULT_TEST_PROPS); } private static final Properties DEFAULT_TEST_PROPS; static { DEFAULT_TEST_PROPS = new Properties(); DEFAULT_TEST_PROPS.put(APPLICATION_ID_CONFIG, "dummy-app-id"); DEFAULT_TEST_PROPS.setProperty(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "dummy"); }
Proposed Changes
We propose to add new constructor to TopologyTestDriver class. This constructor will have only Topology as parameter. Kafka streams config has APPLICATION_ID_CONFIG and BOOTSTRAP_SERVERS_CONFIG as required parameters. Those values will be provided by DEFAULT_TEST_PROPS variable which will initialize those two parameters.
Classes which will have usage for this constructor are
- StreamsBuilderTest.java
- TopologyTest.java
- AbstractStreamTest.java
- ProcessorNodeTest.java
- TopologyTestDriver.java
- TestTopicsTest.java
- TopologyTestDriverTest.java
Compatibility, Deprecation, and Migration Plan
The proposal is backward-compatible because it only adds a new constructor and does not change any existing constructors/methods. All changes will affect test classes and will get rid of redundant properties parameter.
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.