NO-JIRA Making some Test Parameters mandatory

if you miss them, the test would rather fail then silently using less than ideal values
This commit is contained in:
Clebert Suconic 2022-09-12 21:25:30 -04:00
parent 484447d5d5
commit 9fc5886391
4 changed files with 48 additions and 15 deletions

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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);
}