IGNITE-10316 Fixed wrong messages for control.sh utility when cluster is inactive...
authorvd_pyatkov <vldpyatkov@gmail.com>
Wed, 16 Jan 2019 13:02:47 +0000 (16:02 +0300)
committerAlexey Goncharuk <alexey.goncharuk@gmail.com>
Wed, 16 Jan 2019 13:02:47 +0000 (16:02 +0300)
Signed-off-by: Alexey Goncharuk <alexey.goncharuk@gmail.com>
modules/core/src/main/java/org/apache/ignite/internal/visor/baseline/VisorBaselineTask.java
modules/core/src/test/java/org/apache/ignite/util/GridCommandHandlerTest.java

index be5fcca..93c41ab 100644 (file)
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.visor.baseline;
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -173,6 +174,9 @@ public class VisorBaselineTask extends VisorOneNodeTask<VisorBaselineTaskArg, Vi
         private VisorBaselineTaskResult remove(List<String> consistentIds) {
             Map<String, BaselineNode> baseline = currentBaseLine();
 
+            if (F.isEmpty(baseline))
+                return set0(Collections.EMPTY_LIST);
+
             for (String consistentId : consistentIds) {
                 BaselineNode node = baseline.remove(consistentId);
 
index 3817994..081d759 100644 (file)
@@ -415,6 +415,39 @@ public class GridCommandHandlerTest extends GridCommonAbstractTest {
     }
 
     /**
+     * Test baseline remove node on not active cluster via control.sh
+     *
+     * @throws Exception If failed.
+     */
+    @Test
+    public void testBaselineRemoveOnNotActiveCluster() throws Exception {
+        Ignite ignite = startGrids(1);
+        Ignite other = startGrid("nodeToStop");
+
+        assertFalse(ignite.cluster().active());
+
+        String offlineNodeConsId = consistentIds(other);
+
+        assertEquals(EXIT_CODE_UNEXPECTED_ERROR, execute("--baseline", "remove", offlineNodeConsId));
+
+        ignite.cluster().active(true);
+
+        stopGrid("nodeToStop");
+
+        assertEquals(2, ignite.cluster().currentBaselineTopology().size());
+
+        ignite.cluster().active(false);
+
+        assertFalse(ignite.cluster().active());
+
+        injectTestSystemOut();
+
+        assertEquals(EXIT_CODE_UNEXPECTED_ERROR, execute("--baseline", "remove", offlineNodeConsId));
+
+        assertTrue(testOut.toString().contains("Changing BaselineTopology on inactive cluster is not allowed."));
+    }
+
+    /**
      * Test baseline set works via control.sh
      *
      * @throws Exception If failed.