Phillippko commented on code in PR #3792:
URL: https://github.com/apache/ignite-3/pull/3792#discussion_r1611144571


##########
modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/recovery/restart/ItRestartPartitionsTest.java:
##########
@@ -0,0 +1,172 @@
+/*
+ * 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.cli.commands.recovery.restart;
+
+import static java.util.stream.Collectors.joining;
+import static 
org.apache.ignite.internal.TestDefaultProfilesNames.DEFAULT_AIPERSIST_PROFILE_NAME;
+import static 
org.apache.ignite.internal.cli.commands.Options.Constants.CLUSTER_URL_OPTION;
+import static 
org.apache.ignite.internal.cli.commands.Options.Constants.RECOVERY_NODE_NAMES_OPTION;
+import static 
org.apache.ignite.internal.cli.commands.Options.Constants.RECOVERY_PARTITION_IDS_OPTION;
+import static 
org.apache.ignite.internal.cli.commands.Options.Constants.RECOVERY_PURGE_OPTION;
+import static 
org.apache.ignite.internal.cli.commands.Options.Constants.RECOVERY_TABLE_NAME_OPTION;
+import static 
org.apache.ignite.internal.cli.commands.Options.Constants.RECOVERY_ZONE_NAME_OPTION;
+
+import org.apache.ignite.internal.app.IgniteImpl;
+import org.apache.ignite.internal.cli.CliIntegrationTest;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+/** Base test class for Recovery restart partitions commands. */
+public abstract class ItRestartPartitionsTest extends CliIntegrationTest {
+    private static final String ZONE = "first_ZONE";
+
+    private static final String TABLE_NAME = "first_ZONE_table";
+
+    private static final String QUALIFIED_TABLE_NAME = "PUBLIC." + TABLE_NAME;
+
+    private static final int DEFAULT_PARTITION_COUNT = 25;
+
+    @BeforeAll
+    public void createTables() {
+        sql(String.format("CREATE ZONE \"%s\" WITH storage_profiles='%s'", 
ZONE, DEFAULT_AIPERSIST_PROFILE_NAME));
+        sql(String.format("CREATE TABLE PUBLIC.\"%s\" (id INT PRIMARY KEY, val 
INT) WITH PRIMARY_ZONE = '%s'", TABLE_NAME, ZONE));
+    }
+
+    @Test
+    public void testRestartAllPartitions() {
+        execute(CLUSTER_URL_OPTION, NODE_URL,
+                RECOVERY_TABLE_NAME_OPTION, QUALIFIED_TABLE_NAME,
+                RECOVERY_ZONE_NAME_OPTION, ZONE
+        );
+
+        assertErrOutputIsEmpty();
+        assertOutputContains("Restarting partitions without cleanup.");
+    }
+
+    @Test
+    public void testRestartAllPartitionsPurge() {
+        execute(CLUSTER_URL_OPTION, NODE_URL,
+                RECOVERY_TABLE_NAME_OPTION, QUALIFIED_TABLE_NAME,
+                RECOVERY_ZONE_NAME_OPTION, ZONE,
+                RECOVERY_PURGE_OPTION
+        );
+
+        assertErrOutputIsEmpty();
+        assertOutputContains("Restarting partitions with cleanup.");
+    }
+
+    @Test
+    public void testRestartSpecifiedPartitions() {
+        execute(CLUSTER_URL_OPTION, NODE_URL,
+                RECOVERY_TABLE_NAME_OPTION, QUALIFIED_TABLE_NAME,
+                RECOVERY_ZONE_NAME_OPTION, ZONE,
+                RECOVERY_PARTITION_IDS_OPTION, "1,2"
+        );
+
+        assertErrOutputIsEmpty();
+        assertOutputContains("Restarting partitions without cleanup.");
+    }
+
+    @Test
+    public void testRestartPartitionsByNodes() {
+        String nodeNames = CLUSTER.runningNodes()
+                .limit(initialNodes() - 1)
+                .map(IgniteImpl::name)
+                .collect(joining(","));
+
+        execute(CLUSTER_URL_OPTION, NODE_URL,
+                RECOVERY_TABLE_NAME_OPTION, QUALIFIED_TABLE_NAME,
+                RECOVERY_ZONE_NAME_OPTION, ZONE,
+                RECOVERY_PARTITION_IDS_OPTION, "1,2",
+                RECOVERY_NODE_NAMES_OPTION, nodeNames

Review Comment:
   In slack thread Ivan Bessonov said that for CLI / REST test we should just 
check that CLI / REST works and we get "success". Restart logic should be 
tested in DisasterRecoveryManager and it's expensive to duplicate this checks 
in every REST / CLI test - sometimes it's not trivial. 
   
   IMHO we need unit tests, to check that CLI calls REST with correct 
parameters... Will add them



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