use of org.apache.kafka.connect.runtime.RestartRequest in project kafka by apache.
the class StandaloneHerderTest method testRestartConnectorAndTasksOnlyTasks.
@Test
public void testRestartConnectorAndTasksOnlyTasks() throws Exception {
ConnectorTaskId taskId = new ConnectorTaskId(CONNECTOR_NAME, 0);
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(true).anyTimes();
EasyMock.expect(restartPlan.restartTaskCount()).andReturn(1).anyTimes();
EasyMock.expect(restartPlan.totalTaskCount()).andReturn(1).anyTimes();
EasyMock.expect(restartPlan.taskIdsToRestart()).andReturn(Collections.singletonList(taskId)).anyTimes();
EasyMock.expect(restartPlan.restartConnectorStateInfo()).andReturn(connectorStateInfo).anyTimes();
EasyMock.expect(herder.buildRestartPlan(restartRequest)).andReturn(Optional.of(restartPlan)).anyTimes();
herder.onRestart(taskId);
EasyMock.expectLastCall();
connector = PowerMock.createMock(BogusSinkConnector.class);
expectAdd(SourceSink.SINK);
Map<String, String> connectorConfig = connectorConfig(SourceSink.SINK);
Connector connectorMock = PowerMock.createMock(SinkConnector.class);
expectConfigValidation(connectorMock, true, connectorConfig);
worker.stopAndAwaitTasks(Collections.singletonList(taskId));
EasyMock.expectLastCall();
ClusterConfigState configState = new ClusterConfigState(-1, null, Collections.singletonMap(CONNECTOR_NAME, 1), Collections.singletonMap(CONNECTOR_NAME, connectorConfig), Collections.singletonMap(CONNECTOR_NAME, TargetState.STARTED), Collections.singletonMap(taskId, taskConfig(SourceSink.SINK)), new HashSet<>(), transformer);
worker.startTask(taskId, configState, connectorConfig, taskConfig(SourceSink.SINK), herder, TargetState.STARTED);
EasyMock.expectLastCall().andReturn(true);
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();
}
use of org.apache.kafka.connect.runtime.RestartRequest in project kafka by apache.
the class KafkaConfigBackingStoreTest method testRecordToRestartRequestOnlyFailedInconsistent.
@Test
public void testRecordToRestartRequestOnlyFailedInconsistent() {
ConsumerRecord<String, byte[]> record = new ConsumerRecord<>(TOPIC, 0, 0, 0L, TimestampType.CREATE_TIME, 0, 0, RESTART_CONNECTOR_KEYS.get(0), CONFIGS_SERIALIZED.get(0), new RecordHeaders(), Optional.empty());
Struct struct = ONLY_FAILED_MISSING_STRUCT;
SchemaAndValue schemaAndValue = new SchemaAndValue(struct.schema(), structToMap(struct));
RestartRequest restartRequest = configStorage.recordToRestartRequest(record, schemaAndValue);
assertEquals(CONNECTOR_1_NAME, restartRequest.connectorName());
assertEquals(struct.getBoolean(INCLUDE_TASKS_FIELD_NAME), restartRequest.includeTasks());
assertFalse(restartRequest.onlyFailed());
}
use of org.apache.kafka.connect.runtime.RestartRequest in project kafka by apache.
the class KafkaConfigBackingStoreTest method testPutRestartRequestOnlyFailedIncludingTasks.
@Test
public void testPutRestartRequestOnlyFailedIncludingTasks() throws Exception {
RestartRequest restartRequest = new RestartRequest(CONNECTOR_IDS.get(0), true, true);
testPutRestartRequest(restartRequest);
}
use of org.apache.kafka.connect.runtime.RestartRequest in project kafka by apache.
the class KafkaConfigBackingStoreTest method testPutRestartRequestOnlyFailed.
@Test
public void testPutRestartRequestOnlyFailed() throws Exception {
RestartRequest restartRequest = new RestartRequest(CONNECTOR_IDS.get(0), true, false);
testPutRestartRequest(restartRequest);
}
use of org.apache.kafka.connect.runtime.RestartRequest in project kafka by apache.
the class KafkaConfigBackingStoreTest method testRecordToRestartRequest.
@Test
public void testRecordToRestartRequest() {
ConsumerRecord<String, byte[]> record = new ConsumerRecord<>(TOPIC, 0, 0, 0L, TimestampType.CREATE_TIME, 0, 0, RESTART_CONNECTOR_KEYS.get(0), CONFIGS_SERIALIZED.get(0), new RecordHeaders(), Optional.empty());
Struct struct = RESTART_REQUEST_STRUCTS.get(0);
SchemaAndValue schemaAndValue = new SchemaAndValue(struct.schema(), structToMap(struct));
RestartRequest restartRequest = configStorage.recordToRestartRequest(record, schemaAndValue);
assertEquals(CONNECTOR_1_NAME, restartRequest.connectorName());
assertEquals(struct.getBoolean(INCLUDE_TASKS_FIELD_NAME), restartRequest.includeTasks());
assertEquals(struct.getBoolean(ONLY_FAILED_FIELD_NAME), restartRequest.onlyFailed());
}
Aggregations