NSAmelchev commented on code in PR #10360: URL: https://github.com/apache/ignite/pull/10360#discussion_r1018780435
########## modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotDeltaTest.java: ########## @@ -0,0 +1,217 @@ +/* + * 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.processors.cache.persistence.snapshot; + +import java.io.File; +import java.io.IOException; +import java.io.Serializable; +import java.nio.ByteBuffer; +import java.nio.file.OpenOption; +import java.util.Arrays; +import java.util.Collection; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ThreadLocalRandom; +import java.util.function.BiFunction; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.processors.cache.persistence.file.FileIO; +import org.apache.ignite.internal.processors.cache.persistence.file.FileIODecorator; +import org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory; +import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager; +import org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId; +import org.apache.ignite.internal.processors.configuration.distributed.DistributedChangeableProperty; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.lang.IgniteFuture; +import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import static org.apache.ignite.configuration.DataStorageConfiguration.DFLT_PAGE_SIZE; +import static org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_DIR_PREFIX; +import static org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.SNAPSHOT_DELTA_SORT_BATCH_SIZE_KEY; +import static org.apache.ignite.testframework.GridTestUtils.cartesianProduct; +import static org.junit.Assert.assertArrayEquals; + +/** + * Cluster snapshot delta tests. + */ +@RunWith(Parameterized.class) +public class IgniteClusterSnapshotDeltaTest extends AbstractSnapshotSelfTest { + /** */ + @Parameterized.Parameter(1) + public boolean sorted; + + /** Parameters. */ + @Parameterized.Parameters(name = "encryption={0}, sorted={1}") + public static Collection<Object[]> parameters() { + return cartesianProduct(encryptionParams(), F.asList(false, true)); + } + + /** @throws Exception If failed. */ + @Test + public void testSendDelta() throws Exception { + int keys = 1_000; + byte[] payload = new byte[DFLT_PAGE_SIZE / 2]; + int partCnt = 2; + int batchSize = keys / 10; + + // 1. Start a cluster and fill cache. + ThreadLocalRandom.current().nextBytes(payload); + + byte[] expPayload = Arrays.copyOf(payload, payload.length); + + CacheConfiguration<Integer, byte[]> ccfg = new CacheConfiguration<Integer, byte[]>(DEFAULT_CACHE_NAME) + .setAffinity(new RendezvousAffinityFunction(false, partCnt)); + + String cacheDir = CACHE_DIR_PREFIX + DEFAULT_CACHE_NAME; + + IgniteEx srv = startGridsWithCache(1, keys, (k) -> expPayload, ccfg); + + if (sorted) { + setDeltaSortBatchSize(batchSize); + + injectSequentialWriteCheck(srv, batchSize); Review Comment: Could you explain, please? -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
