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 9fc5886391 NO-JIRA Making some Test Parameters mandatory
9fc5886391 is described below

commit 9fc5886391bef0a140c7bad50779269d9ea7f431
Author: Clebert Suconic <[email protected]>
AuthorDate: Mon Sep 12 21:25:30 2022 -0400

    NO-JIRA Making some Test Parameters mandatory
    
    if you miss them, the test would rather fail then silently using less than 
ideal values
---
 .../artemis/tests/soak/TestParameters.java         | 30 ++++++++++++++++++++++
 .../tests/soak/paging/FlowControlPagingTest.java   |  9 ++++---
 .../tests/soak/paging/HorizontalPagingTest.java    | 13 +++++-----
 .../tests/soak/paging/SubscriptionPagingTest.java  | 11 ++++----
 4 files changed, 48 insertions(+), 15 deletions(-)

diff --git 
a/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/TestParameters.java
 
b/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/TestParameters.java
index 95ca311d02..c886f3d0c8 100644
--- 
a/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/TestParameters.java
+++ 
b/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/TestParameters.java
@@ -18,6 +18,7 @@
 package org.apache.activemq.artemis.tests.soak;
 
 import org.jboss.logging.Logger;
+import org.junit.Assert;
 
 /** Encapsulates System properties that could be passed on to the test. */
 public class TestParameters {
@@ -42,6 +43,15 @@ public class TestParameters {
       }
    }
 
+   public static int intMandatoryProperty(String testName, String property) {
+      try {
+         return Integer.parseInt(mandatoryProperty(testName, property));
+      } catch (Throwable e) {
+         Assert.fail(e.getMessage());
+         return -1; // never happening, just to make it compile
+      }
+   }
+
    public static String testProperty(String testName, String property, String 
defaultValue) {
 
       property = propertyName(testName, property);
@@ -65,5 +75,25 @@ public class TestParameters {
    }
 
 
+   public static String mandatoryProperty(String testName, String property) {
+      property = propertyName(testName, property);
+
+      String value = System.getenv(property);
+      if (value == null) {
+         value = System.getProperty(property);
+      }
+
+      if (value == null) {
+         Assert.fail("mandatory System property '" + property + "' not 
defined");
+      } else {
+         logger.debug("Using " + property + "=" + value);
+      }
+
+      logger.info(property + "=" + value);
+
+      return value;
+   }
+
+
 
 }
diff --git 
a/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/paging/FlowControlPagingTest.java
 
b/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/paging/FlowControlPagingTest.java
index c8c6dffe94..950191829b 100644
--- 
a/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/paging/FlowControlPagingTest.java
+++ 
b/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/paging/FlowControlPagingTest.java
@@ -42,6 +42,7 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 
+import static 
org.apache.activemq.artemis.tests.soak.TestParameters.intMandatoryProperty;
 import static 
org.apache.activemq.artemis.tests.soak.TestParameters.testProperty;
 
 /**
@@ -87,11 +88,11 @@ public class FlowControlPagingTest extends SoakTestBase {
 
    public FlowControlPagingTest(String protocol) {
       this.protocol = protocol;
-      MESSAGES = testProperty(TEST_NAME, protocol + "_MESSAGES", 10000);
-      COMMIT_INTERVAL = testProperty(TEST_NAME, protocol + "_COMMIT_INTERVAL", 
1000);
+      MESSAGES = intMandatoryProperty(TEST_NAME, protocol + "_MESSAGES");
+      COMMIT_INTERVAL = intMandatoryProperty(TEST_NAME, protocol + 
"_COMMIT_INTERVAL");
       // if 0 will use AUTO_ACK
-      RECEIVE_COMMIT_INTERVAL = testProperty(TEST_NAME, protocol + 
"_RECEIVE_COMMIT_INTERVAL", 1);
-      MESSAGE_SIZE = testProperty(TEST_NAME, protocol + "_MESSAGE_SIZE", 
30000);
+      RECEIVE_COMMIT_INTERVAL = intMandatoryProperty(TEST_NAME, protocol + 
"_RECEIVE_COMMIT_INTERVAL");
+      MESSAGE_SIZE = intMandatoryProperty(TEST_NAME, protocol + 
"_MESSAGE_SIZE");
    }
 
    Process serverProcess;
diff --git 
a/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/paging/HorizontalPagingTest.java
 
b/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/paging/HorizontalPagingTest.java
index 2560fd57e7..1adb5c7f47 100644
--- 
a/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/paging/HorizontalPagingTest.java
+++ 
b/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/paging/HorizontalPagingTest.java
@@ -43,6 +43,7 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 
+import static 
org.apache.activemq.artemis.tests.soak.TestParameters.intMandatoryProperty;
 import static 
org.apache.activemq.artemis.tests.soak.TestParameters.testProperty;
 
 /**
@@ -91,13 +92,13 @@ public class HorizontalPagingTest extends SoakTestBase {
 
    public HorizontalPagingTest(String protocol) {
       this.protocol = protocol;
-      DESTINATIONS = testProperty(TEST_NAME, protocol + "_DESTINATIONS", 10);
-      MESSAGES = testProperty(TEST_NAME, protocol + "_MESSAGES", 100);
-      COMMIT_INTERVAL = testProperty(TEST_NAME, protocol + "_COMMIT_INTERVAL", 
10);
+      DESTINATIONS = intMandatoryProperty(TEST_NAME, protocol + 
"_DESTINATIONS");
+      MESSAGES = intMandatoryProperty(TEST_NAME, protocol + "_MESSAGES");
+      COMMIT_INTERVAL = intMandatoryProperty(TEST_NAME, protocol + 
"_COMMIT_INTERVAL");
       // if 0 will use AUTO_ACK
-      RECEIVE_COMMIT_INTERVAL = testProperty(TEST_NAME, protocol + 
"_RECEIVE_COMMIT_INTERVAL", 1);
-      MESSAGE_SIZE = testProperty(TEST_NAME, protocol + "_MESSAGE_SIZE", 
60_000);
-      PARALLEL_SENDS = testProperty(TEST_NAME, protocol + "_PARALLEL_SENDS", 
2);
+      RECEIVE_COMMIT_INTERVAL = intMandatoryProperty(TEST_NAME, protocol + 
"_RECEIVE_COMMIT_INTERVAL");
+      MESSAGE_SIZE = intMandatoryProperty(TEST_NAME, protocol + 
"_MESSAGE_SIZE");
+      PARALLEL_SENDS = intMandatoryProperty(TEST_NAME, protocol + 
"_PARALLEL_SENDS");
    }
 
    Process serverProcess;
diff --git 
a/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/paging/SubscriptionPagingTest.java
 
b/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/paging/SubscriptionPagingTest.java
index e3197efc59..849941bb0f 100644
--- 
a/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/paging/SubscriptionPagingTest.java
+++ 
b/tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/paging/SubscriptionPagingTest.java
@@ -45,6 +45,7 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 
+import static 
org.apache.activemq.artemis.tests.soak.TestParameters.intMandatoryProperty;
 import static 
org.apache.activemq.artemis.tests.soak.TestParameters.testProperty;
 
 /**
@@ -93,12 +94,12 @@ public class SubscriptionPagingTest extends SoakTestBase {
 
    public SubscriptionPagingTest(String protocol) {
       this.protocol = protocol;
-      MESSAGES = testProperty(TEST_NAME, protocol + "_MESSAGES", 10000);
-      COMMIT_INTERVAL = testProperty(TEST_NAME, protocol + "_COMMIT_INTERVAL", 
1000);
+      MESSAGES = intMandatoryProperty(TEST_NAME, protocol + "_MESSAGES");
+      COMMIT_INTERVAL = intMandatoryProperty(TEST_NAME, protocol + 
"_COMMIT_INTERVAL");
       // if 0 will use AUTO_ACK
-      RECEIVE_COMMIT_INTERVAL = testProperty(TEST_NAME, protocol + 
"_RECEIVE_COMMIT_INTERVAL", 0);
-      MESSAGE_SIZE = testProperty(TEST_NAME, protocol + "_MESSAGE_SIZE", 
30000);
-      SLOW_SUBSCRIPTIONS = testProperty(TEST_NAME, "SLOW_SUBSCRIPTIONS", 1);
+      RECEIVE_COMMIT_INTERVAL = intMandatoryProperty(TEST_NAME, protocol + 
"_RECEIVE_COMMIT_INTERVAL");
+      MESSAGE_SIZE = intMandatoryProperty(TEST_NAME, protocol + 
"_MESSAGE_SIZE");
+      SLOW_SUBSCRIPTIONS = intMandatoryProperty(TEST_NAME, 
"SLOW_SUBSCRIPTIONS");
       SLEEP_SLOW = testProperty(TEST_NAME, "SLEEP_SLOW", 1000);
    }
 

Reply via email to