mdedetrich commented on code in PR #12728: URL: https://github.com/apache/kafka/pull/12728#discussion_r1374136601
########## connect/runtime/src/test/java/org/apache/kafka/connect/runtime/standalone/StandaloneHerderTest.java: ########## @@ -528,72 +483,64 @@ public void testRestartConnectorAndTasksNoStatus() throws Exception { ExecutionException ee = assertThrows(ExecutionException.class, () -> restartCallback.get(1000L, TimeUnit.MILLISECONDS)); assertTrue(ee.getCause() instanceof NotFoundException); assertTrue(ee.getMessage().contains("Status for connector")); - PowerMock.verifyAll(); } @Test public void testRestartConnectorAndTasksNoRestarts() throws Exception { RestartRequest restartRequest = new RestartRequest(CONNECTOR_NAME, false, true); - RestartPlan restartPlan = PowerMock.createMock(RestartPlan.class); - ConnectorStateInfo connectorStateInfo = PowerMock.createMock(ConnectorStateInfo.class); - EasyMock.expect(restartPlan.shouldRestartConnector()).andReturn(false).anyTimes(); - EasyMock.expect(restartPlan.shouldRestartTasks()).andReturn(false).anyTimes(); - EasyMock.expect(restartPlan.restartConnectorStateInfo()).andReturn(connectorStateInfo).anyTimes(); - EasyMock.expect(herder.buildRestartPlan(restartRequest)) - .andReturn(Optional.of(restartPlan)).anyTimes(); - - connector = PowerMock.createMock(BogusSinkConnector.class); + RestartPlan restartPlan = mock(RestartPlan.class); + ConnectorStateInfo connectorStateInfo = mock(ConnectorStateInfo.class); + when(restartPlan.shouldRestartConnector()).thenReturn(false); + when(restartPlan.shouldRestartTasks()).thenReturn(false); + when(restartPlan.restartConnectorStateInfo()).thenReturn(connectorStateInfo); + doReturn(Optional.of(restartPlan)).when(herder).buildRestartPlan(restartRequest); + + connector = mock(BogusSinkConnector.class); expectAdd(SourceSink.SINK); Map<String, String> connectorConfig = connectorConfig(SourceSink.SINK); - Connector connectorMock = PowerMock.createMock(SinkConnector.class); + Connector connectorMock = mock(SinkConnector.class); expectConfigValidation(connectorMock, true, connectorConfig); - PowerMock.replayAll(); - herder.putConnectorConfig(CONNECTOR_NAME, connectorConfig, false, createCallback); Herder.Created<ConnectorInfo> connectorInfo = createCallback.get(1000L, TimeUnit.SECONDS); assertEquals(createdInfo(SourceSink.SINK), connectorInfo.result()); FutureCallback<ConnectorStateInfo> restartCallback = new FutureCallback<>(); herder.restartConnectorAndTasks(restartRequest, restartCallback); assertEquals(connectorStateInfo, restartCallback.get(1000L, TimeUnit.MILLISECONDS)); - PowerMock.verifyAll(); } @Test public void testRestartConnectorAndTasksOnlyConnector() throws Exception { RestartRequest restartRequest = new RestartRequest(CONNECTOR_NAME, false, true); - RestartPlan restartPlan = PowerMock.createMock(RestartPlan.class); - ConnectorStateInfo connectorStateInfo = PowerMock.createMock(ConnectorStateInfo.class); - EasyMock.expect(restartPlan.shouldRestartConnector()).andReturn(true).anyTimes(); - EasyMock.expect(restartPlan.shouldRestartTasks()).andReturn(false).anyTimes(); - EasyMock.expect(restartPlan.restartConnectorStateInfo()).andReturn(connectorStateInfo).anyTimes(); - EasyMock.expect(herder.buildRestartPlan(restartRequest)) - .andReturn(Optional.of(restartPlan)).anyTimes(); + RestartPlan restartPlan = mock(RestartPlan.class); + ConnectorStateInfo connectorStateInfo = mock(ConnectorStateInfo.class); + when(restartPlan.shouldRestartConnector()).thenReturn(true); + when(restartPlan.shouldRestartTasks()).thenReturn(false); + when(restartPlan.restartConnectorStateInfo()).thenReturn(connectorStateInfo); + doReturn(Optional.of(restartPlan)).when(herder).buildRestartPlan(restartRequest); herder.onRestart(CONNECTOR_NAME); - EasyMock.expectLastCall(); + verify(statusBackingStore).put(new ConnectorStatus(CONNECTOR_NAME, ConnectorStatus.State.RESTARTING, WORKER_ID, 0)); Review Comment: This verification is required because we have https://github.com/apache/kafka/pull/12728/files#diff-9143727aad47387b8283893ef39610c7f135264077f795f70a6f1d67f7db6e21R151-R153 (this is something that you asked to add when the PR was first being required). Without it the test fails, ill see if the `RESTARTING` state fixes this in another way. -- 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