Index: hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java =================================================================== --- hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java (revision 1579453) +++ hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java (working copy) @@ -153,63 +153,67 @@ String table = "tableBadMetaAssign"; TEST_UTIL.createTable(Bytes.toBytes(table), FAM); - // We created 1 table, should be fine - assertNoErrors(doFsck(conf, false)); + try { + // We created 1 table, should be fine + assertNoErrors(doFsck(conf, false)); - // Now let's mess it up and change the assignment in hbase:meta to - // point to a different region server - HTable meta = new HTable(conf, HTableDescriptor.META_TABLEDESC.getTableName(), + // Now let's mess it up and change the assignment in hbase:meta to + // point to a different region server + HTable meta = new HTable(conf, HTableDescriptor.META_TABLEDESC.getTableName(), executorService); - Scan scan = new Scan(); - scan.setStartRow(Bytes.toBytes(table+",,")); - ResultScanner scanner = meta.getScanner(scan); - HRegionInfo hri = null; + Scan scan = new Scan(); + scan.setStartRow(Bytes.toBytes(table+",,")); + ResultScanner scanner = meta.getScanner(scan); + HRegionInfo hri = null; - Result res = scanner.next(); - ServerName currServer = - ServerName.parseFrom(res.getValue(HConstants.CATALOG_FAMILY, - HConstants.SERVER_QUALIFIER)); - long startCode = Bytes.toLong(res.getValue(HConstants.CATALOG_FAMILY, + Result res = scanner.next(); + ServerName currServer = + ServerName.parseFrom(res.getValue(HConstants.CATALOG_FAMILY, + HConstants.SERVER_QUALIFIER)); + long startCode = Bytes.toLong(res.getValue(HConstants.CATALOG_FAMILY, HConstants.STARTCODE_QUALIFIER)); - for (JVMClusterUtil.RegionServerThread rs : + for (JVMClusterUtil.RegionServerThread rs : TEST_UTIL.getHBaseCluster().getRegionServerThreads()) { - ServerName sn = rs.getRegionServer().getServerName(); + ServerName sn = rs.getRegionServer().getServerName(); - // When we find a diff RS, change the assignment and break - if (!currServer.getHostAndPort().equals(sn.getHostAndPort()) || - startCode != sn.getStartcode()) { - Put put = new Put(res.getRow()); - put.setDurability(Durability.SKIP_WAL); - put.add(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER, - Bytes.toBytes(sn.getHostAndPort())); - put.add(HConstants.CATALOG_FAMILY, HConstants.STARTCODE_QUALIFIER, - Bytes.toBytes(sn.getStartcode())); - meta.put(put); - hri = HRegionInfo.getHRegionInfo(res); - break; + // When we find a diff RS, change the assignment and break + if (!currServer.getHostAndPort().equals(sn.getHostAndPort()) || + startCode != sn.getStartcode()) { + Put put = new Put(res.getRow()); + put.setDurability(Durability.SKIP_WAL); + put.add(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER, + Bytes.toBytes(sn.getHostAndPort())); + put.add(HConstants.CATALOG_FAMILY, HConstants.STARTCODE_QUALIFIER, + Bytes.toBytes(sn.getStartcode())); + meta.put(put); + hri = HRegionInfo.getHRegionInfo(res); + break; + } } - } - // Try to fix the data - assertErrors(doFsck(conf, true), new ERROR_CODE[]{ + // Try to fix the data + assertErrors(doFsck(conf, true), new ERROR_CODE[]{ ERROR_CODE.SERVER_DOES_NOT_MATCH_META}); - TEST_UTIL.getHBaseCluster().getMaster() + TEST_UTIL.getHBaseCluster().getMaster() .getAssignmentManager().waitForAssignment(hri); - // Should be fixed now - assertNoErrors(doFsck(conf, false)); + // Should be fixed now + assertNoErrors(doFsck(conf, false)); - // comment needed - what is the purpose of this line - HTable t = new HTable(conf, Bytes.toBytes(table), executorService); - ResultScanner s = t.getScanner(new Scan()); - s.close(); - t.close(); + // comment needed - what is the purpose of this line + HTable t = new HTable(conf, Bytes.toBytes(table), executorService); + ResultScanner s = t.getScanner(new Scan()); + s.close(); + t.close(); - scanner.close(); - meta.close(); + scanner.close(); + meta.close(); + } finally { + deleteTable(TableName.valueOf(table)); + } } @Test(timeout=180000)