Index: hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java =================================================================== --- hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java (revision 1561927) +++ hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java (working copy) @@ -22,9 +22,11 @@ import java.io.File; import java.io.IOException; +import java.io.InterruptedIOException; import java.io.OutputStream; import java.lang.reflect.Field; import java.lang.reflect.Modifier; +import java.net.BindException; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; @@ -551,8 +553,29 @@ public MiniDFSCluster startMiniDFSClusterForTestHLog(int namenodePort) throws IOException { createDirsAndSetProperties(); - dfsCluster = new MiniDFSCluster(namenodePort, conf, 5, false, true, true, null, - null, null, null); + Exception ex = null; + for (int i = 0; i < 30; i++) { + try { + Thread.sleep(500); + } catch (InterruptedException ie) { + InterruptedIOException iie = new InterruptedIOException(); + iie.initCause(ie); + throw iie; + } + try { + dfsCluster = new MiniDFSCluster(namenodePort, conf, 5, false, true, true, null, null, + null, null); + ex = null; + break; + } catch (BindException be) { + ex = be; + LOG.debug("address in use, retry", be); + } + } + if (ex != null) { + throw new IOException("MiniDFSCluster didn't start: ", ex); + } + return dfsCluster; }