Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

Motivation

When using the TopologyTestDriver to assert topologies are working as expected, it can be useful to know the full set of topics the topology produces to during a test run - including internal changelog and repartition topics.

...

This enables valuable catch-all assertions to make sure the application doesn't produce to unexpected topics in addition to the regular assertions that the application does produce the expected data.

Public Interfaces

Addition of a new method to TopologyTestDriver called getOutputTopicNamesproducedTopicNames, that will return the name of all topic names with which it would be possible to call the existing createOutputTopic and get back a topic with data in ittopics the topology produced messages to during the test run, i.e. it returns the names set of the topics that topology has output records totopics the existing createOutputTopic method can be called with, that will return a topic with data available.  This set includes internal and sink topics. The method name deliberately aligns with the `createOutputTopic` method, even though some may say that using 'output topic' is misleading as the method also returns the names of internal topics, e.g. repartition and changelog topics. As createOutputTopic already allows access to internal topics, the name getOutputTopicNames seems consistent with the existing method.  Using a different name would lead to a less cohesive API. 

Code Block
/**
 * Get all the names of all the topics to which records have been outputproduced.
 * <p>
 * Call this method after piping the input into the test driver to retrieve the full set of topics the topology
 * produced records to during the test run.
 * <p>
 * The returned set of topic names includes changelog, repartition and sink topic names.
 *
 * @return the set of output topic names the topology has produced to.
 */
public final Set<String> getOutputTopicNamesproducedTopicNames(){...}

Proposed Changes

...


Code Block
public final Set<String> getOutputTopicNamesproducedTopicNames() {
    return Collections.unmodifiableSet(outputRecordsByTopic.keySet());
}

...

Compatibility, Deprecation, and Migration Plan

None

Rejected Alternatives

Pre-populate the set of topic names returned by produceTopicNames by inspecting the TopologyDescription on construction of the TopologyTestDriver instance.

This was rejected as it would not handle the case of dynamic topic bindings, i.e. non-static TopicNameExtractors. Where these are used, the topic name is not known until run time. Hence a purely `TopologyDescription` driven implementation would completely fulfil the usecase.

A future KIP may still cover extending the `TopologyDescription` with convenience methods to get the set of input, internal and output topic names, as these was considered complementary to this KLIP.

Compatibility, Deprecation, and Migration Plan

None

Rejected Alternatives

None