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

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


The following commit(s) were added to refs/heads/master by this push:
     new fd0dcd2908 [NO ISSUE][OTH] Ignore comparison exception for 
cancellation test
fd0dcd2908 is described below

commit fd0dcd290823c70d1d71fc32ebcd4fba6482dae9
Author: Ali Alsuliman <[email protected]>
AuthorDate: Wed Dec 18 20:49:00 2024 -0800

    [NO ISSUE][OTH] Ignore comparison exception for cancellation test
    
    - user model changes: no
    - storage format changes: no
    - interface changes: no
    
    Details:
    For SqlppExecutionWithCancellationTest, if the request is processed
    and is not cancelled (because it finished faster than the cancellation),
    then we don't need to check the expected result since the main goal of
    the test is to cancel queries and ignore results.
    
    Ext-ref: MB-62799
    
    Change-Id: Ia5b6168aeebcbf54ccf303a0e7eb8ff86a1e39b6
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19217
    Integration-Tests: Jenkins <[email protected]>
    Tested-by: Jenkins <[email protected]>
    Reviewed-by: Ali Alsuliman <[email protected]>
    Reviewed-by: Ian Maxon <[email protected]>
---
 .../test/common/CancellationTestExecutor.java      |  5 +++
 .../asterix/test/common/ComparisonException.java   | 31 +++++++++++++++++--
 .../apache/asterix/test/common/TestExecutor.java   | 36 +++++++++++-----------
 .../asterix/test/sqlpp/ParserTestExecutor.java     |  4 +--
 4 files changed, 54 insertions(+), 22 deletions(-)

diff --git 
a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/CancellationTestExecutor.java
 
b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/CancellationTestExecutor.java
index 766a9d4842..b4b73528e8 100644
--- 
a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/CancellationTestExecutor.java
+++ 
b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/CancellationTestExecutor.java
@@ -20,6 +20,7 @@
 package org.apache.asterix.test.common;
 
 import static 
org.apache.asterix.api.http.server.QueryServiceRequestParameters.Parameter.CLIENT_ID;
+import static 
org.apache.asterix.test.common.ComparisonException.Type.DIFFERENT_RESULT;
 
 import java.io.InputStream;
 import java.net.URI;
@@ -110,6 +111,10 @@ public class CancellationTestExecutor extends TestExecutor 
{
             SqlppExecutionWithCancellationTest.numCancelledQueries++;
             queryCount.increment();
             return false;
+        } else if (e instanceof ComparisonException
+                && ((ComparisonException) e).getExceptionType() == 
DIFFERENT_RESULT) {
+            // for this test, ignore ComparisonException for completed 
requests since the goal is not to compare results
+            return false;
         } else {
             System.err.println(
                     "Expected to find one of the following in error 
text:\n+++++\n" + expectedErrors + "\n+++++");
diff --git 
a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/ComparisonException.java
 
b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/ComparisonException.java
index cb437f01af..ec3cabf884 100644
--- 
a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/ComparisonException.java
+++ 
b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/ComparisonException.java
@@ -19,13 +19,40 @@
 package org.apache.asterix.test.common;
 
 public class ComparisonException extends Exception {
+
+    enum Type {
+        DIFFERENT_RESULT,
+        MALFORMED_RESULT,
+        NO_RESULT
+    }
+
     private static final long serialVersionUID = 1L;
 
-    public ComparisonException(String message) {
+    private final Type exceptionType;
+
+    private ComparisonException(String message, Type type) {
         super(message);
+        exceptionType = type;
     }
 
-    public ComparisonException(String message, Throwable cause) {
+    private ComparisonException(String message, Throwable cause, Type type) {
         super(message, cause);
+        exceptionType = type;
+    }
+
+    public static ComparisonException noResult(String message) {
+        return new ComparisonException(message, Type.NO_RESULT);
+    }
+
+    public static ComparisonException differentResult(String message) {
+        return new ComparisonException(message, Type.DIFFERENT_RESULT);
+    }
+
+    public static ComparisonException malformedResult(String message, 
Throwable cause) {
+        return new ComparisonException(message, cause, Type.MALFORMED_RESULT);
+    }
+
+    public Type getExceptionType() {
+        return exceptionType;
     }
 }
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 e9060391ed..3d39ef4539 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
@@ -424,18 +424,18 @@ public class TestExecutor {
 
     public static ComparisonException createLineChangedException(File 
scriptFile, String lineExpected,
             String lineActual, int num) {
-        return new ComparisonException("Result for " + 
canonicalize(scriptFile) + " changed at line " + num
+        return ComparisonException.differentResult("Result for " + 
canonicalize(scriptFile) + " changed at line " + num
                 + ":\nexpected < " + truncateIfLong(lineExpected) + "\nactual  
 > " + truncateIfLong(lineActual));
     }
 
     public static ComparisonException createLineNotFoundException(File 
scriptFile, String lineExpected, int num) {
-        return new ComparisonException("Result for " + 
canonicalize(scriptFile) + " expected line at " + num
+        return ComparisonException.differentResult("Result for " + 
canonicalize(scriptFile) + " expected line at " + num
                 + " not found: " + truncateIfLong(lineExpected));
     }
 
     private ComparisonException createExpectedLinesNotReturnedException(File 
scriptFile, List<String> expectedLines) {
-        return new ComparisonException("Result for " + 
canonicalize(scriptFile) + " expected lines not returned:\n"
-                + String.join("\n", expectedLines));
+        return ComparisonException.differentResult("Result for " + 
canonicalize(scriptFile)
+                + " expected lines not returned:\n" + String.join("\n", 
expectedLines));
     }
 
     private static String truncateIfLong(String string) {
@@ -621,20 +621,20 @@ public class TestExecutor {
         try {
             expectedJson = SINGLE_JSON_NODE_READER.readTree(readerExpected);
         } catch (JsonProcessingException e) {
-            throw new ComparisonException("Invalid expected JSON for: " + 
scriptFile, e);
+            throw ComparisonException.malformedResult("Invalid expected JSON 
for: " + scriptFile, e);
         }
         try {
             actualJson = SINGLE_JSON_NODE_READER.readTree(readerActual);
         } catch (JsonProcessingException e) {
-            throw new ComparisonException("Invalid actual JSON for: " + 
scriptFile, e);
+            throw ComparisonException.malformedResult("Invalid actual JSON 
for: " + scriptFile, e);
         }
         if (expectedJson == null) {
-            throw new ComparisonException("No expected result for: " + 
scriptFile);
+            throw ComparisonException.noResult("No expected result for: " + 
scriptFile);
         } else if (actualJson == null) {
-            throw new ComparisonException("No actual result for: " + 
scriptFile);
+            throw ComparisonException.noResult("No actual result for: " + 
scriptFile);
         }
         if (!TestHelper.equalJson(expectedJson, actualJson, 
compareUnorderedArray, ignoreExtraFields, false, null)) {
-            throw new ComparisonException("Result for " + scriptFile + " 
didn't match the expected JSON"
+            throw ComparisonException.differentResult("Result for " + 
scriptFile + " didn't match the expected JSON"
                     + "\nexpected result:\n" + expectedJson + "\nactual 
result:\n" + actualJson);
         }
     }
@@ -650,35 +650,35 @@ public class TestExecutor {
         int i = 0;
         for (String expectedLine : expectedLines) {
             if (actualLines.size() <= i) {
-                throw new ComparisonException("Result for " + 
canonicalize(scriptFile) + " expected json line at " + i
-                        + " not found: " + truncateIfLong(expectedLine));
+                throw ComparisonException.differentResult("Result for " + 
canonicalize(scriptFile)
+                        + " expected json line at " + i + " not found: " + 
truncateIfLong(expectedLine));
             }
             String actualLine = actualLines.get(i);
             i += 1;
             try {
                 expectedJson = SINGLE_JSON_NODE_READER.readTree(expectedLine);
             } catch (JsonProcessingException e) {
-                throw new ComparisonException("Invalid expected JSON for: " + 
scriptFile, e);
+                throw ComparisonException.malformedResult("Invalid expected 
JSON for: " + scriptFile, e);
             }
             try {
                 actualJson = SINGLE_JSON_NODE_READER.readTree(actualLine);
             } catch (JsonProcessingException e) {
-                throw new ComparisonException("Invalid actual JSON for: " + 
scriptFile, e);
+                throw ComparisonException.malformedResult("Invalid actual JSON 
for: " + scriptFile, e);
             }
             if (expectedJson == null) {
-                throw new ComparisonException("No expected result for: " + 
scriptFile);
+                throw ComparisonException.noResult("No expected result for: " 
+ scriptFile);
             } else if (actualJson == null) {
-                throw new ComparisonException("No actual result for: " + 
scriptFile);
+                throw ComparisonException.noResult("No actual result for: " + 
scriptFile);
             }
             if (!TestHelper.equalJson(expectedJson, actualJson, 
compareUnorderedArray, ignoreExtraFields, false,
                     null)) {
-                throw new ComparisonException("Result for " + scriptFile + " 
didn't match the expected JSON"
+                throw ComparisonException.differentResult("Result for " + 
scriptFile + " didn't match the expected JSON"
                         + "\nexpected result:\n" + expectedJson + "\nactual 
result:\n" + actualJson);
             }
         }
         if (actualLines.size() > i) {
-            throw new ComparisonException("Result for " + 
canonicalize(scriptFile) + " extra json line at " + i
-                    + " found: " + truncateIfLong(actualLines.get(i)));
+            throw ComparisonException.differentResult("Result for " + 
canonicalize(scriptFile) + " extra json line at "
+                    + i + " found: " + truncateIfLong(actualLines.get(i)));
         }
     }
 
diff --git 
a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/ParserTestExecutor.java
 
b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/ParserTestExecutor.java
index 7effe9d319..b8f669868c 100644
--- 
a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/ParserTestExecutor.java
+++ 
b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/ParserTestExecutor.java
@@ -99,8 +99,8 @@ public class ParserTestExecutor extends TestExecutor {
                 try {
                     if (queryCount >= expectedResultFileCtxs.size()
                             && 
!cUnit.getOutputDir().getValue().equals("none")) {
-                        throw new ComparisonException("no result file for " + 
canonicalize(testFile) + "; queryCount: "
-                                + queryCount + ", filectxs.size: " + 
expectedResultFileCtxs.size());
+                        throw ComparisonException.noResult("no result file for 
" + canonicalize(testFile)
+                                + "; queryCount: " + queryCount + ", 
filectxs.size: " + expectedResultFileCtxs.size());
                     }
 
                     // Runs the test query.

Reply via email to