From 98b66bf9186182d31bcbe051cbad5b113227927b Mon Sep 17 00:00:00 2001 From: mbautin Date: Fri, 13 Apr 2012 18:44:19 -0700 Subject: [PATCH] Fix TestFSErrorsExposed --- .../org/apache/hadoop/hbase/MiniHBaseCluster.java | 15 +++++++++++++++ .../hbase/regionserver/TestFSErrorsExposed.java | 13 +++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java index 6af9188..9cd8587 100644 --- src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java +++ src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java @@ -36,6 +36,8 @@ import org.apache.hadoop.hbase.regionserver.HRegion; import org.apache.hadoop.hbase.regionserver.HRegionServer; import org.apache.hadoop.hbase.security.User; import org.apache.hadoop.hbase.util.Bytes; +import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread; +import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread; import org.apache.hadoop.hbase.util.JVMClusterUtil; import org.apache.hadoop.hbase.util.Threads; import org.apache.hadoop.io.MapWritable; @@ -529,4 +531,17 @@ public class MiniHBaseCluster { } return count; } + + public HMaster getActiveMaster() { + return hbaseCluster.getActiveMaster(); + } + + public void killAll() { + for (RegionServerThread rst : getRegionServerThreads()) { + rst.getRegionServer().abort("killAll"); + } + for (MasterThread masterThread : getMasterThreads()) { + masterThread.getMaster().abort("killAll", new Throwable()); + } + } } diff --git src/test/java/org/apache/hadoop/hbase/regionserver/TestFSErrorsExposed.java src/test/java/org/apache/hadoop/hbase/regionserver/TestFSErrorsExposed.java index 89dfbf7..3ed3eaf 100644 --- src/test/java/org/apache/hadoop/hbase/regionserver/TestFSErrorsExposed.java +++ src/test/java/org/apache/hadoop/hbase/regionserver/TestFSErrorsExposed.java @@ -50,7 +50,6 @@ import org.apache.hadoop.hbase.util.Bytes; import org.junit.Test; import org.junit.experimental.categories.Category; - /** * Test cases that ensure that file system level errors are bubbled up * appropriately to clients, rather than swallowed. @@ -163,13 +162,16 @@ public class TestFSErrorsExposed { * removes the data from HDFS underneath it, and ensures that * errors are bubbled to the client. */ - @Test + @Test(timeout=5 * 60 * 1000) public void testFullSystemBubblesFSErrors() throws Exception { try { // We set it not to run or it will trigger server shutdown while sync'ing // because all the datanodes are bad util.getConfiguration().setInt( "hbase.regionserver.optionallogflushinterval", Integer.MAX_VALUE); + + util.getConfiguration().setInt("hbase.client.retries.number", 3); + util.startMiniCluster(1); byte[] tableName = Bytes.toBytes("table"); byte[] fam = Bytes.toBytes("fam"); @@ -204,7 +206,11 @@ public class TestFSErrorsExposed { assertTrue(e.getMessage().contains("Could not seek")); } + // Restart data nodes so that HBase can shut down cleanly. + util.getDFSCluster().restartDataNodes(); + } finally { + util.getMiniHBaseCluster().killAll(); util.shutdownMiniCluster(); } } @@ -232,7 +238,7 @@ public class TestFSErrorsExposed { for (SoftReference is: inStreams) { is.get().startFaults(); } - } + } } static class FaultyInputStream extends FSDataInputStream { @@ -265,4 +271,3 @@ public class TestFSErrorsExposed { public org.apache.hadoop.hbase.ResourceCheckerJUnitRule cu = new org.apache.hadoop.hbase.ResourceCheckerJUnitRule(); } - -- 1.7.4.4