anton-vinogradov commented on a change in pull request #49:
URL: https://github.com/apache/ignite-extensions/pull/49#discussion_r656235203



##########
File path: 
modules/cdc-ext/src/test/java/org/apache/ignite/cdc/kafka/CdcKafkaReplicationTest.java
##########
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.cdc.kafka;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
+import org.apache.ignite.cdc.AbstractReplicationTest;
+import org.apache.ignite.cdc.ChangeDataCaptureConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.cdc.ChangeDataCapture;
+import org.apache.kafka.clients.consumer.ConsumerConfig;
+import org.apache.kafka.streams.integration.utils.EmbeddedKafkaCluster;
+import org.junit.ClassRule;
+
+import static 
org.apache.ignite.cdc.kafka.KafkaToIgniteCdcStreamerConfiguration.DFLT_PARTS;
+import static 
org.apache.ignite.cdc.kafka.KafkaToIgniteCdcStreamerConfiguration.DFLT_TOPIC;
+import static org.apache.ignite.testframework.GridTestUtils.runAsync;
+
+/**
+ * Tests for kafka replication.
+ */
+public class CdcKafkaReplicationTest extends AbstractReplicationTest {
+    /** */
+    public static final String SRC_DEST_TOPIC = "source-dest";
+
+    /** */
+    public static final String DEST_SRC_TOPIC = "dest-source";
+
+    /** */
+    protected static Properties props;
+
+    /** */
+    @ClassRule
+    public static final EmbeddedKafkaCluster KAFKA = new 
EmbeddedKafkaCluster(1);
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+
+        KAFKA.start();
+
+        if (props == null) {
+            props = new Properties();
+
+            props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, 
KAFKA.bootstrapServers());
+            props.put(ConsumerConfig.GROUP_ID_CONFIG, 
"kafka-to-ignite-applier");
+            props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
+            props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "false");
+            props.put(ConsumerConfig.REQUEST_TIMEOUT_MS_CONFIG, "10000");
+        }

Review comment:
       Do we need to perform this between `KAFKA.start();` and 
`KAFKA.createTopics...` ?
   Seems this used for consumers only?

##########
File path: 
modules/cdc-ext/src/test/java/org/apache/ignite/cdc/kafka/CdcKafkaReplicationAppsTest.java
##########
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.cdc.kafka;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.PrintWriter;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.startup.cmdline.ChangeDataCaptureCommandLineStartup;
+
+import static 
org.apache.ignite.cdc.kafka.KafkaToIgniteCdcStreamerConfiguration.DFLT_PARTS;
+import static 
org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi.DFLT_PORT_RANGE;
+import static org.apache.ignite.testframework.GridTestUtils.getFieldValue;
+import static org.apache.ignite.testframework.GridTestUtils.runAsync;
+
+/** */
+public class CdcKafkaReplicationAppsTest extends CdcKafkaReplicationTest {
+    /** */
+    public static final String INSTANCE_NAME = "INSTANCE_NAME";
+
+    /** */
+    public static final String DISCO_PORT = "DISCO_PORT";
+
+    /** */
+    public static final String DISCO_PORT_RANGE = "DISCO_PORT_RANGE";
+
+    /** */
+    public static final String REPLICATED_CACHE = "REPLICATED_CACHE";
+
+    /** */
+    public static final String TOPIC = "TOPIC";
+
+    /** */
+    public static final String CONSISTENT_ID = "CONSISTENT_ID";
+
+    /** */
+    public static final String KAFKA_PARTS = "KAFKA_PARTS";
+
+    /** */
+    public static final String KAFKA_PARTS_FROM = "KAFKA_PARTS_FROM";
+
+    /** */
+    public static final String KAFKA_PARTS_TO = "KAFKA_PARTS_TO";
+
+    /** */
+    public static final String THREAD_CNT = "THREAD_CNT";
+
+    /** */
+    public static final String MAX_BATCH_SIZE = "MAX_BATCH_SIZE";
+
+    /** */
+    public static final String KAFKA_PROPS_PATH = "KAFKA_PROPS_PATH";
+
+    /** */
+    private String kafkaPropsPath = null;
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+
+        if (kafkaPropsPath == null) {
+            File file = File.createTempFile("kafka", "properties");
+
+            file.deleteOnExit();
+
+            try (FileOutputStream fos = new FileOutputStream(file)) {
+                props.store(fos, null);
+            }
+
+            kafkaPropsPath = "file://" + file.getAbsolutePath();
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteInternalFuture<?> 
igniteToKafka(IgniteConfiguration igniteCfg, String topic, String cache) {
+        Map<String, String> params = new HashMap<>();
+
+        params.put(INSTANCE_NAME, igniteCfg.getIgniteInstanceName());
+        params.put(REPLICATED_CACHE, cache);
+        params.put(TOPIC, topic);
+        params.put(CONSISTENT_ID, String.valueOf(igniteCfg.getConsistentId()));
+        params.put(KAFKA_PARTS, Integer.toString(DFLT_PARTS));
+        params.put(MAX_BATCH_SIZE, Integer.toString(KEYS_CNT));
+        params.put(KAFKA_PROPS_PATH, kafkaPropsPath);
+
+        return runAsync(
+            () -> ChangeDataCaptureCommandLineStartup.main(new String[] 
{prepareConfig("replication/ignite-to-kafka.xml", params)})

Review comment:
       special namespaces for all Kafka configs seem to be useless




-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to