mirror of
https://github.com/apache/sqoop.git
synced 2025-05-02 22:00:49 +08:00
SQOOP-3411: PostgresMetaConnectIncrementalImportTest fails if metastore tables are absent from the database
This closes #51 (Szabolcs Vasas via Boglarka Egyed)
This commit is contained in:
parent
08eb5bdc40
commit
696187bb16
@ -68,11 +68,24 @@ public MetaConnectIncrementalImportTestBase(String metaConnectString, String met
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
try {
|
||||||
|
initMetastoreConnection();
|
||||||
|
resetTable();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
resetMetastoreSchema();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
|
resetMetastoreSchema();
|
||||||
|
try {
|
||||||
|
cm.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String[] getIncrementalJob(String metaConnectString, String metaUser, String metaPass) {
|
protected String[] getIncrementalJob(String metaConnectString, String metaUser, String metaPass) {
|
||||||
@ -123,12 +136,6 @@ protected String[] getExecJob(String metaConnectString, String metaUser, String
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIncrementalJob() throws SQLException {
|
public void testIncrementalJob() throws SQLException {
|
||||||
resetTable();
|
|
||||||
|
|
||||||
initMetastoreConnection();
|
|
||||||
|
|
||||||
resetMetastoreSchema();
|
|
||||||
|
|
||||||
//creates Job
|
//creates Job
|
||||||
createJob();
|
createJob();
|
||||||
|
|
||||||
@ -148,8 +155,6 @@ public void testIncrementalJob() throws SQLException {
|
|||||||
|
|
||||||
//Ensures the last incremental value is updated correctly.
|
//Ensures the last incremental value is updated correctly.
|
||||||
checkIncrementalState(2);
|
checkIncrementalState(2);
|
||||||
|
|
||||||
cm.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkIncrementalState(int expected) throws SQLException {
|
private void checkIncrementalState(int expected) throws SQLException {
|
||||||
@ -195,9 +200,13 @@ private void resetMetastoreSchema() {
|
|||||||
metastoreStatement.execute("DROP TABLE " + cm.escapeTableName("SQOOP_ROOT"));
|
metastoreStatement.execute("DROP TABLE " + cm.escapeTableName("SQOOP_ROOT"));
|
||||||
metastoreStatement.execute("DROP TABLE " + cm.escapeTableName("SQOOP_SESSIONS"));
|
metastoreStatement.execute("DROP TABLE " + cm.escapeTableName("SQOOP_SESSIONS"));
|
||||||
connMeta.commit();
|
connMeta.commit();
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
LOG.error(e.getLocalizedMessage());
|
||||||
LOG.error( e.getLocalizedMessage() );
|
try {
|
||||||
|
connMeta.rollback();
|
||||||
|
} catch (SQLException innerException) {
|
||||||
|
LOG.error(innerException.getLocalizedMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user