SammyVimes commented on code in PR #1016:
URL: https://github.com/apache/ignite-3/pull/1016#discussion_r957339495


##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteInMemoryNodeRestartTest.java:
##########
@@ -0,0 +1,354 @@
+/*
+ * 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.runner.app;
+
+import static 
org.apache.ignite.internal.schema.configuration.SchemaConfigurationConverter.convert;
+import static 
org.apache.ignite.internal.testframework.IgniteTestUtils.testNodeName;
+import static 
org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.function.IntFunction;
+import java.util.stream.IntStream;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgnitionManager;
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.raft.Loza;
+import 
org.apache.ignite.internal.storage.pagememory.configuration.schema.VolatilePageMemoryDataStorageChange;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.testframework.IgniteAbstractTest;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.lang.IgniteStringFormatter;
+import org.apache.ignite.network.NetworkAddress;
+import org.apache.ignite.raft.client.Peer;
+import org.apache.ignite.raft.client.service.RaftGroupService;
+import org.apache.ignite.schema.SchemaBuilders;
+import org.apache.ignite.schema.definition.ColumnType;
+import org.apache.ignite.schema.definition.TableDefinition;
+import org.apache.ignite.table.Table;
+import org.apache.ignite.table.Tuple;
+import org.jetbrains.annotations.Nullable;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
+
+/**
+ * These tests check in-memory node restart scenarios.
+ */
+public class ItIgniteInMemoryNodeRestartTest extends IgniteAbstractTest {
+    /** Default node port. */
+    private static final int DEFAULT_NODE_PORT = 3344;
+
+    /** Value producer for table data, is used to create data and check it 
later. */
+    private static final IntFunction<String> VALUE_PRODUCER = i -> "val " + i;
+
+    /** Prefix for full table name. */
+    private static final String SCHEMA_PREFIX = "PUBLIC.";
+
+    /** Test table name. */
+    private static final String TABLE_NAME = "Table1";
+
+    /** Nodes bootstrap configuration pattern. */
+    private static final String NODE_BOOTSTRAP_CFG = "{\n"
+            + "  network.port: {},\n"
+            + "  network.nodeFinder.netClusterNodes: {}\n"
+            + "}";
+
+    /** Cluster nodes. */
+    private static final List<Ignite> CLUSTER_NODES = new ArrayList<>();
+
+    private static final List<String> CLUSTER_NODES_NAMES = new ArrayList<>();
+
+    /**
+     * Stops all started nodes.
+     */
+    @AfterEach
+    public void afterEach() throws Exception {
+        var closeables = new ArrayList<AutoCloseable>();
+
+        for (String name : CLUSTER_NODES_NAMES) {
+            if (name != null) {
+                closeables.add(() -> IgnitionManager.stop(name));
+            }
+        }
+
+        CLUSTER_NODES.clear();
+        CLUSTER_NODES_NAMES.clear();
+
+        IgniteUtils.closeAll(closeables);
+    }
+
+    /**
+     * Start node with the given parameters.
+     *
+     * @param idx Node index, is used to stop the node later, see {@link 
#stopNode(int)}.
+     * @param nodeName Node name.
+     * @param cfgString Configuration string.
+     * @param workDir Working directory.
+     * @return Created node instance.
+     */
+    private static IgniteImpl startNode(int idx, String nodeName, @Nullable 
String cfgString, Path workDir) {
+        assertTrue(CLUSTER_NODES.size() == idx || CLUSTER_NODES.get(idx) == 
null);
+
+        CLUSTER_NODES_NAMES.add(idx, nodeName);
+
+        CompletableFuture<Ignite> future = IgnitionManager.start(nodeName, 
cfgString, workDir.resolve(nodeName));
+
+        if (CLUSTER_NODES.isEmpty()) {
+            IgnitionManager.init(nodeName, List.of(nodeName), "cluster");
+        }
+
+        assertThat(future, willCompleteSuccessfully());
+
+        Ignite ignite = future.join();
+
+        CLUSTER_NODES.add(idx, ignite);
+
+        return (IgniteImpl) ignite;
+    }
+
+    /**
+     * Start node with the given parameters.
+     *
+     * @param testInfo Test info.
+     * @param idx Node index, is used to stop the node later, see {@link 
#stopNode(int)}.
+     * @return Created node instance.
+     */
+    private IgniteImpl startNode(TestInfo testInfo, int idx) {
+        int port = DEFAULT_NODE_PORT + idx;
+        String nodeName = testNodeName(testInfo, port);
+        String cfgString = configurationString(idx, null, null);
+
+        return startNode(idx, nodeName, cfgString, workDir.resolve(nodeName));
+    }
+
+    /**
+     * Build a configuration string.
+     *
+     * @param idx Node index.
+     * @param cfg Optional configuration string.
+     * @param predefinedPort Predefined port.
+     * @return Configuration string.
+     */
+    private static String configurationString(int idx, @Nullable String cfg, 
@Nullable Integer predefinedPort) {
+        int port = predefinedPort == null ? DEFAULT_NODE_PORT + idx : 
predefinedPort;
+        int connectPort = predefinedPort == null ? DEFAULT_NODE_PORT : 
predefinedPort;
+        String connectAddr = "[\"localhost:" + connectPort + "\"]";
+
+        return cfg == null ? IgniteStringFormatter.format(NODE_BOOTSTRAP_CFG, 
port, connectAddr) : cfg;
+    }
+
+    /**
+     * Stop the node with given index.
+     *
+     * @param idx Node index.
+     */
+    private static void stopNode(int idx) {

Review Comment:
   No reason, it's actually a copy-paste from a different test



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