vldpyatkov commented on code in PR #12981:
URL: https://github.com/apache/ignite/pull/12981#discussion_r3050889217
##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalCompactionSwitchOnTest.java:
##########
@@ -42,84 +46,107 @@ public class WalCompactionSwitchOnTest extends
GridCommonAbstractTest {
private boolean compactionEnabled;
/** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String
igniteInstanceName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
-
- cfg.setDataStorageConfiguration(new DataStorageConfiguration()
- .setDefaultDataRegionConfiguration(
- new DataRegionConfiguration()
- .setPersistenceEnabled(true)
- .setMaxSize(256 * 1024 * 1024))
- .setWalSegmentSize(512 * 1024)
- .setWalSegments(100)
- .setWalCompactionEnabled(compactionEnabled));
-
- return cfg;
+ @Override protected void beforeTest() throws Exception {
+ super.beforeTest();
+
+ stopAllGrids();
+
+ cleanPersistenceDir();
}
/** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ stopAllGrids();
+
cleanPersistenceDir();
}
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String
igniteInstanceName) throws Exception {
+ DataStorageConfiguration dsCfg = new DataStorageConfiguration()
+ .setDefaultDataRegionConfiguration(
+ new DataRegionConfiguration()
+ .setPersistenceEnabled(true)
+ .setMaxSize(256 * 1024 * 1024)
+ )
+ .setWalSegmentSize(512 * 1024)
+ .setWalSegments(100)
+ .setMaxWalArchiveSize(UNLIMITED_WAL_ARCHIVE)
+ .setWalCompactionEnabled(compactionEnabled);
+
+ return super.getConfiguration(igniteInstanceName)
+ .setDataStorageConfiguration(dsCfg)
+ .setCacheConfiguration(new
CacheConfiguration<>(DEFAULT_CACHE_NAME));
+ }
+
/**
* Load without compaction -> Stop -> Enable WAL Compaction -> Start.
*
* @throws Exception On exception.
*/
@Test
public void testWalCompactionSwitch() throws Exception {
- IgniteEx ex = startGrid(0);
-
- ex.cluster().state(ClusterState.ACTIVE);
+ IgniteEx n = startGrid(0);
+ n.cluster().state(ClusterState.ACTIVE);
- IgniteCache<Integer, Integer> cache = ex.getOrCreateCache(
- new CacheConfiguration<Integer, Integer>()
- .setName("c1")
- .setGroupName("g1")
- .setCacheMode(CacheMode.PARTITIONED)
- );
+ IgniteCache<Integer, Integer> cache = n.cache(DEFAULT_CACHE_NAME);
+ for (int i = 0; i < 10_000; i++)
+ cache.put(i, i); // Streamer is intentionally not used to ensure
there are more WalRecords.
- for (int i = 0; i < 500; i++)
- cache.put(i, i);
-
- NodeFileTree ft = ex.context().pdsFolderResolver().fileTree();
+ File walArchiveDir = fileTree(n).walArchive();
+ assertNotNull(walArchiveDir);
forceCheckpoint();
-
- GridTestUtils.waitForCondition(new GridAbsPredicate() {
- @Override public boolean apply() {
- File[] archivedFiles = ft.walSegments();
-
- return archivedFiles.length == 39;
- }
- }, 5000);
+ assertTrue(waitForCondition(() ->
collectAndSortWalSegments(walArchiveDir).length >= 10, 5_000, 32));
stopGrid(0);
+ assertTrue(collectAndSortWalSegments(walArchiveDir).length >= 10);
+ assertTrue(collectAndSortCompactedWalSegments(walArchiveDir).length ==
0);
+
compactionEnabled = true;
+ startGrid(0);
- ex = startGrid(0);
+ assertTrue(waitForCondition(() ->
collectAndSortCompactedWalSegments(walArchiveDir).length >= 5, 5_000, 32));
- ex.cluster().state(ClusterState.ACTIVE);
+ File minTmpFile = minTmpWalSegemnt(walArchiveDir);
+ // Checks that tmp files of compacted WAL segments are missing or have
been deleted for compacted ones.
+ assertTrue(Objects.toString(minTmpFile), minTmpFile == null ||
walSegmentIdx(minTmpFile) >= 5);
Review Comment:
Why do you check a WAL segment ID here? It is incomprehensible because you
check only quantity above.
##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalCompactionSwitchOnTest.java:
##########
@@ -42,84 +46,107 @@ public class WalCompactionSwitchOnTest extends
GridCommonAbstractTest {
private boolean compactionEnabled;
/** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String
igniteInstanceName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
-
- cfg.setDataStorageConfiguration(new DataStorageConfiguration()
- .setDefaultDataRegionConfiguration(
- new DataRegionConfiguration()
- .setPersistenceEnabled(true)
- .setMaxSize(256 * 1024 * 1024))
- .setWalSegmentSize(512 * 1024)
- .setWalSegments(100)
- .setWalCompactionEnabled(compactionEnabled));
-
- return cfg;
+ @Override protected void beforeTest() throws Exception {
+ super.beforeTest();
+
+ stopAllGrids();
+
+ cleanPersistenceDir();
}
/** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ stopAllGrids();
+
cleanPersistenceDir();
}
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String
igniteInstanceName) throws Exception {
+ DataStorageConfiguration dsCfg = new DataStorageConfiguration()
+ .setDefaultDataRegionConfiguration(
+ new DataRegionConfiguration()
+ .setPersistenceEnabled(true)
+ .setMaxSize(256 * 1024 * 1024)
+ )
+ .setWalSegmentSize(512 * 1024)
+ .setWalSegments(100)
+ .setMaxWalArchiveSize(UNLIMITED_WAL_ARCHIVE)
+ .setWalCompactionEnabled(compactionEnabled);
+
+ return super.getConfiguration(igniteInstanceName)
+ .setDataStorageConfiguration(dsCfg)
+ .setCacheConfiguration(new
CacheConfiguration<>(DEFAULT_CACHE_NAME));
+ }
+
/**
* Load without compaction -> Stop -> Enable WAL Compaction -> Start.
*
* @throws Exception On exception.
*/
@Test
public void testWalCompactionSwitch() throws Exception {
- IgniteEx ex = startGrid(0);
-
- ex.cluster().state(ClusterState.ACTIVE);
+ IgniteEx n = startGrid(0);
+ n.cluster().state(ClusterState.ACTIVE);
- IgniteCache<Integer, Integer> cache = ex.getOrCreateCache(
- new CacheConfiguration<Integer, Integer>()
- .setName("c1")
- .setGroupName("g1")
- .setCacheMode(CacheMode.PARTITIONED)
- );
+ IgniteCache<Integer, Integer> cache = n.cache(DEFAULT_CACHE_NAME);
+ for (int i = 0; i < 10_000; i++)
+ cache.put(i, i); // Streamer is intentionally not used to ensure
there are more WalRecords.
- for (int i = 0; i < 500; i++)
- cache.put(i, i);
-
- NodeFileTree ft = ex.context().pdsFolderResolver().fileTree();
+ File walArchiveDir = fileTree(n).walArchive();
+ assertNotNull(walArchiveDir);
forceCheckpoint();
-
- GridTestUtils.waitForCondition(new GridAbsPredicate() {
- @Override public boolean apply() {
- File[] archivedFiles = ft.walSegments();
-
- return archivedFiles.length == 39;
- }
- }, 5000);
+ assertTrue(waitForCondition(() ->
collectAndSortWalSegments(walArchiveDir).length >= 10, 5_000, 32));
stopGrid(0);
+ assertTrue(collectAndSortWalSegments(walArchiveDir).length >= 10);
+ assertTrue(collectAndSortCompactedWalSegments(walArchiveDir).length ==
0);
+
compactionEnabled = true;
+ startGrid(0);
- ex = startGrid(0);
+ assertTrue(waitForCondition(() ->
collectAndSortCompactedWalSegments(walArchiveDir).length >= 5, 5_000, 32));
Review Comment:
It is the first time when I see that anyone decrees the check interval.
Do you think it makes your test faster?
--
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]