Search in sources :

Example 11 with StandaloneConfig

use of org.apache.kafka.connect.runtime.standalone.StandaloneConfig in project apache-kafka-on-k8s by banzaicloud.

the class WorkerSinkTaskTest method setUp.

@Before
public void setUp() {
    time = new MockTime();
    Map<String, String> workerProps = new HashMap<>();
    workerProps.put("key.converter", "org.apache.kafka.connect.json.JsonConverter");
    workerProps.put("value.converter", "org.apache.kafka.connect.json.JsonConverter");
    workerProps.put("internal.key.converter", "org.apache.kafka.connect.json.JsonConverter");
    workerProps.put("internal.value.converter", "org.apache.kafka.connect.json.JsonConverter");
    workerProps.put("internal.key.converter.schemas.enable", "false");
    workerProps.put("internal.value.converter.schemas.enable", "false");
    workerProps.put("offset.storage.file.filename", "/tmp/connect.offsets");
    workerConfig = new StandaloneConfig(workerProps);
    pluginLoader = PowerMock.createMock(PluginClassLoader.class);
    metrics = new MockConnectMetrics(time);
    recordsReturnedTp1 = 0;
    recordsReturnedTp3 = 0;
}
Also used : HashMap(java.util.HashMap) StandaloneConfig(org.apache.kafka.connect.runtime.standalone.StandaloneConfig) MockTime(org.apache.kafka.common.utils.MockTime) PluginClassLoader(org.apache.kafka.connect.runtime.isolation.PluginClassLoader) Before(org.junit.Before)

Example 12 with StandaloneConfig

use of org.apache.kafka.connect.runtime.standalone.StandaloneConfig in project apache-kafka-on-k8s by banzaicloud.

the class WorkerSourceTaskTest method setup.

@Override
public void setup() {
    super.setup();
    Map<String, String> workerProps = new HashMap<>();
    workerProps.put("key.converter", "org.apache.kafka.connect.json.JsonConverter");
    workerProps.put("value.converter", "org.apache.kafka.connect.json.JsonConverter");
    workerProps.put("internal.key.converter", "org.apache.kafka.connect.json.JsonConverter");
    workerProps.put("internal.value.converter", "org.apache.kafka.connect.json.JsonConverter");
    workerProps.put("internal.key.converter.schemas.enable", "false");
    workerProps.put("internal.value.converter.schemas.enable", "false");
    workerProps.put("offset.storage.file.filename", "/tmp/connect.offsets");
    plugins = new Plugins(workerProps);
    config = new StandaloneConfig(workerProps);
    producerCallbacks = EasyMock.newCapture();
    metrics = new MockConnectMetrics();
}
Also used : HashMap(java.util.HashMap) StandaloneConfig(org.apache.kafka.connect.runtime.standalone.StandaloneConfig) Plugins(org.apache.kafka.connect.runtime.isolation.Plugins)

Example 13 with StandaloneConfig

use of org.apache.kafka.connect.runtime.standalone.StandaloneConfig in project apache-kafka-on-k8s by banzaicloud.

the class FileOffsetBackingStoreTest method setup.

@Before
public void setup() throws IOException {
    store = new FileOffsetBackingStore();
    tempFile = File.createTempFile("fileoffsetbackingstore", null);
    props = new HashMap<String, String>();
    props.put(StandaloneConfig.OFFSET_STORAGE_FILE_FILENAME_CONFIG, tempFile.getAbsolutePath());
    props.put(StandaloneConfig.KEY_CONVERTER_CLASS_CONFIG, "org.apache.kafka.connect.json.JsonConverter");
    props.put(StandaloneConfig.VALUE_CONVERTER_CLASS_CONFIG, "org.apache.kafka.connect.json.JsonConverter");
    props.put(StandaloneConfig.INTERNAL_KEY_CONVERTER_CLASS_CONFIG, "org.apache.kafka.connect.json.JsonConverter");
    props.put(StandaloneConfig.INTERNAL_VALUE_CONVERTER_CLASS_CONFIG, "org.apache.kafka.connect.json.JsonConverter");
    config = new StandaloneConfig(props);
    store.configure(config);
    store.start();
}
Also used : StandaloneConfig(org.apache.kafka.connect.runtime.standalone.StandaloneConfig) Before(org.junit.Before)

Example 14 with StandaloneConfig

use of org.apache.kafka.connect.runtime.standalone.StandaloneConfig in project kafka by apache.

the class WorkerSinkTaskThreadedTest method setup.

@Override
public void setup() {
    super.setup();
    time = new MockTime();
    metrics = new MockConnectMetrics();
    Map<String, String> workerProps = new HashMap<>();
    workerProps.put("key.converter", "org.apache.kafka.connect.json.JsonConverter");
    workerProps.put("value.converter", "org.apache.kafka.connect.json.JsonConverter");
    workerProps.put("offset.storage.file.filename", "/tmp/connect.offsets");
    pluginLoader = PowerMock.createMock(PluginClassLoader.class);
    workerConfig = new StandaloneConfig(workerProps);
    workerTask = new WorkerSinkTask(taskId, sinkTask, statusListener, initialState, workerConfig, ClusterConfigState.EMPTY, metrics, keyConverter, valueConverter, headerConverter, new TransformationChain<>(Collections.emptyList(), RetryWithToleranceOperatorTest.NOOP_OPERATOR), consumer, pluginLoader, time, RetryWithToleranceOperatorTest.NOOP_OPERATOR, null, statusBackingStore);
    recordsReturned = 0;
}
Also used : HashMap(java.util.HashMap) StandaloneConfig(org.apache.kafka.connect.runtime.standalone.StandaloneConfig) MockTime(org.apache.kafka.common.utils.MockTime) PluginClassLoader(org.apache.kafka.connect.runtime.isolation.PluginClassLoader)

Example 15 with StandaloneConfig

use of org.apache.kafka.connect.runtime.standalone.StandaloneConfig in project kafka by apache.

the class WorkerTest method setup.

@Before
public void setup() {
    super.setup();
    workerProps.put("key.converter", "org.apache.kafka.connect.json.JsonConverter");
    workerProps.put("value.converter", "org.apache.kafka.connect.json.JsonConverter");
    workerProps.put("offset.storage.file.filename", "/tmp/connect.offsets");
    workerProps.put(CommonClientConfigs.METRIC_REPORTER_CLASSES_CONFIG, MockMetricsReporter.class.getName());
    workerProps.put("config.providers", "file");
    workerProps.put("config.providers.file.class", MockFileConfigProvider.class.getName());
    mockFileProviderTestId = UUID.randomUUID().toString();
    workerProps.put("config.providers.file.param.testId", mockFileProviderTestId);
    workerProps.put(TOPIC_CREATION_ENABLE_CONFIG, String.valueOf(enableTopicCreation));
    config = new StandaloneConfig(workerProps);
    defaultProducerConfigs.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
    defaultProducerConfigs.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.ByteArraySerializer");
    defaultProducerConfigs.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.ByteArraySerializer");
    defaultProducerConfigs.put(ProducerConfig.MAX_BLOCK_MS_CONFIG, Long.toString(Long.MAX_VALUE));
    defaultProducerConfigs.put(ProducerConfig.ACKS_CONFIG, "all");
    defaultProducerConfigs.put(ProducerConfig.MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION, "1");
    defaultProducerConfigs.put(ProducerConfig.DELIVERY_TIMEOUT_MS_CONFIG, Integer.toString(Integer.MAX_VALUE));
    defaultConsumerConfigs.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
    defaultConsumerConfigs.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "false");
    defaultConsumerConfigs.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
    defaultConsumerConfigs.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.ByteArrayDeserializer");
    defaultConsumerConfigs.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.ByteArrayDeserializer");
    // Some common defaults. They might change on individual tests
    connectorProps = anyConnectorConfigMap();
    PowerMock.mockStatic(Plugins.class);
}
Also used : MockFileConfigProvider(org.apache.kafka.common.config.provider.MockFileConfigProvider) MockMetricsReporter(org.apache.kafka.connect.runtime.MockConnectMetrics.MockMetricsReporter) StandaloneConfig(org.apache.kafka.connect.runtime.standalone.StandaloneConfig) Before(org.junit.Before)

Aggregations

StandaloneConfig (org.apache.kafka.connect.runtime.standalone.StandaloneConfig)17 HashMap (java.util.HashMap)8 Before (org.junit.Before)7 MockTime (org.apache.kafka.common.utils.MockTime)5 PluginClassLoader (org.apache.kafka.connect.runtime.isolation.PluginClassLoader)5 Worker (org.apache.kafka.connect.runtime.Worker)4 Plugins (org.apache.kafka.connect.runtime.isolation.Plugins)4 StandaloneHerder (org.apache.kafka.connect.runtime.standalone.StandaloneHerder)4 WorkerConfig (org.apache.kafka.connect.runtime.WorkerConfig)3 URI (java.net.URI)2 TestKafkaBroker (org.apache.ignite.stream.kafka.TestKafkaBroker)2 SystemTime (org.apache.kafka.common.utils.SystemTime)2 Time (org.apache.kafka.common.utils.Time)2 Connect (org.apache.kafka.connect.runtime.Connect)2 Herder (org.apache.kafka.connect.runtime.Herder)2 MockMetricsReporter (org.apache.kafka.connect.runtime.MockConnectMetrics.MockMetricsReporter)2 WorkerInfo (org.apache.kafka.connect.runtime.WorkerInfo)2 RestServer (org.apache.kafka.connect.runtime.rest.RestServer)2 FileOffsetBackingStore (org.apache.kafka.connect.storage.FileOffsetBackingStore)2 FutureCallback (org.apache.kafka.connect.util.FutureCallback)2