KAFKA-20629: Add ducktape system tests for topology description plugin#22769
KAFKA-20629: Add ducktape system tests for topology description plugin#22769lucliu1108 wants to merge 13 commits into
Conversation
…n (1/2)
Introduces the system-test infrastructure for KIP-1331 (Streams Group
Topology Description Plugin):
- New Java driver TopologyDescriptionPluginSystemTest that starts a
small streams app and exits on signal.
- New ducktape suite streams_topology_description_plugin_test with
three scenarios:
* push round-trip succeeds when the plugin is configured and the
client default push is on;
* client opt-out via topology.description.push.enabled=false
prevents the client from ever sending a description;
* no plugin on the broker means no solicitation is issued.
- KafkaService constructor parameter
streams_group_topology_description_plugin_class and matching
config_property constant to propagate
group.streams.topology.description.plugin.class to brokers.
- StreamsTopologyDescriptionPluginService and the supporting
TOPOLOGY_DESCRIPTION_PUSH_ENABLED property constant for the new
driver.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ystem tests (2/2) Wires the InMemoryTopologyDescriptionPlugin into the streams tests that already exercise the streams group protocol, plus a smoke entry in the broker compatibility matrix: - BaseStreamsTest passes the plugin to KafkaService; the plugin is on for every extender, since BaseStreamsTest always uses use_streams_groups=True. - StreamsBrokerBounceTest passes the plugin only when group_protocol='streams', mirroring how use_streams_groups is set. - StreamsBrokerCompatibilityTest adds the plugin class as a raw server_prop_overrides row and appends str(DEV_VERSION) to both broker_version matrices. On the DEV broker, the plugin is loaded at startup; older brokers ignore the unknown config key. The classic-protocol driver does not exercise the push path, so this is a regression smoke that the plugin doesn't break broker startup. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
aliehsaeedii
left a comment
There was a problem hiding this comment.
Thanks @lucliu1108 for the PR. I made the first round:)
| processor = StreamsTopologyDescriptionPluginService( | ||
| self.test_context, self.kafka, topology_description_push_enabled=False) | ||
| processor.start() | ||
| time.sleep(30) |
There was a problem hiding this comment.
The two negative tests can pass vacuously: processor.start() only waits for STREAMS-STARTED, which is printed right after KafkaStreams#start() returns — before the client has joined the streams group. If the app crashes or never manages to join during the 30s sleep, the grep -c == 0 assertions still pass even though nothing was actually verified.
Consider waiting for a positive liveness signal before doing the negative grep — e.g. wait for the State transition from REBALANCING to RUNNING line in the streams log (which implies successful heartbeats with the coordinator), and only then assert the push logs are absent. Same applies to test_topology_description_not_stored_without_plugin below.
There was a problem hiding this comment.
Fix: added assertions to wait for client to join the group.
| """ | ||
| Test the situation when the broker has the topology description plugin configured | ||
| but the client opts out via topology.description.push.enabled=false. The client | ||
| should never send a topology description even though the broker solicits one. |
There was a problem hiding this comment.
Nit on the docstring: "even though the broker solicits one" is true broker-side, but it isn't observable in this test. When the client opts out, StreamThread never sets the wire topology description, so the Broker requested topology description push log in StreamsGroupHeartbeatRequestManager is suppressed too (the condition requires a non-null wire description). Maybe reword so a future reader doesn't try to assert PUSH_REQUESTED_LOG > 0 here and get confused when it's 0.
There was a problem hiding this comment.
Fix: added additional explanation indicating the "broker requested topology description push" log never appears; an additional assertion on this is also added.
| ["transaction.state.log.replication.factor", "1"], | ||
| ["transaction.state.log.min.isr", "1"] | ||
| ["transaction.state.log.min.isr", "1"], | ||
| ["group.streams.topology.description.plugin.class", INMEMORY_TOPOLOGY_DESCRIPTION_PLUGIN_CLASS] |
There was a problem hiding this comment.
The PR description says the plugin is enabled "for DEV_VERSION", but this override applies to every broker version in the matrix. It happens to work because group.streams.topology.description.plugin.class only exists on trunk (not in 4.3 or earlier), so older brokers just log an unknown-config warning and ignore it — but that's subtle enough to deserve an inline comment.
Also, since StreamsBrokerCompatibilityService runs with the classic protocol (no streams groups exist in this test), the plugin is instantiated but never exercised. Could you clarify what this addition is meant to verify — that a DEV broker with the plugin configured doesn't affect classic-protocol streams apps? A short comment stating that intent would help.
There was a problem hiding this comment.
Fix: I added comments about this config: 1) it is only in actual effect when broker_version>4.3 2) This test is only using classic group so the plugin is not taking effect.
| str(LATEST_4_2),str(LATEST_4_3),str(DEV_BRANCH)], | ||
| metadata_quorum=[quorum.combined_kraft] | ||
| ) | ||
|
|
There was a problem hiding this comment.
Stray whitespace-only line added between the @matrix decorator and the test method — please remove.
|
|
||
| @cluster(num_nodes=2) | ||
| @matrix(metadata_quorum=[quorum.combined_kraft]) | ||
| def test_topology_description_available_with_plugin(self, metadata_quorum): |
There was a problem hiding this comment.
Are follow-up scenarios planned for the plugin lifecycle? Three come to mind that the in-memory plugin makes observable with exactly the infrastructure this PR adds:
- Broker bounce → re-solicitation: the
InMemoryTopologyDescriptionPluginloses its state on restart, so after a bounce the broker should solicit again and the client should push a second time (happy-path push → bounce → wait for a secondTopology description pushed successfully). - Client restart with the description already stored: restart only the streams app while the broker keeps running — since
storedDescriptionTopologyEpoch == currentTopologyEpoch, the broker should not solicit again. - Multiple members, single push: with 2+ clients in the group, the solicitation back-off (
StreamsGroupTopologyDescriptionManager.armIfNotActive) should prevent every member from pushing the same description — e.g. assert the second member never sends while the first push succeeds.
No need to grow this PR — just wondering whether these are on the part-2 list.
There was a problem hiding this comment.
Thanks for the ideas! I will append more scenarios in a followup PR.
| processor.start() | ||
| time.sleep(30) | ||
| # count how many lines in streams.log contain Broker requested topology description push | ||
| solicited = processor.node.account.ssh_capture( |
There was a problem hiding this comment.
This only checks Broker requested topology description push count == 0. Belt-and-suspenders: also assert PUSH_SENDING_LOG == 0 and PUSH_SUCCESS_LOG == 0. Cheap defense against a client-side regression where the client pushes uninvited.
There was a problem hiding this comment.
Fix: added the 2 client-side assertions
There was a problem hiding this comment.
StreamsGroupHeartbeatRequestManager.java:657-660:
if (data.topologyDescriptionRequired() && streamsRebalanceData.wireTopologyDescription() != null) {
logger.info("Broker requested topology description push");
When topology.description.push.enabled=false, wireTopologyDescription() is null, so this log line is never emitted. That means: regardless of whether the broker sets topologyDescriptionRequired=true, the count will always be 0. This assertion cannot distinguish "broker never solicited" from "broker did solicit but the client silently ignored it" — and the latter is exactly the gap I originally asked to be defended against. To actually verify this, the assertion needs to move to the broker side (for example, "the broker logged that setTopology was requested, but setTopology was never invoked").
There was a problem hiding this comment.
Thanks! I added a broker log after the config is solicit on the broker side, and an additional check in the system test for its appearance.
Summary
Topology Description Plugin):
TopologyDescriptionPluginSystemTestthat starts asmall streams app and exits on signal.
streams_topology_description_plugin_testwith 3scenarios:
client default push is on;
prevents the client from ever sending a description;
group.streams.topology.description.plugin.class=org.apache.kafka.server.streams.InMemoryTopologyDescriptionPluginto
BaseStreamsTestandStreamsBrokerBounceTest(whenuse_streams_groups=True). The plugin jar is already on the broker
classpath via the server module.
streams_broker_compatibility_testfor DEV_VERSION.
Reviewers: Alieh Saeedi asaeedi@confluent.io, TengYao Chi
frankvicky@apache.org