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



##########
File path: 
modules/indexing/src/test/java/org/apache/ignite/internal/cdc/SQLChangeDataCaptureTest.java
##########
@@ -0,0 +1,240 @@
+/*
+ * 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.internal.cdc;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cdc.AbstractChangeDataCaptureTest;
+import org.apache.ignite.cdc.ChangeDataCaptureConfiguration;
+import org.apache.ignite.cdc.ChangeDataCaptureConsumer;
+import org.apache.ignite.cdc.ChangeDataCaptureEvent;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.WALMode;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.junit.Test;
+
+import static 
org.apache.ignite.cdc.AbstractChangeDataCaptureTest.ChangeEventType.DELETE;
+import static 
org.apache.ignite.cdc.AbstractChangeDataCaptureTest.ChangeEventType.UPDATE;
+import static org.apache.ignite.cluster.ClusterState.ACTIVE;
+import static 
org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheId;
+import static org.apache.ignite.testframework.GridTestUtils.runAsync;
+import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
+
+/** */
+public class SQLChangeDataCaptureTest extends AbstractChangeDataCaptureTest {
+    /** */
+    private static final String JOHN = "John Connor";
+
+    /** */
+    private static final String SARAH = "Sarah Connor";
+
+    /** */
+    public static final String USER = "user";
+
+    /** */
+    public static final String CITY = "city";
+
+    /** */
+    public static final String SPB = "Saint-Petersburg";
+
+    /** */
+    public static final String MSK = "Moscow";
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+        int segmentSz = 10 * 1024 * 1024;
+
+        cfg.setDataStorageConfiguration(new DataStorageConfiguration()
+            .setChangeDataCaptureEnabled(true)
+            .setWalMode(WALMode.FSYNC)
+            .setMaxWalArchiveSize(10 * segmentSz)
+            .setWalSegmentSize(segmentSz)
+            .setWalForceArchiveTimeout(WAL_ARCHIVE_TIMEOUT)
+            .setDefaultDataRegionConfiguration(new DataRegionConfiguration()
+                .setPersistenceEnabled(true)));

Review comment:
       no newline required

##########
File path: 
modules/indexing/src/test/java/org/apache/ignite/internal/cdc/SQLChangeDataCaptureTest.java
##########
@@ -0,0 +1,240 @@
+/*
+ * 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.internal.cdc;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cdc.AbstractChangeDataCaptureTest;
+import org.apache.ignite.cdc.ChangeDataCaptureConfiguration;
+import org.apache.ignite.cdc.ChangeDataCaptureConsumer;
+import org.apache.ignite.cdc.ChangeDataCaptureEvent;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.WALMode;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.junit.Test;
+
+import static 
org.apache.ignite.cdc.AbstractChangeDataCaptureTest.ChangeEventType.DELETE;
+import static 
org.apache.ignite.cdc.AbstractChangeDataCaptureTest.ChangeEventType.UPDATE;
+import static org.apache.ignite.cluster.ClusterState.ACTIVE;
+import static 
org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheId;
+import static org.apache.ignite.testframework.GridTestUtils.runAsync;
+import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
+
+/** */
+public class SQLChangeDataCaptureTest extends AbstractChangeDataCaptureTest {
+    /** */
+    private static final String JOHN = "John Connor";
+
+    /** */
+    private static final String SARAH = "Sarah Connor";
+
+    /** */
+    public static final String USER = "user";
+
+    /** */
+    public static final String CITY = "city";
+
+    /** */
+    public static final String SPB = "Saint-Petersburg";
+
+    /** */
+    public static final String MSK = "Moscow";
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+        int segmentSz = 10 * 1024 * 1024;
+
+        cfg.setDataStorageConfiguration(new DataStorageConfiguration()
+            .setChangeDataCaptureEnabled(true)

Review comment:
       Should this set default WAL_ARCHIVE_TIMEOUT? 
   Does it looks odd to have changeDataCaptureEnabled, but WAL_ARCHIVE_TIMEOUT 
== -1?

##########
File path: 
modules/indexing/src/test/java/org/apache/ignite/internal/cdc/SQLChangeDataCaptureTest.java
##########
@@ -0,0 +1,240 @@
+/*
+ * 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.internal.cdc;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cdc.AbstractChangeDataCaptureTest;
+import org.apache.ignite.cdc.ChangeDataCaptureConfiguration;
+import org.apache.ignite.cdc.ChangeDataCaptureConsumer;
+import org.apache.ignite.cdc.ChangeDataCaptureEvent;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.WALMode;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.junit.Test;
+
+import static 
org.apache.ignite.cdc.AbstractChangeDataCaptureTest.ChangeEventType.DELETE;
+import static 
org.apache.ignite.cdc.AbstractChangeDataCaptureTest.ChangeEventType.UPDATE;
+import static org.apache.ignite.cluster.ClusterState.ACTIVE;
+import static 
org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheId;
+import static org.apache.ignite.testframework.GridTestUtils.runAsync;
+import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
+
+/** */
+public class SQLChangeDataCaptureTest extends AbstractChangeDataCaptureTest {
+    /** */
+    private static final String JOHN = "John Connor";
+
+    /** */
+    private static final String SARAH = "Sarah Connor";
+
+    /** */
+    public static final String USER = "user";
+
+    /** */
+    public static final String CITY = "city";
+
+    /** */
+    public static final String SPB = "Saint-Petersburg";
+
+    /** */
+    public static final String MSK = "Moscow";
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+        int segmentSz = 10 * 1024 * 1024;
+
+        cfg.setDataStorageConfiguration(new DataStorageConfiguration()
+            .setChangeDataCaptureEnabled(true)
+            .setWalMode(WALMode.FSYNC)
+            .setMaxWalArchiveSize(10 * segmentSz)
+            .setWalSegmentSize(segmentSz)
+            .setWalForceArchiveTimeout(WAL_ARCHIVE_TIMEOUT)
+            .setDefaultDataRegionConfiguration(new DataRegionConfiguration()
+                .setPersistenceEnabled(true)));
+
+        return cfg;
+    }
+
+    /** Simplest CDC test. */
+    @Test
+    public void testReadAllSQLRows() throws Exception {
+        IgniteConfiguration cfg = getConfiguration("ignite-0");
+
+        IgniteEx ign = startGrid(cfg);
+
+        ign.cluster().state(ACTIVE);
+
+        BinaryCDCConsumer cnsmr = new BinaryCDCConsumer();
+
+        ChangeDataCaptureConfiguration cdcCfg = new 
ChangeDataCaptureConfiguration();
+
+        cdcCfg.setConsumer(cnsmr);
+        cdcCfg.setKeepBinary(true);
+
+        ChangeDataCapture cdc = new ChangeDataCapture(cfg, null, cdcCfg);
+
+        IgniteInternalFuture<?> fut = runAsync(cdc);
+
+        executeSql(
+            ign,
+            "CREATE TABLE USER(id int, city_id int, name varchar, PRIMARY KEY 
(id, city_id)) WITH \"CACHE_NAME=user\""
+        );
+
+        executeSql(
+            ign,
+            "CREATE TABLE CITY(id int, name varchar, zip_code varchar(6), 
PRIMARY KEY (id)) WITH \"CACHE_NAME=city\""
+        );
+
+        for (int i = 0; i < KEYS_CNT * 2; i++) {
+            executeSql(
+                ign,
+                "INSERT INTO USER VALUES(?, ?, ?)",
+                i,
+                42 * i,
+                (i % 2 == 0 ? JOHN : SARAH) + i);
+
+            executeSql(
+                ign,
+                "INSERT INTO CITY VALUES(?, ?, ?)",
+                i,
+                (i % 2 == 0 ? MSK : SPB) + i,
+                Integer.toString(127000 + i));
+        }
+
+        assertTrue(waitForSize(KEYS_CNT * 2, USER, UPDATE, cnsmr));
+        assertTrue(waitForSize(KEYS_CNT * 2, CITY, UPDATE, cnsmr));
+
+        fut.cancel();
+
+        assertEquals(KEYS_CNT * 2, cnsmr.data(UPDATE, cacheId(USER)).size());
+        assertEquals(KEYS_CNT * 2, cnsmr.data(UPDATE, cacheId(CITY)).size());
+
+        assertTrue(cnsmr.stopped);
+
+        for (int i = 0; i < KEYS_CNT; i++)
+            executeSql(ign, "DELETE FROM USER WHERE id = ?", i);
+
+        IgniteInternalFuture<?> rmvFut = runAsync(cdc);
+
+        assertTrue(waitForSize(KEYS_CNT, USER, DELETE, cnsmr));
+
+        rmvFut.cancel();
+
+        assertTrue(cnsmr.stopped);
+    }
+
+    /** */
+    private boolean waitForSize(

Review comment:
       Looks to be a duplication of another `waitForSize` method

##########
File path: 
modules/core/src/test/java/org/apache/ignite/cdc/AbstractChangeDataCaptureTest.java
##########
@@ -0,0 +1,219 @@
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.cdc.ChangeDataCapture;
+import org.apache.ignite.internal.util.typedef.CI3;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static 
org.apache.ignite.cdc.AbstractChangeDataCaptureTest.ChangeEventType.DELETE;
+import static 
org.apache.ignite.cdc.AbstractChangeDataCaptureTest.ChangeEventType.UPDATE;
+import static 
org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheId;
+import static org.apache.ignite.testframework.GridTestUtils.runAsync;
+import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
+
+/** */
+public abstract class AbstractChangeDataCaptureTest extends 
GridCommonAbstractTest {
+    /** */
+    public static final int WAL_ARCHIVE_TIMEOUT = 5_000;
+
+    /** Keys count. */
+    public static final int KEYS_CNT = 50;
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        stopAllGrids();
+
+        cleanPersistenceDir();
+
+        super.beforeTest();
+    }
+
+    /** */
+    public void addAndWaitForConsumption(
+        ChangeDataCaptureSelfTest.TestCDCConsumer cnsmr,
+        ChangeDataCapture cdc,
+        IgniteCache<Integer, ChangeDataCaptureSelfTest.User> cache,
+        IgniteCache<Integer, ChangeDataCaptureSelfTest.User> txCache,
+        CI3<IgniteCache<Integer, ChangeDataCaptureSelfTest.User>, Integer, 
Integer> addData,
+        int from,
+        int to,
+        long timeout
+    ) throws IgniteCheckedException {
+        IgniteInternalFuture<?> fut = runAsync(cdc);
+
+        addData.apply(cache, from, to);
+
+        if (txCache != null)
+            addData.apply(txCache, from, to);
+
+        assertTrue(waitForSize(to - from, cache.getName(), UPDATE, timeout, 
cnsmr));
+
+        if (txCache != null)
+            assertTrue(waitForSize(to - from, txCache.getName(), UPDATE, 
timeout, cnsmr));
+
+        fut.cancel();
+
+        List<Integer> keys = cnsmr.keys(UPDATE, cacheId(cache.getName()));
+
+        assertEquals(to - from, keys.size());
+
+        for (int i = from; i < to; i++)
+            assertTrue(Integer.toString(i), keys.contains(i));
+
+        assertTrue(cnsmr.stopped);
+    }
+
+    /** */
+    public boolean waitForSize(
+        int expSz,
+        String cacheName,
+        ChangeDataCaptureSelfTest.ChangeEventType evtType,
+        long timeout,
+        ChangeDataCaptureSelfTest.TestCDCConsumer... cnsmrs
+    ) throws IgniteInterruptedCheckedException {
+        return waitForCondition(
+            () -> {
+                int sum = Arrays.stream(cnsmrs).mapToInt(c -> 
F.size(c.keys(evtType, cacheId(cacheName)))).sum();
+                return sum >= expSz;
+            },
+            timeout);
+    }
+
+    /** */
+    public ChangeDataCaptureConfiguration cdcConfig(ChangeDataCaptureConsumer 
cnsmr) {
+        ChangeDataCaptureConfiguration cdcCfg = new 
ChangeDataCaptureConfiguration();
+
+        cdcCfg.setConsumer(cnsmr);
+        cdcCfg.setKeepBinary(false);
+
+        return cdcCfg;
+    }
+
+    /** */
+    public static class TestCDCConsumer implements ChangeDataCaptureConsumer {
+        /** Keys */
+        final ConcurrentMap<IgniteBiTuple<ChangeEventType, Integer>, 
List<Integer>> cacheKeys =
+            new ConcurrentHashMap<>();
+
+        /** */
+        volatile boolean stopped;
+
+        /** */
+        volatile byte drId = -1;
+
+        /** */
+        volatile byte otherDrId = -1;
+
+        /** {@inheritDoc} */
+        @Override public void start() {
+            stopped = false;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void stop() {
+            stopped = true;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean onEvents(Iterator<ChangeDataCaptureEvent> 
evts) {
+            evts.forEachRemaining(evt -> {
+                if (!evt.primary())
+                    return;
+
+                cacheKeys.computeIfAbsent(
+                    F.t(evt.value() == null ? DELETE : UPDATE, evt.cacheId()),
+                    k -> new ArrayList<>()).add((Integer)evt.key()
+                );
+
+                if (drId != -1)
+                    assertEquals(drId, evt.version().dataCenterId());
+
+                if (otherDrId != -1)
+                    assertEquals(otherDrId, 
evt.version().otherDataCenterOrder().dataCenterId());
+
+                if (evt.value() != null) {
+                    assertTrue(((User)evt.value()).getName().startsWith("John 
Connor"));
+                    assertTrue(((User)evt.value()).getAge() >= 42);

Review comment:
       not sure it's the correct place for such checks.

##########
File path: 
modules/core/src/test/java/org/apache/ignite/cdc/ChangeDataCaptureOrderTest.java
##########
@@ -0,0 +1,234 @@
+/*
+ * 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;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.atomic.AtomicLong;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.cdc.ChangeDataCapture;
+import 
org.apache.ignite.internal.processors.cache.CacheConflictResolutionManager;
+import org.apache.ignite.internal.processors.cache.CacheObject;
+import org.apache.ignite.internal.processors.cache.CacheObjectImpl;
+import org.apache.ignite.internal.processors.cache.CacheObjectValueContext;
+import org.apache.ignite.internal.processors.cache.GridCacheManagerAdapter;
+import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.apache.ignite.internal.processors.cache.KeyCacheObject;
+import org.apache.ignite.internal.processors.cache.KeyCacheObjectImpl;
+import org.apache.ignite.internal.processors.cache.dr.GridCacheDrInfo;
+import 
org.apache.ignite.internal.processors.cache.version.CacheVersionConflictResolver;
+import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
+import 
org.apache.ignite.internal.processors.cache.version.GridCacheVersionConflictContext;
+import 
org.apache.ignite.internal.processors.cache.version.GridCacheVersionedEntryEx;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.plugin.AbstractCachePluginProvider;
+import org.apache.ignite.plugin.AbstractTestPluginProvider;
+import org.apache.ignite.plugin.CachePluginContext;
+import org.apache.ignite.plugin.CachePluginProvider;
+import org.jetbrains.annotations.Nullable;
+import org.junit.Test;
+
+import static org.apache.ignite.cluster.ClusterState.ACTIVE;
+import static org.apache.ignite.testframework.GridTestUtils.runAsync;
+import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
+
+/** */
+public class ChangeDataCaptureOrderTest extends AbstractChangeDataCaptureTest {
+    /** */
+    public static final String FOR_OTHER_DR_ID = "for-other-dr-id";
+
+    /** */
+    public static final byte DFLT_DR_ID = 1;
+
+    /** */
+    public static final byte OTHER_DR_ID = 2;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+        int segmentSz = 10 * 1024 * 1024;
+
+        cfg.setDataStorageConfiguration(new DataStorageConfiguration()
+            .setChangeDataCaptureEnabled(true)
+            .setMaxWalArchiveSize(10 * segmentSz)
+            .setWalSegmentSize(segmentSz)
+            .setWalForceArchiveTimeout(WAL_ARCHIVE_TIMEOUT)
+            .setDefaultDataRegionConfiguration(new DataRegionConfiguration()
+                .setPersistenceEnabled(true)));
+
+        cfg.setPluginProviders(new AbstractTestPluginProvider() {
+            @Override public String name() {
+                return "ConflictResolverProvider";
+            }
+
+            @Override public CachePluginProvider 
createCacheProvider(CachePluginContext ctx) {
+                if 
(!ctx.igniteCacheConfiguration().getName().equals(FOR_OTHER_DR_ID))
+                    return null;
+
+                return new AbstractCachePluginProvider() {
+                    @Override public @Nullable Object createComponent(Class 
cls) {
+                        if (cls != CacheConflictResolutionManager.class)
+                            return null;
+
+                        return new TestCacheConflictResolutionManager();
+                    }
+                };
+            }
+        });
+
+        return cfg;
+    }
+
+    /** Simplest CDC test with usage of {@link 
IgniteInternalCache#putAllConflict(Map)}. */
+    @Test
+    public void testReadAllKeysWithOtherDc() throws Exception {
+        IgniteConfiguration cfg = getConfiguration("ignite-conflict-resolver");
+
+        IgniteEx ign = startGrid(cfg);
+
+        ign.context().cache().context().versions().dataCenterId(DFLT_DR_ID);
+        ign.cluster().state(ACTIVE);
+
+        TestCDCConsumer cnsmr = new TestCDCConsumer();
+
+        ChangeDataCapture cdc = new ChangeDataCapture(cfg, null, 
cdcConfig(cnsmr));
+
+        IgniteCache<Integer, User> cache = 
ign.getOrCreateCache(FOR_OTHER_DR_ID);
+
+        cnsmr.drId = DFLT_DR_ID;
+        cnsmr.otherDrId = OTHER_DR_ID;
+
+        addAndWaitForConsumption(cnsmr, cdc, cache, null, 
this::addConflictData, 0, KEYS_CNT * 2, getTestTimeout());
+    }
+
+    /** */
+    @Test
+    public void testOrderIncrease() throws Exception {
+        IgniteConfiguration cfg = getConfiguration("ignite-0");

Review comment:
       Any reason to have such a name? 
   Also related to other tests.

##########
File path: 
modules/spring/src/test/java/org/apache/ignite/cdc/ChangeDataCaptureConfigurationTest.java
##########
@@ -0,0 +1,125 @@
+/*
+ * 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;
+
+import java.util.Iterator;
+import java.util.concurrent.CountDownLatch;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.cdc.ChangeDataCapture;
+import org.apache.ignite.internal.cdc.WALRecordsConsumer;
+import org.apache.ignite.resources.LoggerResource;
+import org.apache.ignite.resources.SpringApplicationContextResource;
+import org.apache.ignite.resources.SpringResource;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static 
org.apache.ignite.cdc.ChangeDataCaptureLoader.loadChangeDataCapture;
+import static org.apache.ignite.internal.cdc.ChangeDataCapture.ERR_MSG;
+import static org.apache.ignite.testframework.GridTestUtils.assertThrows;
+import static org.apache.ignite.testframework.GridTestUtils.getFieldValue;
+import static org.apache.ignite.testframework.GridTestUtils.runAsync;
+
+/** */
+public class ChangeDataCaptureConfigurationTest extends GridCommonAbstractTest 
{
+    /** */
+    @Test
+    public void testLoadConfig() throws Exception {
+        assertThrows(
+            null,
+            () -> 
loadChangeDataCapture("modules/spring/src/test/config/cdc/double-ignite-config.xml"),
+            IgniteCheckedException.class,
+            "Exact 1 IgniteConfiguration should be defined. Found 2"
+        );
+
+        assertThrows(
+            null,
+            () -> 
loadChangeDataCapture("modules/spring/src/test/config/cdc/double-cdc-config.xml"),
+            IgniteCheckedException.class,
+            "Exact 1 CaptureDataChangeConfiguration configuration should be 
defined. Found 2"
+        );
+
+        ChangeDataCapture cdc =
+            
loadChangeDataCapture("modules/spring/src/test/config/cdc/cdc-config-without-persistence.xml");
+
+        assertNotNull(cdc);
+
+        assertThrows(null, cdc::run, IgniteException.class, ERR_MSG);
+    }
+
+    @Test
+    public void testInjectResources() throws Exception {
+        ChangeDataCapture cdc =
+            
loadChangeDataCapture("modules/spring/src/test/config/cdc/correct-cdc-config.xml");
+
+        TestCDCConsumer cnsmr =
+            (TestCDCConsumer)((WALRecordsConsumer<?, ?>)getFieldValue(cdc, 
"consumer")).consumer();
+
+        assertNotNull(cnsmr);
+
+        CountDownLatch startLatch = cnsmr.startLatch;

Review comment:
       javadoc missed

##########
File path: 
modules/indexing/src/test/java/org/apache/ignite/internal/cdc/SQLChangeDataCaptureTest.java
##########
@@ -0,0 +1,240 @@
+/*
+ * 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.internal.cdc;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cdc.AbstractChangeDataCaptureTest;
+import org.apache.ignite.cdc.ChangeDataCaptureConfiguration;
+import org.apache.ignite.cdc.ChangeDataCaptureConsumer;
+import org.apache.ignite.cdc.ChangeDataCaptureEvent;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.WALMode;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.junit.Test;
+
+import static 
org.apache.ignite.cdc.AbstractChangeDataCaptureTest.ChangeEventType.DELETE;
+import static 
org.apache.ignite.cdc.AbstractChangeDataCaptureTest.ChangeEventType.UPDATE;
+import static org.apache.ignite.cluster.ClusterState.ACTIVE;
+import static 
org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheId;
+import static org.apache.ignite.testframework.GridTestUtils.runAsync;
+import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
+
+/** */
+public class SQLChangeDataCaptureTest extends AbstractChangeDataCaptureTest {
+    /** */
+    private static final String JOHN = "John Connor";
+
+    /** */
+    private static final String SARAH = "Sarah Connor";
+
+    /** */
+    public static final String USER = "user";
+
+    /** */
+    public static final String CITY = "city";
+
+    /** */
+    public static final String SPB = "Saint-Petersburg";
+
+    /** */
+    public static final String MSK = "Moscow";
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+        int segmentSz = 10 * 1024 * 1024;
+
+        cfg.setDataStorageConfiguration(new DataStorageConfiguration()
+            .setChangeDataCaptureEnabled(true)
+            .setWalMode(WALMode.FSYNC)
+            .setMaxWalArchiveSize(10 * segmentSz)
+            .setWalSegmentSize(segmentSz)

Review comment:
       why not default?
   
   P.s. all questions before are also related to other tests.

##########
File path: 
modules/indexing/src/test/java/org/apache/ignite/internal/cdc/SQLChangeDataCaptureTest.java
##########
@@ -0,0 +1,240 @@
+/*
+ * 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.internal.cdc;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cdc.AbstractChangeDataCaptureTest;
+import org.apache.ignite.cdc.ChangeDataCaptureConfiguration;
+import org.apache.ignite.cdc.ChangeDataCaptureConsumer;
+import org.apache.ignite.cdc.ChangeDataCaptureEvent;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.WALMode;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.junit.Test;
+
+import static 
org.apache.ignite.cdc.AbstractChangeDataCaptureTest.ChangeEventType.DELETE;
+import static 
org.apache.ignite.cdc.AbstractChangeDataCaptureTest.ChangeEventType.UPDATE;
+import static org.apache.ignite.cluster.ClusterState.ACTIVE;
+import static 
org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheId;
+import static org.apache.ignite.testframework.GridTestUtils.runAsync;
+import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
+
+/** */
+public class SQLChangeDataCaptureTest extends AbstractChangeDataCaptureTest {
+    /** */
+    private static final String JOHN = "John Connor";
+
+    /** */
+    private static final String SARAH = "Sarah Connor";
+
+    /** */
+    public static final String USER = "user";
+
+    /** */
+    public static final String CITY = "city";
+
+    /** */
+    public static final String SPB = "Saint-Petersburg";
+
+    /** */
+    public static final String MSK = "Moscow";
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+        int segmentSz = 10 * 1024 * 1024;
+
+        cfg.setDataStorageConfiguration(new DataStorageConfiguration()
+            .setChangeDataCaptureEnabled(true)
+            .setWalMode(WALMode.FSYNC)

Review comment:
       is this required for this test?

##########
File path: 
modules/indexing/src/test/java/org/apache/ignite/internal/cdc/SQLChangeDataCaptureTest.java
##########
@@ -0,0 +1,240 @@
+/*
+ * 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.internal.cdc;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cdc.AbstractChangeDataCaptureTest;
+import org.apache.ignite.cdc.ChangeDataCaptureConfiguration;
+import org.apache.ignite.cdc.ChangeDataCaptureConsumer;
+import org.apache.ignite.cdc.ChangeDataCaptureEvent;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.WALMode;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.junit.Test;
+
+import static 
org.apache.ignite.cdc.AbstractChangeDataCaptureTest.ChangeEventType.DELETE;
+import static 
org.apache.ignite.cdc.AbstractChangeDataCaptureTest.ChangeEventType.UPDATE;
+import static org.apache.ignite.cluster.ClusterState.ACTIVE;
+import static 
org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheId;
+import static org.apache.ignite.testframework.GridTestUtils.runAsync;
+import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
+
+/** */
+public class SQLChangeDataCaptureTest extends AbstractChangeDataCaptureTest {
+    /** */
+    private static final String JOHN = "John Connor";
+
+    /** */
+    private static final String SARAH = "Sarah Connor";
+
+    /** */
+    public static final String USER = "user";
+
+    /** */
+    public static final String CITY = "city";
+
+    /** */
+    public static final String SPB = "Saint-Petersburg";
+
+    /** */
+    public static final String MSK = "Moscow";
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+        int segmentSz = 10 * 1024 * 1024;
+
+        cfg.setDataStorageConfiguration(new DataStorageConfiguration()
+            .setChangeDataCaptureEnabled(true)
+            .setWalMode(WALMode.FSYNC)
+            .setMaxWalArchiveSize(10 * segmentSz)
+            .setWalSegmentSize(segmentSz)
+            .setWalForceArchiveTimeout(WAL_ARCHIVE_TIMEOUT)
+            .setDefaultDataRegionConfiguration(new DataRegionConfiguration()
+                .setPersistenceEnabled(true)));
+
+        return cfg;
+    }
+
+    /** Simplest CDC test. */
+    @Test
+    public void testReadAllSQLRows() throws Exception {
+        IgniteConfiguration cfg = getConfiguration("ignite-0");
+
+        IgniteEx ign = startGrid(cfg);
+
+        ign.cluster().state(ACTIVE);
+
+        BinaryCDCConsumer cnsmr = new BinaryCDCConsumer();
+
+        ChangeDataCaptureConfiguration cdcCfg = new 
ChangeDataCaptureConfiguration();
+
+        cdcCfg.setConsumer(cnsmr);
+        cdcCfg.setKeepBinary(true);

Review comment:
       true is a default

##########
File path: 
modules/indexing/src/test/java/org/apache/ignite/internal/cdc/SQLChangeDataCaptureTest.java
##########
@@ -0,0 +1,240 @@
+/*
+ * 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.internal.cdc;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cdc.AbstractChangeDataCaptureTest;
+import org.apache.ignite.cdc.ChangeDataCaptureConfiguration;
+import org.apache.ignite.cdc.ChangeDataCaptureConsumer;
+import org.apache.ignite.cdc.ChangeDataCaptureEvent;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.WALMode;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.junit.Test;
+
+import static 
org.apache.ignite.cdc.AbstractChangeDataCaptureTest.ChangeEventType.DELETE;
+import static 
org.apache.ignite.cdc.AbstractChangeDataCaptureTest.ChangeEventType.UPDATE;
+import static org.apache.ignite.cluster.ClusterState.ACTIVE;
+import static 
org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheId;
+import static org.apache.ignite.testframework.GridTestUtils.runAsync;
+import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
+
+/** */
+public class SQLChangeDataCaptureTest extends AbstractChangeDataCaptureTest {

Review comment:
       Better name is Binary*

##########
File path: 
modules/spring/src/test/java/org/apache/ignite/cdc/ChangeDataCaptureConfigurationTest.java
##########
@@ -0,0 +1,125 @@
+/*
+ * 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;
+
+import java.util.Iterator;
+import java.util.concurrent.CountDownLatch;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.cdc.ChangeDataCapture;
+import org.apache.ignite.internal.cdc.WALRecordsConsumer;
+import org.apache.ignite.resources.LoggerResource;
+import org.apache.ignite.resources.SpringApplicationContextResource;
+import org.apache.ignite.resources.SpringResource;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static 
org.apache.ignite.cdc.ChangeDataCaptureLoader.loadChangeDataCapture;
+import static org.apache.ignite.internal.cdc.ChangeDataCapture.ERR_MSG;
+import static org.apache.ignite.testframework.GridTestUtils.assertThrows;
+import static org.apache.ignite.testframework.GridTestUtils.getFieldValue;
+import static org.apache.ignite.testframework.GridTestUtils.runAsync;
+
+/** */
+public class ChangeDataCaptureConfigurationTest extends GridCommonAbstractTest 
{
+    /** */
+    @Test
+    public void testLoadConfig() throws Exception {
+        assertThrows(
+            null,
+            () -> 
loadChangeDataCapture("modules/spring/src/test/config/cdc/double-ignite-config.xml"),
+            IgniteCheckedException.class,
+            "Exact 1 IgniteConfiguration should be defined. Found 2"
+        );
+
+        assertThrows(
+            null,
+            () -> 
loadChangeDataCapture("modules/spring/src/test/config/cdc/double-cdc-config.xml"),
+            IgniteCheckedException.class,
+            "Exact 1 CaptureDataChangeConfiguration configuration should be 
defined. Found 2"
+        );
+
+        ChangeDataCapture cdc =
+            
loadChangeDataCapture("modules/spring/src/test/config/cdc/cdc-config-without-persistence.xml");
+
+        assertNotNull(cdc);
+
+        assertThrows(null, cdc::run, IgniteException.class, ERR_MSG);
+    }
+
+    @Test
+    public void testInjectResources() throws Exception {

Review comment:
       javadoc missed 

##########
File path: 
modules/indexing/src/test/java/org/apache/ignite/internal/cdc/SQLChangeDataCaptureTest.java
##########
@@ -0,0 +1,240 @@
+/*
+ * 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.internal.cdc;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cdc.AbstractChangeDataCaptureTest;
+import org.apache.ignite.cdc.ChangeDataCaptureConfiguration;
+import org.apache.ignite.cdc.ChangeDataCaptureConsumer;
+import org.apache.ignite.cdc.ChangeDataCaptureEvent;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.WALMode;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.junit.Test;
+
+import static 
org.apache.ignite.cdc.AbstractChangeDataCaptureTest.ChangeEventType.DELETE;
+import static 
org.apache.ignite.cdc.AbstractChangeDataCaptureTest.ChangeEventType.UPDATE;
+import static org.apache.ignite.cluster.ClusterState.ACTIVE;
+import static 
org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheId;
+import static org.apache.ignite.testframework.GridTestUtils.runAsync;
+import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
+
+/** */
+public class SQLChangeDataCaptureTest extends AbstractChangeDataCaptureTest {
+    /** */
+    private static final String JOHN = "John Connor";
+
+    /** */
+    private static final String SARAH = "Sarah Connor";
+
+    /** */
+    public static final String USER = "user";
+
+    /** */
+    public static final String CITY = "city";
+
+    /** */
+    public static final String SPB = "Saint-Petersburg";
+
+    /** */
+    public static final String MSK = "Moscow";
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+        int segmentSz = 10 * 1024 * 1024;
+
+        cfg.setDataStorageConfiguration(new DataStorageConfiguration()
+            .setChangeDataCaptureEnabled(true)
+            .setWalMode(WALMode.FSYNC)
+            .setMaxWalArchiveSize(10 * segmentSz)

Review comment:
       why not default?

##########
File path: 
modules/core/src/test/java/org/apache/ignite/cdc/AbstractChangeDataCaptureTest.java
##########
@@ -0,0 +1,219 @@
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.cdc.ChangeDataCapture;
+import org.apache.ignite.internal.util.typedef.CI3;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static 
org.apache.ignite.cdc.AbstractChangeDataCaptureTest.ChangeEventType.DELETE;
+import static 
org.apache.ignite.cdc.AbstractChangeDataCaptureTest.ChangeEventType.UPDATE;
+import static 
org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheId;
+import static org.apache.ignite.testframework.GridTestUtils.runAsync;
+import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
+
+/** */
+public abstract class AbstractChangeDataCaptureTest extends 
GridCommonAbstractTest {
+    /** */
+    public static final int WAL_ARCHIVE_TIMEOUT = 5_000;
+
+    /** Keys count. */
+    public static final int KEYS_CNT = 50;
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        stopAllGrids();
+
+        cleanPersistenceDir();
+
+        super.beforeTest();
+    }
+
+    /** */
+    public void addAndWaitForConsumption(
+        ChangeDataCaptureSelfTest.TestCDCConsumer cnsmr,
+        ChangeDataCapture cdc,
+        IgniteCache<Integer, ChangeDataCaptureSelfTest.User> cache,
+        IgniteCache<Integer, ChangeDataCaptureSelfTest.User> txCache,
+        CI3<IgniteCache<Integer, ChangeDataCaptureSelfTest.User>, Integer, 
Integer> addData,
+        int from,
+        int to,
+        long timeout
+    ) throws IgniteCheckedException {
+        IgniteInternalFuture<?> fut = runAsync(cdc);
+
+        addData.apply(cache, from, to);
+
+        if (txCache != null)
+            addData.apply(txCache, from, to);
+
+        assertTrue(waitForSize(to - from, cache.getName(), UPDATE, timeout, 
cnsmr));
+
+        if (txCache != null)
+            assertTrue(waitForSize(to - from, txCache.getName(), UPDATE, 
timeout, cnsmr));
+
+        fut.cancel();
+
+        List<Integer> keys = cnsmr.keys(UPDATE, cacheId(cache.getName()));
+
+        assertEquals(to - from, keys.size());
+
+        for (int i = from; i < to; i++)
+            assertTrue(Integer.toString(i), keys.contains(i));
+
+        assertTrue(cnsmr.stopped);
+    }
+
+    /** */
+    public boolean waitForSize(
+        int expSz,
+        String cacheName,
+        ChangeDataCaptureSelfTest.ChangeEventType evtType,
+        long timeout,
+        ChangeDataCaptureSelfTest.TestCDCConsumer... cnsmrs
+    ) throws IgniteInterruptedCheckedException {
+        return waitForCondition(
+            () -> {
+                int sum = Arrays.stream(cnsmrs).mapToInt(c -> 
F.size(c.keys(evtType, cacheId(cacheName)))).sum();
+                return sum >= expSz;
+            },
+            timeout);
+    }
+
+    /** */
+    public ChangeDataCaptureConfiguration cdcConfig(ChangeDataCaptureConsumer 
cnsmr) {
+        ChangeDataCaptureConfiguration cdcCfg = new 
ChangeDataCaptureConfiguration();
+
+        cdcCfg.setConsumer(cnsmr);
+        cdcCfg.setKeepBinary(false);
+
+        return cdcCfg;
+    }
+
+    /** */
+    public static class TestCDCConsumer implements ChangeDataCaptureConsumer {
+        /** Keys */
+        final ConcurrentMap<IgniteBiTuple<ChangeEventType, Integer>, 
List<Integer>> cacheKeys =
+            new ConcurrentHashMap<>();
+
+        /** */
+        volatile boolean stopped;
+
+        /** */
+        volatile byte drId = -1;
+
+        /** */
+        volatile byte otherDrId = -1;
+
+        /** {@inheritDoc} */
+        @Override public void start() {
+            stopped = false;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void stop() {
+            stopped = true;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean onEvents(Iterator<ChangeDataCaptureEvent> 
evts) {
+            evts.forEachRemaining(evt -> {
+                if (!evt.primary())
+                    return;
+
+                cacheKeys.computeIfAbsent(
+                    F.t(evt.value() == null ? DELETE : UPDATE, evt.cacheId()),
+                    k -> new ArrayList<>()).add((Integer)evt.key()
+                );
+
+                if (drId != -1)
+                    assertEquals(drId, evt.version().dataCenterId());
+
+                if (otherDrId != -1)
+                    assertEquals(otherDrId, 
evt.version().otherDataCenterOrder().dataCenterId());
+
+                if (evt.value() != null) {
+                    assertTrue(((User)evt.value()).getName().startsWith("John 
Connor"));
+                    assertTrue(((User)evt.value()).getAge() >= 42);
+                }
+            });
+
+            return commit();
+        }
+
+        /** */
+        protected boolean commit() {
+            return true;
+        }
+
+        /** @return Read keys. */
+        public List<Integer> keys(ChangeEventType op, int cacheId) {
+            return cacheKeys.get(F.t(op, cacheId));
+        }
+    }
+
+    /** */
+    public static class User {
+        /** */
+        private final String name;
+
+        /** */
+        private final int age;
+
+        /** */
+        private final byte[] payload;
+
+        /** */
+        public User(String name, int age, byte[] payload) {
+            this.name = name;
+            this.age = age;
+            this.payload = payload;
+        }
+
+        /** */
+        public String getName() {
+            return name;
+        }
+
+        /** */
+        public int getAge() {
+            return age;
+        }
+
+        /** */
+        public byte[] getPayload() {
+            return payload;
+        }
+    }
+
+    public enum ChangeEventType {

Review comment:
       javadoc missed




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