ivanyu commented on code in PR #6934: URL: https://github.com/apache/kafka/pull/6934#discussion_r1587938094
########## 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"); Review Comment: Yes, good idea. Done here and in `StandaloneHerderTest` too. ########## connect/runtime/src/test/java/org/apache/kafka/connect/runtime/standalone/StandaloneHerderTest.java: ########## @@ -751,6 +754,74 @@ public void testPutConnectorConfig() throws Exception { verifyNoMoreInteractions(connectorConfigCb); } + @Test + public void testPatchConnectorConfigNotFound() { + Map<String, String> connConfigPatch = new HashMap<>(); + connConfigPatch.put("foo1", "baz1"); + + Callback<Herder.Created<ConnectorInfo>> patchCallback = mock(Callback.class); + herder.patchConnectorConfig(CONNECTOR_NAME, connConfigPatch, patchCallback); + + ArgumentCaptor<NotFoundException> exceptionCaptor = ArgumentCaptor.forClass(NotFoundException.class); + verify(patchCallback).onCompletion(exceptionCaptor.capture(), isNull()); + assertEquals(exceptionCaptor.getValue().getMessage(), "Connector " + CONNECTOR_NAME + " not found"); + assertNull(exceptionCaptor.getValue().getCause()); + } + + @Test + public void testPatchConnectorConfig() throws ExecutionException, InterruptedException, TimeoutException { + // Create the connector. + Map<String, String> originalConnConfig = connectorConfig(SourceSink.SOURCE); + originalConnConfig.put("foo1", "bar1"); + originalConnConfig.put("foo2", "bar2"); Review Comment: Done -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org