hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject svn commit: r1556590 - in /hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor: TestRegionServerCoprocessorExceptionWithAbort.java TestRegionServerCoprocessorExceptionWithRemove.java
Date Wed, 08 Jan 2014 17:52:49 GMT
Author: apurtell
Date: Wed Jan  8 17:52:49 2014
New Revision: 1556590

URL: http://svn.apache.org/r1556590
Log:
HBASE-10292. TestRegionServerCoprocessorExceptionWithAbort fails occasionally

Modified:
    hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithAbort.java
    hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithRemove.java

Modified: hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithAbort.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithAbort.java?rev=1556590&r1=1556589&r2=1556590&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithAbort.java
(original)
+++ hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithAbort.java
Wed Jan  8 17:52:49 2014
@@ -49,9 +49,7 @@ import static org.junit.Assert.*;
 public class TestRegionServerCoprocessorExceptionWithAbort {
   static final Log LOG = LogFactory.getLog(TestRegionServerCoprocessorExceptionWithAbort.class);
   private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
-  private static final byte[] ROW = Bytes.toBytes("aaa");
-  private static final TableName TABLE_NAME =
-      TableName.valueOf("observed_table");
+  private static final TableName TABLE_NAME = TableName.valueOf("observed_table");
 
   @BeforeClass
   public static void setupBeforeClass() throws Exception {
@@ -83,30 +81,51 @@ public class TestRegionServerCoprocessor
 
     // Note which regionServer will abort (after put is attempted).
     final HRegionServer regionServer = TEST_UTIL.getRSForFirstRegionInTable(TEST_TABLE);
-    Put put = new Put(ROW);
-    put.add(TEST_FAMILY, ROW, ROW);
 
-    Assert.assertFalse("The region server should be available", regionServer.isAborted());
+    boolean threwIOE = false;
     try {
-      LOG.info("Running put " + put);
+      final byte[] ROW = Bytes.toBytes("aaa");
+      Put put = new Put(ROW);
+      put.add(TEST_FAMILY, ROW, ROW);
       table.put(put);
-      fail("The put should have failed, as the coprocessor is buggy");
-    } catch (IOException ignored) {
-      // Expected.
+      table.flushCommits();
+    } catch (IOException e) {
+      threwIOE = true;
+    } finally {
+      assertTrue("The regionserver should have thrown an exception", threwIOE);
     }
-    Assert.assertTrue("The region server should have aborted", regionServer.isAborted());
+
+    // Wait 10 seconds for the regionserver to abort: expected result is that
+    // it will abort.
+    boolean aborted = false;
+    for (int i = 0; i < 10; i++) {
+      aborted = regionServer.isAborted(); 
+      if (aborted) {
+        break;
+      }
+      try {
+        Thread.sleep(1000);
+      } catch (InterruptedException e) {
+        fail("InterruptedException while waiting for regionserver " +
+            "zk node to be deleted.");
+      }
+    }
+    Assert.assertTrue("The region server should have aborted", aborted);
     table.close();
   }
 
   public static class BuggyRegionObserver extends SimpleRegionObserver {
+    @SuppressWarnings("null")
     @Override
     public void prePut(final ObserverContext<RegionCoprocessorEnvironment> c,
                        final Put put, final WALEdit edit,
                        final Durability durability) {
-      TableName tableName =
-          c.getEnvironment().getRegion().getRegionInfo().getTable();
-      if (TABLE_NAME.equals(tableName) && Bytes.equals(put.getRow(), ROW)) {
-        throw new NullPointerException("Buggy coprocessor: " + put);
+      String tableName =
+          c.getEnvironment().getRegion().getRegionInfo().getTable().getNameAsString();
+      if (tableName.equals("observed_table")) {
+        // Trigger a NPE to fail the coprocessor
+        Integer i = null;
+        i = i + 1;
       }
     }
   }

Modified: hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithRemove.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithRemove.java?rev=1556590&r1=1556589&r2=1556590&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithRemove.java
(original)
+++ hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithRemove.java
Wed Jan  8 17:52:49 2014
@@ -25,7 +25,6 @@ import org.apache.hadoop.conf.Configurat
 import org.apache.hadoop.hbase.*;
 import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException;
 import org.apache.hadoop.hbase.client.Durability;
 import org.apache.hadoop.hbase.regionserver.HRegionServer;
 import org.apache.hadoop.hbase.util.Bytes;
@@ -55,6 +54,7 @@ public class TestRegionServerCoprocessor
       String tableName =
           c.getEnvironment().getRegion().getRegionInfo().getTable().getNameAsString();
       if (tableName.equals("observed_table")) {
+        // Trigger a NPE to fail the coprocessor
         Integer i = null;
         i = i + 1;
       }
@@ -100,33 +100,22 @@ public class TestRegionServerCoprocessor
     HRegionServer regionServer =
         TEST_UTIL.getRSForFirstRegionInTable(TEST_TABLE);
 
-    // same logic as {@link TestMasterCoprocessorExceptionWithRemove},
-    // but exception will be RetriesExhaustedWithDetailException rather
-    // than DoNotRetryIOException. The latter exception is what the RegionServer
-    // will have actually thrown, but the client will wrap this in a
-    // RetriesExhaustedWithDetailException.
-    // We will verify that "DoNotRetryIOException" appears in the text of the
-    // the exception's detailMessage.
-    boolean threwDNRE = false;
+    boolean threwIOE = false;
     try {
       final byte[] ROW = Bytes.toBytes("aaa");
       Put put = new Put(ROW);
       put.add(TEST_FAMILY, ROW, ROW);
       table.put(put);
-    } catch (RetriesExhaustedWithDetailsException e) {
-      // below, could call instead :
-      // startsWith("Failed 1 action: DoNotRetryIOException.")
-      // But that might be too brittle if client-side
-      // DoNotRetryIOException-handler changes its message.
-      assertTrue(e.getMessage().contains("DoNotRetryIOException"));
-      threwDNRE = true;
+      table.flushCommits();
+    } catch (IOException e) {
+      threwIOE = true;
     } finally {
-      assertTrue(threwDNRE);
+      assertTrue("The regionserver should have thrown an exception", threwIOE);
     }
 
-    // Wait 3 seconds for the regionserver to abort: expected result is that
+    // Wait 10 seconds for the regionserver to abort: expected result is that
     // it will survive and not abort.
-    for (int i = 0; i < 3; i++) {
+    for (int i = 0; i < 10; i++) {
       assertFalse(regionServer.isAborted());
       try {
         Thread.sleep(1000);



Mime
View raw message