tkalkirill commented on code in PR #12981:
URL: https://github.com/apache/ignite/pull/12981#discussion_r3043404226
##########
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 don't think it's the main one; introducing a wait could cause the test to
fail again due to background WAL and WAL compactor work. This check is more
accurate and fair.
--
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]