alievmirza commented on code in PR #6243:
URL: https://github.com/apache/ignite-3/pull/6243#discussion_r2216210892


##########
modules/runner/src/testFixtures/java/org/apache/ignite/internal/BaseIgniteRestartTest.java:
##########
@@ -139,21 +146,93 @@ void setUp(TestInfo testInfo) {
     public void afterEachTest() throws Exception {
         var closeables = new ArrayList<AutoCloseable>();
 
-        for (IgniteServer node : IGNITE_SERVERS) {
-            if (node != null) {
-                closeables.add(node::shutdown);
+        List<String> serverNames = IGNITE_SERVERS.stream()
+                .filter(Objects::nonNull)
+                .map(IgniteServer::name)
+                .collect(toList());
+
+        List<String> partialNodeNames = this.partialNodes.stream()
+                .filter(Objects::nonNull)
+                .map(PartialNode::name)
+                .collect(toList());
+
+        log.info("Shutting the cluster down [serverNodes={}, 
partialNodes={}]", serverNames, partialNodeNames);
+
+        Set<String> cmgMsNodesNames = new HashSet<>();
+
+        Set<String> cmgMsPartialNodesNames = new HashSet<>();
+
+        if (!partialNodes.isEmpty()) {
+            PartialNode anyPartialNode = partialNodes.get(0);
+
+            ClusterManagementGroupManager component = findComponent(
+                    anyPartialNode.startedComponents(),
+                    ClusterManagementGroupManager.class
+            );
+
+            cmgMsPartialNodesNames = msCmgNodes(component);
+
+            for (PartialNode partialNode : partialNodes) {
+                if (!cmgMsPartialNodesNames.contains(partialNode.name())) {
+                    closeables.add(partialNode::stop);
+                }
             }
         }
 
+        if (!IGNITE_SERVERS.isEmpty()) {
+            IgniteServer anyNode = IGNITE_SERVERS.get(0);
+
+            IgniteImpl ignite = unwrapIgniteImpl(anyNode.api());
+
+            cmgMsNodesNames = 
msCmgNodes(ignite.clusterManagementGroupManager());
+
+            for (IgniteServer node : IGNITE_SERVERS) {
+                if (node != null) {
+                    if (!cmgMsNodesNames.contains(node.name())) {
+                        closeables.add(node::shutdown);
+                    }
+                }
+            }
+        }
+
+        // Add CMG/MS nodes at the end of the list to ensure that they are 
stopped last.
         if (!partialNodes.isEmpty()) {
             for (PartialNode partialNode : partialNodes) {
-                closeables.add(partialNode::stop);
+                if (cmgMsPartialNodesNames.contains(partialNode.name())) {
+                    closeables.add(partialNode::stop);
+                }
+            }
+        }
+
+        if (!IGNITE_SERVERS.isEmpty()) {
+            for (IgniteServer node : IGNITE_SERVERS) {
+                if (node != null) {
+                    if (cmgMsNodesNames.contains(node.name())) {
+                        closeables.add(node::shutdown);
+                    }
+                }
             }
         }
 
         closeAll(closeables);
 
         IGNITE_SERVERS.clear();
+        partialNodes.clear();
+    }
+
+    private static Set<String> msCmgNodes(ClusterManagementGroupManager 
ignite) throws Exception {

Review Comment:
   done
   



##########
modules/runner/src/testFixtures/java/org/apache/ignite/internal/BaseIgniteRestartTest.java:
##########
@@ -139,21 +146,93 @@ void setUp(TestInfo testInfo) {
     public void afterEachTest() throws Exception {
         var closeables = new ArrayList<AutoCloseable>();
 
-        for (IgniteServer node : IGNITE_SERVERS) {
-            if (node != null) {
-                closeables.add(node::shutdown);
+        List<String> serverNames = IGNITE_SERVERS.stream()
+                .filter(Objects::nonNull)
+                .map(IgniteServer::name)
+                .collect(toList());
+
+        List<String> partialNodeNames = this.partialNodes.stream()
+                .filter(Objects::nonNull)
+                .map(PartialNode::name)
+                .collect(toList());
+
+        log.info("Shutting the cluster down [serverNodes={}, 
partialNodes={}]", serverNames, partialNodeNames);
+
+        Set<String> cmgMsNodesNames = new HashSet<>();

Review Comment:
   done



-- 
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-unsubscr...@ignite.apache.org

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

Reply via email to