diff --git src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java index d3cab72..8ec1cfe 100644 --- src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java +++ src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java @@ -88,6 +88,7 @@ import org.apache.hadoop.hbase.regionserver.HRegionServer; import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException; import org.apache.hadoop.hbase.regionserver.Store; import org.apache.hadoop.hbase.util.Bytes; +import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.hadoop.hbase.util.Threads; import org.apache.hadoop.io.DataInputBuffer; import org.junit.After; @@ -4137,7 +4138,7 @@ public class TestFromClientSide { assertEquals(0, Bytes.compareTo(Bytes.add(v1,v2), r.getValue(FAMILY, QUALIFIERS[0]))); assertEquals(0, Bytes.compareTo(Bytes.add(v2,v1), r.getValue(FAMILY, QUALIFIERS[1]))); } - + @Test public void testIncrementWithDeletes() throws Exception { LOG.info("Starting testIncrementWithDeletes"); @@ -4305,6 +4306,10 @@ public class TestFromClientSide { threads.get(1).join(); assertEquals(2, pool.getPoolSize()); + //ensure that ThreadPoolExecutor knows that threads are finished. + while (pool.getCompletedTaskCount() < 2) { + Threads.sleep(1); + } // Now let's simulate adding a RS meaning that we'll go up to three // concurrent threads. The pool should not grow larger than three. pool.submit(threads.get(2)); @@ -4329,14 +4334,15 @@ public class TestFromClientSide { HTable table = TEST_UTIL.createTable(tableName, new byte[][] { FAMILY }, conf, Integer.MAX_VALUE); table.setAutoFlush(true); - Put put = new Put(ROW); - put.add(FAMILY, QUALIFIER, VALUE); + final long ts = EnvironmentEdgeManager.currentTimeMillis(); Get get = new Get(ROW); get.addColumn(FAMILY, QUALIFIER); get.setMaxVersions(); for (int versions = 1; versions <= numVersions; versions++) { + Put put = new Put(ROW); + put.add(FAMILY, QUALIFIER, ts + versions, VALUE); table.put(put); Result result = table.get(get); @@ -4366,14 +4372,15 @@ public class TestFromClientSide { final HTable table = TEST_UTIL.createTable(tableName, new byte[][] { FAMILY }, conf); table.setAutoFlush(true); - final Put put = new Put(ROW); - put.add(FAMILY, QUALIFIER, VALUE); + final long ts = EnvironmentEdgeManager.currentTimeMillis(); final Get get = new Get(ROW); get.addColumn(FAMILY, QUALIFIER); get.setMaxVersions(); for (int versions = 1; versions <= numVersions; versions++) { + Put put = new Put(ROW); + put.add(FAMILY, QUALIFIER, ts + versions, VALUE); table.put(put); Result result = table.get(get); @@ -4398,6 +4405,8 @@ public class TestFromClientSide { @Override public Void call() { try { + Put put = new Put(ROW); + put.add(FAMILY, QUALIFIER, ts + versionsCopy, VALUE); table.put(put); Result result = table.get(get); @@ -4526,7 +4535,7 @@ public class TestFromClientSide { assertEquals("Did not access all the regions in the table", numOfRegions, scanMetrics.countOfRegions.getCurrentIntervalValue()); - // now, test that the metrics are still collected even if you don't call close, but do + // now, test that the metrics are still collected even if you don't call close, but do // run past the end of all the records Scan scanWithoutClose = new Scan(); scanWithoutClose.setAttribute(Scan.SCAN_ATTRIBUTES_METRICS_ENABLE, Bytes.toBytes(Boolean.TRUE)); @@ -4729,7 +4738,7 @@ public class TestFromClientSide { assertNotNull(addrAfter); assertTrue(addrAfter.getPort() != addrCache.getPort()); assertEquals(addrAfter.getPort(), addrNoCache.getPort()); - } + } @Test /**