chesnokoff commented on code in PR #11969:
URL: https://github.com/apache/ignite/pull/11969#discussion_r2106813522


##########
modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/SnapshotCompatibilityTest.java:
##########
@@ -80,201 +80,161 @@ public class SnapshotCompatibilityTest extends 
IgniteCompatibilityAbstractTest {
     /** */
     private static final int ENTRIES_CNT_FOR_INCREMENT = 100;
 
-    /** */
-    private static final String CUSTOM_SNP_RELATIVE_PATH = "ex_snapshots";
-
     /** */
     @Parameterized.Parameter
-    public boolean incSnp;
+    public boolean customConsId;
 
     /** */
     @Parameterized.Parameter(1)
-    public boolean customConsId;
+    public boolean customSnpDir;
 
     /** */
     @Parameterized.Parameter(2)
     public int oldNodesCnt;
 
     /** */
-    @Parameterized.Parameter(3)
-    public boolean cacheDump;
-
-    /** */
-    @Parameterized.Parameter(4)
-    public boolean customSnpPath;
+    private CacheGroupsConfig cacheGrpsCfg;
 
     /** */
-    @Parameterized.Parameter(5)
-    public boolean testCacheGrp;
-
-    /** */
-    private CacheGroupInfo cacheGrpInfo;
-
-    /** */
-    @Parameterized.Parameters(name = "incSnp={0}, customConsId={1}, 
oldNodesCnt={2}, cacheDump={3}, customSnpPath={4}, testCacheGrp={5}")
+    @Parameterized.Parameters(name = "customConsId={0}, customSnpDir={1}, 
oldNodesCnt={2}")
     public static Collection<Object[]> data() {
-        List<Object[]> data = new ArrayList<>();
-
-        for (boolean incSnp : Arrays.asList(true, false))
-            for (boolean customConsId: Arrays.asList(true, false))
-                for (int oldNodesCnt : Arrays.asList(1, 3))
-                    for (boolean cacheDump : Arrays.asList(true, false))
-                        for (boolean customSnpPath : Arrays.asList(true, 
false))
-                            for (boolean testCacheGrp : Arrays.asList(true, 
false))
-                                data.add(new Object[]{incSnp, customConsId, 
oldNodesCnt, cacheDump, customSnpPath, testCacheGrp});
-
-        return data;
+        return GridTestUtils.cartesianProduct(
+            List.of(true, false),
+            List.of(true, false),
+            List.of(1, 3)
+        );
     }
 
     /** */
     @Before
     public void setUp() {
-        cacheGrpInfo = new CacheGroupInfo("test-cache", testCacheGrp ? 2 : 1);
+        cacheGrpsCfg = new CacheGroupsConfig(
+            Set.of(
+                new CacheGroupInfo("singleCache", 
Collections.singleton("singleCache")),
+                new CacheGroupInfo("testCacheGrp", Set.of("testCache1", 
"testCache2"))
+            )
+        );
     }
 
     /** */
     @Test
     public void testSnapshotRestore() throws Exception {
-        if (incSnp) {
-            assumeFalse("Incremental snapshots for cache dump not supported", 
cacheDump);
+        doRestoreTest(false, false, node -> {
+            node.snapshot().restoreSnapshot(SNAPSHOT_NAME, 
cacheGrpsCfg.cacheGroupNames()).get();
 
-            assumeTrue("Incremental snapshots require same consistentID", 
customConsId);
-
-            assumeTrue("https://issues.apache.org/jira/browse/IGNITE-25096";, 
oldNodesCnt == 1);
-        }
-
-        try {
-            for (int i = 1; i <= oldNodesCnt; ++i) {
-                startGrid(
-                    i,
-                    OLD_IGNITE_VERSION,
-                    new ConfigurationClosure(incSnp, consId(i), customSnpPath, 
true, cacheGrpInfo),
-                    i == oldNodesCnt ? new CreateSnapshotClosure(incSnp, 
cacheDump, cacheGrpInfo) : null
-                );
-            }
-
-            stopAllGrids();
-
-            cleanPersistenceDir(true);
-
-            IgniteEx node = startGrid(currentIgniteConfiguration(incSnp, 
consId(1), customSnpPath));
-
-            node.cluster().state(ClusterState.ACTIVE);
-
-            if (cacheDump)
-                checkCacheDump(node);
-            else if (incSnp)
-                checkIncrementalSnapshot(node);
-            else
-                checkSnapshot(node);
-        }
-        finally {
-            stopAllGrids();
-
-            cleanPersistenceDir();
-        }
+            cacheGrpsCfg.cacheGroupInfos().forEach(cacheGrpInfo -> 
cacheGrpInfo.checkCaches(node, BASE_CACHE_SIZE));
+        });
     }
 
     /** */
-    private void checkSnapshot(IgniteEx node) {
-        node.snapshot().restoreSnapshot(SNAPSHOT_NAME, 
Collections.singleton(cacheGrpInfo.name())).get();
+    @Test
+    public void testIncrementalSnapshotRestore() throws Exception {
+        assumeTrue("Incremental snapshots require same consistentID", 
customConsId);
 
-        cacheGrpInfo.checkCaches(node, BASE_CACHE_SIZE);
-    }
+        assumeTrue("https://issues.apache.org/jira/browse/IGNITE-25096";, 
oldNodesCnt == 1);
 
-    /** */
-    private void checkIncrementalSnapshot(IgniteEx node) {
-        node.snapshot().restoreSnapshot(SNAPSHOT_NAME, 
Collections.singleton(cacheGrpInfo.name()), 1).get();
+        doRestoreTest(true, false, node -> {
+            node.snapshot().restoreSnapshot(SNAPSHOT_NAME, 
cacheGrpsCfg.cacheGroupNames(), 1).get();
 
-        cacheGrpInfo.checkCaches(node, BASE_CACHE_SIZE + 
ENTRIES_CNT_FOR_INCREMENT);
+            cacheGrpsCfg.cacheGroupInfos().forEach(
+                cacheGrpInfo -> cacheGrpInfo.checkCaches(node, BASE_CACHE_SIZE 
+ ENTRIES_CNT_FOR_INCREMENT)
+            );
+        });
     }
 
     /** */
-    private void checkCacheDump(IgniteEx node) throws IgniteCheckedException {
-        Map<String, Integer> foundCacheSizes = new ConcurrentHashMap<>();
-
-        Set<String> foundCacheNames = ConcurrentHashMap.newKeySet();
+    @Test
+    public void testDumpRestore() throws Exception {
+        doRestoreTest(false, true, node -> {
+            try {
+                CacheGroupsConfig foundCacheGrpsInfo = new CacheGroupsConfig();
 
-        DumpConsumer consumer = new DumpConsumer() {
-            @Override public void start() {
-                // No-op.
-            }
+                Map<String, Integer> foundCacheSizes = new HashMap<>();
 
-            @Override public void onMappings(Iterator<TypeMapping> mappings) {
-                // No-op.
-            }
+                DumpConsumer consumer = new DumpConsumer() {
+                    @Override public void start() {
+                        // No-op.
+                    }
 
-            @Override public void onTypes(Iterator<BinaryType> types) {
-                // No-op.
-            }
+                    @Override public void onMappings(Iterator<TypeMapping> 
mappings) {
+                        // No-op.
+                    }
 
-            @Override public void onCacheConfigs(Iterator<StoredCacheData> 
caches) {
-                assertNotNull(cacheGrpInfo);
+                    @Override public void onTypes(Iterator<BinaryType> types) {
+                        // No-op.
+                    }
 
-                caches.forEachRemaining(cache -> {
-                    CacheConfiguration<?, ?> ccfg = cache.config();
+                    @Override public void 
onCacheConfigs(Iterator<StoredCacheData> caches) {
+                        assertNotNull(cacheGrpsCfg);
 
-                    assertNotNull(ccfg);
+                        caches.forEachRemaining(cache -> {
+                            CacheConfiguration<?, ?> ccfg = cache.config();
 
-                    assertEquals(cacheGrpInfo.name(), ccfg.getGroupName());
+                            assertNotNull(ccfg);
 
-                    foundCacheNames.add(ccfg.getName());
-                });
-            }
+                            foundCacheGrpsInfo.addCache(ccfg.getGroupName(), 
ccfg.getName());
+                        });
+                    }
 
-            @Override public void onPartition(int grp, int part, 
Iterator<DumpEntry> data) {
-                assertNotNull(cacheGrpInfo);
+                    @Override public void onPartition(int grp, int part, 
Iterator<DumpEntry> data) {
+                        data.forEachRemaining(de -> {

Review Comment:
   Rename de to entry or dumpEntry



-- 
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

Reply via email to