Fix execution of tests that are run multiple times.

Due to separation of some test in TestJdbcQuery into TestViews and 
TestMetadataDDL
which are derived from TestJdbcQuery, all tests in TestJdbcQuery are run thrice.


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

Branch: refs/heads/master
Commit: 4198a17a8b8ba9fd109e7f8a55c66d466a895c18
Parents: fcd5988
Author: vkorukanti <[email protected]>
Authored: Wed Jun 11 23:41:26 2014 -0700
Committer: vkorukanti <[email protected]>
Committed: Wed Jun 11 23:41:26 2014 -0700

----------------------------------------------------------------------
 .../drill/jdbc/test/JdbcTestQueryBase.java      | 98 ++++++++++++++++++++
 .../apache/drill/jdbc/test/TestJdbcQuery.java   | 61 +-----------
 .../apache/drill/jdbc/test/TestMetadataDDL.java |  2 +-
 .../org/apache/drill/jdbc/test/TestViews.java   |  2 +-
 4 files changed, 101 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/4198a17a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/JdbcTestQueryBase.java
----------------------------------------------------------------------
diff --git 
a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/JdbcTestQueryBase.java 
b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/JdbcTestQueryBase.java
new file mode 100644
index 0000000..259fa8c
--- /dev/null
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/JdbcTestQueryBase.java
@@ -0,0 +1,98 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.jdbc.test;
+
+import com.google.common.base.Stopwatch;
+import org.apache.commons.io.FileUtils;
+import org.apache.drill.common.util.TestTools;
+import org.apache.drill.exec.store.hive.HiveTestDataGenerator;
+import org.apache.drill.jdbc.Driver;
+import org.apache.drill.jdbc.JdbcTest;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.rules.TestRule;
+
+import java.io.File;
+import java.nio.file.Paths;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.Statement;
+import java.util.concurrent.TimeUnit;
+
+public class JdbcTestQueryBase extends JdbcTest {
+  // Set a timeout unless we're debugging.
+  @Rule
+  public TestRule TIMEOUT = TestTools.getTimeoutRule(20000);
+
+  protected static final String WORKING_PATH;
+  static{
+    Driver.load();
+    WORKING_PATH = Paths.get("").toAbsolutePath().toString();
+
+  }
+
+  @BeforeClass
+  public static void generateHive() throws Exception{
+    new HiveTestDataGenerator().generateTestData();
+
+    // delete tmp workspace directory
+    File f = new File("/tmp/drilltest");
+    if(f.exists()){
+      FileUtils.cleanDirectory(f);
+      FileUtils.forceDelete(f);
+    }
+  }
+
+  protected void testQuery(String sql) throws Exception{
+    boolean success = false;
+    try (Connection c = DriverManager.getConnection("jdbc:drill:zk=local", 
null);) {
+      for (int x = 0; x < 1; x++) {
+        Stopwatch watch = new Stopwatch().start();
+        Statement s = c.createStatement();
+        ResultSet r = s.executeQuery(sql);
+        boolean first = true;
+        while (r.next()) {
+          ResultSetMetaData md = r.getMetaData();
+          if (first == true) {
+            for (int i = 1; i <= md.getColumnCount(); i++) {
+              System.out.print(md.getColumnName(i));
+              System.out.print('\t');
+            }
+            System.out.println();
+            first = false;
+          }
+
+          for (int i = 1; i <= md.getColumnCount(); i++) {
+            System.out.print(r.getObject(i));
+            System.out.print('\t');
+          }
+          System.out.println();
+        }
+
+        System.out.println(String.format("Query completed in %d millis.", 
watch.elapsed(TimeUnit.MILLISECONDS)));
+      }
+
+      System.out.println("\n\n\n");
+      success = true;
+    }finally{
+      if(!success) Thread.sleep(2000);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/4198a17a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java
----------------------------------------------------------------------
diff --git 
a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java 
b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java
index 932f207..311b3a5 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java
@@ -50,32 +50,9 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-public class TestJdbcQuery extends JdbcTest{
+public class TestJdbcQuery extends JdbcTestQueryBase{
   static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(TestJdbcQuery.class);
 
-
-  // Set a timeout unless we're debugging.
-  @Rule public TestRule TIMEOUT = TestTools.getTimeoutRule(20000);
-
-  protected static final String WORKING_PATH;
-  static{
-    Driver.load();
-    WORKING_PATH = Paths.get("").toAbsolutePath().toString();
-
-  }
-
-  @BeforeClass
-  public static void generateHive() throws Exception{
-    new HiveTestDataGenerator().generateTestData();
-
-    // delete tmp workspace directory
-    File f = new File("/tmp/drilltest");
-    if(f.exists()){
-      FileUtils.cleanDirectory(f);
-      FileUtils.forceDelete(f);
-    }
-  }
-
   @Test
   public void testHiveReadWithDb() throws Exception{
     testQuery("select * from hive.`default`.kv");
@@ -146,42 +123,6 @@ public class TestJdbcQuery extends JdbcTest{
     testQuery(String.format("SELECT unknownColumn FROM 
dfs.`%s/../../sample-data/region.parquet`", WORKING_PATH));
   }
 
-  protected void testQuery(String sql) throws Exception{
-    boolean success = false;
-    try (Connection c = DriverManager.getConnection("jdbc:drill:zk=local", 
null);) {
-      for (int x = 0; x < 1; x++) {
-        Stopwatch watch = new Stopwatch().start();
-        Statement s = c.createStatement();
-        ResultSet r = s.executeQuery(sql);
-        boolean first = true;
-        while (r.next()) {
-          ResultSetMetaData md = r.getMetaData();
-          if (first == true) {
-            for (int i = 1; i <= md.getColumnCount(); i++) {
-              System.out.print(md.getColumnName(i));
-              System.out.print('\t');
-            }
-            System.out.println();
-            first = false;
-          }
-
-          for (int i = 1; i <= md.getColumnCount(); i++) {
-            System.out.print(r.getObject(i));
-            System.out.print('\t');
-          }
-          System.out.println();
-        }
-
-        System.out.println(String.format("Query completed in %d millis.", 
watch.elapsed(TimeUnit.MILLISECONDS)));
-      }
-
-      System.out.println("\n\n\n");
-      success = true;
-    }finally{
-      if(!success) Thread.sleep(2000);
-    }
-  }
-
   @Test
   public void testLikeNotLike() throws Exception{
     JdbcAssert.withNoDefaultSchema()

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/4198a17a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestMetadataDDL.java
----------------------------------------------------------------------
diff --git 
a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestMetadataDDL.java 
b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestMetadataDDL.java
index 123c160..bb50e40 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestMetadataDDL.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestMetadataDDL.java
@@ -33,7 +33,7 @@ import static org.junit.Assert.assertTrue;
  * -- USE schema
  * -- SHOW FILES
  */
-public class TestMetadataDDL extends TestJdbcQuery {
+public class TestMetadataDDL extends JdbcTestQueryBase {
 
   @Test
   public void testInfoSchema() throws Exception{

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/4198a17a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestViews.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestViews.java 
b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestViews.java
index 93626d5..976c5fa 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestViews.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestViews.java
@@ -28,7 +28,7 @@ import java.sql.Statement;
 import static org.junit.Assert.assertTrue;
 
 /** Contains tests for creating/droping and using views in Drill. */
-public class TestViews extends TestJdbcQuery {
+public class TestViews extends JdbcTestQueryBase {
 
   private final static String NEW_LINE = System.getProperty("line.separator");
 

Reply via email to