nizhikov commented on code in PR #10314: URL: https://github.com/apache/ignite/pull/10314#discussion_r1081076810
########## modules/core/src/test/java/org/apache/ignite/internal/processors/cache/consistentcut/AbstractConsistentCutTest.java: ########## @@ -0,0 +1,296 @@ +/* + * 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.consistentcut; + +import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.UUID; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteException; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cluster.ClusterState; +import org.apache.ignite.configuration.CacheConfiguration; +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.IgniteInterruptedCheckedException; +import org.apache.ignite.internal.pagemem.wal.WALIterator; +import org.apache.ignite.internal.pagemem.wal.record.ConsistentCutFinishRecord; +import org.apache.ignite.internal.pagemem.wal.record.ConsistentCutStartRecord; +import org.apache.ignite.internal.pagemem.wal.record.DataRecord; +import org.apache.ignite.internal.pagemem.wal.record.WALRecord; +import org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer; +import org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory; +import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; +import org.apache.ignite.internal.util.tostring.GridToStringInclude; +import org.apache.ignite.internal.util.typedef.G; +import org.apache.ignite.internal.util.typedef.T2; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.lang.IgniteBiTuple; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.jetbrains.annotations.Nullable; + +import static org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordType.CONSISTENT_CUT_FINISH_RECORD; +import static org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordType.CONSISTENT_CUT_START_RECORD; +import static org.apache.ignite.internal.pagemem.wal.record.WALRecord.RecordType.DATA_RECORD_V2; +import static org.apache.ignite.internal.processors.cache.persistence.snapshot.AbstractSnapshotSelfTest.snp; + +/** Base class for testing Consistency Cut algorithm. */ +public abstract class AbstractConsistentCutTest extends GridCommonAbstractTest { + /** */ + protected static final String CACHE = "CACHE"; + + /** */ + protected static final String SNP = "base"; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String instanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(instanceName); + + cfg.setDataStorageConfiguration(new DataStorageConfiguration() + .setWalCompactionEnabled(true) + .setDefaultDataRegionConfiguration(new DataRegionConfiguration() + .setName("consistent-cut-persist") + .setPersistenceEnabled(true))); + + cfg.setCacheConfiguration(cacheConfiguration(CACHE)); + + cfg.setConsistentId(instanceName); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + cleanPersistenceDir(); + + startGrids(nodes()); + + grid(0).cluster().state(ClusterState.ACTIVE); + + startClientGrid(nodes()); + + snp(grid(0)).createSnapshot(SNP).get(); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + + cleanPersistenceDir(); + } + + /** */ + protected CacheConfiguration<Integer, Integer> cacheConfiguration(String cacheName) { + return new CacheConfiguration<Integer, Integer>() + .setName(cacheName) + .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) + .setBackups(backups()); + } + + /** + * @return Number of server nodes. + */ + protected abstract int nodes(); + + /** + * @return Number of backups for cache. + */ + protected abstract int backups(); + + /** */ + protected void awaitSnapshotResourcesCleaned() { + try { + GridTestUtils.waitForCondition(() -> { Review Comment: It seems we need to `assertTrue(waitForCondition())` waitForCondition don't throw if condition doesn't meet before timeout -- 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: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org