Skip to content

Commit aeb912d

Browse files
committed
IGNITE-13805 Simplify test.
1 parent 74ab3cc commit aeb912d

1 file changed

Lines changed: 12 additions & 27 deletions

File tree

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

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,8 @@
5555
import org.apache.ignite.internal.GridKernalContext;
5656
import org.apache.ignite.internal.IgniteEx;
5757
import org.apache.ignite.internal.IgniteInternalFuture;
58-
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
5958
import org.apache.ignite.internal.TestRecordingCommunicationSpi;
6059
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
61-
import org.apache.ignite.internal.managers.discovery.IgniteDiscoverySpi;
6260
import org.apache.ignite.internal.processors.cache.CacheGroupDescriptor;
6361
import org.apache.ignite.internal.processors.cache.DynamicCacheChangeBatch;
6462
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage;
@@ -656,54 +654,39 @@ public void testNodeFailDuringRestore() throws Exception {
656654
public void testNodeFailDuringFilesCopy() throws Exception {
657655
dfltCacheCfg.setCacheMode(CacheMode.REPLICATED);
658656

659-
IgniteEx ignite = startGridsWithSnapshot(3, CACHE_KEYS_RANGE);
657+
startGridsWithSnapshot(3, CACHE_KEYS_RANGE);
660658

659+
TestRecordingCommunicationSpi spi = TestRecordingCommunicationSpi.spi(grid(2));
661660
CountDownLatch stopLatch = new CountDownLatch(1);
662-
CountDownLatch failLatch = new CountDownLatch(1);
663-
664-
File node2dbDir = ((FilePageStoreManager)grid(2).context().cache().context().pageStore()).
665-
cacheWorkDir(dfltCacheCfg).getParentFile();
666-
667-
TestRecordingCommunicationSpi spi = TestRecordingCommunicationSpi.spi(grid(1));
668661

669662
spi.blockMessages((node, msg) -> msg instanceof SingleNodeMessage &&
670663
((SingleNodeMessage<?>)msg).type() == RESTORE_CACHE_GROUP_SNAPSHOT_PREPARE.ordinal());
671664

665+
String failingFilePath = Paths.get(CACHE_DIR_PREFIX + dfltCacheCfg.getName(), "part-5.bin").toString();
666+
672667
grid(2).context().cache().context().snapshotMgr().ioFactory(
673668
new CustomFileIOFactory(new RandomAccessFileIOFactory(),
674669
file -> {
675-
String expPath = Paths.get(CACHE_DIR_PREFIX + dfltCacheCfg.getName(), "part-5.bin").toString();
676-
677-
if (file.getPath().endsWith(expPath)) {
670+
if (file.getPath().endsWith(failingFilePath)) {
678671
stopLatch.countDown();
679672

680-
try {
681-
U.await(failLatch, TIMEOUT, TimeUnit.MILLISECONDS);
682-
}
683-
catch (IgniteInterruptedCheckedException ignore) {
684-
// No-op.
685-
}
686-
687-
throw new RuntimeException(new ClusterTopologyCheckedException("Expected"));
673+
throw new RuntimeException("Test exception");
688674
}
689675
}));
690676

677+
File node2dbDir = ((FilePageStoreManager)grid(2).context().cache().context().pageStore()).
678+
cacheWorkDir(dfltCacheCfg).getParentFile();
679+
691680
IgniteInternalFuture<Object> stopFut = runAsync(() -> {
692681
U.await(stopLatch, TIMEOUT, TimeUnit.MILLISECONDS);
693682

694-
((IgniteDiscoverySpi)grid(2).configuration().getDiscoverySpi()).simulateNodeFailure();
695-
696-
failLatch.countDown();
697-
698683
stopGrid(2, true);
699684

700-
spi.stopBlock();
701-
702685
return null;
703686
});
704687

705688
IgniteFuture<Void> fut =
706-
ignite.snapshot().restoreSnapshot(SNAPSHOT_NAME, Collections.singleton(dfltCacheCfg.getName()));
689+
grid(0).snapshot().restoreSnapshot(SNAPSHOT_NAME, Collections.singleton(dfltCacheCfg.getName()));
707690

708691
stopFut.get(TIMEOUT);
709692

@@ -716,6 +699,8 @@ public void testNodeFailDuringFilesCopy() throws Exception {
716699

717700
files = node2dbDir.listFiles(file -> file.getName().startsWith(TMP_CACHE_DIR_PREFIX));
718701
assertEquals("A temp directory should be removed at node startup", 0, files.length);
702+
703+
ensureCacheDirEmpty(dfltCacheCfg);
719704
}
720705

721706
/** @throws Exception If failed. */

0 commit comments

Comments
 (0)