Skip to content

Commit d21a784

Browse files
authored
IGNITE-28664 Fix failed tests in Disk Page Compressions 4,5,6 Suites (#12913)
1 parent 8eff8da commit d21a784

6 files changed

Lines changed: 61 additions & 18 deletions

File tree

modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/AbstractSnapshotSelfTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
import org.apache.ignite.lang.IgniteBiTuple;
9797
import org.apache.ignite.lang.IgniteFuture;
9898
import org.apache.ignite.lang.IgniteFutureCancelledException;
99+
import org.apache.ignite.lang.IgniteFutureTimeoutException;
99100
import org.apache.ignite.lang.IgnitePredicate;
100101
import org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage;
101102
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
@@ -903,6 +904,18 @@ private void checkIncrementalSnapshotWalRecords(IgniteEx node, IncrementalSnapsh
903904
}
904905
}
905906

907+
/** Print thread dump if {@code IgniteFutureTimeoutException} is raised. */
908+
protected void runWithLoggedThreadDump(Runnable action) {
909+
try {
910+
action.run();
911+
}
912+
catch (IgniteFutureTimeoutException ex) {
913+
U.dumpThreads(log);
914+
915+
throw ex;
916+
}
917+
}
918+
906919
/**
907920
* @param ignite Ignite instance to resolve discovery spi to.
908921
* @return BlockingCustomMessageDiscoverySpi instance.

modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotHandlerTest.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ public class IgniteClusterSnapshotHandlerTest extends IgniteClusterSnapshotResto
6161
/** Custom snapshot handlers. */
6262
private final List<SnapshotHandler<?>> handlers = new ArrayList<>();
6363

64+
/** Timeout in milliseconds to await for snapshot operation being completed. */
65+
protected static final long TIMEOUT = 60_000;
66+
6467
/** Extensions plugin provider. */
6568
private final PluginProvider<PluginConfiguration> pluginProvider = new AbstractTestPluginProvider() {
6669
@Override public String name() {
@@ -84,7 +87,7 @@ public class IgniteClusterSnapshotHandlerTest extends IgniteClusterSnapshotResto
8487

8588
/** {@inheritDoc} */
8689
@Override protected Function<Integer, Object> valueBuilder() {
87-
return Integer::new;
90+
return Integer::valueOf;
8891
}
8992

9093
/**
@@ -142,11 +145,13 @@ public void testClusterSnapshotHandlers() throws Exception {
142145

143146
IgniteFuture<Void> fut = ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, null);
144147

145-
GridTestUtils.assertThrowsAnyCause(log, () -> fut.get(TIMEOUT), IgniteCheckedException.class, expMsg);
148+
runWithLoggedThreadDump(() ->
149+
GridTestUtils.assertThrowsAnyCause(log, () -> fut.get(TIMEOUT), IgniteCheckedException.class, expMsg));
146150

147151
changeMetadataRequestIdOnDisk(reqIdRef.get());
148152

149-
ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, null).get(TIMEOUT);
153+
runWithLoggedThreadDump(() ->
154+
ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, null).get(TIMEOUT));
150155

151156
assertCacheKeys(ignite.cache(DEFAULT_CACHE_NAME), CACHE_KEYS_RANGE);
152157
}
@@ -212,7 +217,8 @@ public void testClusterSnapshotHandlerFailure() throws Exception {
212217

213218
IgniteFuture<Void> fut = snp(ignite).createSnapshot(SNAPSHOT_NAME, null, false, onlyPrimary);
214219

215-
GridTestUtils.assertThrowsAnyCause(log, () -> fut.get(TIMEOUT), IgniteCheckedException.class, expMsg);
220+
runWithLoggedThreadDump(() ->
221+
GridTestUtils.assertThrowsAnyCause(log, () -> fut.get(TIMEOUT), IgniteCheckedException.class, expMsg));
216222

217223
failCreateFlag.set(false);
218224

@@ -224,11 +230,13 @@ public void testClusterSnapshotHandlerFailure() throws Exception {
224230

225231
IgniteFuture<Void> fut0 = ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, null);
226232

227-
GridTestUtils.assertThrowsAnyCause(log, () -> fut0.get(TIMEOUT), IgniteCheckedException.class, expMsg);
233+
runWithLoggedThreadDump(() ->
234+
GridTestUtils.assertThrowsAnyCause(log, () -> fut0.get(TIMEOUT), IgniteCheckedException.class, expMsg));
228235

229236
failRestoreFlag.set(false);
230237

231-
ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, null).get(TIMEOUT);
238+
runWithLoggedThreadDump(() ->
239+
ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, null).get(TIMEOUT));
232240

233241
assertCacheKeys(ignite.cache(DEFAULT_CACHE_NAME), CACHE_KEYS_RANGE);
234242
}
@@ -406,7 +414,8 @@ public void testHandlerSnapshotLocation() throws Exception {
406414
ignite.destroyCache(DEFAULT_CACHE_NAME);
407415
awaitPartitionMapExchange();
408416

409-
snpMgr.restoreSnapshot(snpName, snpDir.getAbsolutePath(), null).get(TIMEOUT);
417+
runWithLoggedThreadDump(() ->
418+
snpMgr.restoreSnapshot(snpName, snpDir.getAbsolutePath(), null).get(TIMEOUT));
410419
}
411420
finally {
412421
U.delete(snpDir);

modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotRestoreSelfTest.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ public class IgniteClusterSnapshotRestoreSelfTest extends IgniteClusterSnapshotR
9595
/** Reset consistent ID flag. */
9696
private boolean resetConsistentId;
9797

98+
/** Timeout in milliseconds to await for snapshot operation being completed. */
99+
protected static final long TIMEOUT = 60_000;
100+
98101
/** {@inheritDoc} */
99102
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
100103
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
@@ -117,7 +120,8 @@ public void testRestoreWithEmptyPartitions() throws Exception {
117120
// Skip check because some partitions will be empty - keysCnt == parts/2.
118121
Ignite ignite = startGridsWithSnapshot(1, keysCnt, false, true);
119122

120-
ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, null).get(TIMEOUT);
123+
runWithLoggedThreadDump(() ->
124+
ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, null).get(TIMEOUT));
121125

122126
assertCacheKeys(ignite.cache(DEFAULT_CACHE_NAME), keysCnt);
123127
}
@@ -235,7 +239,8 @@ private void doRestoreAllGroups() throws Exception {
235239
TestRecordingCommunicationSpi.spi(g).record(SnapshotFilesRequestMessage.class);
236240

237241
// Restore all cache groups.
238-
grid(0).snapshot().restoreSnapshot(SNAPSHOT_NAME, null).get(TIMEOUT);
242+
runWithLoggedThreadDump(() ->
243+
grid(0).snapshot().restoreSnapshot(SNAPSHOT_NAME, null).get(TIMEOUT));
239244

240245
awaitPartitionMapExchange(true, true, null, true);
241246

@@ -277,8 +282,9 @@ private void checkStartClusterSnapshotRestoreMultithreaded(IntSupplier nodeIdxSu
277282

278283
IgniteInternalFuture<Long> fut = GridTestUtils.runMultiThreadedAsync(() -> {
279284
try {
280-
grid(nodeIdxSupplier.getAsInt()).snapshot().restoreSnapshot(
281-
SNAPSHOT_NAME, Collections.singleton(DEFAULT_CACHE_NAME)).get(TIMEOUT);
285+
runWithLoggedThreadDump(() ->
286+
grid(nodeIdxSupplier.getAsInt()).snapshot().restoreSnapshot(
287+
SNAPSHOT_NAME, Collections.singleton(DEFAULT_CACHE_NAME)).get(TIMEOUT));
282288

283289
successCnt.incrementAndGet();
284290
}
@@ -444,7 +450,8 @@ public void testClusterSnapshotRestoreOnSmallerTopology() throws Exception {
444450

445451
resetBaselineTopology();
446452

447-
grid(0).snapshot().restoreSnapshot(SNAPSHOT_NAME, Collections.singleton(DEFAULT_CACHE_NAME)).get(TIMEOUT);
453+
runWithLoggedThreadDump(() ->
454+
grid(0).snapshot().restoreSnapshot(SNAPSHOT_NAME, Collections.singleton(DEFAULT_CACHE_NAME)).get(TIMEOUT));
448455

449456
assertCacheKeys(grid(0).cache(DEFAULT_CACHE_NAME), CACHE_KEYS_RANGE);
450457
waitForEvents(EVT_CLUSTER_SNAPSHOT_RESTORE_STARTED, EVT_CLUSTER_SNAPSHOT_RESTORE_FINISHED);

modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotMXBeanTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ public class IgniteSnapshotMXBeanTest extends AbstractSnapshotSelfTest {
5353
/** Snapshot group name. */
5454
private static final String SNAPSHOT_GROUP = "Snapshot";
5555

56+
/** Timeout in milliseconds to await for snapshot operation being completed. */
57+
protected static final long TIMEOUT = 60_000;
58+
5659
/** {@inheritDoc} */
5760
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
5861
return super.getConfiguration(igniteInstanceName)

modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotCheckWithIndexesTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
* Cluster-wide snapshot test check command with indexes.
3737
*/
3838
public class IgniteClusterSnapshotCheckWithIndexesTest extends AbstractSnapshotSelfTest {
39+
/** Timeout in milliseconds to await for snapshot operation being completed. */
40+
protected static final long TIMEOUT = 60_000;
41+
3942
/** @throws Exception If fails. */
4043
@Test
4144
public void testClusterSnapshotCheckEmptyCache() throws Exception {
@@ -87,7 +90,9 @@ public void testClusterSnapshotCheckWithNodeFilter() throws Exception {
8790
cache2.put(i, new Account(i, i));
8891
}
8992

90-
createAndCheckSnapshot(grid(0), SNAPSHOT_NAME, null, TIMEOUT);
93+
runWithLoggedThreadDump(() ->
94+
createAndCheckSnapshot(grid(0), SNAPSHOT_NAME, null, TIMEOUT)
95+
);
9196

9297
IdleVerifyResult res = grid(0).context().cache().context().snapshotMgr()
9398
.checkSnapshot(SNAPSHOT_NAME, null).get().idleVerifyResult();

modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotRestoreWithIndexingTest.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ public class IgniteClusterSnapshotRestoreWithIndexingTest extends IgniteClusterS
5757
/** Number of cache keys to pre-create at node start. */
5858
private static final int CACHE_KEYS_RANGE = 10_000;
5959

60+
/** Timeout in milliseconds to await for snapshot operation being completed. */
61+
protected static final long TIMEOUT = 60_000;
62+
6063
/** {@inheritDoc} */
6164
@Override protected <K, V> CacheConfiguration<K, V> txCacheConfig(CacheConfiguration<K, V> ccfg) {
6265
return super.txCacheConfig(ccfg).setSqlIndexMaxInlineSize(255).setSqlSchema("PUBLIC")
@@ -74,7 +77,8 @@ public void testBasicClusterSnapshotRestore() throws Exception {
7477

7578
IgniteEx client = startGridsWithSnapshot(2, CACHE_KEYS_RANGE, true);
7679

77-
grid(0).snapshot().restoreSnapshot(SNAPSHOT_NAME, Collections.singleton(DEFAULT_CACHE_NAME)).get(TIMEOUT);
80+
runWithLoggedThreadDump(() ->
81+
grid(0).snapshot().restoreSnapshot(SNAPSHOT_NAME, Collections.singleton(DEFAULT_CACHE_NAME)).get(TIMEOUT));
7882

7983
// Only primary mode leads to index rebuild on restore.
8084
// Must wait until index rebuild finish so subsequent checks will pass.
@@ -101,7 +105,8 @@ public void testBasicClusterSnapshotRestoreWithMetadata() throws Exception {
101105

102106
forceCheckpoint();
103107

104-
ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, Collections.singleton(DEFAULT_CACHE_NAME)).get(TIMEOUT);
108+
runWithLoggedThreadDump(() ->
109+
ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, Collections.singleton(DEFAULT_CACHE_NAME)).get(TIMEOUT));
105110

106111
// Only primary mode leads to index rebuild on restore.
107112
// Must wait until index rebuild finish so subsequent checks will pass.
@@ -126,7 +131,8 @@ public void testClusterSnapshotRestoreOnBiggerTopology() throws Exception {
126131

127132
startGridsWithCache(nodesCnt - 2, CACHE_KEYS_RANGE, valueBuilder(), dfltCacheCfg);
128133

129-
grid(0).snapshot().createSnapshot(SNAPSHOT_NAME).get(TIMEOUT);
134+
runWithLoggedThreadDump(() ->
135+
grid(0).snapshot().createSnapshot(SNAPSHOT_NAME).get(TIMEOUT));
130136

131137
startGrid(nodesCnt - 2);
132138

@@ -152,8 +158,8 @@ public void testClusterSnapshotRestoreOnBiggerTopology() throws Exception {
152158
forceCheckpoint();
153159

154160
// Restore from an empty node.
155-
ignite.snapshot().restoreSnapshot(
156-
SNAPSHOT_NAME, Collections.singleton(DEFAULT_CACHE_NAME)).get(TIMEOUT);
161+
runWithLoggedThreadDump(() -> ignite.snapshot().restoreSnapshot(
162+
SNAPSHOT_NAME, Collections.singleton(DEFAULT_CACHE_NAME)).get(TIMEOUT));
157163

158164
awaitPartitionMapExchange();
159165

0 commit comments

Comments
 (0)