diff --git itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java index 46c623d34b..0e2ebb7a49 100644 --- itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java +++ itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java @@ -455,11 +455,13 @@ public Table apply(@Nullable Table table) { } }; InjectableBehaviourObjectStore.setGetTableBehaviour(ptnedTableNuller); - - // The ptned table will not be dumped as getTable will return null - run("REPL DUMP " + dbName, driver); - ptnedTableNuller.assertInjectionsPerformed(true,true); - InjectableBehaviourObjectStore.resetGetTableBehaviour(); // reset the behaviour + try { + // The ptned table will not be dumped as getTable will return null + run("REPL DUMP " + dbName, driver); + ptnedTableNuller.assertInjectionsPerformed(true,true); + } finally { + InjectableBehaviourObjectStore.resetGetTableBehaviour(); // reset the behaviour + } String replDumpLocn = getResult(0, 0, driver); String replDumpId = getResult(0, 1, true, driver); @@ -520,11 +522,13 @@ public void testBootstrapWithConcurrentDropPartition() throws IOException { } }; InjectableBehaviourObjectStore.setListPartitionNamesBehaviour(listPartitionNamesNuller); - - // None of the partitions will be dumped as the partitions list was empty - run("REPL DUMP " + dbName, driver); - listPartitionNamesNuller.assertInjectionsPerformed(true, false); - InjectableBehaviourObjectStore.resetListPartitionNamesBehaviour(); // reset the behaviour + try { + // None of the partitions will be dumped as the partitions list was empty + run("REPL DUMP " + dbName, driver); + listPartitionNamesNuller.assertInjectionsPerformed(true, false); + } finally { + InjectableBehaviourObjectStore.resetListPartitionNamesBehaviour(); // reset the behaviour + } String replDumpLocn = getResult(0, 0, driver); String replDumpId = getResult(0, 1, true, driver); @@ -607,12 +611,13 @@ public void run() { } }; InjectableBehaviourObjectStore.setGetTableBehaviour(ptnedTableRenamer); - - // The intermediate rename would've failed as bootstrap dump in progress - bootstrapLoadAndVerify(dbName, replDbName); - - ptnedTableRenamer.assertInjectionsPerformed(true,true); - InjectableBehaviourObjectStore.resetGetTableBehaviour(); // reset the behaviour + try { + // The intermediate rename would've failed as bootstrap dump in progress + bootstrapLoadAndVerify(dbName, replDbName); + ptnedTableRenamer.assertInjectionsPerformed(true,true); + } finally { + InjectableBehaviourObjectStore.resetGetTableBehaviour(); // reset the behaviour + } // The ptned table should be there in both source and target as rename was not successful verifyRun("SELECT a from " + dbName + ".ptned WHERE (b=1) ORDER BY a", ptn_data, driver); @@ -660,7 +665,7 @@ public void run() { CommandProcessorResponse ret = driver2.run("DROP TABLE " + dbName + ".ptned"); success = (ret.getException() == null); assertTrue(success); - LOG.info("Exit new thread success - {}", success); + LOG.info("Exit new thread success - {}", success, ret.getException()); } }); t.start(); @@ -675,11 +680,13 @@ public void run() { } }; InjectableBehaviourObjectStore.setGetTableBehaviour(ptnedTableRenamer); - - Tuple bootstrap = bootstrapLoadAndVerify(dbName, replDbName); - - ptnedTableRenamer.assertInjectionsPerformed(true,true); - InjectableBehaviourObjectStore.resetGetTableBehaviour(); // reset the behaviour + Tuple bootstrap = null; + try { + bootstrap = bootstrapLoadAndVerify(dbName, replDbName); + ptnedTableRenamer.assertInjectionsPerformed(true,true); + } finally { + InjectableBehaviourObjectStore.resetGetTableBehaviour(); // reset the behaviour + } incrementalLoadAndVerify(dbName, bootstrap.lastReplId, replDbName); verifyIfTableNotExist(replDbName, "ptned", metaStoreClientMirror); @@ -853,12 +860,14 @@ public NotificationEventResponse apply(@Nullable NotificationEventResponse event } }; InjectableBehaviourObjectStore.setGetNextNotificationBehaviour(eventIdSkipper); - - advanceDumpDir(); - CommandProcessorResponse ret = driver.run("REPL DUMP " + dbName + " FROM " + replDumpId); - assertTrue(ret.getResponseCode() == ErrorMsg.REPL_EVENTS_MISSING_IN_METASTORE.getErrorCode()); - eventIdSkipper.assertInjectionsPerformed(true,false); - InjectableBehaviourObjectStore.resetGetNextNotificationBehaviour(); // reset the behaviour + try { + advanceDumpDir(); + CommandProcessorResponse ret = driver.run("REPL DUMP " + dbName + " FROM " + replDumpId); + assertTrue(ret.getResponseCode() == ErrorMsg.REPL_EVENTS_MISSING_IN_METASTORE.getErrorCode()); + eventIdSkipper.assertInjectionsPerformed(true,false); + } finally { + InjectableBehaviourObjectStore.resetGetNextNotificationBehaviour(); // reset the behaviour + } } @Test @@ -1372,11 +1381,12 @@ public NotificationEventResponse apply(@Nullable NotificationEventResponse event } }; InjectableBehaviourObjectStore.setGetNextNotificationBehaviour(eventTypeValidator); - - incrementalLoadAndVerify(dbName, bootstrap.lastReplId, replDbName); - - eventTypeValidator.assertInjectionsPerformed(true,false); - InjectableBehaviourObjectStore.resetGetNextNotificationBehaviour(); // reset the behaviour + try { + incrementalLoadAndVerify(dbName, bootstrap.lastReplId, replDbName); + eventTypeValidator.assertInjectionsPerformed(true,false); + } finally { + InjectableBehaviourObjectStore.resetGetNextNotificationBehaviour(); // reset the behaviour + } verifyRun("SELECT a from " + replDbName + ".ptned where (b=1)", ptn_data, driverMirror); } @@ -1431,11 +1441,12 @@ public NotificationEventResponse apply(@Nullable NotificationEventResponse event } }; InjectableBehaviourObjectStore.setGetNextNotificationBehaviour(insertEventRepeater); - - incrementalLoadAndVerify(dbName, bootstrap.lastReplId, replDbName); - - insertEventRepeater.assertInjectionsPerformed(true,false); - InjectableBehaviourObjectStore.resetGetNextNotificationBehaviour(); // reset the behaviour + try { + incrementalLoadAndVerify(dbName, bootstrap.lastReplId, replDbName); + insertEventRepeater.assertInjectionsPerformed(true,false); + } finally { + InjectableBehaviourObjectStore.resetGetNextNotificationBehaviour(); // reset the behaviour + } verifyRun("SELECT a from " + replDbName + ".unptned", unptn_data, driverMirror); }