From a5408fc0e758ac61f9c81ee87da5cf1feb58c4c2 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Sat, 19 Jun 2010 19:00:41 +0000 Subject: [PATCH] HBASE-2624 TestMultiParallelPuts flaky on trunk git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@956270 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop/hbase/TestMultiParallelPut.java | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/test/java/org/apache/hadoop/hbase/TestMultiParallelPut.java b/src/test/java/org/apache/hadoop/hbase/TestMultiParallelPut.java index 43924e87b2b..1727930b858 100644 --- a/src/test/java/org/apache/hadoop/hbase/TestMultiParallelPut.java +++ b/src/test/java/org/apache/hadoop/hbase/TestMultiParallelPut.java @@ -20,6 +20,8 @@ package org.apache.hadoop.hbase; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.hadoop.hbase.client.Get; import org.apache.hadoop.hbase.client.HBaseAdmin; import org.apache.hadoop.hbase.client.HTable; @@ -31,6 +33,7 @@ import java.util.ArrayList; import java.util.List; public class TestMultiParallelPut extends MultiRegionTable { + final Log LOG = LogFactory.getLog(getClass()); private static final byte[] VALUE = Bytes.toBytes("value"); private static final byte[] QUALIFIER = Bytes.toBytes("qual"); private static final String FAMILY = "family"; @@ -42,7 +45,6 @@ public class TestMultiParallelPut extends MultiRegionTable { super(2, FAMILY); desc = new HTableDescriptor(TEST_TABLE); desc.addFamily(new HColumnDescriptor(FAMILY)); - makeKeys(); } @@ -51,7 +53,6 @@ public class TestMultiParallelPut extends MultiRegionTable { byte [] cp = new byte[k.length+1]; System.arraycopy(k, 0, cp, 0, k.length); cp[k.length] = 1; - keys.add(cp); } } @@ -59,35 +60,33 @@ public class TestMultiParallelPut extends MultiRegionTable { List keys = new ArrayList(); public void testParallelPut() throws Exception { + LOG.info("Starting testParallelPut"); doATest(false); } + public void testParallelPutWithRSAbort() throws Exception { + LOG.info("Starting testParallelPutWithRSAbort"); doATest(true); } public void doATest(boolean doAbort) throws Exception { - HTable table = new HTable(TEST_TABLE); table.setAutoFlush(false); table.setWriteBufferSize(10 * 1024 * 1024); - for ( byte [] k : keys ) { Put put = new Put(k); put.add(BYTES_FAMILY, QUALIFIER, VALUE); - table.put(put); } - table.flushCommits(); if (doAbort) { + LOG.info("Aborting..."); cluster.abortRegionServer(0); - // try putting more keys after the abort. for ( byte [] k : keys ) { Put put = new Put(k); put.add(BYTES_FAMILY, QUALIFIER, VALUE); - table.put(put); } table.flushCommits(); @@ -96,9 +95,7 @@ public class TestMultiParallelPut extends MultiRegionTable { for (byte [] k : keys ) { Get get = new Get(k); get.addColumn(BYTES_FAMILY, QUALIFIER); - Result r = table.get(get); - assertTrue(r.containsColumn(BYTES_FAMILY, QUALIFIER)); assertEquals(0, Bytes.compareTo(VALUE, @@ -107,16 +104,13 @@ public class TestMultiParallelPut extends MultiRegionTable { HBaseAdmin admin = new HBaseAdmin(conf); ClusterStatus cs = admin.getClusterStatus(); - int expectedServerCount = 2; - if (doAbort) - expectedServerCount = 1; - + if (doAbort) expectedServerCount = 1; + LOG.info("Clusterstatus servers count " + cs.getServers()); assertEquals(expectedServerCount, cs.getServers()); for ( HServerInfo info : cs.getServerInfo()) { - System.out.println(info); - assertTrue( info.getLoad().getNumberOfRegions() > 10); + LOG.info("Info from clusterstatus=" + info); + assertTrue(info.getLoad().getNumberOfRegions() > 8); } } - -} +} \ No newline at end of file