HBASE-12384 TestTags can hang on fast test hosts
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/415b8ff4 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/415b8ff4 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/415b8ff4 Branch: refs/heads/0.98 Commit: 415b8ff438b9bdc5c2e1b15a9b6de81bb472fe24 Parents: 5874ae0 Author: Andrew Purtell <[email protected]> Authored: Thu Oct 30 10:45:02 2014 -0700 Committer: Andrew Purtell <[email protected]> Committed: Thu Oct 30 10:51:55 2014 -0700 ---------------------------------------------------------------------- .../hadoop/hbase/regionserver/TestTags.java | 93 ++++++-------------- 1 file changed, 28 insertions(+), 65 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/415b8ff4/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestTags.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestTags.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestTags.java index 3de6ed3..f218a43 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestTags.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestTags.java @@ -123,13 +123,12 @@ public class TestTags { put.setAttribute("visibility", Bytes.toBytes("myTag")); table.put(put); admin.flush(tableName.getName()); - List<HRegion> regions = TEST_UTIL.getHBaseCluster().getRegions(tableName.getName()); - for (HRegion region : regions) { - Store store = region.getStore(fam); - while (!(store.getStorefilesCount() > 0)) { - Thread.sleep(10); - } - } + // We are lacking an API for confirming flush request compaction. + // Just sleep for a short time. We won't be able to confirm flush + // completion but the test won't hang now or in the future if + // default compaction policy causes compaction between flush and + // when we go to confirm it. + Thread.sleep(1000); Put put1 = new Put(row1); byte[] value1 = Bytes.toBytes("1000dfsdf"); @@ -137,28 +136,16 @@ public class TestTags { // put1.setAttribute("visibility", Bytes.toBytes("myTag3")); table.put(put1); admin.flush(tableName.getName()); - regions = TEST_UTIL.getHBaseCluster().getRegions(tableName.getName()); - for (HRegion region : regions) { - Store store = region.getStore(fam); - while (!(store.getStorefilesCount() > 1)) { - Thread.sleep(10); - } - } + Thread.sleep(1000); Put put2 = new Put(row2); byte[] value2 = Bytes.toBytes("1000dfsdf"); put2.add(fam, qual, HConstants.LATEST_TIMESTAMP, value2); put2.setAttribute("visibility", Bytes.toBytes("myTag3")); table.put(put2); - admin.flush(tableName.getName()); - regions = TEST_UTIL.getHBaseCluster().getRegions(tableName.getName()); - for (HRegion region : regions) { - Store store = region.getStore(fam); - while (!(store.getStorefilesCount() > 2)) { - Thread.sleep(10); - } - } + Thread.sleep(1000); + result(fam, row, qual, row2, table, value, value2, row1, value1); admin.compact(tableName.getName()); while (admin.getCompactionState(tableName.getName()) != CompactionState.NONE) { @@ -201,40 +188,27 @@ public class TestTags { put.add(fam, qual, HConstants.LATEST_TIMESTAMP, value); table.put(put); admin.flush(tableName.getName()); - List<HRegion> regions = TEST_UTIL.getHBaseCluster().getRegions(tableName.getName()); - for (HRegion region : regions) { - Store store = region.getStore(fam); - while (!(store.getStorefilesCount() > 0)) { - Thread.sleep(10); - } - } + // We are lacking an API for confirming flush request compaction. + // Just sleep for a short time. We won't be able to confirm flush + // completion but the test won't hang now or in the future if + // default compaction policy causes compaction between flush and + // when we go to confirm it. + Thread.sleep(1000); Put put1 = new Put(row1); byte[] value1 = Bytes.toBytes("1000dfsdf"); put1.add(fam, qual, HConstants.LATEST_TIMESTAMP, value1); table.put(put1); admin.flush(tableName.getName()); - regions = TEST_UTIL.getHBaseCluster().getRegions(tableName.getName()); - for (HRegion region : regions) { - Store store = region.getStore(fam); - while (!(store.getStorefilesCount() > 1)) { - Thread.sleep(10); - } - } + Thread.sleep(1000); Put put2 = new Put(row2); byte[] value2 = Bytes.toBytes("1000dfsdf"); put2.add(fam, qual, HConstants.LATEST_TIMESTAMP, value2); table.put(put2); - admin.flush(tableName.getName()); - regions = TEST_UTIL.getHBaseCluster().getRegions(tableName.getName()); - for (HRegion region : regions) { - Store store = region.getStore(fam); - while (!(store.getStorefilesCount() > 2)) { - Thread.sleep(10); - } - } + Thread.sleep(1000); + Scan s = new Scan(row); ResultScanner scanner = table.getScanner(s); try { @@ -312,26 +286,20 @@ public class TestTags { put1.add(fam, qual, HConstants.LATEST_TIMESTAMP, value1); table.put(put1); admin.flush(tableName.getName()); - List<HRegion> regions = TEST_UTIL.getHBaseCluster().getRegions(tableName.getName()); - for (HRegion region : regions) { - Store store = region.getStore(fam); - while (!(store.getStorefilesCount() > 0)) { - Thread.sleep(10); - } - } + // We are lacking an API for confirming flush request compaction. + // Just sleep for a short time. We won't be able to confirm flush + // completion but the test won't hang now or in the future if + // default compaction policy causes compaction between flush and + // when we go to confirm it. + Thread.sleep(1000); put1 = new Put(row2); value1 = Bytes.toBytes("1000dfsdf"); put1.add(fam, qual, HConstants.LATEST_TIMESTAMP, value1); table.put(put1); admin.flush(tableName.getName()); - regions = TEST_UTIL.getHBaseCluster().getRegions(tableName.getName()); - for (HRegion region : regions) { - Store store = region.getStore(fam); - while (!(store.getStorefilesCount() > 1)) { - Thread.sleep(10); - } - } + Thread.sleep(1000); + Put put2 = new Put(rowd); byte[] value2 = Bytes.toBytes("1000dfsdf"); put2.add(fam, qual, HConstants.LATEST_TIMESTAMP, value2); @@ -342,13 +310,8 @@ public class TestTags { put.setAttribute("visibility", Bytes.toBytes("ram")); table.put(put2); admin.flush(tableName.getName()); - regions = TEST_UTIL.getHBaseCluster().getRegions(tableName.getName()); - for (HRegion region : regions) { - Store store = region.getStore(fam); - while (!(store.getStorefilesCount() > 2)) { - Thread.sleep(10); - } - } + Thread.sleep(1000); + TestCoprocessorForTags.checkTagPresence = true; Scan s = new Scan(row); s.setCaching(1);
