gemmellr commented on code in PR #4601:
URL: https://github.com/apache/activemq-artemis/pull/4601#discussion_r1312777201
##########
artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/check/QueueCheck.java:
##########
@@ -179,7 +179,7 @@ private void checkQueueConsume(final CheckContext context)
throws Exception {
connection.start();
if (consume == -1) {
- queueConsumer.receiveNoWait();
+ System.out.println("REceived " + queueConsumer.receiveNoWait());
Review Comment:
Typo.
##########
tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/checkTest/CheckTest.java:
##########
@@ -0,0 +1,350 @@
+/*
+ * 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.tests.smoke.checkTest;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import java.io.File;
+import java.lang.invoke.MethodHandles;
+
+import org.apache.activemq.artemis.api.core.QueueConfiguration;
+import org.apache.activemq.artemis.api.core.RoutingType;
+import org.apache.activemq.artemis.api.core.client.ClientSession;
+import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
+import org.apache.activemq.artemis.api.core.client.ServerLocator;
+import org.apache.activemq.artemis.api.core.management.SimpleManagement;
+import org.apache.activemq.artemis.cli.CLIException;
+import org.apache.activemq.artemis.cli.commands.ActionContext;
+import org.apache.activemq.artemis.cli.commands.check.NodeCheck;
+import org.apache.activemq.artemis.cli.commands.check.QueueCheck;
+import org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl;
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.tests.smoke.common.SmokeTestBase;
+import org.apache.activemq.artemis.tests.util.CFUtil;
+import org.apache.activemq.artemis.util.ServerUtil;
+import org.apache.activemq.artemis.utils.RandomUtil;
+import org.apache.activemq.artemis.utils.Wait;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CheckTest extends SmokeTestBase {
+
+ private static ActionContext ACTION_CONTEXT = new ActionContext(System.in,
System.out, System.out);
+
+ private static final Logger logger =
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ private static final String SERVER_NAME_1 = "check-test/live";
+ private static final String SERVER_NAME_2 = "check-test/backup";
+
+ Process liveProcess;
+ Process backupProcess;
+
+ @Before
+ public void before() throws Exception {
+ cleanupData(SERVER_NAME_1);
+ cleanupData(SERVER_NAME_2);
+
+ File location = new File(getServerLocation(SERVER_NAME_1));
+ deleteDirectory(new File(location, "../data"));
+
+ disableCheckThread();
+ }
+
+ @Test
+ public void testNodeCheckActions() throws Exception {
+ liveProcess = startServer(SERVER_NAME_1, 0, 0);
+ ServerUtil.waitForServerToStart("tcp://localhost:61616", 5_000);
+
+ NodeCheck nodeCheck = new NodeCheck();
+ nodeCheck.setUser("admin");
+ nodeCheck.setPassword("admin");
+ Assert.assertEquals(1, nodeCheck.execute(ACTION_CONTEXT));
+
+ nodeCheck = new NodeCheck();
+ nodeCheck.setUser("admin");
+ nodeCheck.setPassword("admin");
+ nodeCheck.setUp(true);
+ Assert.assertEquals(1, nodeCheck.execute(ACTION_CONTEXT));
+
+ nodeCheck = new NodeCheck();
+ nodeCheck.setUser("admin");
+ nodeCheck.setPassword("admin");
+ nodeCheck.setDiskUsage(-1);
+ Assert.assertEquals(1, nodeCheck.execute(ACTION_CONTEXT));
+
+ nodeCheck = new NodeCheck();
+ nodeCheck.setUser("admin");
+ nodeCheck.setPassword("admin");
+ nodeCheck.setDiskUsage(90);
+ Assert.assertEquals(1, nodeCheck.execute(ACTION_CONTEXT));
+
+ try {
+ nodeCheck = new NodeCheck();
+ nodeCheck.setUser("admin");
+ nodeCheck.setPassword("admin");
+ nodeCheck.setDiskUsage(0);
+ nodeCheck.execute(ACTION_CONTEXT);
+
+ Assert.fail("CLIException expected.");
+ } catch (Exception e) {
+ Assert.assertTrue("CLIException expected.", e instanceof
CLIException);
+ }
+
+ nodeCheck = new NodeCheck();
+ nodeCheck.setUser("admin");
+ nodeCheck.setPassword("admin");
+ nodeCheck.setMemoryUsage(90);
+ Assert.assertEquals(1, nodeCheck.execute(ACTION_CONTEXT));
+
+ try {
+ nodeCheck = new NodeCheck();
+ nodeCheck.setUser("admin");
+ nodeCheck.setPassword("admin");
+ nodeCheck.setMemoryUsage(-1);
+ nodeCheck.execute(ACTION_CONTEXT);
+
+ Assert.fail("CLIException expected.");
+ } catch (Exception e) {
+ Assert.assertTrue("CLIException expected.", e instanceof
CLIException);
+ }
+ }
+
+ @Test
+ public void testCheckTopology() throws Exception {
+ liveProcess = startServer(SERVER_NAME_1, 0, 0);
+ ServerUtil.waitForServerToStart("tcp://localhost:61616", 5_000);
+
+ NodeCheck nodeCheck = new NodeCheck();
+ nodeCheck.setUser("admin");
+ nodeCheck.setPassword("admin");
+ nodeCheck.setLive(true);
+ Assert.assertEquals(1, nodeCheck.execute(ACTION_CONTEXT));
+
+ try {
+ nodeCheck = new NodeCheck();
+ nodeCheck.setUser("admin");
+ nodeCheck.setPassword("admin");
+ nodeCheck.setBackup(true);
+ nodeCheck.execute(ACTION_CONTEXT);
+
+ Assert.fail("CLIException expected.");
+ } catch (Exception e) {
+ Assert.assertTrue("CLIException expected.", e instanceof
CLIException);
+ }
+
+ nodeCheck = new NodeCheck();
+ nodeCheck.setUser("admin");
+ nodeCheck.setPassword("admin");
+ nodeCheck.setLive(true);
+ Assert.assertEquals(1, nodeCheck.execute(ACTION_CONTEXT));
+
+ try {
+ nodeCheck = new NodeCheck();
+ nodeCheck.setUser("admin");
+ nodeCheck.setPassword("admin");
+ nodeCheck.setBackup(true);
+ nodeCheck.execute(ACTION_CONTEXT);
+
+ Assert.fail("CLIException expected.");
+ } catch (Exception e) {
+ Assert.assertTrue("CLIException expected.", e instanceof
CLIException);
+ }
+
+ backupProcess = startServer(SERVER_NAME_2, 0, 0);
+
+ SimpleManagement simpleManagement = new
SimpleManagement("tcp://localhost:61616", "admin", "admin");
+ Wait.assertTrue(() -> hasBackup(simpleManagement));
+ nodeCheck = new NodeCheck();
+ nodeCheck.setUser("admin");
+ nodeCheck.setPassword("admin");
+ nodeCheck.setLive(true);
+ nodeCheck.setBackup(true);
+ nodeCheck.setPeers(2);
+ Assert.assertEquals(3, nodeCheck.execute(ACTION_CONTEXT));
+ }
+
+ public boolean hasBackup(SimpleManagement simpleManagement) {
+ try {
+ JsonArray topology = simpleManagement.listNetworkTopology();
+ if (topology.size() != 1) {
+ return false;
+ }
+
+ return topology.getJsonObject(0).getString("backup", null) != null;
+ } catch (Throwable e) {
+ logger.warn(e.getMessage(), e);
+ }
+
+ return false;
+ }
+
+ @Test
+ public void testQueueCheckUp() throws Exception {
+ liveProcess = startServer(SERVER_NAME_1, 0, 0);
+ ServerUtil.waitForServerToStart("tcp://localhost:61616", 5_000);
+
+ SimpleManagement simpleManagement = new
SimpleManagement("tcp://localhost:61616", "admin", "admin");
+
+ String queueName = "Q_" + RandomUtil.randomString();
+
+ QueueCheck queueCheck;
+
+ try {
+ queueCheck = new QueueCheck();
+ queueCheck.setUser("admin");
+ queueCheck.setPassword("admin");
+ queueCheck.setName(queueName);
+ queueCheck.execute(ACTION_CONTEXT);
+
+ Assert.fail("CLIException expected.");
+ } catch (Exception e) {
+ Assert.assertTrue("CLIException expected.", e instanceof
CLIException);
+ }
+
+ ServerLocator locator =
ServerLocatorImpl.newLocator("tcp://localhost:61616");
+ try (ClientSessionFactory factory = locator.createSessionFactory();
ClientSession session = factory.createSession()) {
+ session.createQueue(new
QueueConfiguration(queueName).setRoutingType(RoutingType.ANYCAST));
+ }
+
+ try {
+ queueCheck = new QueueCheck();
+ queueCheck.setUser("admin");
+ queueCheck.setPassword("admin");
+ queueCheck.setName(queueName);
+ queueCheck.setConsume(1);
+ queueCheck.setTimeout(100);
+ queueCheck.execute(ACTION_CONTEXT);
+
+ Assert.fail("CLIException expected.");
+ } catch (Exception e) {
+ Assert.assertTrue("CLIException expected.", e instanceof
CLIException);
+ }
+
+
+ queueCheck = new QueueCheck();
+ queueCheck.setUser("admin");
+ queueCheck.setPassword("admin");
+ queueCheck.setName(queueName);
+ Assert.assertEquals(1, queueCheck.execute(ACTION_CONTEXT));
+
+ queueCheck = new QueueCheck();
+ queueCheck.setUser("admin");
+ queueCheck.setPassword("admin");
+ queueCheck.setUp(true);
+ queueCheck.setName(queueName);
+ Assert.assertEquals(1, queueCheck.execute(ACTION_CONTEXT));
+
+ ConnectionFactory cf = CFUtil.createConnectionFactory("core",
"tcp://localhost:61616");
+
+ final int messages = 3;
+
+ queueCheck = new QueueCheck();
+ queueCheck.setUser("admin");
+ queueCheck.setPassword("admin");
+ queueCheck.setName(queueName);
+ queueCheck.setBrowse(null);
+ Assert.assertEquals(1, queueCheck.execute(ACTION_CONTEXT));
+
+
+ queueCheck = new QueueCheck();
+ queueCheck.setUser("admin");
+ queueCheck.setPassword("admin");
+ queueCheck.setName(queueName);
+ queueCheck.setConsume(null);
+ Assert.assertEquals(1, queueCheck.execute(ACTION_CONTEXT));
+
+
+ try (Connection connection = cf.createConnection(); Session session =
connection.createSession(true, Session.SESSION_TRANSACTED)) {
+ MessageProducer producer =
session.createProducer(session.createQueue(queueName));
+ for (int i = 0; i < messages; i++) {
+ System.out.println("Sending " + i);
Review Comment:
Logger...debug?
##########
tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/checkTest/CheckTest.java:
##########
@@ -0,0 +1,350 @@
+/*
+ * 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.tests.smoke.checkTest;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import java.io.File;
+import java.lang.invoke.MethodHandles;
+
+import org.apache.activemq.artemis.api.core.QueueConfiguration;
+import org.apache.activemq.artemis.api.core.RoutingType;
+import org.apache.activemq.artemis.api.core.client.ClientSession;
+import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
+import org.apache.activemq.artemis.api.core.client.ServerLocator;
+import org.apache.activemq.artemis.api.core.management.SimpleManagement;
+import org.apache.activemq.artemis.cli.CLIException;
+import org.apache.activemq.artemis.cli.commands.ActionContext;
+import org.apache.activemq.artemis.cli.commands.check.NodeCheck;
+import org.apache.activemq.artemis.cli.commands.check.QueueCheck;
+import org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl;
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.tests.smoke.common.SmokeTestBase;
+import org.apache.activemq.artemis.tests.util.CFUtil;
+import org.apache.activemq.artemis.util.ServerUtil;
+import org.apache.activemq.artemis.utils.RandomUtil;
+import org.apache.activemq.artemis.utils.Wait;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CheckTest extends SmokeTestBase {
+
+ private static ActionContext ACTION_CONTEXT = new ActionContext(System.in,
System.out, System.out);
+
+ private static final Logger logger =
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ private static final String SERVER_NAME_1 = "check-test/live";
+ private static final String SERVER_NAME_2 = "check-test/backup";
+
+ Process liveProcess;
+ Process backupProcess;
+
+ @Before
+ public void before() throws Exception {
+ cleanupData(SERVER_NAME_1);
+ cleanupData(SERVER_NAME_2);
+
+ File location = new File(getServerLocation(SERVER_NAME_1));
+ deleteDirectory(new File(location, "../data"));
+
+ disableCheckThread();
+ }
+
+ @Test
Review Comment:
Might be good to add a timeout to the tests.
##########
tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/checkTest/CheckTest.java:
##########
@@ -0,0 +1,350 @@
+/*
+ * 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.tests.smoke.checkTest;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import java.io.File;
+import java.lang.invoke.MethodHandles;
+
+import org.apache.activemq.artemis.api.core.QueueConfiguration;
+import org.apache.activemq.artemis.api.core.RoutingType;
+import org.apache.activemq.artemis.api.core.client.ClientSession;
+import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
+import org.apache.activemq.artemis.api.core.client.ServerLocator;
+import org.apache.activemq.artemis.api.core.management.SimpleManagement;
+import org.apache.activemq.artemis.cli.CLIException;
+import org.apache.activemq.artemis.cli.commands.ActionContext;
+import org.apache.activemq.artemis.cli.commands.check.NodeCheck;
+import org.apache.activemq.artemis.cli.commands.check.QueueCheck;
+import org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl;
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.tests.smoke.common.SmokeTestBase;
+import org.apache.activemq.artemis.tests.util.CFUtil;
+import org.apache.activemq.artemis.util.ServerUtil;
+import org.apache.activemq.artemis.utils.RandomUtil;
+import org.apache.activemq.artemis.utils.Wait;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CheckTest extends SmokeTestBase {
+
+ private static ActionContext ACTION_CONTEXT = new ActionContext(System.in,
System.out, System.out);
+
+ private static final Logger logger =
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ private static final String SERVER_NAME_1 = "check-test/live";
+ private static final String SERVER_NAME_2 = "check-test/backup";
+
+ Process liveProcess;
+ Process backupProcess;
+
+ @Before
+ public void before() throws Exception {
+ cleanupData(SERVER_NAME_1);
+ cleanupData(SERVER_NAME_2);
+
+ File location = new File(getServerLocation(SERVER_NAME_1));
+ deleteDirectory(new File(location, "../data"));
+
+ disableCheckThread();
+ }
+
+ @Test
+ public void testNodeCheckActions() throws Exception {
+ liveProcess = startServer(SERVER_NAME_1, 0, 0);
+ ServerUtil.waitForServerToStart("tcp://localhost:61616", 5_000);
+
+ NodeCheck nodeCheck = new NodeCheck();
+ nodeCheck.setUser("admin");
+ nodeCheck.setPassword("admin");
+ Assert.assertEquals(1, nodeCheck.execute(ACTION_CONTEXT));
+
+ nodeCheck = new NodeCheck();
+ nodeCheck.setUser("admin");
+ nodeCheck.setPassword("admin");
+ nodeCheck.setUp(true);
+ Assert.assertEquals(1, nodeCheck.execute(ACTION_CONTEXT));
+
+ nodeCheck = new NodeCheck();
+ nodeCheck.setUser("admin");
+ nodeCheck.setPassword("admin");
+ nodeCheck.setDiskUsage(-1);
+ Assert.assertEquals(1, nodeCheck.execute(ACTION_CONTEXT));
+
+ nodeCheck = new NodeCheck();
+ nodeCheck.setUser("admin");
+ nodeCheck.setPassword("admin");
+ nodeCheck.setDiskUsage(90);
+ Assert.assertEquals(1, nodeCheck.execute(ACTION_CONTEXT));
+
+ try {
+ nodeCheck = new NodeCheck();
+ nodeCheck.setUser("admin");
+ nodeCheck.setPassword("admin");
+ nodeCheck.setDiskUsage(0);
+ nodeCheck.execute(ACTION_CONTEXT);
+
+ Assert.fail("CLIException expected.");
+ } catch (Exception e) {
+ Assert.assertTrue("CLIException expected.", e instanceof
CLIException);
+ }
+
+ nodeCheck = new NodeCheck();
+ nodeCheck.setUser("admin");
+ nodeCheck.setPassword("admin");
+ nodeCheck.setMemoryUsage(90);
+ Assert.assertEquals(1, nodeCheck.execute(ACTION_CONTEXT));
+
+ try {
+ nodeCheck = new NodeCheck();
+ nodeCheck.setUser("admin");
+ nodeCheck.setPassword("admin");
+ nodeCheck.setMemoryUsage(-1);
+ nodeCheck.execute(ACTION_CONTEXT);
+
+ Assert.fail("CLIException expected.");
+ } catch (Exception e) {
+ Assert.assertTrue("CLIException expected.", e instanceof
CLIException);
+ }
+ }
+
+ @Test
+ public void testCheckTopology() throws Exception {
+ liveProcess = startServer(SERVER_NAME_1, 0, 0);
+ ServerUtil.waitForServerToStart("tcp://localhost:61616", 5_000);
+
+ NodeCheck nodeCheck = new NodeCheck();
+ nodeCheck.setUser("admin");
+ nodeCheck.setPassword("admin");
+ nodeCheck.setLive(true);
+ Assert.assertEquals(1, nodeCheck.execute(ACTION_CONTEXT));
+
+ try {
+ nodeCheck = new NodeCheck();
+ nodeCheck.setUser("admin");
+ nodeCheck.setPassword("admin");
+ nodeCheck.setBackup(true);
+ nodeCheck.execute(ACTION_CONTEXT);
+
+ Assert.fail("CLIException expected.");
+ } catch (Exception e) {
+ Assert.assertTrue("CLIException expected.", e instanceof
CLIException);
+ }
+
+ nodeCheck = new NodeCheck();
+ nodeCheck.setUser("admin");
+ nodeCheck.setPassword("admin");
+ nodeCheck.setLive(true);
+ Assert.assertEquals(1, nodeCheck.execute(ACTION_CONTEXT));
+
+ try {
+ nodeCheck = new NodeCheck();
+ nodeCheck.setUser("admin");
+ nodeCheck.setPassword("admin");
+ nodeCheck.setBackup(true);
+ nodeCheck.execute(ACTION_CONTEXT);
+
+ Assert.fail("CLIException expected.");
+ } catch (Exception e) {
+ Assert.assertTrue("CLIException expected.", e instanceof
CLIException);
+ }
+
+ backupProcess = startServer(SERVER_NAME_2, 0, 0);
+
+ SimpleManagement simpleManagement = new
SimpleManagement("tcp://localhost:61616", "admin", "admin");
+ Wait.assertTrue(() -> hasBackup(simpleManagement));
+ nodeCheck = new NodeCheck();
+ nodeCheck.setUser("admin");
+ nodeCheck.setPassword("admin");
+ nodeCheck.setLive(true);
+ nodeCheck.setBackup(true);
+ nodeCheck.setPeers(2);
+ Assert.assertEquals(3, nodeCheck.execute(ACTION_CONTEXT));
+ }
+
+ public boolean hasBackup(SimpleManagement simpleManagement) {
+ try {
+ JsonArray topology = simpleManagement.listNetworkTopology();
+ if (topology.size() != 1) {
+ return false;
+ }
+
+ return topology.getJsonObject(0).getString("backup", null) != null;
+ } catch (Throwable e) {
+ logger.warn(e.getMessage(), e);
+ }
+
+ return false;
+ }
+
+ @Test
+ public void testQueueCheckUp() throws Exception {
+ liveProcess = startServer(SERVER_NAME_1, 0, 0);
+ ServerUtil.waitForServerToStart("tcp://localhost:61616", 5_000);
+
+ SimpleManagement simpleManagement = new
SimpleManagement("tcp://localhost:61616", "admin", "admin");
+
+ String queueName = "Q_" + RandomUtil.randomString();
+
+ QueueCheck queueCheck;
+
+ try {
+ queueCheck = new QueueCheck();
+ queueCheck.setUser("admin");
+ queueCheck.setPassword("admin");
+ queueCheck.setName(queueName);
+ queueCheck.execute(ACTION_CONTEXT);
+
+ Assert.fail("CLIException expected.");
+ } catch (Exception e) {
+ Assert.assertTrue("CLIException expected.", e instanceof
CLIException);
+ }
+
+ ServerLocator locator =
ServerLocatorImpl.newLocator("tcp://localhost:61616");
+ try (ClientSessionFactory factory = locator.createSessionFactory();
ClientSession session = factory.createSession()) {
+ session.createQueue(new
QueueConfiguration(queueName).setRoutingType(RoutingType.ANYCAST));
+ }
+
+ try {
+ queueCheck = new QueueCheck();
+ queueCheck.setUser("admin");
+ queueCheck.setPassword("admin");
+ queueCheck.setName(queueName);
+ queueCheck.setConsume(1);
+ queueCheck.setTimeout(100);
+ queueCheck.execute(ACTION_CONTEXT);
+
+ Assert.fail("CLIException expected.");
+ } catch (Exception e) {
+ Assert.assertTrue("CLIException expected.", e instanceof
CLIException);
+ }
+
+
+ queueCheck = new QueueCheck();
+ queueCheck.setUser("admin");
+ queueCheck.setPassword("admin");
+ queueCheck.setName(queueName);
+ Assert.assertEquals(1, queueCheck.execute(ACTION_CONTEXT));
+
+ queueCheck = new QueueCheck();
+ queueCheck.setUser("admin");
+ queueCheck.setPassword("admin");
+ queueCheck.setUp(true);
+ queueCheck.setName(queueName);
+ Assert.assertEquals(1, queueCheck.execute(ACTION_CONTEXT));
+
+ ConnectionFactory cf = CFUtil.createConnectionFactory("core",
"tcp://localhost:61616");
+
+ final int messages = 3;
+
+ queueCheck = new QueueCheck();
+ queueCheck.setUser("admin");
+ queueCheck.setPassword("admin");
+ queueCheck.setName(queueName);
+ queueCheck.setBrowse(null);
+ Assert.assertEquals(1, queueCheck.execute(ACTION_CONTEXT));
+
+
+ queueCheck = new QueueCheck();
+ queueCheck.setUser("admin");
+ queueCheck.setPassword("admin");
+ queueCheck.setName(queueName);
+ queueCheck.setConsume(null);
+ Assert.assertEquals(1, queueCheck.execute(ACTION_CONTEXT));
+
+
+ try (Connection connection = cf.createConnection(); Session session =
connection.createSession(true, Session.SESSION_TRANSACTED)) {
+ MessageProducer producer =
session.createProducer(session.createQueue(queueName));
+ for (int i = 0; i < messages; i++) {
+ System.out.println("Sending " + i);
+ TextMessage message = session.createTextMessage("hello " + i);
+ message.setStringProperty("local", String.valueOf(i));
+ producer.send(message);
+ }
+ session.commit();
+ Wait.assertEquals(messages, () -> getMessageCount(simpleManagement,
queueName));
Review Comment:
Using the default 30 seconds of wait with 100ms periods seems excessive
here....and everywhere below.
##########
artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java:
##########
@@ -272,7 +272,7 @@ public class Create extends InstallAbstract {
@Option(names = "--jdbc", description = "Store message data in JDBC instead
of local files.")
boolean jdbc;
- @Option(names = "--staticCluster", description = "Cluster node connectors
list separated by comma, e.g.
\"tcp://server:61616,tcp://server2:61616,tcp://server3:61616\".")
+ @Option(names = {"--staticCluster", "--static-cluster"}, description =
"Cluster node connectors list separated by comma, e.g.
\"tcp://server:61616,tcp://server2:61616,tcp://server3:61616\".")
Review Comment:
Feels like it should be a seperate change, has little directly to do with
moving+improving this test, and folks are less likely to know it was added if
buried in this commit.
##########
tests/smoke-tests/pom.xml:
##########
@@ -1199,7 +1199,7 @@
<arg>--name</arg>
<arg>cluster1</arg>
<arg>--clustered</arg>
- <arg>--staticCluster</arg>
+ <arg>--static-cluster</arg>
Review Comment:
Similarly seems like its unrelated - not even for the test in question.
Would also likely be clearer if separated out, why this one is being changed
and the other server for the test isnt, that they are synonym options.
--
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]