drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject [2/3] drill git commit: DRILL-1879: Unit test failures on Windows
Date Thu, 18 Dec 2014 00:51:33 GMT
DRILL-1879: Unit test failures on Windows


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

Branch: refs/heads/0.7.0
Commit: 9360e250b71a764af322a6b7d8808eab49387945
Parents: 0831d72
Author: Aditya Kishore <adi@apache.org>
Authored: Tue Dec 16 17:04:08 2014 -0800
Committer: Aditya Kishore <adi@apache.org>
Committed: Wed Dec 17 16:47:45 2014 -0800

----------------------------------------------------------------------
 .../java/org/apache/drill/BaseTestQuery.java    | 40 +++++++-------------
 .../java/org/apache/drill/PlanTestBase.java     |  4 +-
 .../test/java/org/apache/drill/TestBuilder.java |  2 +-
 3 files changed, 17 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/9360e250/exec/java-exec/src/test/java/org/apache/drill/BaseTestQuery.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/BaseTestQuery.java b/exec/java-exec/src/test/java/org/apache/drill/BaseTestQuery.java
index f75a574..17bcb79 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/BaseTestQuery.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/BaseTestQuery.java
@@ -18,26 +18,15 @@
 package org.apache.drill;
 
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.Array;
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 import java.util.Properties;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicInteger;
+import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import com.google.common.base.Joiner;
-import com.google.common.base.Strings;
-
 import org.apache.drill.common.config.DrillConfig;
-import org.apache.drill.common.types.TypeProtos;
-import org.apache.drill.common.types.Types;
 import org.apache.drill.common.util.TestTools;
 import org.apache.drill.exec.ExecConstants;
 import org.apache.drill.exec.ExecTest;
@@ -50,11 +39,7 @@ import org.apache.drill.exec.memory.BufferAllocator;
 import org.apache.drill.exec.memory.TopLevelAllocator;
 import org.apache.drill.exec.proto.UserBitShared.QueryId;
 import org.apache.drill.exec.proto.UserBitShared.QueryType;
-import org.apache.drill.exec.record.BatchSchema;
-import org.apache.drill.exec.record.HyperVectorWrapper;
-import org.apache.drill.exec.record.MaterializedField;
 import org.apache.drill.exec.record.RecordBatchLoader;
-import org.apache.drill.exec.record.VectorWrapper;
 import org.apache.drill.exec.rpc.RpcException;
 import org.apache.drill.exec.rpc.user.ConnectionThrottle;
 import org.apache.drill.exec.rpc.user.QueryResultBatch;
@@ -62,10 +47,7 @@ import org.apache.drill.exec.rpc.user.UserResultsListener;
 import org.apache.drill.exec.server.Drillbit;
 import org.apache.drill.exec.server.RemoteServiceSet;
 import org.apache.drill.exec.util.VectorUtil;
-import org.apache.drill.exec.vector.ValueVector;
-import org.apache.hadoop.io.Text;
 import org.junit.AfterClass;
-import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.rules.TestRule;
 import org.junit.rules.TestWatcher;
@@ -74,9 +56,6 @@ import org.junit.runner.Description;
 import com.google.common.base.Charsets;
 import com.google.common.io.Resources;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
 public class BaseTestQuery extends ExecTest{
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(BaseTestQuery.class);
 
@@ -180,19 +159,19 @@ public class BaseTestQuery extends ExecTest{
   }
 
   public static List<QueryResultBatch>  testRunAndReturn(QueryType type, String query)
throws Exception{
-    query = query.replace("[WORKING_PATH]", TestTools.getWorkingPath());
+    query = normalizeQuery(query);
     return client.runQuery(type, query);
   }
 
   public static int testRunAndPrint(QueryType type, String query) throws Exception{
-    query = query.replace("[WORKING_PATH]", TestTools.getWorkingPath());
+    query = normalizeQuery(query);
     PrintingResultsListener resultListener = new PrintingResultsListener(client.getConfig(),
Format.TSV, VectorUtil.DEFAULT_COLUMN_WIDTH);
     client.runQuery(type, query, resultListener);
     return resultListener.await();
   }
 
   protected void testWithListener(QueryType type, String query, UserResultsListener resultListener)
{
-    query = query.replace("[WORKING_PATH]", TestTools.getWorkingPath());
+    query = normalizeQuery(query);
     client.runQuery(type, query, resultListener);
   }
 
@@ -216,7 +195,7 @@ public class BaseTestQuery extends ExecTest{
   }
 
   public static void test(String query) throws Exception{
-    query = query.replaceAll(Pattern.quote("${WORKING_PATH}"), TestTools.getWorkingPath());
+    query = normalizeQuery(query);
     String[] queries = query.split(";");
     for (String q : queries) {
       if (q.trim().isEmpty()) {
@@ -226,6 +205,15 @@ public class BaseTestQuery extends ExecTest{
     }
   }
 
+  public static String normalizeQuery(String query) {
+    if (query.contains("${WORKING_PATH}")) {
+      return query.replaceAll(Pattern.quote("${WORKING_PATH}"), Matcher.quoteReplacement(TestTools.getWorkingPath()));
+    } else if (query.contains("[WORKING_PATH]")) {
+      return query.replaceAll(Pattern.quote("[WORKING_PATH]"), Matcher.quoteReplacement(TestTools.getWorkingPath()));
+    }
+    return query;
+  }
+
   protected int testLogical(String query) throws Exception{
     return testRunAndPrint(QueryType.LOGICAL, query);
   }

http://git-wip-us.apache.org/repos/asf/drill/blob/9360e250/exec/java-exec/src/test/java/org/apache/drill/PlanTestBase.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/PlanTestBase.java b/exec/java-exec/src/test/java/org/apache/drill/PlanTestBase.java
index 580a1f0..c52545d 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/PlanTestBase.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/PlanTestBase.java
@@ -47,7 +47,7 @@ public class PlanTestBase extends BaseTestQuery {
    */
   public void testPhysicalPlan(String sql, String... expectedSubstrs)
       throws Exception {
-    sql = "EXPLAIN PLAN for " + sql.replace("[WORKING_PATH]", TestTools.getWorkingPath());
+    sql = "EXPLAIN PLAN for " + normalizeQuery(sql);
 
     String planStr = getPlanInString(sql, JSON_FORMAT);
 
@@ -184,7 +184,7 @@ public class PlanTestBase extends BaseTestQuery {
     }
 
     sql = "EXPLAIN PLAN " + levelStr + " " + depthStr + "  for "
-        + sql.replace("[WORKING_PATH]", TestTools.getWorkingPath());
+        + normalizeQuery(sql);
 
     return getPlanInString(sql, OPTIQ_FORMAT);
   }

http://git-wip-us.apache.org/repos/asf/drill/blob/9360e250/exec/java-exec/src/test/java/org/apache/drill/TestBuilder.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestBuilder.java b/exec/java-exec/src/test/java/org/apache/drill/TestBuilder.java
index 99cf707..978e565 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/TestBuilder.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/TestBuilder.java
@@ -124,7 +124,7 @@ public class TestBuilder {
   }
 
   public TestBuilder sqlQuery(String query) {
-    this.query = query.replaceAll(Pattern.quote("${WORKING_PATH}"), TestTools.getWorkingPath());
+    this.query = BaseTestQuery.normalizeQuery(query);
     this.queryType = UserBitShared.QueryType.SQL;
     return this;
   }


Mime
View raw message