hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject hbase git commit: HBASE-18902 TestCoprocessorServiceBackwardCompatibility fails
Date Tue, 03 Oct 2017 20:48:54 GMT
Repository: hbase
Updated Branches:
  refs/heads/master 2ad7be24a -> c205b5b5e


HBASE-18902 TestCoprocessorServiceBackwardCompatibility fails


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

Branch: refs/heads/master
Commit: c205b5b5ed873a2c503915aa70267ef2800f4d20
Parents: 2ad7be2
Author: tedyu <yuzhihong@gmail.com>
Authored: Tue Oct 3 13:48:46 2017 -0700
Committer: tedyu <yuzhihong@gmail.com>
Committed: Tue Oct 3 13:48:46 2017 -0700

----------------------------------------------------------------------
 .../protobuf/DummyRegionServerEndpoint.proto    |  1 +
 ...CoprocessorServiceBackwardCompatibility.java | 64 +++++++++++---------
 2 files changed, 36 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/c205b5b5/hbase-endpoint/src/main/protobuf/DummyRegionServerEndpoint.proto
----------------------------------------------------------------------
diff --git a/hbase-endpoint/src/main/protobuf/DummyRegionServerEndpoint.proto b/hbase-endpoint/src/main/protobuf/DummyRegionServerEndpoint.proto
index 539f7da..8894718 100644
--- a/hbase-endpoint/src/main/protobuf/DummyRegionServerEndpoint.proto
+++ b/hbase-endpoint/src/main/protobuf/DummyRegionServerEndpoint.proto
@@ -25,6 +25,7 @@ option java_generic_services = true;
 option java_generate_equals_and_hash = true;
 
 message DummyRequest {
+  optional uint64 value = 1;
 }
 
 message DummyResponse {

http://git-wip-us.apache.org/repos/asf/hbase/blob/c205b5b5/hbase-endpoint/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorServiceBackwardCompatibility.java
----------------------------------------------------------------------
diff --git a/hbase-endpoint/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorServiceBackwardCompatibility.java
b/hbase-endpoint/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorServiceBackwardCompatibility.java
index c2ff36e..c51da81 100644
--- a/hbase-endpoint/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorServiceBackwardCompatibility.java
+++ b/hbase-endpoint/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorServiceBackwardCompatibility.java
@@ -43,9 +43,19 @@ public class TestCoprocessorServiceBackwardCompatibility {
   private static HBaseTestingUtility TEST_UTIL = null;
   private static Configuration CONF = null;
 
+  private static final long MASTER = 1;
+  private static final long REGIONSERVER = 2;
+  private static final long REGION = 3;
+
   public static class DummyCoprocessorService extends DummyService
       implements CoprocessorService, SingletonCoprocessorService {
-    static int numCalls = 0;
+    // depending on the value passed thru DummyRequest, the following fields would be incremented
+    // value == MASTER
+    static int numMaster = 0;
+    // value == REGIONSERVER
+    static int numRegionServer = 0;
+    // value == REGION
+    static int numRegion = 0;
 
     @Override
     public Service getService() {
@@ -56,7 +66,13 @@ public class TestCoprocessorServiceBackwardCompatibility {
     public void dummyCall(RpcController controller, DummyRequest request,
         RpcCallback<DummyResponse> callback) {
       callback.run(DummyResponse.newBuilder().setValue("").build());
-      numCalls++;
+      if (request.getValue() == MASTER) {
+        numMaster += request.getValue();
+      } else if (request.getValue() == REGIONSERVER) {
+        numRegionServer += request.getValue();
+      } else if (request.getValue() == REGION) {
+        numRegion += request.getValue();
+      }
     }
 
     @Override
@@ -69,48 +85,38 @@ public class TestCoprocessorServiceBackwardCompatibility {
   public static void setupBeforeClass() throws Exception {
     TEST_UTIL = new HBaseTestingUtility();
     CONF = TEST_UTIL.getConfiguration();
-    DummyCoprocessorService.numCalls = 0;
+    CONF.setStrings(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY,
+        DummyCoprocessorService.class.getName());
+    CONF.setStrings(CoprocessorHost.REGIONSERVER_COPROCESSOR_CONF_KEY,
+        DummyCoprocessorService.class.getName());
+    CONF.setStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
+        DummyCoprocessorService.class.getName());
+    TEST_UTIL.startMiniCluster();
   }
 
   @AfterClass
-  public static void tearDownAfterClass() throws Exception {
+  public static void tearDownAfter() throws Exception {
     TEST_UTIL.shutdownMiniCluster();
   }
 
   @Test
-  public void testCoprocessorServiceLoadedByMaster() throws Exception {
-    CONF.setStrings(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY,
-        DummyCoprocessorService.class.getName());
-    TEST_UTIL.startMiniCluster();
-
+  public void testCoprocessorServiceLoadedByMaster() throws Throwable {
     TEST_UTIL.getAdmin().coprocessorService().callBlockingMethod(
             DummyCoprocessorService.getDescriptor().findMethodByName("dummyCall"), null,
-        DummyRequest.getDefaultInstance(), DummyResponse.getDefaultInstance());
+            DummyRequest.newBuilder().setValue(MASTER).build(), DummyResponse.getDefaultInstance());
+    assertEquals(MASTER, DummyCoprocessorService.numMaster);
 
-    assertEquals(1, DummyCoprocessorService.numCalls);
-  }
-
-  @Test
-  public void testCoprocessorServiceLoadedByRegionServer() throws Exception {
-    CONF.setStrings(CoprocessorHost.REGIONSERVER_COPROCESSOR_CONF_KEY,
-        DummyCoprocessorService.class.getName());
-    TEST_UTIL.startMiniCluster();
     TEST_UTIL.getAdmin().coprocessorService(
         TEST_UTIL.getHBaseCluster().getRegionServer(0).getServerName()).callBlockingMethod(
             DummyCoprocessorService.getDescriptor().findMethodByName("dummyCall"), null,
-        DummyRequest.getDefaultInstance(), DummyResponse.getDefaultInstance());
-    assertEquals(1, DummyCoprocessorService.numCalls);
-  }
+            DummyRequest.newBuilder().setValue(REGIONSERVER).build(),
+            DummyResponse.getDefaultInstance());
+    assertEquals(REGIONSERVER, DummyCoprocessorService.numRegionServer);
 
-  @Test
-  public void testCoprocessorServiceLoadedByRegion() throws Throwable {
-    CONF.setStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
-        DummyCoprocessorService.class.getName());
-    TEST_UTIL.startMiniCluster();
     TEST_UTIL.getConnection().getTable(TableName.valueOf("hbase:meta")).batchCoprocessorService(
-            DummyCoprocessorService.getDescriptor().findMethodByName("dummyCall"),
-        DummyRequest.getDefaultInstance(), Bytes.toBytes(""), Bytes.toBytes(""),
+        DummyCoprocessorService.getDescriptor().findMethodByName("dummyCall"),
+        DummyRequest.newBuilder().setValue(REGION).build(), Bytes.toBytes(""), Bytes.toBytes(""),
         DummyResponse.getDefaultInstance());
-    assertEquals(1, DummyCoprocessorService.numCalls);
+    assertEquals(REGION, DummyCoprocessorService.numRegion);
   }
 }


Mime
View raw message