zstan commented on code in PR #13577:
URL: https://github.com/apache/ignite/pull/13577#discussion_r4142400109


##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/AbstractSnapshotSelfTest.java:
##########
@@ -814,6 +847,82 @@ public static void doSnapshotCancellationTest(
         assertEquals("Snapshot directory must be empty due to snapshot 
cancelled", 0, snpDir.list().length);
     }
 
+    /** Tests concurrent snapshot deletion. */
+    protected void doTestConcurrentSnapshotDeleteOperation(
+        ExRunnable prepareCluster,
+        ExRunnable concurrentOp,
+        @Nullable Function<Exception, Boolean> errValidator,
+        boolean rerunAtTheEnd
+    ) throws Exception {
+        CountDownLatch delProcInitLatch = new CountDownLatch(1);
+        CountDownLatch delProcProceedLatch = new CountDownLatch(1);
+
+        pluginProvider = new AbstractTestPluginProvider() {
+            @Override public String name() {
+                return "TestSnpMgrProvider";
+            }
+
+            @Override public <T> T createComponent(PluginContext ctx, Class<T> 
cls) {
+                if (IgniteSnapshotManager.class.isAssignableFrom(cls)) {
+                    return (T)new 
IgniteSnapshotManager(((IgniteEx)ctx.grid()).context()) {
+                        @Override public T2<Boolean, Boolean> 
deleteLocalSnapshot(SnapshotFileTree sft) {
+                            delProcInitLatch.countDown();
+
+                            try {
+                                
assertTrue(delProcProceedLatch.await(getTestTimeout(), TimeUnit.MILLISECONDS));
+                            }
+                            catch (InterruptedException e) {
+                                throw new RuntimeException("Interrupted.", e);
+                            }
+
+                            return super.deleteLocalSnapshot(sft);
+                        }
+                    };
+                }
+
+                return super.createComponent(ctx, cls);
+            }
+        };
+
+        prepareCluster.run();
+
+        var delFut = snp(grid(0)).deleteSnapshot(SNAPSHOT_NAME, null);
+
+        assertTrue(delProcInitLatch.await(getTestTimeout(), 
TimeUnit.MILLISECONDS));
+
+        try {
+            concurrentOp.run();
+
+            if (errValidator != null)
+                throw new IllegalStateException("Exception is not thrown.");
+        }
+        catch (Exception e) {
+            if (errValidator == null || !errValidator.apply(e))
+                throw new IllegalStateException("Unexpected exception: " + 
e.getMessage(), e);
+        }
+
+        delProcProceedLatch.countDown();
+
+        delFut.get(getTestTimeout());
+
+        for (var node : G.allGrids())

Review Comment:
   var usage



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