diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/replication/TestVerifyReplicationAdjunct.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/replication/TestVerifyReplicationAdjunct.java index 21528de6dc63..8049cba7aaa0 100644 --- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/replication/TestVerifyReplicationAdjunct.java +++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/replication/TestVerifyReplicationAdjunct.java @@ -342,7 +342,7 @@ public void testVerifyReplicationWithSnapshotSupport() throws Exception { } @AfterAll - public static void tearDownAfterClass() throws Exception { + public static void tearDownAfterAll() throws Exception { htable3.close(); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncFSWAL.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncFSWAL.java index 5dd5e3b26c89..33dd3e00d6f3 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncFSWAL.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncFSWAL.java @@ -88,7 +88,7 @@ public static void setUpBeforeClass() throws Exception { } @AfterAll - public static void tearDownAfterClass() throws Exception { + public static void tearDownAfterAll() throws Exception { if (GROUP != null) { GROUP.shutdownGracefully(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncProtobufLog.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncProtobufLog.java index 0e89201d4374..7de41b104ff3 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncProtobufLog.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncProtobufLog.java @@ -47,7 +47,7 @@ public static void setUpBeforeClass() throws Exception { } @AfterAll - public static void tearDownAfterClass() throws Exception { + public static void tearDownAfterAll() throws Exception { if (EVENT_LOOP_GROUP != null) { EVENT_LOOP_GROUP.shutdownGracefully().syncUninterruptibly(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncWALReplay.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncWALReplay.java index a1b64817fecf..9c14c222465c 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncWALReplay.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestAsyncWALReplay.java @@ -65,7 +65,7 @@ public static void setUpBeforeClass() throws Exception { } @AfterAll - public static void tearDownAfterClass() throws Exception { + public static void tearDownAfterAll() throws Exception { if (GROUP != null) { GROUP.shutdownGracefully(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/SyncReplicationTestBaseNoBeforeAll.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/SyncReplicationTestBaseNoBeforeAll.java index 06d46c37e1d2..172f53ad52a1 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/SyncReplicationTestBaseNoBeforeAll.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/SyncReplicationTestBaseNoBeforeAll.java @@ -136,28 +136,38 @@ protected static void startClusters() throws Exception { } private static void shutdown(HBaseTestingUtil util) throws Exception { - if (util.getHBaseCluster() == null) { - return; - } - Admin admin = util.getAdmin(); - if (!admin.listReplicationPeers(Pattern.compile(PEER_ID)).isEmpty()) { - if ( - admin.getReplicationPeerSyncReplicationState(PEER_ID) - != SyncReplicationState.DOWNGRADE_ACTIVE - ) { - admin.transitReplicationPeerSyncReplicationState(PEER_ID, - SyncReplicationState.DOWNGRADE_ACTIVE); + try { + if (util.getHBaseCluster() != null) { + Admin admin = util.getAdmin(); + if (!admin.listReplicationPeers(Pattern.compile(PEER_ID)).isEmpty()) { + if ( + admin.getReplicationPeerSyncReplicationState(PEER_ID) + != SyncReplicationState.DOWNGRADE_ACTIVE + ) { + admin.transitReplicationPeerSyncReplicationState(PEER_ID, + SyncReplicationState.DOWNGRADE_ACTIVE); + } + admin.removeReplicationPeer(PEER_ID); + } } - admin.removeReplicationPeer(PEER_ID); + } finally { + // Always, even if the cluster failed to start or the peer cleanup above failed on a broken + // cluster: otherwise DFS is left running and a surefire rerun in this JVM fails to start. + util.shutdownMiniCluster(); } - util.shutdownMiniCluster(); } @AfterAll public static void tearDown() throws Exception { - shutdown(UTIL1); - shutdown(UTIL2); - ZK_UTIL.shutdownMiniZKCluster(); + try { + shutdown(UTIL1); + } finally { + try { + shutdown(UTIL2); + } finally { + ZK_UTIL.shutdownMiniZKCluster(); + } + } } protected final void write(HBaseTestingUtil util, int start, int end) throws IOException { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestClaimReplicationQueue.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestClaimReplicationQueue.java index b7f6558d55b7..336eb95f1faa 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestClaimReplicationQueue.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestClaimReplicationQueue.java @@ -108,7 +108,7 @@ public static void setUpBeforeClass() throws Exception { } @AfterAll - public static void tearDownAfterClass() throws Exception { + public static void tearDownAfterAll() throws Exception { Closeables.close(table3, true); Closeables.close(table4, true); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestNamespaceReplication.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestNamespaceReplication.java index a2a2bc9015cc..12e1a1a97432 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestNamespaceReplication.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestNamespaceReplication.java @@ -124,7 +124,7 @@ public static void setUpBeforeClass() throws Exception { } @AfterAll - public static void tearDownAfterClass() throws Exception { + public static void tearDownAfterAll() throws Exception { admin1.disableTable(tabAName); admin1.deleteTable(tabAName); admin1.disableTable(tabBName); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestRemovePeerProcedureWaitForSCP.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestRemovePeerProcedureWaitForSCP.java index b3bfccafe1f1..9037d4e9ec8f 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestRemovePeerProcedureWaitForSCP.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestRemovePeerProcedureWaitForSCP.java @@ -124,7 +124,7 @@ public void removeExtraPeer() throws Exception { } @AfterAll - public static void tearDownAfterClass() throws Exception { + public static void tearDownAfterAll() throws Exception { Closeables.close(table3, true); }