use of org.apache.kafka.connect.connector.Connector in project apache-kafka-on-k8s by banzaicloud.
the class AbstractHerderTest method createConfigValidationHerder.
private AbstractHerder createConfigValidationHerder(Class<? extends Connector> connectorClass) {
ConfigBackingStore configStore = strictMock(ConfigBackingStore.class);
StatusBackingStore statusStore = strictMock(StatusBackingStore.class);
AbstractHerder herder = partialMockBuilder(AbstractHerder.class).withConstructor(Worker.class, String.class, String.class, StatusBackingStore.class, ConfigBackingStore.class).withArgs(worker, workerId, kafkaClusterId, statusStore, configStore).addMockedMethod("generation").createMock();
EasyMock.expect(herder.generation()).andStubReturn(generation);
// Call to validateConnectorConfig
EasyMock.expect(worker.getPlugins()).andStubReturn(plugins);
final Connector connector;
try {
connector = connectorClass.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException("Couldn't create connector", e);
}
EasyMock.expect(plugins.newConnector(connectorClass.getName())).andReturn(connector);
EasyMock.expect(plugins.compareAndSwapLoaders(connector)).andReturn(classLoader);
return herder;
}
use of org.apache.kafka.connect.connector.Connector in project kafka-connect-storage-cloud by confluentinc.
the class S3SinkConnectorTest method connectorType.
@Test
public void connectorType() {
Connector connector = new S3SinkConnector();
assertTrue(SinkConnector.class.isAssignableFrom(connector.getClass()));
}
use of org.apache.kafka.connect.connector.Connector in project kafka by apache.
the class DistributedHerderTest method testConnectorNameConflictsWithWorkerGroupId.
@SuppressWarnings("unchecked")
@Test
public void testConnectorNameConflictsWithWorkerGroupId() {
Map<String, String> config = new HashMap<>(CONN2_CONFIG);
config.put(ConnectorConfig.NAME_CONFIG, "test-group");
Connector connectorMock = PowerMock.createMock(SinkConnector.class);
// CONN2 creation should fail because the worker group id (connect-test-group) conflicts with
// the consumer group id we would use for this sink
Map<String, ConfigValue> validatedConfigs = herder.validateBasicConnectorConfig(connectorMock, ConnectorConfig.configDef(), config);
ConfigValue nameConfig = validatedConfigs.get(ConnectorConfig.NAME_CONFIG);
assertNotNull(nameConfig.errorMessages());
assertFalse(nameConfig.errorMessages().isEmpty());
}
use of org.apache.kafka.connect.connector.Connector in project kafka by apache.
the class StandaloneHerderTest method testRestartConnectorAndTasksNoRestarts.
@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);
expectAdd(SourceSink.SINK);
Map<String, String> connectorConfig = connectorConfig(SourceSink.SINK);
Connector connectorMock = PowerMock.createMock(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();
}
use of org.apache.kafka.connect.connector.Connector in project kafka by apache.
the class StandaloneHerderTest method testCreateSinkConnector.
@Test
public void testCreateSinkConnector() throws Exception {
connector = PowerMock.createMock(BogusSinkConnector.class);
expectAdd(SourceSink.SINK);
Map<String, String> config = connectorConfig(SourceSink.SINK);
Connector connectorMock = PowerMock.createMock(SinkConnector.class);
expectConfigValidation(connectorMock, true, config);
PowerMock.replayAll();
herder.putConnectorConfig(CONNECTOR_NAME, config, false, createCallback);
Herder.Created<ConnectorInfo> connectorInfo = createCallback.get(1000L, TimeUnit.SECONDS);
assertEquals(createdInfo(SourceSink.SINK), connectorInfo.result());
PowerMock.verifyAll();
}
Aggregations