### Eclipse Workspace Patch 1.0 #P apache-hbase-trunk Index: hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java =================================================================== --- hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java (revision 1403987) +++ hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java (working copy) @@ -1401,10 +1401,10 @@ * the RS's reference. * @param tableName user table to lookup in .META. * @return region server that holds it, null if the row doesn't exist - * @throws IOException + * @throws IOException,InterruptedException */ public HRegionServer getRSForFirstRegionInTable(byte[] tableName) - throws IOException { + throws IOException, InterruptedException { List metaRows = getMetaTableRows(tableName); if (metaRows == null || metaRows.isEmpty()) { return null; @@ -1413,7 +1413,17 @@ Bytes.toString(tableName)); byte [] firstrow = metaRows.get(0); LOG.debug("FirstRow=" + Bytes.toString(firstrow)); + long startWait = System.currentTimeMillis(); + long timeoutMillis = 5000l; int index = getMiniHBaseCluster().getServerWith(firstrow); + while (index == -1) { + assertTrue( + "Timed out waiting for region " + Bytes.toStringBinary(firstrow) + + " online", + System.currentTimeMillis() - startWait < timeoutMillis); + index = getMiniHBaseCluster().getServerWith(firstrow); + Thread.sleep(200); + } return getMiniHBaseCluster().getRegionServerThreads().get(index).getRegionServer(); }