diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotHandlerTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotHandlerTest.java index 7b679de89ad4f..da7e437f17028 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotHandlerTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotHandlerTest.java @@ -84,7 +84,7 @@ public class IgniteClusterSnapshotHandlerTest extends IgniteClusterSnapshotResto /** {@inheritDoc} */ @Override protected Function valueBuilder() { - return Integer::new; + return Integer::valueOf; } /** @@ -142,11 +142,13 @@ public void testClusterSnapshotHandlers() throws Exception { IgniteFuture fut = ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, null); - GridTestUtils.assertThrowsAnyCause(log, () -> fut.get(TIMEOUT), IgniteCheckedException.class, expMsg); + runWithLogggedThreadDump(() -> + GridTestUtils.assertThrowsAnyCause(log, () -> fut.get(TIMEOUT), IgniteCheckedException.class, expMsg)); changeMetadataRequestIdOnDisk(reqIdRef.get()); - ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, null).get(TIMEOUT); + runWithLogggedThreadDump(() -> + ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, null).get(TIMEOUT)); assertCacheKeys(ignite.cache(DEFAULT_CACHE_NAME), CACHE_KEYS_RANGE); } @@ -212,7 +214,8 @@ public void testClusterSnapshotHandlerFailure() throws Exception { IgniteFuture fut = snp(ignite).createSnapshot(SNAPSHOT_NAME, null, false, onlyPrimary); - GridTestUtils.assertThrowsAnyCause(log, () -> fut.get(TIMEOUT), IgniteCheckedException.class, expMsg); + runWithLogggedThreadDump(() -> + GridTestUtils.assertThrowsAnyCause(log, () -> fut.get(TIMEOUT), IgniteCheckedException.class, expMsg)); failCreateFlag.set(false); @@ -224,11 +227,13 @@ public void testClusterSnapshotHandlerFailure() throws Exception { IgniteFuture fut0 = ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, null); - GridTestUtils.assertThrowsAnyCause(log, () -> fut0.get(TIMEOUT), IgniteCheckedException.class, expMsg); + runWithLogggedThreadDump(() -> + GridTestUtils.assertThrowsAnyCause(log, () -> fut0.get(TIMEOUT), IgniteCheckedException.class, expMsg)); failRestoreFlag.set(false); - ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, null).get(TIMEOUT); + runWithLogggedThreadDump(() -> + ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, null).get(TIMEOUT)); assertCacheKeys(ignite.cache(DEFAULT_CACHE_NAME), CACHE_KEYS_RANGE); } @@ -406,7 +411,8 @@ public void testHandlerSnapshotLocation() throws Exception { ignite.destroyCache(DEFAULT_CACHE_NAME); awaitPartitionMapExchange(); - snpMgr.restoreSnapshot(snpName, snpDir.getAbsolutePath(), null).get(TIMEOUT); + runWithLogggedThreadDump(() -> + snpMgr.restoreSnapshot(snpName, snpDir.getAbsolutePath(), null).get(TIMEOUT)); } finally { U.delete(snpDir); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotRestoreBaseTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotRestoreBaseTest.java index 4393f08ce64fb..6c57bf2118de2 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotRestoreBaseTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotRestoreBaseTest.java @@ -24,7 +24,9 @@ import org.apache.ignite.internal.TestRecordingCommunicationSpi; import org.apache.ignite.internal.util.distributed.DistributedProcess; import org.apache.ignite.internal.util.distributed.SingleNodeMessage; +import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteFuture; +import org.apache.ignite.lang.IgniteFutureTimeoutException; /** * Snapshot restore test base. @@ -94,4 +96,16 @@ protected class BinaryValueBuilder implements Function { return builder.build(); } } + + /** Print thread dump if {@code IgniteFutureTimeoutException} is raised. */ + protected void runWithLogggedThreadDump(Runnable action) { + try { + action.run(); + } + catch (IgniteFutureTimeoutException ex) { + U.dumpThreads(log); + + throw ex; + } + } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotRestoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotRestoreSelfTest.java index 409c1fb13cbd8..aa3a24fca9339 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotRestoreSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotRestoreSelfTest.java @@ -95,6 +95,9 @@ public class IgniteClusterSnapshotRestoreSelfTest extends IgniteClusterSnapshotR /** Reset consistent ID flag. */ private boolean resetConsistentId; + /** Timeout in milliseconds to await for snapshot operation being completed. */ + protected static final long TIMEOUT = 60_000; + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); @@ -117,7 +120,8 @@ public void testRestoreWithEmptyPartitions() throws Exception { // Skip check because some partitions will be empty - keysCnt == parts/2. Ignite ignite = startGridsWithSnapshot(1, keysCnt, false, true); - ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, null).get(TIMEOUT); + runWithLogggedThreadDump(() -> + ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, null).get(TIMEOUT)); assertCacheKeys(ignite.cache(DEFAULT_CACHE_NAME), keysCnt); } @@ -235,7 +239,8 @@ private void doRestoreAllGroups() throws Exception { TestRecordingCommunicationSpi.spi(g).record(SnapshotFilesRequestMessage.class); // Restore all cache groups. - grid(0).snapshot().restoreSnapshot(SNAPSHOT_NAME, null).get(TIMEOUT); + runWithLogggedThreadDump(() -> + grid(0).snapshot().restoreSnapshot(SNAPSHOT_NAME, null).get(TIMEOUT)); awaitPartitionMapExchange(true, true, null, true); @@ -277,8 +282,9 @@ private void checkStartClusterSnapshotRestoreMultithreaded(IntSupplier nodeIdxSu IgniteInternalFuture fut = GridTestUtils.runMultiThreadedAsync(() -> { try { - grid(nodeIdxSupplier.getAsInt()).snapshot().restoreSnapshot( - SNAPSHOT_NAME, Collections.singleton(DEFAULT_CACHE_NAME)).get(TIMEOUT); + runWithLogggedThreadDump(() -> + grid(nodeIdxSupplier.getAsInt()).snapshot().restoreSnapshot( + SNAPSHOT_NAME, Collections.singleton(DEFAULT_CACHE_NAME)).get(TIMEOUT)); successCnt.incrementAndGet(); } @@ -444,7 +450,8 @@ public void testClusterSnapshotRestoreOnSmallerTopology() throws Exception { resetBaselineTopology(); - grid(0).snapshot().restoreSnapshot(SNAPSHOT_NAME, Collections.singleton(DEFAULT_CACHE_NAME)).get(TIMEOUT); + runWithLogggedThreadDump(() -> + grid(0).snapshot().restoreSnapshot(SNAPSHOT_NAME, Collections.singleton(DEFAULT_CACHE_NAME)).get(TIMEOUT)); assertCacheKeys(grid(0).cache(DEFAULT_CACHE_NAME), CACHE_KEYS_RANGE); waitForEvents(EVT_CLUSTER_SNAPSHOT_RESTORE_STARTED, EVT_CLUSTER_SNAPSHOT_RESTORE_FINISHED); diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotRestoreWithIndexingTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotRestoreWithIndexingTest.java index b8ebe10a7d202..ab14c005c3df4 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotRestoreWithIndexingTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotRestoreWithIndexingTest.java @@ -74,7 +74,8 @@ public void testBasicClusterSnapshotRestore() throws Exception { IgniteEx client = startGridsWithSnapshot(2, CACHE_KEYS_RANGE, true); - grid(0).snapshot().restoreSnapshot(SNAPSHOT_NAME, Collections.singleton(DEFAULT_CACHE_NAME)).get(TIMEOUT); + runWithLogggedThreadDump(() -> + grid(0).snapshot().restoreSnapshot(SNAPSHOT_NAME, Collections.singleton(DEFAULT_CACHE_NAME)).get(TIMEOUT)); // Only primary mode leads to index rebuild on restore. // Must wait until index rebuild finish so subsequent checks will pass. @@ -101,7 +102,8 @@ public void testBasicClusterSnapshotRestoreWithMetadata() throws Exception { forceCheckpoint(); - ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, Collections.singleton(DEFAULT_CACHE_NAME)).get(TIMEOUT); + runWithLogggedThreadDump(() -> + ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, Collections.singleton(DEFAULT_CACHE_NAME)).get(TIMEOUT)); // Only primary mode leads to index rebuild on restore. // Must wait until index rebuild finish so subsequent checks will pass. @@ -126,7 +128,8 @@ public void testClusterSnapshotRestoreOnBiggerTopology() throws Exception { startGridsWithCache(nodesCnt - 2, CACHE_KEYS_RANGE, valueBuilder(), dfltCacheCfg); - grid(0).snapshot().createSnapshot(SNAPSHOT_NAME).get(TIMEOUT); + runWithLogggedThreadDump(() -> + grid(0).snapshot().createSnapshot(SNAPSHOT_NAME).get(TIMEOUT)); startGrid(nodesCnt - 2); @@ -152,8 +155,8 @@ public void testClusterSnapshotRestoreOnBiggerTopology() throws Exception { forceCheckpoint(); // Restore from an empty node. - ignite.snapshot().restoreSnapshot( - SNAPSHOT_NAME, Collections.singleton(DEFAULT_CACHE_NAME)).get(TIMEOUT); + runWithLogggedThreadDump(() -> ignite.snapshot().restoreSnapshot( + SNAPSHOT_NAME, Collections.singleton(DEFAULT_CACHE_NAME)).get(TIMEOUT)); awaitPartitionMapExchange();