You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ib...@apache.org on 2021/08/17 06:26:24 UTC

[ignite] branch master updated: IGNITE-15232 Fixed flaky CacheGroupKeyChangeTest#testWalArchiveCleanup (#9332)

This is an automated email from the ASF dual-hosted git repository.

ibessonov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new 2637eb1  IGNITE-15232 Fixed flaky CacheGroupKeyChangeTest#testWalArchiveCleanup (#9332)
2637eb1 is described below

commit 2637eb153148bd592f355a6ffcaf6d2de745d39f
Author: Kirill Tkalenko <tk...@yandex.ru>
AuthorDate: Tue Aug 17 09:25:54 2021 +0300

    IGNITE-15232 Fixed flaky CacheGroupKeyChangeTest#testWalArchiveCleanup (#9332)
---
 .../encryption/CacheGroupKeyChangeTest.java        | 39 ++++++++++------------
 1 file changed, 18 insertions(+), 21 deletions(-)

diff --git a/modules/core/src/test/java/org/apache/ignite/internal/encryption/CacheGroupKeyChangeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/encryption/CacheGroupKeyChangeTest.java
index 57a950a..6661e34 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/encryption/CacheGroupKeyChangeTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/encryption/CacheGroupKeyChangeTest.java
@@ -129,10 +129,21 @@ public class CacheGroupKeyChangeTest extends AbstractEncryptionTest {
     }
 
     /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+
+        stopAllGrids();
+
+        cleanPersistenceDir();
+    }
+
+    /** {@inheritDoc} */
     @Override protected void afterTest() throws Exception {
         stopAllGrids();
 
         cleanPersistenceDir();
+
+        super.afterTest();
     }
 
     /** @throws Exception If failed. */
@@ -723,8 +734,6 @@ public class CacheGroupKeyChangeTest extends AbstractEncryptionTest {
      */
     @Test
     public void testWalArchiveCleanup() throws Exception {
-        cleanPersistenceDir();
-
         IgniteEx node = startGrid(GRID_0);
 
         node.cluster().state(ClusterState.ACTIVE);
@@ -736,18 +745,12 @@ public class CacheGroupKeyChangeTest extends AbstractEncryptionTest {
         IgniteWriteAheadLogManager walMgr = node.context().cache().context().wal();
 
         long reservedIdx = walMgr.currentSegment();
+        assertTrue(walMgr.reserve(new WALPointer(reservedIdx, 0, 0)));
 
-        boolean reserved = walMgr.reserve(new WALPointer(reservedIdx, 0, 0));
-        assertTrue(reserved);
+        while (walMgr.lastArchivedSegment() < reservedIdx) {
+            long val = ThreadLocalRandom.current().nextLong();
 
-        IgniteInternalFuture<?> loadFut = loadDataAsync(node);
-
-        // Wait until the reserved segment is moved to the archive.
-        try {
-            boolean success = waitForCondition(() -> walMgr.lastArchivedSegment() >= reservedIdx, MAX_AWAIT_MILLIS);
-            assertTrue(success);
-        } finally {
-            loadFut.cancel();
+            node.cache(cacheName()).put(val, String.valueOf(val));
         }
 
         forceCheckpoint();
@@ -769,16 +772,10 @@ public class CacheGroupKeyChangeTest extends AbstractEncryptionTest {
 
         node.cluster().state(ClusterState.ACTIVE);
 
-        loadFut = loadDataAsync(node);
+        while (node.context().encryption().groupKeyIds(grpId).size() != 1) {
+            long val = ThreadLocalRandom.current().nextLong();
 
-        // Make sure that unused encryption key has been deleted.
-        try {
-            GridEncryptionManager encryptMgr = node.context().encryption();
-
-            boolean success = waitForCondition(() -> encryptMgr.groupKeyIds(grpId).size() == 1, MAX_AWAIT_MILLIS);
-            assertTrue(success);
-        } finally {
-            loadFut.cancel();
+            node.cache(cacheName()).put(val, String.valueOf(val));
         }
 
         checkGroupKey(grpId, INITIAL_KEY_ID + 1, MAX_AWAIT_MILLIS);