vldpyatkov commented on code in PR #12981:
URL: https://github.com/apache/ignite/pull/12981#discussion_r3040707526


##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalCompactionSwitchOnTest.java:
##########
@@ -69,57 +80,36 @@ public class WalCompactionSwitchOnTest extends 
GridCommonAbstractTest {
      */
     @Test
     public void testWalCompactionSwitch() throws Exception {
-        IgniteEx ex = startGrid(0);
+        IgniteEx n = startGrid(0);
+        n.cluster().state(ClusterState.ACTIVE);
 
-        ex.cluster().state(ClusterState.ACTIVE);
-
-        IgniteCache<Integer, Integer> cache = ex.getOrCreateCache(
+        IgniteCache<Integer, Integer> cache = n.getOrCreateCache(
             new CacheConfiguration<Integer, Integer>()
                     .setName("c1")
                     .setGroupName("g1")
                     .setCacheMode(CacheMode.PARTITIONED)
         );
 
-        for (int i = 0; i < 500; i++)
+        for (int i = 0; i < 10_000; i++)
             cache.put(i, i);
 
-        NodeFileTree ft = ex.context().pdsFolderResolver().fileTree();
-
         forceCheckpoint();
 
-        GridTestUtils.waitForCondition(new GridAbsPredicate() {
-            @Override public boolean apply() {
-                File[] archivedFiles = ft.walSegments();
-
-                return archivedFiles.length == 39;
-            }
-        }, 5000);
+        assertTrue(waitForCondition(() -> ft(grid(0)).walSegments().length >= 
10, 5_000, 32));
 
         stopGrid(0);
 
         compactionEnabled = true;
 
-        ex = startGrid(0);
-
-        ex.cluster().state(ClusterState.ACTIVE);
-
-        File archiveDir = 
ex.context().pdsFolderResolver().fileTree().walArchive();
-
-        GridTestUtils.waitForCondition(new GridAbsPredicate() {
-            @Override public boolean apply() {
-                File[] archivedFiles = 
archiveDir.listFiles(NodeFileTree::walCompactedSegment);
+        n = startGrid(0);
+        n.cluster().state(ClusterState.ACTIVE);
 
-                return archivedFiles.length == 20;
-            }
-        }, 5000);
-
-        File[] tmpFiles = 
archiveDir.listFiles(WAL_SEGMENT_TEMP_FILE_COMPACTED_FILTER);
-
-        assertEquals(0, tmpFiles.length);
+        assertTrue(waitForCondition(() -> 
ft(grid(0)).walArchiveCompactedSegments().length >= 5, 5_000, 32));
+        
assertTrue(ft(n).walArchive().listFiles(WAL_SEGMENT_TEMP_FILE_COMPACTED_FILTER).length
 >= 0);
     }
 
-    /** {@inheritDoc} */
-    @Override protected void afterTest() throws Exception {
-        stopAllGrids();
+    /** */
+    private static NodeFileTree ft(IgniteEx n) {

Review Comment:
   Two layers' names for a method are terrible. Please make this readable.



##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalCompactionSwitchOnTest.java:
##########
@@ -69,57 +80,36 @@ public class WalCompactionSwitchOnTest extends 
GridCommonAbstractTest {
      */
     @Test
     public void testWalCompactionSwitch() throws Exception {
-        IgniteEx ex = startGrid(0);
+        IgniteEx n = startGrid(0);
+        n.cluster().state(ClusterState.ACTIVE);
 
-        ex.cluster().state(ClusterState.ACTIVE);
-
-        IgniteCache<Integer, Integer> cache = ex.getOrCreateCache(
+        IgniteCache<Integer, Integer> cache = n.getOrCreateCache(
             new CacheConfiguration<Integer, Integer>()
                     .setName("c1")
                     .setGroupName("g1")
                     .setCacheMode(CacheMode.PARTITIONED)
         );
 
-        for (int i = 0; i < 500; i++)
+        for (int i = 0; i < 10_000; i++)
             cache.put(i, i);

Review Comment:
   If you are still going to change the test, it's better to use a data 
streamer here.



##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalCompactionSwitchOnTest.java:
##########
@@ -69,57 +80,36 @@ public class WalCompactionSwitchOnTest extends 
GridCommonAbstractTest {
      */
     @Test
     public void testWalCompactionSwitch() throws Exception {
-        IgniteEx ex = startGrid(0);
+        IgniteEx n = startGrid(0);
+        n.cluster().state(ClusterState.ACTIVE);
 
-        ex.cluster().state(ClusterState.ACTIVE);
-
-        IgniteCache<Integer, Integer> cache = ex.getOrCreateCache(
+        IgniteCache<Integer, Integer> cache = n.getOrCreateCache(
             new CacheConfiguration<Integer, Integer>()
                     .setName("c1")
                     .setGroupName("g1")
                     .setCacheMode(CacheMode.PARTITIONED)
         );
 
-        for (int i = 0; i < 500; i++)
+        for (int i = 0; i < 10_000; i++)
             cache.put(i, i);
 
-        NodeFileTree ft = ex.context().pdsFolderResolver().fileTree();
-
         forceCheckpoint();
 
-        GridTestUtils.waitForCondition(new GridAbsPredicate() {
-            @Override public boolean apply() {
-                File[] archivedFiles = ft.walSegments();
-
-                return archivedFiles.length == 39;
-            }
-        }, 5000);
+        assertTrue(waitForCondition(() -> ft(grid(0)).walSegments().length >= 
10, 5_000, 32));
 
         stopGrid(0);
 
         compactionEnabled = true;
 
-        ex = startGrid(0);
-
-        ex.cluster().state(ClusterState.ACTIVE);
-
-        File archiveDir = 
ex.context().pdsFolderResolver().fileTree().walArchive();
-
-        GridTestUtils.waitForCondition(new GridAbsPredicate() {
-            @Override public boolean apply() {
-                File[] archivedFiles = 
archiveDir.listFiles(NodeFileTree::walCompactedSegment);
+        n = startGrid(0);
+        n.cluster().state(ClusterState.ACTIVE);
 
-                return archivedFiles.length == 20;
-            }
-        }, 5000);
-
-        File[] tmpFiles = 
archiveDir.listFiles(WAL_SEGMENT_TEMP_FILE_COMPACTED_FILTER);
-
-        assertEquals(0, tmpFiles.length);
+        assertTrue(waitForCondition(() -> 
ft(grid(0)).walArchiveCompactedSegments().length >= 5, 5_000, 32));
+        
assertTrue(ft(n).walArchive().listFiles(WAL_SEGMENT_TEMP_FILE_COMPACTED_FILTER).length
 >= 0);

Review Comment:
   I believe it is a main check in the test. Let's wait the strict 0 here.



##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalCompactionSwitchOnTest.java:
##########
@@ -69,57 +80,36 @@ public class WalCompactionSwitchOnTest extends 
GridCommonAbstractTest {
      */
     @Test
     public void testWalCompactionSwitch() throws Exception {
-        IgniteEx ex = startGrid(0);
+        IgniteEx n = startGrid(0);
+        n.cluster().state(ClusterState.ACTIVE);
 
-        ex.cluster().state(ClusterState.ACTIVE);
-
-        IgniteCache<Integer, Integer> cache = ex.getOrCreateCache(
+        IgniteCache<Integer, Integer> cache = n.getOrCreateCache(
             new CacheConfiguration<Integer, Integer>()
                     .setName("c1")
                     .setGroupName("g1")
                     .setCacheMode(CacheMode.PARTITIONED)
         );
 
-        for (int i = 0; i < 500; i++)
+        for (int i = 0; i < 10_000; i++)
             cache.put(i, i);
 
-        NodeFileTree ft = ex.context().pdsFolderResolver().fileTree();
-
         forceCheckpoint();
 
-        GridTestUtils.waitForCondition(new GridAbsPredicate() {
-            @Override public boolean apply() {
-                File[] archivedFiles = ft.walSegments();
-
-                return archivedFiles.length == 39;
-            }
-        }, 5000);
+        assertTrue(waitForCondition(() -> ft(grid(0)).walSegments().length >= 
10, 5_000, 32));
 
         stopGrid(0);
 
         compactionEnabled = true;
 
-        ex = startGrid(0);
-
-        ex.cluster().state(ClusterState.ACTIVE);
-
-        File archiveDir = 
ex.context().pdsFolderResolver().fileTree().walArchive();
-
-        GridTestUtils.waitForCondition(new GridAbsPredicate() {
-            @Override public boolean apply() {
-                File[] archivedFiles = 
archiveDir.listFiles(NodeFileTree::walCompactedSegment);
+        n = startGrid(0);
+        n.cluster().state(ClusterState.ACTIVE);

Review Comment:
   Why does autoactivation not happen here, or is the line redundant?



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