sanpwc commented on a change in pull request #642:
URL: https://github.com/apache/ignite-3/pull/642#discussion_r838317631



##########
File path: 
modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItIgniteNodeRestartTest.java
##########
@@ -140,31 +582,357 @@ public void twoCustomPropertiesTest(TestInfo testInfo) {
                 new String[]{"localhost:3344", "localhost:3343"},
                 
ignite.nodeConfiguration().getConfiguration(NetworkConfiguration.KEY).nodeFinder().netClusterNodes().value()
         );
-
-        IgnitionManager.stop(ignite.name());
     }
 
     /**
      * Restarts the node which stores some data.
      */
     @Test
-    @Disabled("https://issues.apache.org/jira/browse/IGNITE-16433";)
     public void nodeWithDataTest(TestInfo testInfo) {
-        String nodeName = testNodeName(testInfo, 3344);
-
-        Ignite ignite = IgnitionManager.start(nodeName, "{\n"
-                + "  \"node\": {\n"
-                + "    \"metastorageNodes\":[ " + nodeName + " ]\n"
-                + "  },\n"
-                + "  \"network\": {\n"
-                + "    \"port\":3344,\n"
-                + "    \"nodeFinder\": {\n"
-                + "      \"netClusterNodes\":[ \"localhost:3344\" ] \n"
-                + "    }\n"
-                + "  }\n"
-                + "}", workDir);
-
-        TableDefinition scmTbl1 = SchemaBuilders.tableBuilder("PUBLIC", 
TABLE_NAME).columns(
+        Ignite ignite = startNode(testInfo, 0);
+
+        createTableWithData(ignite, TABLE_NAME, 1);
+
+        stopNode(0);
+
+        ignite = startNode(testInfo, 0);
+
+        checkTableWithData(ignite, TABLE_NAME);
+    }
+
+    /**
+     * Starts two nodes and checks that the data are storing through restarts.
+     * Nodes restart in the same order when they started at first.
+     *
+     * @param testInfo Test information object.
+     */
+    @Test
+    public void testTwoNodesRestartDirect(TestInfo testInfo) {
+        twoNodesRestart(testInfo, true);
+    }
+
+    /**
+     * Starts two nodes and checks that the data are storing through restarts.
+     * Nodes restart in reverse order when they started at first.
+     *
+     * @param testInfo Test information object.
+     */
+    @Test
+    @Disabled("IGNITE-16034 Unblock a node start that happenes before 
Metastorage is ready")
+    public void testTwoNodesRestartReverse(TestInfo testInfo) {
+        twoNodesRestart(testInfo, false);
+    }
+
+    /**
+     * Starts two nodes and checks that the data are storing through restarts.
+     *
+     * @param testInfo Test information object.
+     * @param directOrder When the parameter is true, nodes restart in direct 
order, otherwise they restart in reverse order.
+     */
+    private void twoNodesRestart(TestInfo testInfo, boolean directOrder) {
+        Ignite ignite = startNode(testInfo, 0);
+
+        startNode(testInfo, 1);
+
+        createTableWithData(ignite, TABLE_NAME, 2);
+        createTableWithData(ignite, TABLE_NAME_2, 2);
+
+        stopNode(0);
+        stopNode(1);
+
+        if (directOrder) {
+            startNode(testInfo, 0);
+            ignite = startNode(testInfo, 1);
+        } else {
+            ignite = startNode(testInfo, 1);
+            startNode(testInfo, 0);
+        }
+
+        checkTableWithData(ignite, TABLE_NAME);
+        checkTableWithData(ignite, TABLE_NAME_2);
+    }
+
+    /**
+     * Find component of a given type in list.
+     *
+     * @param components Components list.
+     * @param cls Class.
+     * @param <T> Type parameter.
+     * @return Ignite component.
+     */
+    private <T extends IgniteComponent> T findComponent(List<IgniteComponent> 
components, Class<T> cls) {
+        for (IgniteComponent component : components) {
+            if (cls.isAssignableFrom(component.getClass())) {
+                return (T) component;
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * Checks that one node in a cluster of 2 nodes is able to restart and 
recover a table that was created when this node was absent.
+     * Also checks that the table created before node stop, is not available 
when majority if lost.
+     *
+     * @param testInfo Test info.
+     */
+    @Test
+    public void testOneNodeRestartWithGap(TestInfo testInfo) {
+        Ignite ignite = startNode(testInfo, 0);
+
+        String cfgString = configurationString(testInfo, 1, null, null);
+
+        List<IgniteComponent> components = 
startPartialNode(testNodeName(testInfo, DEFAULT_NODE_PORT + 1), cfgString);
+
+        createTableWithData(ignite, TABLE_NAME, 2);
+
+        stopPartialNode(components);
+
+        Table table = ignite.tables().table(SCHEMA_PREFIX + TABLE_NAME);
+
+        assertNotNull(table);
+
+        assertThrowsWithCause(() -> table.keyValueView().get(null, 
Tuple.create().set("id", 0)), TimeoutException.class);
+
+        components = startPartialNode(testNodeName(testInfo, DEFAULT_NODE_PORT 
+ 1), cfgString);
+
+        TableManager tableManager = findComponent(components, 
TableManager.class);
+
+        assertNotNull(tableManager);
+
+        assertNotNull(tableManager.latestTables().get(SCHEMA_PREFIX + 
TABLE_NAME.toUpperCase()));
+    }
+
+    /**
+     * Checks that the table created in cluster of 2 nodes, is recovered on a 
node after restart of this node.
+     *
+     * @param testInfo Test info.
+     */
+    @Test
+    public void testRecoveryOnOneNode(TestInfo testInfo) {
+        Ignite ignite = startNode(testInfo, 0);
+
+        String cfgString = configurationString(testInfo, 1, null, null);
+
+        List<IgniteComponent> components = 
startPartialNode(testNodeName(testInfo, DEFAULT_NODE_PORT + 1), cfgString);
+
+        createTableWithData(ignite, TABLE_NAME, 2, 1);
+
+        stopPartialNode(components);
+
+        components = startPartialNode(testNodeName(testInfo, DEFAULT_NODE_PORT 
+ 1), cfgString);
+
+        TableManager tableManager = findComponent(components, 
TableManager.class);
+
+        assertNotNull(tableManager);
+
+        assertNotNull(tableManager.latestTables().get(SCHEMA_PREFIX + 
TABLE_NAME.toUpperCase()));
+    }
+
+    /**
+     * Checks that a cluster is able to restart when some changes were made in 
configuration.
+     *
+     * @param testInfo Test info.
+     */
+    @Test
+    public void testRestartDiffConfig(TestInfo testInfo) {
+        Ignite ignite0 = startNode(testInfo, 0);
+        Ignite ignite1 = startNode(testInfo, 1);
+
+        createTableWithData(ignite0, TABLE_NAME, 2);
+        createTableWithData(ignite0, TABLE_NAME_2, 2);
+
+        String igniteName = ignite1.name();
+
+        stopNode(0);
+        stopNode(1);
+
+        ignite0 = startNode(testInfo, 0);
+
+        String metastorageName = ignite0.name();
+
+        String cfgString = IgniteStringFormatter.format(NODE_BOOTSTRAP_CFG,
+                metastorageName,
+                DEFAULT_NODE_PORT + 11,
+                "\"localhost:" + (DEFAULT_NODE_PORT) + '\"'
+        );
+
+        List<IgniteComponent> components = startPartialNode(igniteName, 
cfgString);
+
+        TableManager tableManager = findComponent(components, 
TableManager.class);
+
+        assertNotNull(tableManager.latestTables().get(SCHEMA_PREFIX + 
TABLE_NAME.toUpperCase()));
+    }
+
+    /**
+     * The test for node restart when there is a gap between the node local 
configuration and distributed configuration.
+     *
+     * @param testInfo Test info.
+     */
+    @Test
+    public void testCfgGapWithoutData(TestInfo testInfo) {
+        System.setProperty("CONFIGURATION_CATCH_UP_DIFFERENCE", "0");
+
+        try {
+            final int nodes = 4;
+
+            for (int i = 0; i < nodes; i++) {
+                startNode(testInfo, i);
+            }
+
+            createTableWithData(CLUSTER_NODES.get(0), "t1", nodes);
+
+            String igniteName = CLUSTER_NODES.get(nodes - 1).name();
+
+            log.info("Stopping the node.");
+
+            stopNode(nodes - 1);
+
+            createTableWithData(CLUSTER_NODES.get(0), "t2", nodes);
+
+            log.info("Starting the node.");
+
+            List<IgniteComponent> components = startPartialNode(igniteName, 
configurationString(testInfo, nodes - 1, null, null));
+
+            TableManager tableManager = findComponent(components, 
TableManager.class);
+
+            assertNotNull(tableManager.latestTables().get(SCHEMA_PREFIX + 
"T1"));
+            assertNotNull(tableManager.latestTables().get(SCHEMA_PREFIX + 
"T2"));
+        } finally {
+            System.clearProperty("CONFIGURATION_CATCH_UP_DIFFERENCE");
+        }
+    }
+
+    /**
+     * The test for node restart when there is a gap between the node local 
configuration and distributed configuration.

Review comment:
       Inconsistent description.




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