[NO ISSUE][TEST] Add timeout multiplier for test executor timeouts
Change-Id: I340098ce840f31f2afcef5dd66e43a21ed7ceb9d
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2513
Reviewed-by: Murtadha Hubail <mhubail@apache.org>
Tested-by: Michael Blow <mblow@apache.org>
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
index 8c0a3d4..80048bd 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
@@ -154,6 +154,7 @@
protected int endpointSelector;
protected IExternalUDFLibrarian librarian;
private Map<File, TestLoop> testLoops = new HashMap<>();
+ private double timeoutMultiplier = 1;
public TestExecutor() {
this(Inet4Address.getLoopbackAddress().getHostAddress(), 19002);
@@ -183,6 +184,10 @@
this.replicationAddress = replicationAddress;
}
+ public void setTimeoutMultiplier(double timeoutMultiplier) {
+ this.timeoutMultiplier = timeoutMultiplier;
+ }
+
/**
* Probably does not work well with symlinks.
*/
@@ -1449,10 +1454,10 @@
return false;
}
- public static int getTimeoutSecs(String statement) {
+ public int getTimeoutSecs(String statement) {
final Matcher timeoutMatcher = POLL_TIMEOUT_PATTERN.matcher(statement);
if (timeoutMatcher.find()) {
- return Integer.parseInt(timeoutMatcher.group(1));
+ return (int) (Integer.parseInt(timeoutMatcher.group(1)) * timeoutMultiplier);
} else {
throw new IllegalArgumentException("ERROR: polltimeoutsecs=nnn must be present in poll file");
}
@@ -1796,7 +1801,8 @@
waitForClusterState("ACTIVE", timeoutSecs, timeUnit);
}
- public void waitForClusterState(String desiredState, int timeout, TimeUnit timeUnit) throws Exception {
+ public void waitForClusterState(String desiredState, int baseTimeout, TimeUnit timeUnit) throws Exception {
+ int timeout = (int) (baseTimeout * timeoutMultiplier);
LOGGER.info("Waiting for cluster state " + desiredState + "...");
Thread t = new Thread(() -> {
while (true) {
@@ -1874,7 +1880,7 @@
}
String host = command[0];
int port = Integer.parseInt(command[1]);
- int timeoutSec = Integer.parseInt(command[2]);
+ int timeoutSec = (int) (Integer.parseInt(command[2]) * timeoutMultiplier);
while (isPortActive(host, port)) {
TimeUnit.SECONDS.sleep(1);
timeoutSec--;