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 2022/06/30 15:51:48 UTC

[ignite-3] branch main updated: IGNITE-17283 Start nodes in parallel in ItCmgRaftServiceTest (#911)

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

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


The following commit(s) were added to refs/heads/main by this push:
     new bea62dd19 IGNITE-17283 Start nodes in parallel in ItCmgRaftServiceTest (#911)
bea62dd19 is described below

commit bea62dd190b8dc2096526ccbe79b3903903eb989
Author: Alexander Polovtcev <al...@gmail.com>
AuthorDate: Thu Jun 30 18:51:43 2022 +0300

    IGNITE-17283 Start nodes in parallel in ItCmgRaftServiceTest (#911)
---
 .../management/raft/ItCmgRaftServiceTest.java      | 72 ++++++++++++----------
 1 file changed, 39 insertions(+), 33 deletions(-)

diff --git a/modules/cluster-management/src/integrationTest/java/org/apache/ignite/internal/cluster/management/raft/ItCmgRaftServiceTest.java b/modules/cluster-management/src/integrationTest/java/org/apache/ignite/internal/cluster/management/raft/ItCmgRaftServiceTest.java
index 451ed3ea5..31a27d6c2 100644
--- a/modules/cluster-management/src/integrationTest/java/org/apache/ignite/internal/cluster/management/raft/ItCmgRaftServiceTest.java
+++ b/modules/cluster-management/src/integrationTest/java/org/apache/ignite/internal/cluster/management/raft/ItCmgRaftServiceTest.java
@@ -44,7 +44,9 @@ import org.apache.ignite.internal.properties.IgniteProductVersion;
 import org.apache.ignite.internal.raft.Loza;
 import org.apache.ignite.internal.testframework.WorkDirectory;
 import org.apache.ignite.internal.testframework.WorkDirectoryExtension;
+import org.apache.ignite.internal.util.IgniteUtils;
 import org.apache.ignite.lang.IgniteInternalException;
+import org.apache.ignite.lang.NodeStoppingException;
 import org.apache.ignite.network.ClusterNode;
 import org.apache.ignite.network.ClusterService;
 import org.apache.ignite.network.NetworkAddress;
@@ -83,34 +85,48 @@ public class ItCmgRaftServiceTest {
             raftManager.start();
         }
 
-        void afterNodeStart() throws Exception {
-            assertTrue(waitForCondition(() -> clusterService.topologyService().allMembers().size() == cluster.size(), 1000));
+        void afterNodeStart() {
+            try {
+                assertTrue(waitForCondition(() -> clusterService.topologyService().allMembers().size() == cluster.size(), 1000));
 
-            raftStorage.start();
+                raftStorage.start();
 
-            CompletableFuture<RaftGroupService> raftService = raftManager.prepareRaftGroup(
-                    TEST_GROUP,
-                    List.copyOf(clusterService.topologyService().allMembers()),
-                    () -> new CmgRaftGroupListener(raftStorage),
-                    defaults()
-            );
+                CompletableFuture<RaftGroupService> raftService = raftManager.prepareRaftGroup(
+                        TEST_GROUP,
+                        List.copyOf(clusterService.topologyService().allMembers()),
+                        () -> new CmgRaftGroupListener(raftStorage),
+                        defaults()
+                );
 
-            assertThat(raftService, willCompleteSuccessfully());
+                assertThat(raftService, willCompleteSuccessfully());
 
-            this.raftService = new CmgRaftService(raftService.get(), clusterService);
+                this.raftService = new CmgRaftService(raftService.join(), clusterService);
+            } catch (InterruptedException | NodeStoppingException e) {
+                throw new RuntimeException(e);
+            }
         }
 
-        void beforeNodeStop() throws Exception {
-            raftManager.stopRaftGroup(TEST_GROUP);
+        void beforeNodeStop() {
+            try {
+                raftManager.stopRaftGroup(TEST_GROUP);
+            } catch (NodeStoppingException e) {
+                throw new RuntimeException(e);
+            }
 
             raftManager.beforeNodeStop();
             clusterService.beforeNodeStop();
         }
 
-        void stop() throws Exception {
-            raftManager.stop();
-            raftStorage.close();
-            clusterService.stop();
+        void stop() {
+            try {
+                IgniteUtils.closeAll(
+                        raftManager::stop,
+                        raftStorage,
+                        clusterService::stop
+                );
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
         }
 
         ClusterNode localMember() {
@@ -121,7 +137,7 @@ public class ItCmgRaftServiceTest {
     private final List<Node> cluster = new ArrayList<>();
 
     @BeforeEach
-    void setUp(@WorkDirectory Path workDir, TestInfo testInfo) throws Exception {
+    void setUp(@WorkDirectory Path workDir, TestInfo testInfo) {
         var addr1 = new NetworkAddress("localhost", 10000);
         var addr2 = new NetworkAddress("localhost", 10001);
 
@@ -130,24 +146,14 @@ public class ItCmgRaftServiceTest {
         cluster.add(new Node(testInfo, addr1, nodeFinder, workDir.resolve("node1")));
         cluster.add(new Node(testInfo, addr2, nodeFinder, workDir.resolve("node2")));
 
-        for (Node node : cluster) {
-            node.start();
-        }
-
-        for (Node node : cluster) {
-            node.afterNodeStart();
-        }
+        cluster.parallelStream().forEach(Node::start);
+        cluster.parallelStream().forEach(Node::afterNodeStart);
     }
 
     @AfterEach
-    void tearDown() throws Exception {
-        for (Node node : cluster) {
-            node.beforeNodeStop();
-        }
-
-        for (Node node : cluster) {
-            node.stop();
-        }
+    void tearDown() {
+        cluster.parallelStream().forEach(Node::beforeNodeStop);
+        cluster.parallelStream().forEach(Node::stop);
     }
 
     /**