This is an automated email from the ASF dual-hosted git repository.
timoninmaxim pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new ad73c62a3e5 IGNITE-22165: Add dump cancellation test (#11337)
ad73c62a3e5 is described below
commit ad73c62a3e5a5b24acb7baaf1bb039fb8665c4da
Author: Vladimir Steshin <[email protected]>
AuthorDate: Tue May 7 18:13:11 2024 +0300
IGNITE-22165: Add dump cancellation test (#11337)
---
.../snapshot/AbstractSnapshotSelfTest.java | 20 ++++++++++-
.../snapshot/dump/IgniteCacheDumpSelf2Test.java | 40 ++++++++++++++++++++++
2 files changed, 59 insertions(+), 1 deletion(-)
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/AbstractSnapshotSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/AbstractSnapshotSelfTest.java
index bc0d3b1e8c6..23b37cabf37 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/AbstractSnapshotSelfTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/AbstractSnapshotSelfTest.java
@@ -783,6 +783,23 @@ public abstract class AbstractSnapshotSelfTest extends
GridCommonAbstractTest {
List<IgniteEx> srvs,
IgniteCache<?, ?> cache,
Consumer<String> snpCanceller
+ ) {
+ doSnapshotCancellationTest(false, startCli, srvs, cache, snpCanceller);
+ }
+
+ /**
+ * @param dump Dump flag.
+ * @param startCli Client node to start snapshot.
+ * @param srvs Server nodes.
+ * @param cache Persisted cache.
+ * @param snpCanceller Snapshot cancel closure.
+ */
+ public static void doSnapshotCancellationTest(
+ boolean dump,
+ IgniteEx startCli,
+ List<IgniteEx> srvs,
+ IgniteCache<?, ?> cache,
+ Consumer<String> snpCanceller
) {
IgniteEx srv = srvs.get(0);
@@ -795,7 +812,8 @@ public abstract class AbstractSnapshotSelfTest extends
GridCommonAbstractTest {
List<BlockingExecutor> execs = setBlockingSnapshotExecutor(srvs);
- IgniteFuture<Void> fut =
startCli.snapshot().createSnapshot(SNAPSHOT_NAME);
+ IgniteFuture<Void> fut = snp(startCli).createSnapshot(SNAPSHOT_NAME,
null, null, false,
+ false, dump, false, false);
for (BlockingExecutor exec : execs)
exec.waitForBlocked(30_000L);
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java
index 67f6a928d71..158f4369a5f 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java
@@ -26,6 +26,7 @@ import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
@@ -33,6 +34,7 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.BiConsumer;
@@ -108,12 +110,16 @@ import static java.nio.file.StandardOpenOption.WRITE;
import static
org.apache.ignite.configuration.IgniteConfiguration.DFLT_SNAPSHOT_DIRECTORY;
import static org.apache.ignite.dump.DumpReaderConfiguration.DFLT_THREAD_CNT;
import static org.apache.ignite.dump.DumpReaderConfiguration.DFLT_TIMEOUT;
+import static org.apache.ignite.events.EventType.EVTS_CLUSTER_SNAPSHOT;
+import static org.apache.ignite.events.EventType.EVT_CLUSTER_SNAPSHOT_FAILED;
+import static org.apache.ignite.events.EventType.EVT_CLUSTER_SNAPSHOT_STARTED;
import static
org.apache.ignite.internal.encryption.AbstractEncryptionTest.MASTER_KEY_NAME_2;
import static
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_DATA_FILENAME;
import static
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.CACHE_DIR_PREFIX;
import static
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.PART_FILE_PREFIX;
import static
org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.ZIP_SUFFIX;
import static
org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderResolver.DB_DEFAULT_FOLDER;
+import static
org.apache.ignite.internal.processors.cache.persistence.snapshot.AbstractSnapshotSelfTest.doSnapshotCancellationTest;
import static
org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.DFLT_SNAPSHOT_TMP_DIR;
import static
org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.DUMP_LOCK;
import static
org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.SNAPSHOT_TRANSFER_RATE_DMS_KEY;
@@ -129,6 +135,7 @@ import static
org.apache.ignite.internal.processors.cache.persistence.snapshot.d
import static
org.apache.ignite.internal.processors.cache.persistence.snapshot.dump.DumpEntrySerializer.HEADER_SZ;
import static org.apache.ignite.testframework.GridTestUtils.assertContains;
import static org.apache.ignite.testframework.GridTestUtils.assertThrows;
+import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
/** */
public class IgniteCacheDumpSelf2Test extends GridCommonAbstractTest {
@@ -155,6 +162,8 @@ public class IgniteCacheDumpSelf2Test extends
GridCommonAbstractTest {
.setDefaultDataRegionConfiguration(new
DataRegionConfiguration().setPersistenceEnabled(true)));
}
+ cfg.setIncludeEventTypes(EVTS_CLUSTER_SNAPSHOT);
+
return cfg;
}
@@ -572,6 +581,37 @@ public class IgniteCacheDumpSelf2Test extends
GridCommonAbstractTest {
assertFalse(Objects.equals(hash0, hash1));
}
+ /** */
+ @Test
+ public void testCancelDump() throws Exception {
+ persistence = true;
+
+ IgniteEx srv = startGrids(3);
+
+ Collection<Integer> locEvts = ConcurrentHashMap.newKeySet();
+
+ srv.events().localListen(e -> locEvts.add(e.type()),
EVTS_CLUSTER_SNAPSHOT);
+
+ IgniteEx startCli = startClientGrid(G.allGrids().size());
+
+ IgniteEx killCli = startClientGrid(G.allGrids().size());
+
+ startCli.cluster().state(ClusterState.ACTIVE);
+
+ startCli.createCache(defaultCacheConfiguration());
+
+ try (IgniteDataStreamer<Integer, Integer> ds =
startCli.dataStreamer(DEFAULT_CACHE_NAME)) {
+ for (int i = 0; i < 1000; i++)
+ ds.addData(i, i);
+ }
+
+ doSnapshotCancellationTest(true, startCli,
Collections.singletonList(srv),
+ srv.cache(DEFAULT_CACHE_NAME), snpName ->
killCli.snapshot().cancelSnapshot(snpName).get());
+
+ waitForCondition(() ->
locEvts.containsAll(Arrays.asList(EVT_CLUSTER_SNAPSHOT_STARTED,
EVT_CLUSTER_SNAPSHOT_FAILED)),
+ getTestTimeout());
+ }
+
/** */
@Test
public void testCustomLocation() throws Exception {