You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2022/03/11 11:14:19 UTC

[GitHub] [ignite-3] sanpwc opened a new pull request #717: IGNITE-16678 RaftGroupService#transferLeadership fixed.

sanpwc opened a new pull request #717:
URL: https://github.com/apache/ignite-3/pull/717


   …ransferLeadership fixed.


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] sanpwc commented on a change in pull request #717: IGNITE-16678 RaftGroupService#transferLeadership fixed.

Posted by GitBox <gi...@apache.org>.
sanpwc commented on a change in pull request #717:
URL: https://github.com/apache/ignite-3/pull/717#discussion_r826031416



##########
File path: modules/raft/src/integrationTest/java/org/apache/ignite/internal/raft/ItRaftGroupServiceTest.java
##########
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.raft;
+
+import static org.apache.ignite.raft.jraft.test.TestUtils.waitForCondition;
+import static org.apache.ignite.raft.jraft.test.TestUtils.waitForTopology;
+import static org.apache.ignite.utils.ClusterServiceTestUtils.findLocalAddresses;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.testframework.WorkDirectory;
+import org.apache.ignite.internal.testframework.WorkDirectoryExtension;
+import org.apache.ignite.network.ClusterNode;
+import org.apache.ignite.network.ClusterService;
+import org.apache.ignite.network.NetworkAddress;
+import org.apache.ignite.network.StaticNodeFinder;
+import org.apache.ignite.network.scalecube.TestScaleCubeClusterServiceFactory;
+import org.apache.ignite.raft.client.Peer;
+import org.apache.ignite.raft.client.service.RaftGroupListener;
+import org.apache.ignite.raft.client.service.RaftGroupService;
+import org.apache.ignite.utils.ClusterServiceTestUtils;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+/**
+ * Integration test methods of raft group service.
+ */
+@ExtendWith(WorkDirectoryExtension.class)
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+public class ItRaftGroupServiceTest {
+    @WorkDirectory
+    private static Path workDir;
+
+    private static final int NODES_CNT = 2;
+
+    private static final int NODE_PORT_BASE = 20_000;
+
+    private static final TestScaleCubeClusterServiceFactory NETWORK_FACTORY = new TestScaleCubeClusterServiceFactory();
+
+    private static final String RAFT_GROUP_NAME = "part1";
+
+    private static List<ClusterService> clusterServices = new ArrayList<>();
+
+    private static List<Loza> raftSrvs = new ArrayList<>();
+
+    private static Map<ClusterNode, CompletableFuture<RaftGroupService>> raftGroups = new HashMap<>();
+
+    @BeforeAll
+    public static void beforeAll(TestInfo testInfo) throws Exception {
+        List<NetworkAddress> localAddresses = findLocalAddresses(NODE_PORT_BASE,
+                NODE_PORT_BASE + NODES_CNT);
+
+        var nodeFinder = new StaticNodeFinder(localAddresses);
+
+        for (int i = 0; i < NODES_CNT; i++) {
+            ClusterService clusterService = ClusterServiceTestUtils.clusterService(
+                    testInfo,
+                    NODE_PORT_BASE + i,
+                    nodeFinder,
+                    NETWORK_FACTORY
+            );
+
+            clusterServices.add(clusterService);
+
+            clusterService.start();
+        }
+
+        assertTrue(waitForTopology(clusterServices.get(NODES_CNT - 1), NODES_CNT, 1000));
+
+        List<ClusterNode> nodes = clusterServices.stream().map(cs -> cs.topologyService().localMember()).collect(Collectors.toList());
+
+        for (int i = 0; i < NODES_CNT; i++) {
+            Loza raftServer = new Loza(clusterServices.get(i), workDir);
+
+            raftSrvs.add(raftServer);
+
+            raftServer.start();
+
+            CompletableFuture<RaftGroupService> raftGroupServiceFuture = raftSrvs.get(i).prepareRaftGroup(
+                    RAFT_GROUP_NAME,
+                    nodes,
+                    () -> mock(RaftGroupListener.class)
+            );
+
+            raftGroups.put(clusterServices.get(i).topologyService().localMember(), raftGroupServiceFuture);
+        }
+
+        raftGroups.get(clusterServices.get(0).topologyService().localMember()).get();
+        raftGroups.get(clusterServices.get(1).topologyService().localMember()).get();
+    }
+
+    @AfterAll
+    public static void afterAll() throws Exception {
+        for (Loza raftSrv : raftSrvs) {

Review comment:
       Fixed.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] kgusakov commented on a change in pull request #717: IGNITE-16678 RaftGroupService#transferLeadership fixed.

Posted by GitBox <gi...@apache.org>.
kgusakov commented on a change in pull request #717:
URL: https://github.com/apache/ignite-3/pull/717#discussion_r825898795



##########
File path: modules/raft/src/integrationTest/java/org/apache/ignite/internal/raft/ItRaftGroupServiceTest.java
##########
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.raft;
+
+import static org.apache.ignite.raft.jraft.test.TestUtils.waitForCondition;
+import static org.apache.ignite.raft.jraft.test.TestUtils.waitForTopology;
+import static org.apache.ignite.utils.ClusterServiceTestUtils.findLocalAddresses;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.testframework.WorkDirectory;
+import org.apache.ignite.internal.testframework.WorkDirectoryExtension;
+import org.apache.ignite.network.ClusterNode;
+import org.apache.ignite.network.ClusterService;
+import org.apache.ignite.network.NetworkAddress;
+import org.apache.ignite.network.StaticNodeFinder;
+import org.apache.ignite.network.scalecube.TestScaleCubeClusterServiceFactory;
+import org.apache.ignite.raft.client.Peer;
+import org.apache.ignite.raft.client.service.RaftGroupListener;
+import org.apache.ignite.raft.client.service.RaftGroupService;
+import org.apache.ignite.utils.ClusterServiceTestUtils;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+/**
+ * Integration test methods of raft group service.
+ */
+@ExtendWith(WorkDirectoryExtension.class)
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+public class ItRaftGroupServiceTest {
+    @WorkDirectory
+    private static Path workDir;
+
+    private static final int NODES_CNT = 2;
+
+    private static final int NODE_PORT_BASE = 20_000;
+
+    private static final TestScaleCubeClusterServiceFactory NETWORK_FACTORY = new TestScaleCubeClusterServiceFactory();
+
+    private static final String RAFT_GROUP_NAME = "part1";
+
+    private static List<ClusterService> clusterServices = new ArrayList<>();
+
+    private static List<Loza> raftSrvs = new ArrayList<>();
+
+    private static Map<ClusterNode, CompletableFuture<RaftGroupService>> raftGroups = new HashMap<>();
+
+    @BeforeAll
+    public static void beforeAll(TestInfo testInfo) throws Exception {
+        List<NetworkAddress> localAddresses = findLocalAddresses(NODE_PORT_BASE,
+                NODE_PORT_BASE + NODES_CNT);
+
+        var nodeFinder = new StaticNodeFinder(localAddresses);
+
+        for (int i = 0; i < NODES_CNT; i++) {
+            ClusterService clusterService = ClusterServiceTestUtils.clusterService(
+                    testInfo,
+                    NODE_PORT_BASE + i,
+                    nodeFinder,
+                    NETWORK_FACTORY
+            );
+
+            clusterServices.add(clusterService);
+
+            clusterService.start();
+        }
+
+        assertTrue(waitForTopology(clusterServices.get(NODES_CNT - 1), NODES_CNT, 1000));
+
+        List<ClusterNode> nodes = clusterServices.stream().map(cs -> cs.topologyService().localMember()).collect(Collectors.toList());
+
+        for (int i = 0; i < NODES_CNT; i++) {
+            Loza raftServer = new Loza(clusterServices.get(i), workDir);
+
+            raftSrvs.add(raftServer);
+
+            raftServer.start();
+
+            CompletableFuture<RaftGroupService> raftGroupServiceFuture = raftSrvs.get(i).prepareRaftGroup(
+                    RAFT_GROUP_NAME,
+                    nodes,
+                    () -> mock(RaftGroupListener.class)
+            );
+
+            raftGroups.put(clusterServices.get(i).topologyService().localMember(), raftGroupServiceFuture);
+        }
+
+        raftGroups.get(clusterServices.get(0).topologyService().localMember()).get();
+        raftGroups.get(clusterServices.get(1).topologyService().localMember()).get();
+    }
+
+    @AfterAll
+    public static void afterAll() throws Exception {
+        for (Loza raftSrv : raftSrvs) {

Review comment:
       We should shutdown clients from `raftGroups`, shouldn't we? I see, that `org.apache.ignite.raft.jraft.rpc.impl.RaftGroupServiceImpl#shutdown` is empty now, but it can be defined better in future.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] sanpwc merged pull request #717: IGNITE-16678 RaftGroupService#transferLeadership fixed.

Posted by GitBox <gi...@apache.org>.
sanpwc merged pull request #717:
URL: https://github.com/apache/ignite-3/pull/717


   


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org