ivanyu commented on code in PR #6934:
URL: https://github.com/apache/kafka/pull/6934#discussion_r1587958141
##########
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/distributed/DistributedHerderTest.java:
##########
@@ -2336,6 +2336,95 @@ public void testPutConnectorConfig() throws Exception {
verifyNoMoreInteractions(worker, member, configBackingStore,
statusBackingStore);
}
+ @Test
+ public void testPatchConnectorConfigNotFound() {
+ ClusterConfigState clusterConfigState = new ClusterConfigState(
+ 0,
+ null,
+ Collections.emptyMap(),
+ Collections.emptyMap(),
+ Collections.emptyMap(),
+ Collections.emptyMap(),
+ Collections.emptyMap(),
+ Collections.emptyMap(),
+ Collections.emptySet(),
+ Collections.emptySet());
+ expectConfigRefreshAndSnapshot(clusterConfigState);
+
+ Map<String, String> connConfigPatch = new HashMap<>();
+ connConfigPatch.put("foo1", "baz1");
+
+ FutureCallback<Herder.Created<ConnectorInfo>> patchCallback = new
FutureCallback<>();
+ herder.patchConnectorConfig(CONN2, connConfigPatch, patchCallback);
+ herder.tick();
+ assertTrue(patchCallback.isDone());
+ ExecutionException exception = assertThrows(ExecutionException.class,
patchCallback::get);
+ assertInstanceOf(NotFoundException.class, exception.getCause());
+ }
+
+ @Test
+ public void testPatchConnectorConfig() throws Exception {
+ when(member.memberId()).thenReturn("leader");
+ expectRebalance(1, Arrays.asList(CONN1), Collections.emptyList(),
true);
+
when(statusBackingStore.connectors()).thenReturn(Collections.emptySet());
+
+ Map<String, String> originalConnConfig = new HashMap<>(CONN1_CONFIG);
+ originalConnConfig.put("foo1", "bar1");
+ originalConnConfig.put("foo2", "bar2");
+
+ // The connector is pre-existing due to the mocks.
+
+ ClusterConfigState originalSnapshot = new ClusterConfigState(
+ 1,
+ null,
+ Collections.singletonMap(CONN1, 0),
+ Collections.singletonMap(CONN1, originalConnConfig),
+ Collections.singletonMap(CONN1, TargetState.STARTED),
+ Collections.emptyMap(),
+ Collections.emptyMap(),
+ Collections.emptyMap(),
+ Collections.emptySet(),
+ Collections.emptySet());
+ expectConfigRefreshAndSnapshot(originalSnapshot);
+ when(member.currentProtocolVersion()).thenReturn(CONNECT_PROTOCOL_V0);
+
+ expectMemberPoll();
+
+ // Patch the connector config.
+ Map<String, String> connConfigPatch = new HashMap<>();
+ connConfigPatch.put("foo1", "changed");
+ connConfigPatch.put("foo2", null);
+ connConfigPatch.put("foo3", "added");
+
+ Map<String, String> patchedConnConfig = new
HashMap<>(originalConnConfig);
+ patchedConnConfig.put("foo1", "changed");
+ patchedConnConfig.remove("foo2");
+ patchedConnConfig.put("foo3", "added");
+
+ expectMemberEnsureActive();
+ expectRebalance(1, Arrays.asList(CONN1), Collections.emptyList(),
true);
+ when(worker.getPlugins()).thenReturn(plugins);
Review Comment:
Thanks, fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]