Index: hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverScannerOpenHook.java =================================================================== --- hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverScannerOpenHook.java (revision 1535514) +++ hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionObserverScannerOpenHook.java (working copy) @@ -27,6 +27,8 @@ import java.util.List; import java.util.NavigableSet; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.Cell; @@ -47,6 +49,7 @@ import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.filter.FilterBase; +import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.GetRegionInfoResponse.CompactionState; import org.apache.hadoop.hbase.regionserver.HRegion; import org.apache.hadoop.hbase.regionserver.HRegionServer; import org.apache.hadoop.hbase.regionserver.HStore; @@ -62,6 +65,7 @@ @Category(MediumTests.class) public class TestRegionObserverScannerOpenHook { + private static final Log LOG = LogFactory.getLog(TestRegionObserverScannerOpenHook.class); private static HBaseTestingUtility UTIL = new HBaseTestingUtility(); static final Path DIR = UTIL.getDataTestDir(); @@ -249,19 +253,31 @@ // run a compaction, which normally would should get rid of the data // wait for the compaction checker to complete - Thread.sleep(1000); + long now = System.currentTimeMillis(); + CompactionState cs = admin.getCompactionState(region.getRegionName()); + while (cs.getNumber() == CompactionState.NONE_VALUE) { + Thread.sleep(10); + cs = admin.getCompactionState(region.getRegionName()); + } + LOG.info("Waiting for compaction to complete"); + while (cs.getNumber() != CompactionState.NONE_VALUE) { + Thread.sleep(100); + cs = admin.getCompactionState(region.getRegionName()); + } + LOG.info("Performing check"); // check both rows to ensure that they aren't there Get get = new Get(ROW); Result r = table.get(get); assertNull( - "Got an unexpected number of rows - no data should be returned with the NoDataFromScan coprocessor. Found: " - + r, r.listCells()); + "Got unexpected number of rows - no data should be returned with NoDataFromScan coprocessor." + + "Found: " + r + " @ " + now, r.listCells()); get = new Get(Bytes.toBytes("anotherrow")); r = table.get(get); + now = System.currentTimeMillis(); assertNull( - "Got an unexpected number of rows - no data should be returned with the NoDataFromScan coprocessor Found: " - + r, r.listCells()); + "Got unexpected number of rows - no data should be returned with NoDataFromScan coprocessor." + + "Found: " + r + " @ " + now, r.listCells()); table.close(); UTIL.shutdownMiniCluster();