You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2022/07/22 14:24:56 UTC

[activemq-artemis] 02/03: ARTEMIS-3901 Improvements on PerfCommand

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

commit e35758a4d0802a9acf580352a2df1caa4c831af6
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Fri Jul 22 08:46:17 2022 -0400

    ARTEMIS-3901 Improvements on PerfCommand
---
 .../commands/messages/perf/PerfClientCommand.java  | 185 +++++++++++++++++++++
 .../cli/commands/messages/perf/PerfCommand.java    |  75 +++++++++
 .../activemq/cli/test/CliPerfClientTest.java       |  28 ++--
 3 files changed, 272 insertions(+), 16 deletions(-)

diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/perf/PerfClientCommand.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/perf/PerfClientCommand.java
index e8e7159fd4..0ffb448042 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/perf/PerfClientCommand.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/perf/PerfClientCommand.java
@@ -209,6 +209,191 @@ public class PerfClientCommand extends PerfCommand {
          // topic destinations instead.
          destinations = Collections.singletonList(ActiveMQDestination.TOPIC_QUALIFIED_PREFIX + "TEST");
       }
+
+      if (durableSubscription && clientID == null) {
+         throw new IllegalArgumentException("The clientID must be set on durable subscriptions");
+      }
+
       return super.execute(context);
    }
+
+   public boolean isTransaction() {
+      return transaction;
+   }
+
+   public PerfClientCommand setTransaction(boolean transaction) {
+      this.transaction = transaction;
+      return this;
+   }
+
+   public int getSharedSubscription() {
+      return sharedSubscription;
+   }
+
+   public PerfClientCommand setSharedSubscription(int sharedSubscription) {
+      this.sharedSubscription = sharedSubscription;
+      return this;
+   }
+
+   public boolean isDurableSubscription() {
+      return durableSubscription;
+   }
+
+   public PerfClientCommand setDurableSubscription(boolean durableSubscription) {
+      this.durableSubscription = durableSubscription;
+      return this;
+   }
+
+   public int getConsumerConnections() {
+      return consumerConnections;
+   }
+
+   public PerfClientCommand setConsumerConnections(int consumerConnections) {
+      this.consumerConnections = consumerConnections;
+      return this;
+   }
+
+   public int getConsumersPerDestination() {
+      return consumersPerDestination;
+   }
+
+   public PerfClientCommand setConsumersPerDestination(int consumersPerDestination) {
+      this.consumersPerDestination = consumersPerDestination;
+      return this;
+   }
+
+   public boolean isPersistent() {
+      return persistent;
+   }
+
+   public PerfClientCommand setPersistent(boolean persistent) {
+      this.persistent = persistent;
+      return this;
+   }
+
+   public int getMessageSize() {
+      return messageSize;
+   }
+
+   public PerfClientCommand setMessageSize(int messageSize) {
+      this.messageSize = messageSize;
+      return this;
+   }
+
+   public Long getRate() {
+      return rate;
+   }
+
+   public PerfClientCommand setRate(Long rate) {
+      this.rate = rate;
+      return this;
+   }
+
+   public long getTtl() {
+      return ttl;
+   }
+
+   public PerfClientCommand setTtl(long ttl) {
+      this.ttl = ttl;
+      return this;
+   }
+
+   public String getMsgGroupID() {
+      return msgGroupID;
+   }
+
+   public PerfClientCommand setMsgGroupID(String msgGroupID) {
+      this.msgGroupID = msgGroupID;
+      return this;
+   }
+
+   public boolean isSharedConnections() {
+      return sharedConnections;
+   }
+
+   public PerfClientCommand setSharedConnections(boolean sharedConnections) {
+      this.sharedConnections = sharedConnections;
+      return this;
+   }
+
+   public long getTxSize() {
+      return txSize;
+   }
+
+   public PerfClientCommand setTxSize(long txSize) {
+      this.txSize = txSize;
+      return this;
+   }
+
+   public int getProducersPerDestination() {
+      return producersPerDestination;
+   }
+
+   public PerfClientCommand setProducersPerDestination(int producersPerDestination) {
+      this.producersPerDestination = producersPerDestination;
+      return this;
+   }
+
+   public int getThreads() {
+      return threads;
+   }
+
+   public PerfClientCommand setThreads(int threads) {
+      this.threads = threads;
+      return this;
+   }
+
+   public long getMaxPending() {
+      return maxPending;
+   }
+
+   public PerfClientCommand setMaxPending(long maxPending) {
+      this.maxPending = maxPending;
+      return this;
+   }
+
+   public String getConsumerUrl() {
+      return consumerUrl;
+   }
+
+   public PerfClientCommand setConsumerUrl(String consumerUrl) {
+      this.consumerUrl = consumerUrl;
+      return this;
+   }
+
+   public String getConsumerProtocol() {
+      return consumerProtocol;
+   }
+
+   public PerfClientCommand setConsumerProtocol(String consumerProtocol) {
+      this.consumerProtocol = consumerProtocol;
+      return this;
+   }
+
+   public boolean isEnableMessageID() {
+      return enableMessageID;
+   }
+
+   public PerfClientCommand setEnableMessageID(boolean enableMessageID) {
+      this.enableMessageID = enableMessageID;
+      return this;
+   }
+
+   public boolean isEnableTimestamp() {
+      return enableTimestamp;
+   }
+
+   public PerfClientCommand setEnableTimestamp(boolean enableTimestamp) {
+      this.enableTimestamp = enableTimestamp;
+      return this;
+   }
+
+   public BenchmarkService getProducerBenchmark() {
+      return producerBenchmark;
+   }
+
+   public PerfClientCommand setProducerBenchmark(BenchmarkService producerBenchmark) {
+      this.producerBenchmark = producerBenchmark;
+      return this;
+   }
 }
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/perf/PerfCommand.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/perf/PerfCommand.java
index c30dc59899..0d57c752ae 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/perf/PerfCommand.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/perf/PerfCommand.java
@@ -151,4 +151,79 @@ public abstract class PerfCommand extends ConnectionAbstract {
       return jmsDestinations;
    }
 
+   public boolean isShowLatency() {
+      return showLatency;
+   }
+
+   public PerfCommand setShowLatency(boolean showLatency) {
+      this.showLatency = showLatency;
+      return this;
+   }
+
+   public String getReportFileName() {
+      return reportFileName;
+   }
+
+   public PerfCommand setReportFileName(String reportFileName) {
+      this.reportFileName = reportFileName;
+      return this;
+   }
+
+   public String getHdrFileName() {
+      return hdrFileName;
+   }
+
+   public PerfCommand setHdrFileName(String hdrFileName) {
+      this.hdrFileName = hdrFileName;
+      return this;
+   }
+
+   public int getDuration() {
+      return duration;
+   }
+
+   public PerfCommand setDuration(int duration) {
+      this.duration = duration;
+      return this;
+   }
+
+   public int getWarmup() {
+      return warmup;
+   }
+
+   public PerfCommand setWarmup(int warmup) {
+      this.warmup = warmup;
+      return this;
+   }
+
+   public long getMessageCount() {
+      return messageCount;
+   }
+
+   public PerfCommand setMessageCount(long messageCount) {
+      this.messageCount = messageCount;
+      return this;
+   }
+
+   public int getNumDestinations() {
+      return numDestinations;
+   }
+
+   public PerfCommand setNumDestinations(int numDestinations) {
+      this.numDestinations = numDestinations;
+      return this;
+   }
+
+   public List<String> getDestinations() {
+      return destinations;
+   }
+
+   public PerfCommand setDestinations(List<String> destinations) {
+      this.destinations = destinations;
+      return this;
+   }
+
+   public CountDownLatch getCompleted() {
+      return completed;
+   }
 }
diff --git a/artemis-cli/src/test/java/org/apache/activemq/cli/test/CliPerfClientTest.java b/artemis-cli/src/test/java/org/apache/activemq/cli/test/CliPerfClientTest.java
index aa487ec599..9f6668ade4 100644
--- a/artemis-cli/src/test/java/org/apache/activemq/cli/test/CliPerfClientTest.java
+++ b/artemis-cli/src/test/java/org/apache/activemq/cli/test/CliPerfClientTest.java
@@ -16,10 +16,10 @@
  */
 package org.apache.activemq.cli.test;
 
-import org.apache.activemq.artemis.cli.commands.ActionContext;
 import org.apache.activemq.artemis.cli.commands.messages.perf.PerfClientCommand;
 import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
 import org.junit.After;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -46,26 +46,22 @@ public class CliPerfClientTest extends CliTestBase {
       super.tearDown();
    }
 
-   private void start(boolean durable) throws Exception {
-      PerfClientCommand command = new PerfClientCommand() {
-         @Override
-         public Object execute(ActionContext context) throws Exception {
-            clientID = "perfClientTest";
-            durableSubscription = durable;
-            messageCount = 1;
-            return super.execute(context);
-         }
-      };
-      command.setUser("admin").setPassword("admin").execute(new TestActionContext());
-   }
-
    @Test
    public void testNonDurableStarts() throws Exception {
-      start(false);
+      new PerfClientCommand().setDurableSubscription(false).setMessageCount(1).setUser("admin").setPassword("admin").setClientID("perfClientTest").execute(new TestActionContext());
    }
 
    @Test
    public void testDurableStarts() throws Exception {
-      start(true);
+      new PerfClientCommand().setDurableSubscription(true).setMessageCount(1).setUser("admin").setPassword("admin").setClientID("perfClientTest").execute(new TestActionContext());
+   }
+
+   @Test
+   public void testDurableNoClientIDSet() throws Exception {
+      try {
+         new PerfClientCommand().setDurableSubscription(true).setMessageCount(1).setUser("admin").setPassword("admin").execute(new TestActionContext());
+         Assert.fail("Exception expected");
+      } catch (IllegalArgumentException cliExpected) {
+      }
    }
 }
\ No newline at end of file