asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ti...@apache.org
Subject asterixdb git commit: Add support for binary test results
Date Sun, 30 Apr 2017 14:49:33 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master 6c2c01dd0 -> b3982c733


Add support for binary test results

Change-Id: Id23536e3cb056266549455db3ac8c1cbf2cf2ae9
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1710
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
BAD: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/b3982c73
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/b3982c73
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/b3982c73

Branch: refs/heads/master
Commit: b3982c733a2455cde2bca14d87e9bc1579a31039
Parents: 6c2c01d
Author: Till Westmann <tillw@apache.org>
Authored: Sat Apr 29 15:56:32 2017 -0700
Committer: Till Westmann <tillw@apache.org>
Committed: Sun Apr 30 07:49:07 2017 -0700

----------------------------------------------------------------------
 .../apache/asterix/test/common/TestExecutor.java  | 18 +++++++++++++-----
 .../asterix/test/sqlpp/ParserTestExecutor.java    |  4 +++-
 .../testframework/context/TestCaseContext.java    |  7 +++++--
 .../src/main/resources/Catalog.xsd                |  1 +
 4 files changed, 22 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/b3982c73/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java
----------------------------------------------------------------------
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 e88f647..f992e68 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
@@ -58,6 +58,7 @@ import org.apache.asterix.test.server.TestServerProvider;
 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;
@@ -149,7 +150,8 @@ public class TestExecutor {
         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 =
@@ -158,7 +160,12 @@ public class TestExecutor {
                 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")) {
@@ -881,7 +888,7 @@ public class TestExecutor {
                 writeOutputToFile(actualResultFile, resultStream);
 
                 runScriptAndCompareWithResult(testFile, new PrintWriter(System.err), expectedResultFile,
-                        actualResultFile);
+                        actualResultFile, ComparisonEnum.TEXT);
                 queryCount.increment();
 
                 // Deletes the matched result file.
@@ -904,7 +911,8 @@ public class TestExecutor {
                         + "_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 {
@@ -995,7 +1003,7 @@ public class TestExecutor {
                     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;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/b3982c73/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/ParserTestExecutor.java
----------------------------------------------------------------------
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.ComparisonException;
 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 @@ public class ParserTestExecutor extends TestExecutor {
             }
             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;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/b3982c73/asterixdb/asterix-test-framework/src/main/java/org/apache/asterix/testframework/context/TestCaseContext.java
----------------------------------------------------------------------
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 @@ public class TestCaseContext {
         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 @@ public class TestCaseContext {
                     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 class TestCaseContext {
     }
 
     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);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/b3982c73/asterixdb/asterix-test-framework/src/main/resources/Catalog.xsd
----------------------------------------------------------------------
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"/>


Mime
View raw message