Till Westmann has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/1710

Change subject: Add support for binary test results
......................................................................

Add support for binary test results

Change-Id: Id23536e3cb056266549455db3ac8c1cbf2cf2ae9
---
M 
asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
M 
asterixdb/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/ParserTestExecutor.java
M 
asterixdb/asterix-test-framework/src/main/java/org/apache/asterix/testframework/context/TestCaseContext.java
M asterixdb/asterix-test-framework/src/main/resources/Catalog.xsd
4 files changed, 22 insertions(+), 8 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb 
refs/changes/10/1710/1

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 8457681..ad06855 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
@@ -57,6 +57,7 @@
 import org.apache.asterix.testframework.context.TestCaseContext;
 import org.apache.asterix.testframework.context.TestCaseContext.OutputFormat;
 import org.apache.asterix.testframework.context.TestFileContext;
+import org.apache.asterix.testframework.xml.ComparisonEnum;
 import org.apache.asterix.testframework.xml.TestCase.CompilationUnit;
 import org.apache.asterix.testframework.xml.TestGroup;
 import org.apache.commons.io.FileUtils;
@@ -148,7 +149,8 @@
         return path.delete();
     }
 
-    public void runScriptAndCompareWithResult(File scriptFile, PrintWriter 
print, File expectedFile, File actualFile)
+    public void runScriptAndCompareWithResult(File scriptFile, PrintWriter 
print, File expectedFile, File actualFile,
+            ComparisonEnum compare)
             throws Exception {
         System.err.println("Expected results file: " + 
expectedFile.toString());
         BufferedReader readerExpected =
@@ -157,7 +159,12 @@
                 new BufferedReader(new InputStreamReader(new 
FileInputStream(actualFile), "UTF-8"));
         boolean regex = false;
         try {
-            if (actualFile.toString().endsWith(".regex")) {
+            if (ComparisonEnum.BINARY.equals(compare)) {
+                if (!IOUtils.contentEquals(new FileInputStream(actualFile), 
new FileInputStream(expectedFile))) {
+                    throw new Exception("Result for " + scriptFile + ": actual 
file did not match expected result");
+                }
+                return;
+            } else if (actualFile.toString().endsWith(".regex")) {
                 runScriptAndCompareWithResultRegex(scriptFile, expectedFile, 
actualFile);
                 return;
             } else if (actualFile.toString().endsWith(".regexadm")) {
@@ -869,7 +876,7 @@
                 writeOutputToFile(actualResultFile, resultStream);
 
                 runScriptAndCompareWithResult(testFile, new 
PrintWriter(System.err), expectedResultFile,
-                        actualResultFile);
+                        actualResultFile, ComparisonEnum.TEXT);
                 queryCount.increment();
 
                 // Deletes the matched result file.
@@ -892,7 +899,8 @@
                         + "_qar.adm");
                 writeOutputToFile(qarFile, resultStream);
                 qbcFile = getTestCaseQueryBeforeCrashFile(actualPath, 
testCaseCtx, cUnit);
-                runScriptAndCompareWithResult(testFile, new 
PrintWriter(System.err), qbcFile, qarFile);
+                runScriptAndCompareWithResult(testFile, new 
PrintWriter(System.err), qbcFile, qarFile,
+                        ComparisonEnum.TEXT);
                 break;
             case "txneu": // eu represents erroneous update
                 try {
@@ -983,7 +991,7 @@
                     actualResultFile = testCaseCtx.getActualResultFile(cUnit, 
expectedResultFile, new File(actualPath));
                     writeOutputToFile(actualResultFile, resultStream);
                     runScriptAndCompareWithResult(testFile, new 
PrintWriter(System.err), expectedResultFile,
-                            actualResultFile);
+                            actualResultFile, 
cUnit.getOutputDir().getCompare());
                 }
                 queryCount.increment();
                 break;
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 da8f810..493af30 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
@@ -51,6 +51,7 @@
 import org.apache.asterix.test.common.TestExecutor;
 import org.apache.asterix.testframework.context.TestCaseContext;
 import org.apache.asterix.testframework.context.TestFileContext;
+import org.apache.asterix.testframework.xml.ComparisonEnum;
 import org.apache.asterix.testframework.xml.TestCase.CompilationUnit;
 import org.apache.asterix.testframework.xml.TestGroup;
 import org.junit.Assert;
@@ -148,7 +149,8 @@
             }
             writer.close();
             // Compares the actual result and the expected result.
-            runScriptAndCompareWithResult(queryFile, new 
PrintWriter(System.err), expectedFile, actualResultFile);
+            runScriptAndCompareWithResult(queryFile, new 
PrintWriter(System.err), expectedFile, actualResultFile,
+                    ComparisonEnum.TEXT);
         } catch (Exception e) {
             GlobalConfig.ASTERIX_LOGGER.warning("Failed while testing file " + 
queryFile);
             throw e;
diff --git 
a/asterixdb/asterix-test-framework/src/main/java/org/apache/asterix/testframework/context/TestCaseContext.java
 
b/asterixdb/asterix-test-framework/src/main/java/org/apache/asterix/testframework/context/TestCaseContext.java
index a696a0a..ff914b5 100644
--- 
a/asterixdb/asterix-test-framework/src/main/java/org/apache/asterix/testframework/context/TestCaseContext.java
+++ 
b/asterixdb/asterix-test-framework/src/main/java/org/apache/asterix/testframework/context/TestCaseContext.java
@@ -46,7 +46,8 @@
         CSV("csv", "text/csv"),
         CSV_HEADER("csv-header", "text/csv; header=present"),
         AST("ast", "application/x-ast"),
-        PLAN("plan", "application/x-plan");
+        PLAN("plan", "application/x-plan"),
+        BINARY("", "application/octet-stream");
 
         private final String extension;
         private final String mimetype;
@@ -77,6 +78,8 @@
                     return OutputFormat.CSV;
                 case CSV_HEADER:
                     return OutputFormat.CSV_HEADER;
+                case BINARY:
+                    return OutputFormat.BINARY;
                 case INSPECT:
                 case IGNORE:
                     return OutputFormat.NONE;
@@ -131,7 +134,7 @@
     }
 
     public List<TestFileContext> getFilesInDir(String basePath, String 
dirName, boolean withType) {
-        List<TestFileContext> testFileCtxs = new ArrayList<TestFileContext>();
+        List<TestFileContext> testFileCtxs = new ArrayList<>();
 
         File path = tsRoot;
         path = new File(path, basePath);
diff --git a/asterixdb/asterix-test-framework/src/main/resources/Catalog.xsd 
b/asterixdb/asterix-test-framework/src/main/resources/Catalog.xsd
index f4ba0ee..7a5387c 100644
--- a/asterixdb/asterix-test-framework/src/main/resources/Catalog.xsd
+++ b/asterixdb/asterix-test-framework/src/main/resources/Catalog.xsd
@@ -212,6 +212,7 @@
       <xs:restriction base="xs:string">
          <xs:enumeration value="XML"/>
          <xs:enumeration value="Text"/>
+         <xs:enumeration value="Binary"/>
          <xs:enumeration value="Inspect"/>
          <xs:enumeration value="Ignore"/>
          <xs:enumeration value="Clean-JSON"/>

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1710
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id23536e3cb056266549455db3ac8c1cbf2cf2ae9
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Till Westmann <[email protected]>

Reply via email to