sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject sqoop git commit: SQOOP-3411: PostgresMetaConnectIncrementalImportTest fails if metastore tables are absent from the database
Date Mon, 26 Nov 2018 11:05:31 GMT
Repository: sqoop
Updated Branches:
  refs/heads/trunk 08eb5bdc4 -> 696187bb1


SQOOP-3411: PostgresMetaConnectIncrementalImportTest fails if metastore tables are absent
from the database

This closes #51

(Szabolcs Vasas via Boglarka Egyed)


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

Branch: refs/heads/trunk
Commit: 696187bb16ae31ca2aa78be93c342604cc1290d1
Parents: 08eb5bd
Author: Boglarka Egyed <bogi@apache.org>
Authored: Mon Nov 26 12:05:03 2018 +0100
Committer: Boglarka Egyed <bogi@apache.org>
Committed: Mon Nov 26 12:05:03 2018 +0100

----------------------------------------------------------------------
 .../MetaConnectIncrementalImportTestBase.java   | 31 +++++++++++++-------
 1 file changed, 20 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/696187bb/src/test/org/apache/sqoop/metastore/MetaConnectIncrementalImportTestBase.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/sqoop/metastore/MetaConnectIncrementalImportTestBase.java
b/src/test/org/apache/sqoop/metastore/MetaConnectIncrementalImportTestBase.java
index 53f55d1..3dec9f3 100644
--- a/src/test/org/apache/sqoop/metastore/MetaConnectIncrementalImportTestBase.java
+++ b/src/test/org/apache/sqoop/metastore/MetaConnectIncrementalImportTestBase.java
@@ -68,11 +68,24 @@ public abstract class MetaConnectIncrementalImportTestBase extends BaseSqoopTest
     @Before
     public void setUp() {
         super.setUp();
+        try {
+            initMetastoreConnection();
+            resetTable();
+        } catch (SQLException e) {
+            throw new RuntimeException(e);
+        }
+        resetMetastoreSchema();
     }
 
     @After
     public void tearDown() {
         super.tearDown();
+        resetMetastoreSchema();
+        try {
+            cm.close();
+        } catch (SQLException e) {
+            throw new RuntimeException(e);
+        }
     }
 
     protected String[] getIncrementalJob(String metaConnectString, String metaUser, String
metaPass) {
@@ -123,12 +136,6 @@ public abstract class MetaConnectIncrementalImportTestBase extends BaseSqoopTest
 
     @Test
     public void testIncrementalJob() throws SQLException {
-        resetTable();
-
-        initMetastoreConnection();
-
-        resetMetastoreSchema();
-
         //creates Job
         createJob();
 
@@ -148,8 +155,6 @@ public abstract class MetaConnectIncrementalImportTestBase extends BaseSqoopTest
 
         //Ensures the last incremental value is updated correctly.
         checkIncrementalState(2);
-
-        cm.close();
     }
 
     private void checkIncrementalState(int expected) throws SQLException {
@@ -195,9 +200,13 @@ public abstract class MetaConnectIncrementalImportTestBase extends BaseSqoopTest
             metastoreStatement.execute("DROP TABLE " + cm.escapeTableName("SQOOP_ROOT"));
             metastoreStatement.execute("DROP TABLE " + cm.escapeTableName("SQOOP_SESSIONS"));
             connMeta.commit();
-        }
-        catch (Exception e) {
-            LOG.error( e.getLocalizedMessage() );
+        } catch (Exception e) {
+            LOG.error(e.getLocalizedMessage());
+            try {
+                connMeta.rollback();
+            } catch (SQLException innerException) {
+                LOG.error(innerException.getLocalizedMessage());
+            }
         }
     }
 


Mime
View raw message