This is an automated email from the ASF dual-hosted git repository.

mblow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git

commit 757684048eb136389f8764cd7bb58b185a004c8e
Author: Michael Blow <[email protected]>
AuthorDate: Thu Jul 23 17:42:17 2020 -0400

    [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 <[email protected]>
    Tested-by: Jenkins <[email protected]>
    Reviewed-by: Michael Blow <[email protected]>
    Reviewed-by: Till Westmann <[email protected]>
---
 .../java/org/apache/asterix/test/common/TestExecutor.java  | 14 ++++++++++++--
 .../algebricks/common/exceptions/AlgebricksException.java  |  2 +-
 2 files changed, 13 insertions(+), 3 deletions(-)

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.concurrent.TimeoutException;
 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 @@ public class TestExecutor {
     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 @@ public class TestExecutor {
             // 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 @@ public class AlgebricksException extends Exception 
implements IFormattedExceptio
         return errorCode;
     }
 
-    public Object[] getParams() {
+    public Serializable[] getParams() {
         return params;
     }
 

Reply via email to