[NO ISSUE] Minor AlgebricksException, TestExecutor updates
- update AlgebricksException.getParams() to return Serializable[]
- accept regex patters for expected errors
Change-Id: I2b181719979878b2d8ec0442dab0ed3678c0d9b4
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/7324
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mblow@apache.org>
Reviewed-by: Till Westmann <tillw@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 5d71a26..e4063c0 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
@@ -68,6 +68,7 @@
import java.util.function.Predicate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
import java.util.stream.IntStream;
import java.util.stream.Stream;
@@ -1576,13 +1577,22 @@
protected static boolean isExpected(Exception e, CompilationUnit cUnit) {
final List<String> expErrors = cUnit.getExpectedError();
for (String exp : expErrors) {
- if (e.toString().contains(exp)) {
+ if (e.toString().contains(exp) || containsPattern(e.toString(), exp)) {
return true;
}
}
return false;
}
+ private static boolean containsPattern(String exception, String maybePattern) {
+ try {
+ return Pattern.compile(maybePattern).matcher(exception).find();
+ } catch (PatternSyntaxException pse) {
+ // ignore, this isn't always a legal pattern
+ return false;
+ }
+ }
+
public int getTimeoutSecs(String statement) {
final Matcher timeoutMatcher = POLL_TIMEOUT_PATTERN.matcher(statement);
if (timeoutMatcher.find()) {
@@ -1903,7 +1913,7 @@
// Get the expected exception
expectedError = expectedErrors.get(numOfErrors - 1);
String actualError = e.toString();
- if (!actualError.contains(expectedError)) {
+ if (!actualError.contains(expectedError) && !containsPattern(actualError, expectedError)) {
LOGGER.error("Expected to find the following in error text: +++++{}+++++", expectedError);
return true;
}
diff --git a/hyracks-fullstack/algebricks/algebricks-common/src/main/java/org/apache/hyracks/algebricks/common/exceptions/AlgebricksException.java b/hyracks-fullstack/algebricks/algebricks-common/src/main/java/org/apache/hyracks/algebricks/common/exceptions/AlgebricksException.java
index 46e80be..ac22b60 100644
--- a/hyracks-fullstack/algebricks/algebricks-common/src/main/java/org/apache/hyracks/algebricks/common/exceptions/AlgebricksException.java
+++ b/hyracks-fullstack/algebricks/algebricks-common/src/main/java/org/apache/hyracks/algebricks/common/exceptions/AlgebricksException.java
@@ -135,7 +135,7 @@
return errorCode;
}
- public Object[] getParams() {
+ public Serializable[] getParams() {
return params;
}