drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From par...@apache.org
Subject [9/9] drill git commit: DRILL-2887: Fix bad applications of JdbcTest.connect(...).
Date Wed, 06 May 2015 05:26:25 GMT
DRILL-2887: Fix bad applications of JdbcTest.connect(...).

- Removed use of Jdbc.connect() from:
  - Drill2128GetColumnsDataTypeNotTypeCodeIntBugsTest
  - Drill2489CallsAfterCloseThrowExceptionsTest
- Added (manual) test for use of auto-resetting connection.  [JdbcTest]
- Documented need to avoid Jdbc.connect() in above and similar tests.
- Add "document" TODO for JdbcTest.


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

Branch: refs/heads/master
Commit: 7ab51dd745177276c0df9b1a707adb354e50dab0
Parents: c492d4f
Author: dbarclay <dbarclay@maprtech.com>
Authored: Mon Apr 27 12:33:46 2015 -0700
Committer: Parth Chandra <pchandra@maprtech.com>
Committed: Tue May 5 19:29:18 2015 -0700

----------------------------------------------------------------------
 .../jdbc/ConnectionTransactionMethodsTest.java  |  3 +++
 .../jdbc/DatabaseMetaDataGetColumnsTest.java    |  3 +++
 .../apache/drill/jdbc/DatabaseMetaDataTest.java |  5 ++++-
 .../java/org/apache/drill/jdbc/JdbcTest.java    | 22 ++++++++++++++++++++
 .../jdbc/ResultSetGetMethodConversionsTest.java |  3 ++-
 .../jdbc/test/Bug1735ConnectionCloseTest.java   |  9 ++++++--
 ...etColumnsDataTypeNotTypeCodeIntBugsTest.java | 10 ++++++++-
 ...2463GetNullsFailedWithAssertionsBugTest.java |  3 +++
 ...l2489CallsAfterCloseThrowExceptionsTest.java |  4 +++-
 9 files changed, 56 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/7ab51dd7/exec/jdbc/src/test/java/org/apache/drill/jdbc/ConnectionTransactionMethodsTest.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/ConnectionTransactionMethodsTest.java
b/exec/jdbc/src/test/java/org/apache/drill/jdbc/ConnectionTransactionMethodsTest.java
index dd92c9b..1aff918 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/ConnectionTransactionMethodsTest.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/ConnectionTransactionMethodsTest.java
@@ -41,6 +41,9 @@ public class ConnectionTransactionMethodsTest {
 
   @BeforeClass
   public static void setUpConnection() throws SQLException {
+    // (Note: Can't use JdbcTest's connect(...) because JdbcTest closes
+    // Connection--and other JDBC objects--on test method failure, but this test
+    // class uses some objects across methods.)
     connection = new Driver().connect( "jdbc:drill:zk=local", null );
   }
 

http://git-wip-us.apache.org/repos/asf/drill/blob/7ab51dd7/exec/jdbc/src/test/java/org/apache/drill/jdbc/DatabaseMetaDataGetColumnsTest.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/DatabaseMetaDataGetColumnsTest.java
b/exec/jdbc/src/test/java/org/apache/drill/jdbc/DatabaseMetaDataGetColumnsTest.java
index 0f3d838..19be2fd 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/DatabaseMetaDataGetColumnsTest.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/DatabaseMetaDataGetColumnsTest.java
@@ -169,6 +169,9 @@ public class DatabaseMetaDataGetColumnsTest extends JdbcTest {
   public static void setUpConnectionAndMetadataToCheck() throws Exception {
 
     // Get JDBC connection to Drill:
+    // (Note: Can't use JdbcTest's connect(...) because JdbcTest closes
+    // Connection--and other JDBC objects--on test method failure, but this test
+    // class uses some objects across methods.)
     connection = new Driver().connect( "jdbc:drill:zk=local", JdbcAssert.getDefaultProperties());
     dbMetadata = connection.getMetaData();
     Statement stmt = connection.createStatement();

http://git-wip-us.apache.org/repos/asf/drill/blob/7ab51dd7/exec/jdbc/src/test/java/org/apache/drill/jdbc/DatabaseMetaDataTest.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/DatabaseMetaDataTest.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/DatabaseMetaDataTest.java
index 8b885a4..886f974 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/DatabaseMetaDataTest.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/DatabaseMetaDataTest.java
@@ -22,13 +22,13 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.fail;
 import static org.junit.Assert.assertThat;
 import static org.hamcrest.CoreMatchers.*;
+
 import org.apache.drill.jdbc.Driver;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Ignore;
 import org.junit.Test;
 
-
 import static java.sql.Connection.*;
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
@@ -47,6 +47,9 @@ public class DatabaseMetaDataTest {
 
   @BeforeClass
   public static void setUpConnection() throws SQLException {
+    // (Note: Can't use JdbcTest's connect(...) because JdbcTest closes
+    // Connection--and other JDBC objects--on test method failure, but this test
+    // class uses some objects across methods.)
     connection = new Driver().connect( "jdbc:drill:zk=local", null );
   }
 

http://git-wip-us.apache.org/repos/asf/drill/blob/7ab51dd7/exec/jdbc/src/test/java/org/apache/drill/jdbc/JdbcTest.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/JdbcTest.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/JdbcTest.java
index e486898..0042f24 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/JdbcTest.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/JdbcTest.java
@@ -17,6 +17,8 @@
  */
 package org.apache.drill.jdbc;
 
+import static org.junit.Assert.fail;
+
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.ResultSet;
@@ -25,15 +27,21 @@ import java.sql.Statement;
 import java.util.Properties;
 
 import com.google.common.base.Strings;
+
 import org.apache.drill.exec.ExecTest;
 import org.apache.drill.jdbc.test.JdbcAssert;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
+import org.junit.Ignore;
 import org.junit.Rule;
+import org.junit.Test;
 import org.junit.rules.TestRule;
 import org.junit.rules.TestWatcher;
 import org.junit.runner.Description;
 
+// TODO:  Document this, especially what writers of unit tests need to know
+//   (e.g., the reusing of connections, the automatic interception of test
+//   failures and resetting of connections, etc.).
 public class JdbcTest extends ExecTest {
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(JdbcTest.class);
 
@@ -130,4 +138,18 @@ public class JdbcTest extends ExecTest {
   public static void tearDownTestCase() throws Exception {
     factory.closeConnections();
   }
+
+  /**
+   * Test of whether tests that get connection from JdbcTest.connect(...)
+   * work with resetting of connections.  If enabling this (failing) test method
+   * causes other test methods to fail, something needs to be fixed.
+   * (Note:  Not a guaranteed test--depends on order in which test methods are
+   * run.)
+   */
+  @Ignore( "Usually disabled; enable temporarily to check tests" )
+  @Test
+  public void testJdbcTestConnectionResettingCompatibility() {
+    fail( "Intentional failure--did other test methods still run?" );
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/7ab51dd7/exec/jdbc/src/test/java/org/apache/drill/jdbc/ResultSetGetMethodConversionsTest.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/ResultSetGetMethodConversionsTest.java
b/exec/jdbc/src/test/java/org/apache/drill/jdbc/ResultSetGetMethodConversionsTest.java
index eced72b..49e41e4 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/ResultSetGetMethodConversionsTest.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/ResultSetGetMethodConversionsTest.java
@@ -68,7 +68,8 @@ public class ResultSetGetMethodConversionsTest extends JdbcTest {
   public static void setUpConnectionAndMetadataToCheck() throws SQLException {
     // Get JDBC connection to Drill:
     // (Note: Can't use JdbcTest's connect(...) because JdbcTest closes
-    // connection on test method failure, but we use ResultSet across methods.)
+    // Connection--and other JDBC objects--on test method failure, but this test
+    // class uses some objects across methods.)
     connection = new Driver().connect( "jdbc:drill:zk=local", null );
 
     // Set up result row with values of various types.

http://git-wip-us.apache.org/repos/asf/drill/blob/7ab51dd7/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Bug1735ConnectionCloseTest.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Bug1735ConnectionCloseTest.java
b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Bug1735ConnectionCloseTest.java
index 78a8af2..7800fd5 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Bug1735ConnectionCloseTest.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Bug1735ConnectionCloseTest.java
@@ -77,7 +77,8 @@ public class Bug1735ConnectionCloseTest extends JdbcTestQueryBase {
     for ( int i = 1; i <= SMALL_ITERATION_COUNT; i++ ) {
       logger.info( "iteration " + i + ":" );
       System.out.println( "iteration " + i + ":" );
-      Connection connection = new Driver().connect( "jdbc:drill:zk=local", JdbcAssert.getDefaultProperties()
);
+      Connection connection = new Driver().connect( "jdbc:drill:zk=local",
+                                                     JdbcAssert.getDefaultProperties() );
       connection.close();
     }
   }
@@ -94,7 +95,11 @@ public class Bug1735ConnectionCloseTest extends JdbcTestQueryBase {
     for ( int i = 1; i <= LARGE_ITERATION_COUNT; i++ ) {
       logger.info( "iteration " + i + ":" );
       System.out.println( "iteration " + i + ":" );
-      Connection connection = new Driver().connect( "jdbc:drill:zk=local", JdbcAssert.getDefaultProperties()
);
+
+      // (Note: Can't use JdbcTest's connect(...) because it returns connection
+      // that doesn't really close.
+      Connection connection = new Driver().connect( "jdbc:drill:zk=local",
+                                                    JdbcAssert.getDefaultProperties() );
       connection.close();
     }
   }

http://git-wip-us.apache.org/repos/asf/drill/blob/7ab51dd7/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2128GetColumnsDataTypeNotTypeCodeIntBugsTest.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2128GetColumnsDataTypeNotTypeCodeIntBugsTest.java
b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2128GetColumnsDataTypeNotTypeCodeIntBugsTest.java
index 38c6d46..d32712d 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2128GetColumnsDataTypeNotTypeCodeIntBugsTest.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2128GetColumnsDataTypeNotTypeCodeIntBugsTest.java
@@ -29,11 +29,13 @@ import org.junit.rules.TestRule;
 
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
+import java.sql.DriverManager;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Types;
 
 import org.apache.drill.common.util.TestTools;
+import org.apache.drill.jdbc.Driver;
 import org.apache.drill.jdbc.JdbcTest;
 
 
@@ -51,7 +53,13 @@ public class Drill2128GetColumnsDataTypeNotTypeCodeIntBugsTest extends
JdbcTest
 
   @BeforeClass
   public static void setUpConnection() throws Exception {
-    connection = connect( "jdbc:drill:zk=local" );
+    // Get JDBC connection to Drill:
+    // (Note: Can't use JdbcTest's connect(...) because JdbcTest closes
+    // Connection--and other JDBC objects--on test method failure, but this test
+    // class uses connection (and dependent DatabaseMetaData object) across
+    // methods.)
+    Driver.load();
+    connection = DriverManager.getConnection( "jdbc:drill:zk=local" );
     dbMetadata = connection.getMetaData();
   }
 

http://git-wip-us.apache.org/repos/asf/drill/blob/7ab51dd7/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2463GetNullsFailedWithAssertionsBugTest.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2463GetNullsFailedWithAssertionsBugTest.java
b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2463GetNullsFailedWithAssertionsBugTest.java
index 1d1361a..ea9c943 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2463GetNullsFailedWithAssertionsBugTest.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2463GetNullsFailedWithAssertionsBugTest.java
@@ -41,6 +41,9 @@ public class Drill2463GetNullsFailedWithAssertionsBugTest extends JdbcTest
{
 
   @BeforeClass
   public static void setUpConnection() throws SQLException {
+    // (Note: Can't use JdbcTest's connect(...) because JdbcTest closes
+    // Connection--and other JDBC objects--on test method failure, but this test
+    // class uses some objects across methods.)
     connection = new Driver().connect( "jdbc:drill:zk=local", JdbcAssert.getDefaultProperties()
);
     statement = connection.createStatement();
 

http://git-wip-us.apache.org/repos/asf/drill/blob/7ab51dd7/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2489CallsAfterCloseThrowExceptionsTest.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2489CallsAfterCloseThrowExceptionsTest.java
b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2489CallsAfterCloseThrowExceptionsTest.java
index 3282945..1732e5c 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2489CallsAfterCloseThrowExceptionsTest.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2489CallsAfterCloseThrowExceptionsTest.java
@@ -77,7 +77,9 @@ public class Drill2489CallsAfterCloseThrowExceptionsTest extends JdbcTest
{
 
   @BeforeClass
   public static void setUpConnection() throws Exception {
-    final Connection connection = new Driver().connect( "jdbc:drill:zk=local", JdbcAssert.getDefaultProperties()
);
+    // (Note: Can't use JdbcTest's connect(...) for this test class.)
+    final Connection connection =
+        new Driver().connect( "jdbc:drill:zk=local", JdbcAssert.getDefaultProperties() );
     final Statement stmt = connection.createStatement();
     final ResultSet result =
         stmt.executeQuery( "SELECT * FROM INFORMATION_SCHEMA.CATALOGS" );


Mime
View raw message