Index: hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java =================================================================== --- hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java (revision 1462711) +++ hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java (working copy) @@ -1943,15 +1943,20 @@ attempted.clear(); } regCount = regions.size(); - idx = random.nextInt(regions.size()); - // if we have just tried this region, there is no need to try again - if (attempted.contains(idx)) continue; - try { - regions.get(idx).checkSplit(); - return regions.get(idx); - } catch (Exception ex) { - LOG.warn("Caught exception", ex); - attempted.add(idx); + // There are chances that before we get the region for the table from an RS the region may + // be going for CLOSE. This may be because online schema change is enabled + if(regCount > 0){ + idx = random.nextInt(regCount); + // if we have just tried this region, there is no need to try again + if (attempted.contains(idx)) + continue; + try { + regions.get(idx).checkSplit(); + return regions.get(idx); + } catch (Exception ex) { + LOG.warn("Caught exception", ex); + attempted.add(idx); + } } attempts++; } while (maxAttempts == -1 || attempts < maxAttempts); Index: hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestTableLockManager.java =================================================================== --- hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestTableLockManager.java (revision 1462711) +++ hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestTableLockManager.java (working copy) @@ -355,10 +355,16 @@ public void chore() { try { HRegion region = TEST_UTIL.getSplittableRegion(tableName, -1); - byte[] regionName = region.getRegionName(); - admin.flush(regionName); - admin.compact(regionName); - admin.split(regionName); + if (region != null) { + byte[] regionName = region.getRegionName(); + admin.flush(regionName); + admin.compact(regionName); + admin.split(regionName); + } else { + LOG.warn("Could not find suitable region for the table. Possibly the " + + "region got closed and the attempts got over before" + + "the region could have got reassigned."); + } } catch (NotServingRegionException nsre) { // the region may be in transition LOG.warn("Caught exception", nsre);