From 5aab961a72ee7e06dc1c9638d866a671d761573b Mon Sep 17 00:00:00 2001 From: stack Date: Wed, 23 Sep 2015 10:13:48 -0700 Subject: [PATCH] HBASE-14472 TestHCM and TestRegionServerNoMaster fixes --- .../apache/hadoop/hbase/client/TestHCM.java | 2 +- .../TestRegionServerNoMaster.java | 4 ++-- .../hbase/regionserver/TestWALLockup.java | 21 +++++++++++++------ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java index 109143a54cf..b8f495f0176 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java @@ -336,7 +336,7 @@ public class TestHCM { // We want to work on a separate connection. c2.set(HConstants.HBASE_CLIENT_INSTANCE_ID, String.valueOf(-1)); c2.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 100); // retry a lot - c2.setInt(HConstants.HBASE_CLIENT_PAUSE, 0); // don't wait between retries. + c2.setInt(HConstants.HBASE_CLIENT_PAUSE, 1); // don't wait between retries. c2.setInt(RpcClient.FAILED_SERVER_EXPIRY_KEY, 0); // Server do not really expire c2.setBoolean(RpcClient.SPECIFIC_WRITE_THREAD, allowsInterrupt); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerNoMaster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerNoMaster.java index 592bf1e55ef..e71089d7fc1 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerNoMaster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerNoMaster.java @@ -92,12 +92,12 @@ public class TestRegionServerNoMaster { throws IOException, InterruptedException { // Stop master HMaster master = HTU.getHBaseCluster().getMaster(); + Thread masterThread = HTU.getHBaseCluster().getMasterThread(); ServerName masterAddr = master.getServerName(); master.stopMaster(); Log.info("Waiting until master thread exits"); - while (HTU.getHBaseCluster().getMasterThread() != null - && HTU.getHBaseCluster().getMasterThread().isAlive()) { + while (masterThread != null && masterThread.isAlive()) { Threads.sleep(100); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestWALLockup.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestWALLockup.java index 11f77085040..a7014434f62 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestWALLockup.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestWALLockup.java @@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.regionserver; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.io.IOException; import java.util.concurrent.CountDownLatch; @@ -233,8 +234,8 @@ public class TestWALLockup { try { region.flush(false); } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + LOG.info("In flush", e); + fail(); } }; }; @@ -246,13 +247,21 @@ public class TestWALLockup { assertTrue(originalWAL != dodgyWAL.getCurrentFileName()); // Can I append to it? dodgyWAL.throwException = false; - region.put(put); + try { + region.put(put); + } catch (Exception e) { + LOG.info("In the put", e); + } } finally { // To stop logRoller, its server has to say it is stopped. Mockito.when(server.isStopped()).thenReturn(true); if (logRoller != null) logRoller.interrupt(); - if (region != null) region.close(); - if (dodgyWAL != null) dodgyWAL.close(); + try { + if (region != null) region.close(); + if (dodgyWAL != null) dodgyWAL.close(); + } catch (Exception e) { + LOG.info("On way out", e); + } } } @@ -265,4 +274,4 @@ public class TestWALLockup { return TEST_UTIL.createLocalHRegion(tableName, startKey, stopKey, false, Durability.SYNC_WAL, wal, COLUMN_FAMILY_BYTES); } -} \ No newline at end of file +}