Author: liyin Date: Thu May 16 19:20:22 2013 New Revision: 1483524 URL: http://svn.apache.org/r1483524 Log: [HBASE-8083] Fixes TestHCM
Author: rshroff Summary: One of the test cases testRemoteServerFailure, changed the HRegion class used to perform the operations. The test did not reset the class back to original one after completion. This would cause errors to any other tests executing after this test case. Changed it to reset the class to the original one on completion. Also, changed the order to ensure that there are test cases which run after this test case to check whether its works or not. Test Plan: mr Reviewers: liyintang, manukranthk Reviewed By: liyintang CC: hbase-eng@ Differential Revision: https://phabricator.fb.com/D809815 Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java?rev=1483524&r1=1483523&r2=1483524&view=diff ============================================================================== --- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java (original) +++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java Thu May 16 19:20:22 2013 @@ -160,7 +160,48 @@ public class TestHCM { " regions."); } - + /** + * Simulates a case where the RegionServer throws exception because + * a put operation failed. + * @throws Exception + */ + @Test + public void testRemoteServerFailure() throws Exception { + + HTable table = TEST_UTIL.createTable(Bytes.toBytes("testRemoteServerFailure"), FAM_NAM); + table.setAutoFlush(true); + + TEST_UTIL.createMultiRegions(table, FAM_NAM); + + try { + + for (int i = 0; i < REGION_SERVERS; i++) { + TEST_UTIL.getHBaseCluster().getRegionServer(i). + getConfiguration().set(HConstants.REGION_IMPL, + TestHRegion.class.getName()); + } + + TEST_UTIL.closeRegionByRow(ROW, table); + // Enough time for region to close and reopen with the new TestHRegionClass + Thread.sleep(10000); + + Put put = new Put(ROW); + put.add(FAM_NAM, ROW, ROW); + + table.put(put); + + assertNull("Put should not succeed"); + } catch (RetriesExhaustedException e) { + assertTrue(e.wasOperationAttemptedByServer()); + } finally { + for (int i = 0; i < REGION_SERVERS; i++) { + TEST_UTIL.getHBaseCluster().getRegionServer(i). + getConfiguration().set(HConstants.REGION_IMPL, + HRegion.class.getName()); + } + } + } + /** * Test that when we delete a location using the first row of a region * that we really delete it. @@ -382,41 +423,6 @@ public class TestHCM { return null; } - /** - * Simulates a case where the RegionServer throws exception because - * a put operation failed. - * @throws Exception - */ - @Test - public void testRemoteServerFailure() throws Exception { - - HTable table = TEST_UTIL.createTable(Bytes.toBytes("testRemoteServerFailure"), FAM_NAM); - table.setAutoFlush(true); - - TEST_UTIL.createMultiRegions(table, FAM_NAM); - - try { - - for (int i = 0; i < REGION_SERVERS; i++) { - TEST_UTIL.getHBaseCluster().getRegionServer(i). - getConfiguration().set(HConstants.REGION_IMPL, - TestHRegion.class.getName()); - } - - TEST_UTIL.closeRegionByRow(ROW, table); - // Enough time for region to close and reopen with the new TestHRegionClass - Thread.sleep(10000); - - Put put = new Put(ROW); - put.add(FAM_NAM, ROW, ROW); - - table.put(put); - - assertNull("Put should not succeed"); - } catch (RetriesExhaustedException e) { - assertTrue(e.wasOperationAttemptedByServer()); - } - } static public class TestHRegion extends HRegion { public TestHRegion(Path basedir, HLog log, FileSystem fs,
