drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject [2/3] drill git commit: DRILL-1827: Unit test framework fix, expected and actual results were flipped in unordered comparison error message.
Date Tue, 05 May 2015 01:38:26 GMT
DRILL-1827: Unit test framework fix, expected and actual results were flipped in unordered
comparison error message.

Small fix to expected message in unit test framework tests.


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

Branch: refs/heads/master
Commit: dcbf46194775b01031e817b715dfed98b8be5c3e
Parents: 800dad0
Author: Jason Altekruse <altekrusejason@gmail.com>
Authored: Mon Dec 8 15:55:00 2014 -0800
Committer: Jason Altekruse <altekrusejason@gmail.com>
Committed: Mon May 4 16:32:27 2015 -0700

----------------------------------------------------------------------
 .../java/org/apache/drill/DrillTestWrapper.java | 61 +++++++++++---------
 .../org/apache/drill/TestFrameworkTest.java     |  2 +-
 2 files changed, 36 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/dcbf4619/exec/java-exec/src/test/java/org/apache/drill/DrillTestWrapper.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/DrillTestWrapper.java b/exec/java-exec/src/test/java/org/apache/drill/DrillTestWrapper.java
index d05c896..856dfa5 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/DrillTestWrapper.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/DrillTestWrapper.java
@@ -37,6 +37,7 @@ import java.io.UnsupportedEncodingException;
 import java.lang.reflect.Array;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -267,28 +268,32 @@ public class DrillTestWrapper {
     RecordBatchLoader loader = new RecordBatchLoader(getAllocator());
     BatchSchema schema = null;
 
-    BaseTestQuery.test(testOptionSettingQueries);
-    List<QueryDataBatch> expected = BaseTestQuery.testRunAndReturn(queryType, query);
+    List<QueryDataBatch> actual = Collections.EMPTY_LIST;;
+    List<QueryDataBatch> expected = Collections.EMPTY_LIST;
+    List<Map> expectedRecords = new ArrayList<>();
+    List<Map> actualRecords = new ArrayList<>();
 
-    addTypeInfoIfMissing(expected.get(0), testBuilder);
+    try {
+      BaseTestQuery.test(testOptionSettingQueries);
+      actual = BaseTestQuery.testRunAndReturn(queryType, query);
 
-    List<Map> expectedRecords = new ArrayList<>();
-    addToMaterializedResults(expectedRecords, expected, loader, schema);
+      addTypeInfoIfMissing(actual.get(0), testBuilder);
+      addToMaterializedResults(actualRecords, actual, loader, schema);
 
-    List<QueryDataBatch> results = new ArrayList();
-    List<Map> actualRecords = new ArrayList<>();
-    // If baseline data was not provided to the test builder directly, we must run a query
for the baseline, this includes
-    // the cases where the baseline is stored in a file.
-    if (baselineRecords == null) {
-      BaseTestQuery.test(baselineOptionSettingQueries);
-      results = BaseTestQuery.testRunAndReturn(baselineQueryType, testBuilder.getValidationQuery());
-      addToMaterializedResults(actualRecords, results, loader, schema);
-    } else {
-      actualRecords = baselineRecords;
-    }
+      // If baseline data was not provided to the test builder directly, we must run a query
for the baseline, this includes
+      // the cases where the baseline is stored in a file.
+      if (baselineRecords == null) {
+        BaseTestQuery.test(baselineOptionSettingQueries);
+        expected = BaseTestQuery.testRunAndReturn(baselineQueryType, testBuilder.getValidationQuery());
+        addToMaterializedResults(expectedRecords, expected, loader, schema);
+      } else {
+        expectedRecords = baselineRecords;
+      }
 
-    compareResults(expectedRecords, actualRecords);
-    cleanupBatches(expected, results);
+      compareResults(expectedRecords, actualRecords);
+    } finally {
+      cleanupBatches(actual, expected);
+    }
   }
 
   /**
@@ -312,15 +317,18 @@ public class DrillTestWrapper {
     RecordBatchLoader loader = new RecordBatchLoader(getAllocator());
     BatchSchema schema = null;
 
+    List<QueryDataBatch> actual = Collections.EMPTY_LIST;;
+    List<QueryDataBatch> expected = Collections.EMPTY_LIST;
+    Map<String, List> actualSuperVectors;
+    Map<String, List> expectedSuperVectors;
+
+    try {
     BaseTestQuery.test(testOptionSettingQueries);
-    List<QueryDataBatch> results = BaseTestQuery.testRunAndReturn(queryType, query);
+    actual = BaseTestQuery.testRunAndReturn(queryType, query);
     // To avoid extra work for test writers, types can optionally be inferred from the test
query
-    addTypeInfoIfMissing(results.get(0), testBuilder);
-
-    Map<String, List> actualSuperVectors = addToCombinedVectorResults(results, loader,
schema);
+    addTypeInfoIfMissing(actual.get(0), testBuilder);
 
-    List<QueryDataBatch> expected = null;
-    Map<String, List> expectedSuperVectors = null;
+    actualSuperVectors = addToCombinedVectorResults(actual, loader, schema);
 
     // If baseline data was not provided to the test builder directly, we must run a query
for the baseline, this includes
     // the cases where the baseline is stored in a file.
@@ -344,8 +352,9 @@ public class DrillTestWrapper {
     }
 
     compareMergedVectors(expectedSuperVectors, actualSuperVectors);
-
-    cleanupBatches(expected, results);
+    } finally {
+      cleanupBatches(expected, actual);
+    }
   }
 
   public void compareResultsHyperVector() throws Exception {

http://git-wip-us.apache.org/repos/asf/drill/blob/dcbf4619/exec/java-exec/src/test/java/org/apache/drill/TestFrameworkTest.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestFrameworkTest.java b/exec/java-exec/src/test/java/org/apache/drill/TestFrameworkTest.java
index 3abd193..31a7a64 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/TestFrameworkTest.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/TestFrameworkTest.java
@@ -337,7 +337,7 @@ public class TestFrameworkTest extends BaseTestQuery{
           .expectsEmptyResultSet()
           .build().run();
     } catch (AssertionError ex) {
-      assertEquals("Different number of records returned expected:<4> but was:<0>",
ex.getMessage());
+      assertEquals("Different number of records returned expected:<0> but was:<4>",
ex.getMessage());
       // this indicates successful completion of the test
       return;
     }


Mime
View raw message