You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by jy...@apache.org on 2014/12/20 04:14:23 UTC

hbase git commit: HBASE-12703 Cleanup TestClientPushback for repeatability

Repository: hbase
Updated Branches:
  refs/heads/master feede7abd -> e267db45a


HBASE-12703 Cleanup TestClientPushback for repeatability


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/e267db45
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/e267db45
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/e267db45

Branch: refs/heads/master
Commit: e267db45ac1dca0b56ca562d6407f16ee1f68ab2
Parents: feede7a
Author: Jesse Yates <jy...@apache.org>
Authored: Fri Dec 19 19:16:43 2014 -0800
Committer: Jesse Yates <jy...@apache.org>
Committed: Fri Dec 19 19:16:43 2014 -0800

----------------------------------------------------------------------
 .../hadoop/hbase/client/TestClientPushback.java | 28 +++++++++++++-------
 1 file changed, 18 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/e267db45/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientPushback.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientPushback.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientPushback.java
index 9bb4dc1..d8bf57b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientPushback.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientPushback.java
@@ -17,9 +17,13 @@
  */
 package org.apache.hadoop.hbase.client;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.*;
 import org.apache.hadoop.hbase.client.backoff.ServerStatistics;
+import org.apache.hadoop.hbase.regionserver.HRegion;
+import org.apache.hadoop.hbase.regionserver.HRegionServer;
 import org.apache.hadoop.hbase.testclassification.MediumTests;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.junit.AfterClass;
@@ -36,6 +40,7 @@ import static org.junit.Assert.assertNotNull;
 @Category(MediumTests.class)
 public class TestClientPushback {
 
+  private static final Log LOG = LogFactory.getLog(TestClientPushback.class);
   private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
 
   private static final byte[] tableName = Bytes.toBytes("client-pushback");
@@ -54,7 +59,7 @@ public class TestClientPushback {
     // ensure we block the flushes when we are double that flushsize
     conf.setLong("hbase.hregion.memstore.block.multiplier", 2);
 
-    UTIL.startMiniCluster();
+    UTIL.startMiniCluster(1);
     UTIL.createTable(tableName, family);
   }
 
@@ -69,29 +74,32 @@ public class TestClientPushback {
     TableName tablename = TableName.valueOf(tableName);
     Connection conn = ConnectionFactory.createConnection(conf);
     HTable table = (HTable) conn.getTable(tablename);
-    //make sure we flush after each put
-    table.setAutoFlushTo(true);
 
+    HRegionServer rs = UTIL.getHBaseCluster().getRegionServer(0);
+    HRegion region = rs.getOnlineRegions(tablename).get(0);
+
+    LOG.debug("Writing some data to "+tablename);
     // write some data
     Put p = new Put(Bytes.toBytes("row"));
     p.add(family, qualifier, Bytes.toBytes("value1"));
     table.put(p);
+    table.flushCommits();
+
+    // get the current load on RS. Hopefully memstore isn't flushed since we wrote the the data
+    int load = (int)((region.addAndGetGlobalMemstoreSize(0) * 100) / flushSizeBytes);
+    LOG.debug("Done writing some data to "+tablename);
 
     // get the stats for the region hosting our table
     ClusterConnection connection = table.connection;
     ServerStatisticTracker stats = connection.getStatisticsTracker();
     assertNotNull( "No stats configured for the client!", stats);
     // get the names so we can query the stats
-    ServerName server = UTIL.getHBaseCluster().getRegionServer(0).getServerName();
-    byte[] regionName = UTIL.getHBaseCluster().getRegionServer(0).getOnlineRegions(tablename).get
-        (0).getRegionName();
+    ServerName server = rs.getServerName();
+    byte[] regionName = region.getRegionName();
 
     // check to see we found some load on the memstore
     ServerStatistics serverStats = stats.getServerStatsForTesting(server);
     ServerStatistics.RegionStatistics regionStats = serverStats.getStatsForRegion(regionName);
-    int load = regionStats.getMemstoreLoadPercent();
-    if (load < 11) {
-      assertEquals("Load on memstore too low", 11, load);
-    }
+    assertEquals(load, regionStats.getMemstoreLoadPercent());
   }
 }
\ No newline at end of file