This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new 4b8c7199e7 ARTEMIS-4384 Moving Cluster verify under verify group
4b8c7199e7 is described below

commit 4b8c7199e75d0213793a0fb7573d12876f96314f
Author: Clebert Suconic <[email protected]>
AuthorDate: Fri Sep 8 12:58:20 2023 -0400

    ARTEMIS-4384 Moving Cluster verify under verify group
    
    With this you would access the same functionality as ./artemis check cluster
---
 .../org/apache/activemq/artemis/cli/Artemis.java   |  3 --
 .../artemis/cli/commands/check/CheckGroup.java     |  2 +-
 .../Verify.java => check/ClusterCheck.java}        | 10 +++---
 .../ClusterNodeVerifier.java}                      | 10 +++---
 .../cli/commands/tools/cluster/ClusterGroup.java   | 38 ----------------------
 .../activemq/cli/test/ClusterVerifyTest.java       |  8 ++---
 .../smoke/topologycheck/TopologyCheckTest.java     |  4 +--
 7 files changed, 17 insertions(+), 58 deletions(-)

diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
index f4cc10637b..4986a28fbf 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
@@ -51,7 +51,6 @@ import 
org.apache.activemq.artemis.cli.commands.messages.Transfer;
 import org.apache.activemq.artemis.cli.commands.messages.perf.PerfGroup;
 import org.apache.activemq.artemis.cli.commands.queue.QueueGroup;
 import org.apache.activemq.artemis.cli.commands.tools.DataGroup;
-import org.apache.activemq.artemis.cli.commands.tools.cluster.ClusterGroup;
 import org.apache.activemq.artemis.cli.commands.tools.journal.PerfJournal;
 import org.apache.activemq.artemis.cli.commands.user.UserGroup;
 import org.apache.activemq.artemis.dto.ManagementContextDTO;
@@ -301,8 +300,6 @@ public class Artemis implements Runnable {
          commandLine.addSubcommand(new Upgrade());
       }
 
-      commandLine.addSubcommand(new ClusterGroup(commandLine));
-
       return commandLine;
    }
 
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/check/CheckGroup.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/check/CheckGroup.java
index c5d1dddadf..0fad6c30b7 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/check/CheckGroup.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/check/CheckGroup.java
@@ -21,7 +21,7 @@ import org.apache.activemq.artemis.cli.commands.HelpAction;
 import picocli.CommandLine;
 import picocli.CommandLine.Command;
 
-@Command(name = "check", description = "use 'help check' for sub commands 
list", subcommands = {NodeCheck.class, QueueCheck.class})
+@Command(name = "check", description = "use 'help check' for sub commands 
list", subcommands = {NodeCheck.class, QueueCheck.class, ClusterCheck.class})
 public class CheckGroup implements Runnable {
 
    CommandLine commandLine;
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/cluster/Verify.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/check/ClusterCheck.java
similarity index 78%
rename from 
artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/cluster/Verify.java
rename to 
artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/check/ClusterCheck.java
index 584b7e556b..498ac4adb5 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/cluster/Verify.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/check/ClusterCheck.java
@@ -15,14 +15,14 @@
  * limitations under the License.
  */
 
-package org.apache.activemq.artemis.cli.commands.tools.cluster;
+package org.apache.activemq.artemis.cli.commands.check;
 
 import org.apache.activemq.artemis.cli.commands.ActionContext;
 import org.apache.activemq.artemis.cli.commands.messages.ConnectionAbstract;
 import picocli.CommandLine;
 
[email protected](name = "verify", description = "Verify if all the nodes 
match the same topology.")
-public class Verify extends ConnectionAbstract {
[email protected](name = "cluster", description = "Verify if all the nodes 
on the cluster match the same topology and time configuration.")
+public class ClusterCheck extends ConnectionAbstract {
 
    @CommandLine.Option(names = "--variance", description = "Allowed variance 
in milliseconds before considered a failure. (default=1000)")
    public long variance = 1000;
@@ -33,8 +33,8 @@ public class Verify extends ConnectionAbstract {
 
       createConnectionFactory();
 
-      try (ClusterVerifier clusterVerifier = new ClusterVerifier(brokerURL, 
user, password, variance).open()) {
+      try (ClusterNodeVerifier clusterVerifier = new 
ClusterNodeVerifier(brokerURL, user, password, variance).open()) {
          return clusterVerifier.verify(context);
       }
    }
-}
+}
\ No newline at end of file
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/cluster/ClusterVerifier.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/check/ClusterNodeVerifier.java
similarity index 97%
rename from 
artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/cluster/ClusterVerifier.java
rename to 
artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/check/ClusterNodeVerifier.java
index 2fe7f4c773..6314e39578 100644
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/cluster/ClusterVerifier.java
+++ 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/check/ClusterNodeVerifier.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.activemq.artemis.cli.commands.tools.cluster;
+package org.apache.activemq.artemis.cli.commands.check;
 
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -31,7 +31,7 @@ import org.apache.activemq.artemis.json.JsonArray;
 import org.apache.activemq.artemis.json.JsonObject;
 import org.apache.activemq.artemis.json.JsonString;
 
-public class ClusterVerifier implements AutoCloseable {
+public class ClusterNodeVerifier implements AutoCloseable {
 
    final String uri, user, password;
 
@@ -39,11 +39,11 @@ public class ClusterVerifier implements AutoCloseable {
 
    final long allowedVariance;
 
-   public ClusterVerifier(String uri, String user, String password) {
+   public ClusterNodeVerifier(String uri, String user, String password) {
       this(uri, user, password, 1000);
    }
 
-   public ClusterVerifier(String uri, String user, String password, long 
variance) {
+   public ClusterNodeVerifier(String uri, String user, String password, long 
variance) {
       this.uri = uri;
       this.user = user;
       this.password = password;
@@ -56,7 +56,7 @@ public class ClusterVerifier implements AutoCloseable {
       simpleManagement.close();
    }
 
-   public ClusterVerifier open() throws Exception {
+   public ClusterNodeVerifier open() throws Exception {
       simpleManagement.open();
       return this;
    }
diff --git 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/cluster/ClusterGroup.java
 
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/cluster/ClusterGroup.java
deleted file mode 100644
index ac37bbac7f..0000000000
--- 
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/cluster/ClusterGroup.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.activemq.artemis.cli.commands.tools.cluster;
-
-import org.apache.activemq.artemis.cli.commands.HelpAction;
-import picocli.CommandLine;
-import picocli.CommandLine.Command;
-
-@Command(name = "cluster", description = "use 'help cluster' for sub commands 
list", subcommands = {Verify.class})
-public class ClusterGroup implements Runnable {
-
-   CommandLine commandLine;
-
-   public ClusterGroup(CommandLine commandLine) {
-      this.commandLine = commandLine;
-   }
-
-   @Override
-   public void run() {
-      HelpAction.help(commandLine, "cluster");
-   }
-
-}
diff --git 
a/artemis-cli/src/test/java/org/apache/activemq/cli/test/ClusterVerifyTest.java 
b/artemis-cli/src/test/java/org/apache/activemq/cli/test/ClusterVerifyTest.java
index e4463a19a1..7308508efb 100644
--- 
a/artemis-cli/src/test/java/org/apache/activemq/cli/test/ClusterVerifyTest.java
+++ 
b/artemis-cli/src/test/java/org/apache/activemq/cli/test/ClusterVerifyTest.java
@@ -22,7 +22,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.activemq.artemis.api.core.JsonUtil;
 import org.apache.activemq.artemis.cli.commands.ActionContext;
-import org.apache.activemq.artemis.cli.commands.tools.cluster.ClusterVerifier;
+import org.apache.activemq.artemis.cli.commands.check.ClusterNodeVerifier;
 import org.apache.activemq.artemis.json.JsonArray;
 import org.apache.commons.lang3.NotImplementedException;
 import org.junit.Assert;
@@ -47,10 +47,10 @@ public class ClusterVerifyTest {
       // A:1 topology:[{"nodeID":"A1","live":"A:1", "backup":"B:1"}, 
{"nodeID":"A2","live":"A:2", "backup":"B:2"}, {"nodeID":"A3","live":"A:3", 
"backup":"B:3"}]
       // A:2 topology:[{"nodeID":"A1","live":"A:1"}, 
{"nodeID":"A2","live":"A:2"}, {"nodeID":"A3","live":"A:3"}]
       // A:3 topology:[{"nodeID":"A1","live":"A:1", "backup":"B:1"}, 
{"nodeID":"A2","live":"A:2", "backup":"B:2"}] [
-      ClusterVerifier fakeVerifier = new ClusterVerifier("fake", "a", "b") {
+      ClusterNodeVerifier fakeVerifier = new ClusterNodeVerifier("fake", "a", 
"b") {
          @Override
          protected void verifyTime(ActionContext context,
-                                   Map<String, ClusterVerifier.TopologyItem> 
mainTopology,
+                                   Map<String, 
ClusterNodeVerifier.TopologyItem> mainTopology,
                                    AtomicBoolean verificationResult,
                                    boolean supportTime) {
             // not doing it
@@ -112,7 +112,7 @@ public class ClusterVerifyTest {
    // The server is not clustered, and listTopology will return []
    @Test
    public void testReadEmpty() throws Exception {
-      ClusterVerifier fakeVerifier = new ClusterVerifier("fake", "a", "b") {
+      ClusterNodeVerifier fakeVerifier = new ClusterNodeVerifier("fake", "a", 
"b") {
          @Override
          protected void verifyTime(ActionContext context,
                                    Map<String, TopologyItem> mainTopology,
diff --git 
a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/topologycheck/TopologyCheckTest.java
 
b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/topologycheck/TopologyCheckTest.java
index 9b29fd2170..97ac9095a3 100644
--- 
a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/topologycheck/TopologyCheckTest.java
+++ 
b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/topologycheck/TopologyCheckTest.java
@@ -21,7 +21,7 @@ import java.lang.invoke.MethodHandles;
 
 import org.apache.activemq.artemis.api.core.management.SimpleManagement;
 import org.apache.activemq.artemis.cli.commands.ActionContext;
-import org.apache.activemq.artemis.cli.commands.tools.cluster.ClusterVerifier;
+import org.apache.activemq.artemis.cli.commands.check.ClusterNodeVerifier;
 import org.apache.activemq.artemis.json.JsonArray;
 import org.apache.activemq.artemis.json.JsonObject;
 import org.apache.activemq.artemis.json.JsonString;
@@ -134,7 +134,7 @@ public class TopologyCheckTest extends SmokeTestBase {
          }
       }
 
-      ClusterVerifier clusterVerifier = new 
ClusterVerifier(uris[validNodes[0]], "admin", "admin");
+      ClusterNodeVerifier clusterVerifier = new 
ClusterNodeVerifier(uris[validNodes[0]], "admin", "admin");
       Assert.assertTrue(clusterVerifier.verify(new ActionContext()));
    }
 

Reply via email to