HBASE-6715 TestFromClientSide.testCacheOnWriteEvictOnClose is flaky

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1381671 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
jxiang 2012-09-06 16:38:37 +00:00
parent f89a1b58ed
commit 82d9956a7a
1 changed files with 25 additions and 7 deletions

View File

@ -39,6 +39,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -61,13 +62,11 @@ import org.apache.hadoop.hbase.filter.RegexStringComparator;
import org.apache.hadoop.hbase.filter.RowFilter;
import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;
import org.apache.hadoop.hbase.filter.WhileMatchFilter;
import org.apache.hadoop.hbase.generated.master.table_jsp;
import org.apache.hadoop.hbase.io.hfile.BlockCache;
import org.apache.hadoop.hbase.io.hfile.CacheConfig;
import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.regionserver.HRegionServer;
import org.apache.hadoop.hbase.regionserver.Store;
import org.apache.hadoop.hbase.regionserver.HStore;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
import org.apache.hadoop.io.DataInputBuffer;
@ -87,6 +86,7 @@ import static org.junit.Assert.*;
* Each creates a table named for the method and does its stuff against that.
*/
@Category(LargeTests.class)
@SuppressWarnings ("deprecation")
public class TestFromClientSide {
final Log LOG = LogFactory.getLog(getClass());
protected final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
@ -4477,8 +4477,8 @@ public class TestFromClientSide {
}
final Object waitLock = new Object();
ExecutorService executorService = Executors.newFixedThreadPool(numVersions);
final AtomicReference<AssertionError> error = new AtomicReference<AssertionError>(null);
for (int versions = numVersions; versions < numVersions * 2; versions++) {
final int versionsCopy = versions;
executorService.submit(new Callable<Void>() {
@ -4503,6 +4503,11 @@ public class TestFromClientSide {
waitLock.wait();
}
} catch (Exception e) {
} catch (AssertionError e) {
// the error happens in a thread, it won't fail the test,
// need to pass it to the caller for proper handling.
error.set(e);
LOG.error(e);
}
return null;
@ -4513,9 +4518,9 @@ public class TestFromClientSide {
waitLock.notifyAll();
}
executorService.shutdownNow();
assertNull(error.get());
}
@Test
public void testCheckAndPut() throws IOException {
final byte [] anotherrow = Bytes.toBytes("anotherrow");
@ -4561,6 +4566,7 @@ public class TestFromClientSide {
* @throws Exception
*/
@Test
@SuppressWarnings ("unused")
public void testScanMetrics() throws Exception {
byte [] TABLENAME = Bytes.toBytes("testScanMetrics");
@ -4629,7 +4635,6 @@ public class TestFromClientSide {
ScanMetrics scanMetricsWithClose = getScanMetrics(scanWithClose);
assertEquals("Did not access all the regions in the table", numOfRegions,
scanMetricsWithClose.countOfRegions.getCurrentIntervalValue());
}
private ScanMetrics getScanMetrics(Scan scan) throws Exception {
@ -4670,6 +4675,20 @@ public class TestFromClientSide {
long startBlockCount = cache.getBlockCount();
long startBlockHits = cache.getStats().getHitCount();
long startBlockMiss = cache.getStats().getMissCount();
// wait till baseline is stable, (minimal 500 ms)
for (int i = 0; i < 5; i++) {
Thread.sleep(100);
if (startBlockCount != cache.getBlockCount()
|| startBlockHits != cache.getStats().getHitCount()
|| startBlockMiss != cache.getStats().getMissCount()) {
startBlockCount = cache.getBlockCount();
startBlockHits = cache.getStats().getHitCount();
startBlockMiss = cache.getStats().getMissCount();
i = -1;
}
}
// insert data
Put put = new Put(ROW);
put.add(FAMILY, QUALIFIER, data);
@ -4812,7 +4831,6 @@ public class TestFromClientSide {
HTable table = TEST_UTIL.createTable(TABLE, new byte[][] {FAMILY}, 10);
int numOfRegions = TEST_UTIL.createMultiRegions(table, FAMILY);
assertEquals(25, numOfRegions);
HBaseAdmin admin = new HBaseAdmin(TEST_UTIL.getConfiguration());
// Get the regions in this range
List<HRegionLocation> regionsList = table.getRegionsInRange(startKey,