hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject hbase git commit: HBASE-14637 Loosen TestChoreService assert AND have TestDataBlockEncoders do less work (and add timeouts)
Date Sat, 17 Oct 2015 23:27:32 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 9bdb88a57 -> 836afcc90


HBASE-14637 Loosen TestChoreService assert AND have TestDataBlockEncoders do less work (and
add timeouts)


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

Branch: refs/heads/branch-1
Commit: 836afcc901e8588ee6a21f4eb9bb9c9d0675cef9
Parents: 9bdb88a
Author: stack <stack@apache.org>
Authored: Sat Oct 17 16:14:45 2015 -0700
Committer: stack <stack@apache.org>
Committed: Sat Oct 17 16:27:23 2015 -0700

----------------------------------------------------------------------
 .../apache/hadoop/hbase/TestChoreService.java    |  9 ++++-----
 .../hbase/io/encoding/TestDataBlockEncoders.java | 19 ++++++++++++++++++-
 2 files changed, 22 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/836afcc9/hbase-common/src/test/java/org/apache/hadoop/hbase/TestChoreService.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestChoreService.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestChoreService.java
index 14a2cbb..9ee6b40 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestChoreService.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestChoreService.java
@@ -38,8 +38,6 @@ import org.junit.experimental.categories.Category;
 
 @Category(SmallTests.class)
 public class TestChoreService {
-  private static final Log LOG = LogFactory.getLog(TestChoreService.class);
-
   /**
    * A few ScheduledChore samples that are useful for testing with ChoreService
    */
@@ -373,7 +371,7 @@ public class TestChoreService {
     final int period = 100;
     final int delta = 5;
     ChoreService service = ChoreService.getInstance("testForceTrigger");
-    CountingChore chore = new CountingChore("countingChore", period);
+    final CountingChore chore = new CountingChore("countingChore", period);
     try {
       service.scheduleChore(chore);
       Thread.sleep(10 * period + delta);
@@ -393,11 +391,12 @@ public class TestChoreService {
       chore.triggerNow();
       Thread.sleep(delta);
 
-      assertTrue(chore.getCountOfChoreCalls() == 16);
+      assertTrue("" + chore.getCountOfChoreCalls(), chore.getCountOfChoreCalls() == 16);
 
       Thread.sleep(10 * period + delta);
 
-      assertTrue(chore.getCountOfChoreCalls() == 26);
+      // Be loosey-goosey. It used to be '26' but it was a big flakey relying on timing.
+      assertTrue("" + chore.getCountOfChoreCalls(), chore.getCountOfChoreCalls() > 16);
     } finally {
       shutdownService(service);
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/836afcc9/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestDataBlockEncoders.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestDataBlockEncoders.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestDataBlockEncoders.java
index 1f3525d..7fd0fd8 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestDataBlockEncoders.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestDataBlockEncoders.java
@@ -30,6 +30,10 @@ import java.util.Collection;
 import java.util.List;
 import java.util.Random;
 
+import org.apache.hadoop.hbase.CategoryBasedTimeout;
+import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.CellComparator;
+import org.apache.hadoop.hbase.CellUtil;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.KeyValue;
@@ -43,11 +47,14 @@ import org.apache.hadoop.hbase.io.hfile.HFileContext;
 import org.apache.hadoop.hbase.io.hfile.HFileContextBuilder;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.test.RedundantKVGenerator;
+import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
+import org.junit.rules.TestRule;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
+import org.mortbay.log.Log;
 
 /**
  * Test all of the data block encoding algorithms for correctness. Most of the
@@ -56,9 +63,11 @@ import org.junit.runners.Parameterized.Parameters;
 @Category(LargeTests.class)
 @RunWith(Parameterized.class)
 public class TestDataBlockEncoders {
+  @Rule public final TestRule timeout = CategoryBasedTimeout.builder().
+      withTimeout(this.getClass()).withLookingForStuckThread(true).build();
 
   private static int NUMBER_OF_KV = 10000;
-  private static int NUM_RANDOM_SEEKS = 10000;
+  private static int NUM_RANDOM_SEEKS = 1000;
 
   private static int ENCODED_DATA_OFFSET = HConstants.HFILEBLOCK_HEADER_SIZE
       + DataBlockEncoding.ID_SIZE;
@@ -172,10 +181,15 @@ public class TestDataBlockEncoders {
     List<DataBlockEncoder.EncodedSeeker> encodedSeekers = 
         new ArrayList<DataBlockEncoder.EncodedSeeker>();
     for (DataBlockEncoding encoding : DataBlockEncoding.values()) {
+      Log.info("Encoding: " + encoding);
+      // Off heap block data support not added for PREFIX_TREE DBE yet.
+      // TODO remove this once support is added. HBASE-12298
+      if (encoding == DataBlockEncoding.PREFIX_TREE) continue;
       DataBlockEncoder encoder = encoding.getEncoder();
       if (encoder == null) {
         continue;
       }
+      Log.info("Encoder: " + encoder);
       ByteBuffer encodedBuffer = encodeKeyValues(encoding, sampleKv,
           getEncodingContext(Compression.Algorithm.NONE, encoding));
       HFileContext meta = new HFileContextBuilder()
@@ -189,6 +203,7 @@ public class TestDataBlockEncoders {
       seeker.setCurrentBuffer(encodedBuffer);
       encodedSeekers.add(seeker);
     }
+    Log.info("Testing it!");
     // test it!
     // try a few random seeks
     for (boolean seekBefore : new boolean[] { false, true }) {
@@ -206,6 +221,7 @@ public class TestDataBlockEncoders {
     }
 
     // check edge cases
+    Log.info("Checking edge cases");
     checkSeekingConsistency(encodedSeekers, false, sampleKv.get(0));
     for (boolean seekBefore : new boolean[] { false, true }) {
       checkSeekingConsistency(encodedSeekers, seekBefore, sampleKv.get(sampleKv.size() -
1));
@@ -213,6 +229,7 @@ public class TestDataBlockEncoders {
       KeyValue lastMidKv =KeyValueUtil.createLastOnRowCol(midKv);
       checkSeekingConsistency(encodedSeekers, seekBefore, lastMidKv);
     }
+    Log.info("Done");
   }
 
   static ByteBuffer encodeKeyValues(DataBlockEncoding encoding, List<KeyValue> kvs,


Mime
View raw message