Repository: hbase
Updated Branches:
  refs/heads/master 8eaaa6311 -> b8134fe5b


HBASE-21221 Ineffective assertion in TestFromClientSide3#testMultiRowMutations


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

Branch: refs/heads/master
Commit: b8134fe5b6ce4a411c79d5bd63404906bf174c3d
Parents: 8eaaa63
Author: tedyu <[email protected]>
Authored: Tue Sep 25 09:17:26 2018 -0700
Committer: tedyu <[email protected]>
Committed: Tue Sep 25 09:17:26 2018 -0700

----------------------------------------------------------------------
 .../hbase/client/TestFromClientSide3.java       | 21 +++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/b8134fe5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java
index fad4f45..aa5bfb0 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java
@@ -35,6 +35,7 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.Cell;
@@ -829,8 +830,8 @@ public class TestFromClientSide3 {
         }
       });
       ExecutorService cpService = Executors.newSingleThreadExecutor();
+      AtomicBoolean exceptionDuringMutateRows = new AtomicBoolean();
       cpService.execute(() -> {
-        boolean threw;
         Put put1 = new Put(row);
         Put put2 = new Put(rowLocked);
         put1.addColumn(FAMILY, QUALIFIER, value1);
@@ -844,26 +845,25 @@ public class TestFromClientSide3 {
                       
org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.MutationType.PUT,
 put2))
               .build();
           
table.coprocessorService(MultiRowMutationProtos.MultiRowMutationService.class,
-            ROW, ROW,
+              ROW, ROW,
             (MultiRowMutationProtos.MultiRowMutationService exe) -> {
               ServerRpcController controller = new ServerRpcController();
               
CoprocessorRpcUtils.BlockingRpcCallback<MultiRowMutationProtos.MutateRowsResponse>
                 rpcCallback = new CoprocessorRpcUtils.BlockingRpcCallback<>();
               exe.mutateRows(controller, request, rpcCallback);
+              if (controller.failedOnException()) {
+                exceptionDuringMutateRows.set(true);
+              }
               return rpcCallback.get();
             });
-          threw = false;
         } catch (Throwable ex) {
-          threw = true;
-        }
-        if (!threw) {
-          // Can't call fail() earlier because the catch would eat it.
-          fail("This cp should fail because the target lock is blocked by 
previous put");
+          LOG.error("encountered " + ex);
         }
       });
       cpService.shutdown();
       cpService.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);
-      WaitingForMultiMutationsObserver observer = find(tableName, 
WaitingForMultiMutationsObserver.class);
+      WaitingForMultiMutationsObserver observer = find(tableName,
+          WaitingForMultiMutationsObserver.class);
       observer.latch.countDown();
       putService.shutdown();
       putService.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);
@@ -877,6 +877,9 @@ public class TestFromClientSide3 {
         assertTrue(Bytes.equals(r1.getValue(FAMILY, QUALIFIER), value0));
       }
       assertNoLocks(tableName);
+      if (!exceptionDuringMutateRows.get()) {
+        fail("This cp should fail because the target lock is blocked by 
previous put");
+      }
     }
   }
 

Reply via email to