petrov-mg commented on code in PR #10527:
URL: https://github.com/apache/ignite/pull/10527#discussion_r1101995023


##########
modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java:
##########
@@ -2810,4 +2815,35 @@ protected DistributedChangeableProperty<Serializable> 
computeJobWorkerInterruptT
 
         return timeoutProperty;
     }
+
+    /** Clean work directory, excluding snapshot directory. */
+    protected IgniteEx restartWithCleanPersistence(int nodes, 
Collection<String> caches) throws Exception {
+        stopAllGrids();

Review Comment:
   It seems to be clearer given the method name if we use ` int nodesCnt = 
Ignition.allGrids().size();` instead of `nodes` argument.
   
   That is up to you.



##########
modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java:
##########
@@ -2810,4 +2815,35 @@ protected DistributedChangeableProperty<Serializable> 
computeJobWorkerInterruptT
 
         return timeoutProperty;
     }
+
+    /** Clean work directory, excluding snapshot directory. */
+    protected IgniteEx restartWithCleanPersistence(int nodes, 
Collection<String> caches) throws Exception {
+        stopAllGrids();
+
+        assertTrue(U.delete(Paths.get(U.defaultWorkDirectory(), 
"cp").toFile()));
+        assertTrue(U.delete(Paths.get(U.defaultWorkDirectory(), 
DFLT_MARSHALLER_PATH).toFile()));
+
+        deleteNodesDirs(nodes, DFLT_STORE_DIR, DFLT_BINARY_METADATA_PATH, 
DFLT_WAL_PATH, DFLT_WAL_ARCHIVE_PATH);
+
+        IgniteEx ign = startGrids(nodes);
+
+        ign.cluster().state(ClusterState.ACTIVE);
+
+        // Destroy caches configured with IgniteConfiguration before restoring 
snapshot.
+        ign.destroyCaches(caches);

Review Comment:
   We can avoid explicitly destroying caches  by moving current test to 
`IgniteClusterSnapshotRestoreSelfTest` and setting `dfltCacheCfg = null;` 
before `IgniteEx ign = startGrids(nodes);` It also will make 
`Collection<String> caches` argument unnecessary.



##########
modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java:
##########
@@ -2810,4 +2815,35 @@ protected DistributedChangeableProperty<Serializable> 
computeJobWorkerInterruptT
 
         return timeoutProperty;
     }
+
+    /** Clean work directory, excluding snapshot directory. */
+    protected IgniteEx restartWithCleanPersistence(int nodes, 
Collection<String> caches) throws Exception {
+        stopAllGrids();
+
+        assertTrue(U.delete(Paths.get(U.defaultWorkDirectory(), 
"cp").toFile()));
+        assertTrue(U.delete(Paths.get(U.defaultWorkDirectory(), 
DFLT_MARSHALLER_PATH).toFile()));
+
+        deleteNodesDirs(nodes, DFLT_STORE_DIR, DFLT_BINARY_METADATA_PATH, 
DFLT_WAL_PATH, DFLT_WAL_ARCHIVE_PATH);
+
+        IgniteEx ign = startGrids(nodes);
+
+        ign.cluster().state(ClusterState.ACTIVE);
+
+        // Destroy caches configured with IgniteConfiguration before restoring 
snapshot.
+        ign.destroyCaches(caches);
+
+        awaitPartitionMapExchange();
+
+        return ign;
+    }
+
+    /** */
+    private void deleteNodesDirs(int nodes, String... dirs) throws 
IgniteCheckedException {

Review Comment:
   It seems that we can make this method more reusable if we change the `nodes` 
count argument to the name or index of a single node.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to