rpuch commented on code in PR #1403:
URL: https://github.com/apache/ignite-3/pull/1403#discussion_r1039582808


##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/AbstractClusterIntegrationTest.java:
##########
@@ -79,57 +85,113 @@ public abstract class AbstractClusterIntegrationTest 
extends BaseIgniteAbstractT
      */
     @BeforeEach
     void startNodes(TestInfo testInfo) {
-        String connectNodeAddr = "\"localhost:" + BASE_PORT + '\"';
-
-        List<CompletableFuture<Ignite>> futures = IntStream.range(0, nodes())
-                .mapToObj(i -> {
-                    String nodeName = testNodeName(testInfo, i);
-
-                    String config = 
IgniteStringFormatter.format(NODE_BOOTSTRAP_CFG, BASE_PORT + i, 
connectNodeAddr);
-
-                    return IgnitionManager.start(nodeName, config, 
WORK_DIR.resolve(nodeName));
-                })
+        List<CompletableFuture<Ignite>> futures = IntStream.range(0, 
initialNodes())
+                .mapToObj(i -> startNode0(i, testInfo))
                 .collect(toList());
 
-        String metaStorageNodeName = testNodeName(testInfo, nodes() - 1);
+        String metaStorageNodeName = testNodeName(testInfo, initialNodes() - 
1);
 
         IgnitionManager.init(metaStorageNodeName, 
List.of(metaStorageNodeName), "cluster");
 
         for (CompletableFuture<Ignite> future : futures) {
-            assertThat(future, willCompleteSuccessfully());
+            assertThat(future, willSucceedIn(10, TimeUnit.SECONDS));
 
             clusterNodes.add(future.join());
         }
     }
 
+    private static CompletableFuture<Ignite> startNode0(int nodeIndex, 
TestInfo testInfo) {
+        String connectNodeAddr = "\"localhost:" + BASE_PORT + '\"';
+
+        String nodeName = testNodeName(testInfo, nodeIndex);
+
+        String config = IgniteStringFormatter.format(NODE_BOOTSTRAP_CFG, 
BASE_PORT + nodeIndex, connectNodeAddr);
+
+        return IgnitionManager.start(nodeName, config, 
WORK_DIR.resolve(nodeName));
+    }
+
     /**
-     * Get a count of nodes in the Ignite cluster.
+     * Starts an Ignite node with the given index.
      *
-     * @return Count of nodes.
+     * @param nodeIndex Zero-based index (used to build node name).
+     * @param testInfo Test info (used to build node name).
+     * @return Started Ignite node.
      */
-    protected int nodes() {
+    protected Ignite startNode(int nodeIndex, TestInfo testInfo) {
+        CompletableFuture<Ignite> future = startNode0(nodeIndex, testInfo);
+
+        assertThat(future, willSucceedIn(10, TimeUnit.SECONDS));
+
+        Ignite ignite = future.join();
+
+        if (nodeIndex < clusterNodes.size()) {
+            clusterNodes.set(nodeIndex, ignite);
+        } else if (nodeIndex == clusterNodes.size()) {
+            clusterNodes.add(ignite);
+        } else {
+            throw new IllegalArgumentException("Cannot start node with index " 
+ nodeIndex + " because we only have "
+                    + clusterNodes.size() + " nodes");
+        }
+
+        return ignite;
+    }
+
+    /**
+     * Returns count of nodes in the Ignite cluster started before each test.
+     *
+     * @return Count of nodes in initial cluster.
+     */
+    protected int initialNodes() {

Review Comment:
   Node count might change during the lifetime of a cluster if we add a node 
dynamically. This method returns the *initial* value of nodes count.



-- 
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]

Reply via email to