This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git

commit a4088a60655633a6f49db4802b71c8cf76970a06
Author: liubao <bao....@huawei.com>
AuthorDate: Thu Apr 12 20:51:42 2018 +0800

    [SCB-481]Fix qps handler compatible issues due to assumption to schema ids 
not contains dot
---
 .../src/main/resources/microservice.yaml           |   2 +-
 .../qps/ConsumerQpsFlowControlHandler.java         |   3 +-
 .../qps/ProviderQpsFlowControlHandler.java         |   3 +-
 .../servicecomb/qps/QpsControllerManager.java      |  20 +-
 .../servicecomb/qps/QpsControllerManagerTest.java  | 309 ++++++++++++++++-----
 .../qps/TestConsumerQpsFlowControlHandler.java     |  12 +-
 .../qps/TestProviderQpsFlowControlHandler.java     |   6 +-
 7 files changed, 270 insertions(+), 85 deletions(-)

diff --git a/demo/demo-pojo/pojo-client/src/main/resources/microservice.yaml 
b/demo/demo-pojo/pojo-client/src/main/resources/microservice.yaml
index 30efc87..302c3d0 100644
--- a/demo/demo-pojo/pojo-client/src/main/resources/microservice.yaml
+++ b/demo/demo-pojo/pojo-client/src/main/resources/microservice.yaml
@@ -26,7 +26,7 @@ cse:
   handler:
     chain:
       Consumer:
-        default: bizkeeper-consumer,loadbalance
+        default: qps-flowcontrol-consumer,bizkeeper-consumer,loadbalance
   isolation:
     Consumer:
       enabled: false
diff --git 
a/handlers/handler-flowcontrol-qps/src/main/java/org/apache/servicecomb/qps/ConsumerQpsFlowControlHandler.java
 
b/handlers/handler-flowcontrol-qps/src/main/java/org/apache/servicecomb/qps/ConsumerQpsFlowControlHandler.java
index 101babc..bc82c6c 100644
--- 
a/handlers/handler-flowcontrol-qps/src/main/java/org/apache/servicecomb/qps/ConsumerQpsFlowControlHandler.java
+++ 
b/handlers/handler-flowcontrol-qps/src/main/java/org/apache/servicecomb/qps/ConsumerQpsFlowControlHandler.java
@@ -38,8 +38,7 @@ public class ConsumerQpsFlowControlHandler implements Handler 
{
       return;
     }
 
-    QpsController qpsController = qpsControllerMgr.getOrCreate(
-        invocation.getOperationMeta().getMicroserviceQualifiedName());
+    QpsController qpsController = 
qpsControllerMgr.getOrCreate(invocation.getMicroserviceName(), invocation);
     if (qpsController.isLimitNewRequest()) {
       // return http status 429
       CommonExceptionData errorData = new CommonExceptionData("rejected by qps 
flowcontrol");
diff --git 
a/handlers/handler-flowcontrol-qps/src/main/java/org/apache/servicecomb/qps/ProviderQpsFlowControlHandler.java
 
b/handlers/handler-flowcontrol-qps/src/main/java/org/apache/servicecomb/qps/ProviderQpsFlowControlHandler.java
index b81581f..d2ff0d8 100644
--- 
a/handlers/handler-flowcontrol-qps/src/main/java/org/apache/servicecomb/qps/ProviderQpsFlowControlHandler.java
+++ 
b/handlers/handler-flowcontrol-qps/src/main/java/org/apache/servicecomb/qps/ProviderQpsFlowControlHandler.java
@@ -41,8 +41,7 @@ public class ProviderQpsFlowControlHandler implements Handler 
{
     QpsController qpsController =
         StringUtils.isEmpty(microServiceName)
             ? qpsControllerMgr.getGlobalQpsController()
-            : qpsControllerMgr.getOrCreate(microServiceName + 
QpsControllerManager.SEPARATOR
-                + invocation.getOperationMeta().getSchemaQualifiedName());
+            : qpsControllerMgr.getOrCreate(microServiceName, invocation);
     if (isLimitNewRequest(qpsController, asyncResp)) {
       return;
     }
diff --git 
a/handlers/handler-flowcontrol-qps/src/main/java/org/apache/servicecomb/qps/QpsControllerManager.java
 
b/handlers/handler-flowcontrol-qps/src/main/java/org/apache/servicecomb/qps/QpsControllerManager.java
index 09a69ed..b2d25c1 100644
--- 
a/handlers/handler-flowcontrol-qps/src/main/java/org/apache/servicecomb/qps/QpsControllerManager.java
+++ 
b/handlers/handler-flowcontrol-qps/src/main/java/org/apache/servicecomb/qps/QpsControllerManager.java
@@ -19,8 +19,8 @@ package org.apache.servicecomb.qps;
 
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.regex.Pattern;
 
+import org.apache.servicecomb.core.Invocation;
 import org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -30,8 +30,6 @@ import com.netflix.config.DynamicProperty;
 public class QpsControllerManager {
   private static final Logger LOGGER = 
LoggerFactory.getLogger(QpsControllerManager.class);
 
-  private static final Pattern QUALIFIED_KEY_CHECKER = 
Pattern.compile("^[^.]+\\.[^.]+\\.[^.]+$");
-
   /**
    * Describe the relationship between configuration and qpsController.
    */
@@ -48,22 +46,22 @@ public class QpsControllerManager {
 
   private String configKeyPrefix;
 
-  public QpsController getOrCreate(String key) {
-    return qualifiedNameControllerMap.computeIfAbsent(key, this::create);
+  public QpsController getOrCreate(String microerviceName, Invocation 
invocation) {
+    return qualifiedNameControllerMap
+        .computeIfAbsent(microerviceName + SEPARATOR + 
invocation.getOperationMeta().getSchemaQualifiedName(), key -> {
+          return create(key, microerviceName, invocation);
+        });
   }
 
   /**
    * Create relevant qpsLimit dynamicProperty and watch the configuration 
change.
    * Search and return a valid qpsController.
    */
-  protected QpsController create(String qualifiedNameKey) {
-    if (!QUALIFIED_KEY_CHECKER.matcher(qualifiedNameKey).matches()) {
-      throw new IllegalArgumentException("Unexpected qualified name: [" + 
qualifiedNameKey + "]");
-    }
+  protected QpsController create(String qualifiedNameKey, String 
microerviceName, Invocation invocation) {
     // create "microservice"
-    createQpsControllerIfNotExist(qualifiedNameKey.substring(0, 
qualifiedNameKey.indexOf(SEPARATOR)));
+    createQpsControllerIfNotExist(microerviceName);
     // create "microservice.schema"
-    createQpsControllerIfNotExist(qualifiedNameKey.substring(0, 
qualifiedNameKey.lastIndexOf(SEPARATOR)));
+    createQpsControllerIfNotExist(qualifiedNameKey.substring(0, 
microerviceName.length() + invocation.getSchemaId().length() + 1));
     // create "microservice.schema.operation"
     createQpsControllerIfNotExist(qualifiedNameKey);
 
diff --git 
a/handlers/handler-flowcontrol-qps/src/test/java/org/apache/servicecomb/qps/QpsControllerManagerTest.java
 
b/handlers/handler-flowcontrol-qps/src/test/java/org/apache/servicecomb/qps/QpsControllerManagerTest.java
index 1837ff2..82c0d89 100644
--- 
a/handlers/handler-flowcontrol-qps/src/test/java/org/apache/servicecomb/qps/QpsControllerManagerTest.java
+++ 
b/handlers/handler-flowcontrol-qps/src/test/java/org/apache/servicecomb/qps/QpsControllerManagerTest.java
@@ -30,6 +30,8 @@ import org.junit.Test;
 import org.mockito.Mockito;
 
 import mockit.Deencapsulation;
+import mockit.Expectations;
+import mockit.Mocked;
 
 public class QpsControllerManagerTest {
 
@@ -44,125 +46,236 @@ public class QpsControllerManagerTest {
   }
 
   @Test
-  public void testGetOrCreate() {
+  public void testGetOrCreate(@Mocked Invocation invocation, @Mocked 
OperationMeta operationMeta) {
+    new Expectations() {
+      {
+        invocation.getOperationMeta();
+        result = operationMeta;
+        invocation.getSchemaId();
+        result = "server";
+        operationMeta.getSchemaQualifiedName();
+        result = "server.test";
+      }
+    };
     QpsControllerManager testQpsControllerManager = new QpsControllerManager()
         .setConfigKeyPrefix(Config.CONSUMER_LIMIT_KEY_PREFIX);
-    initTestQpsControllerManager(testQpsControllerManager);
+    initTestQpsControllerManager(testQpsControllerManager, invocation, 
operationMeta);
 
     // pojo
     setConfigWithDefaultPrefix("pojo", 100);
-    QpsController qpsController = 
testQpsControllerManager.getOrCreate("pojo.server.test");
+    QpsController qpsController = testQpsControllerManager.getOrCreate("pojo", 
invocation);
     Assert.assertEquals("pojo", qpsController.getKey());
     Assert.assertTrue(100 == qpsController.getQpsLimit());
-    qpsController = testQpsControllerManager.getOrCreate("pojo2.server.test");
+    qpsController = testQpsControllerManager.getOrCreate("pojo2", invocation);
     Assert.assertEquals("pojo2", qpsController.getKey());
     Assert.assertNull(qpsController.getQpsLimit());
-    qpsController = testQpsControllerManager.getOrCreate("poj.server.test");
+    qpsController = testQpsControllerManager.getOrCreate("poj", invocation);
     Assert.assertEquals("poj", qpsController.getKey());
     Assert.assertNull(qpsController.getQpsLimit());
 
-    testGetOrCreateCommon(testQpsControllerManager);
+    ArchaiusUtils.setProperty("cse.flowcontrol.Consumer.qps.limit.poj.server", 
10000);
+    qpsController = testQpsControllerManager.getOrCreate("poj", invocation);
+    Assert.assertEquals("poj.server", qpsController.getKey());
+    Assert.assertEquals(qpsController.getQpsLimit(), (Integer)10000);
+    
+    
ArchaiusUtils.setProperty("cse.flowcontrol.Consumer.qps.limit.poj.server.test", 
20000);
+    qpsController = testQpsControllerManager.getOrCreate("poj", invocation);
+    Assert.assertEquals("poj.server.test", qpsController.getKey());
+    Assert.assertEquals(qpsController.getQpsLimit(), (Integer)20000);
+    
+    testGetOrCreateCommon(testQpsControllerManager, invocation, operationMeta);
   }
 
   @Test
-  public void testGetOrCreateWithGlobalConfig() {
+  public void testGetOrCreateWithGlobalConfig(@Mocked Invocation invocation, 
@Mocked OperationMeta operationMeta) {
+    new Expectations() {
+      {
+        invocation.getOperationMeta();
+        result = operationMeta;
+        invocation.getSchemaId();
+        result = "server";
+        operationMeta.getSchemaQualifiedName();
+        result = "server.test";
+      }
+    };
+
     QpsControllerManager testQpsControllerManager = new QpsControllerManager()
         .setGlobalQpsController(Config.PROVIDER_LIMIT_KEY_GLOBAL)
         .setConfigKeyPrefix(Config.CONSUMER_LIMIT_KEY_PREFIX);
 
     // global
     setConfig(Config.PROVIDER_LIMIT_KEY_GLOBAL, 50);
-    QpsController qpsController = 
testQpsControllerManager.getOrCreate("pojo.server.test");
+    QpsController qpsController = testQpsControllerManager.getOrCreate("pojo", 
invocation);
     Assert.assertEquals(Config.PROVIDER_LIMIT_KEY_GLOBAL, 
qpsController.getKey());
     Assert.assertTrue(50 == qpsController.getQpsLimit());
-    qpsController = testQpsControllerManager.getOrCreate("pojo2.server.test");
+    qpsController = testQpsControllerManager.getOrCreate("pojo2", invocation);
     Assert.assertEquals(Config.PROVIDER_LIMIT_KEY_GLOBAL, 
qpsController.getKey());
     Assert.assertTrue(50 == qpsController.getQpsLimit());
-    qpsController = testQpsControllerManager.getOrCreate("poj.server.test");
+    qpsController = testQpsControllerManager.getOrCreate("poj", invocation);
     Assert.assertEquals(Config.PROVIDER_LIMIT_KEY_GLOBAL, 
qpsController.getKey());
     Assert.assertTrue(50 == qpsController.getQpsLimit());
 
     // pojo
     setConfigWithDefaultPrefix("pojo", 100);
-    qpsController = testQpsControllerManager.getOrCreate("pojo.server.test");
+    qpsController = testQpsControllerManager.getOrCreate("pojo", invocation);
     Assert.assertEquals("pojo", qpsController.getKey());
     Assert.assertTrue(100 == qpsController.getQpsLimit());
-    qpsController = testQpsControllerManager.getOrCreate("pojo2.server.test");
+    qpsController = testQpsControllerManager.getOrCreate("pojo2", invocation);
     Assert.assertEquals(Config.PROVIDER_LIMIT_KEY_GLOBAL, 
qpsController.getKey());
     Assert.assertTrue(50 == qpsController.getQpsLimit());
-    qpsController = testQpsControllerManager.getOrCreate("poj.server.test");
+    qpsController = testQpsControllerManager.getOrCreate("poj", invocation);
     Assert.assertEquals(Config.PROVIDER_LIMIT_KEY_GLOBAL, 
qpsController.getKey());
     Assert.assertTrue(50 == qpsController.getQpsLimit());
 
-    testGetOrCreateCommon(testQpsControllerManager);
+    testGetOrCreateCommon(testQpsControllerManager, invocation, operationMeta);
   }
 
   @Test
-  public void testQualifiedNameKey() {
+  public void testQualifiedNameKey(@Mocked Invocation invocation, @Mocked 
OperationMeta operationMeta) {
+    new Expectations() {
+      {
+        invocation.getOperationMeta();
+        result = operationMeta;
+        invocation.getSchemaId();
+        result = "schema";
+        operationMeta.getSchemaQualifiedName();
+        result = "schema.opr";
+      }
+    };
     QpsControllerManager qpsControllerManager = new QpsControllerManager();
-    QpsController qpsController = 
qpsControllerManager.getOrCreate("service.schema.opr");
+    QpsController qpsController = qpsControllerManager.getOrCreate("service", 
invocation);
     Assert.assertEquals("service", qpsController.getKey());
     Assert.assertNull(qpsController.getQpsLimit());
 
-    qpsController = 
qpsControllerManager.getOrCreate("test_service.test_schema.test_opr");
+    new Expectations() {
+      {
+        invocation.getOperationMeta();
+        result = operationMeta;
+        invocation.getSchemaId();
+        result = "test_schema";
+        operationMeta.getSchemaQualifiedName();
+        result = "test_schema.test_opr";
+      }
+    };
+    qpsController = qpsControllerManager.getOrCreate("test_service", 
invocation);
     Assert.assertEquals("test_service", qpsController.getKey());
     Assert.assertNull(qpsController.getQpsLimit());
 
-    qpsController = 
qpsControllerManager.getOrCreate("test-service.test-schema.test-opr");
+    new Expectations() {
+      {
+        invocation.getOperationMeta();
+        result = operationMeta;
+        invocation.getSchemaId();
+        result = "test_schema";
+        operationMeta.getSchemaQualifiedName();
+        result = "test-schema.test-opr";
+      }
+    };
+    qpsController = qpsControllerManager.getOrCreate("test-service", 
invocation);
     Assert.assertEquals("test-service", qpsController.getKey());
     Assert.assertNull(qpsController.getQpsLimit());
 
-    Exception exception = null;
-    try {
-      qpsControllerManager.getOrCreate("svc.schema.opr.tail");
-    } catch (Exception e) {
-      exception = e;
-    }
-    Assert.assertNotNull(exception);
-    Assert.assertEquals(IllegalArgumentException.class, exception.getClass());
-    Assert.assertEquals("Unexpected qualified name: [svc.schema.opr.tail]", 
exception.getMessage());
-
-    try {
-      qpsControllerManager.getOrCreate("svc.schema");
-    } catch (Exception e) {
-      exception = e;
-    }
-    Assert.assertNotNull(exception);
-    Assert.assertEquals(IllegalArgumentException.class, exception.getClass());
-    Assert.assertEquals("Unexpected qualified name: [svc.schema]", 
exception.getMessage());
-
-    try {
-      qpsControllerManager.getOrCreate("...");
-    } catch (Exception e) {
-      exception = e;
-    }
-    Assert.assertNotNull(exception);
-    Assert.assertEquals(IllegalArgumentException.class, exception.getClass());
-    Assert.assertEquals("Unexpected qualified name: [...]", 
exception.getMessage());
+
+    new Expectations() {
+      {
+        invocation.getOperationMeta();
+        result = operationMeta;
+        invocation.getSchemaId();
+        result = "schema";
+        operationMeta.getSchemaQualifiedName();
+        result = "schema.opr.tail";
+      }
+    };
+    qpsController = qpsControllerManager.getOrCreate("svc", invocation);
+    Assert.assertEquals("svc", qpsController.getKey());
+    Assert.assertNull(qpsController.getQpsLimit());
+
+    new Expectations() {
+      {
+        invocation.getOperationMeta();
+        result = operationMeta;
+        invocation.getSchemaId();
+        result = "schema.opr2";
+        operationMeta.getSchemaQualifiedName();
+        result = "schema.opr2.tail";
+      }
+    };
+    qpsController = qpsControllerManager.getOrCreate("svc", invocation);
+    Assert.assertEquals("svc", qpsController.getKey());
+    Assert.assertNull(qpsController.getQpsLimit());
   }
 
-  private void testGetOrCreateCommon(QpsControllerManager 
testQpsControllerManager) {
-    // pojo.server
+  private void testGetOrCreateCommon(QpsControllerManager 
testQpsControllerManager, Invocation invocation,
+      OperationMeta operationMeta) {
+    new Expectations() {
+      {
+        invocation.getOperationMeta();
+        result = operationMeta;
+        operationMeta.getSchemaQualifiedName();
+        result = "server.test";
+      }
+    };
     setConfigWithDefaultPrefix("pojo.server", 200);
-    QpsController qpsController = 
testQpsControllerManager.getOrCreate("pojo.server.test");
+    QpsController qpsController = testQpsControllerManager.getOrCreate("pojo", 
invocation);
     Assert.assertEquals("pojo.server", qpsController.getKey());
     Assert.assertTrue(200 == qpsController.getQpsLimit());
-    qpsController = testQpsControllerManager.getOrCreate("pojo.server2.test");
+    new Expectations() {
+      {
+        invocation.getOperationMeta();
+        result = operationMeta;
+        operationMeta.getSchemaQualifiedName();
+        result = "server2.test";
+      }
+    };
+    qpsController = testQpsControllerManager.getOrCreate("pojo", invocation);
     Assert.assertEquals("pojo", qpsController.getKey());
     Assert.assertTrue(100 == qpsController.getQpsLimit());
-    qpsController = testQpsControllerManager.getOrCreate("pojo.serve.test");
+    new Expectations() {
+      {
+        invocation.getOperationMeta();
+        result = operationMeta;
+        operationMeta.getSchemaQualifiedName();
+        result = "serve.test";
+      }
+    };
+    qpsController = testQpsControllerManager.getOrCreate("pojo", invocation);
     Assert.assertEquals("pojo", qpsController.getKey());
     Assert.assertTrue(100 == qpsController.getQpsLimit());
 
     // pojo.server.test
+    new Expectations() {
+      {
+        invocation.getOperationMeta();
+        result = operationMeta;
+        operationMeta.getSchemaQualifiedName();
+        result = "server.test";
+      }
+    };
     setConfigWithDefaultPrefix("pojo.server.test", 300);
-    qpsController = testQpsControllerManager.getOrCreate("pojo.server.test");
+    qpsController = testQpsControllerManager.getOrCreate("pojo", invocation);
     Assert.assertEquals("pojo.server.test", qpsController.getKey());
     Assert.assertTrue(300 == qpsController.getQpsLimit());
-    qpsController = testQpsControllerManager.getOrCreate("pojo.server.test2");
+    new Expectations() {
+      {
+        invocation.getOperationMeta();
+        result = operationMeta;
+        operationMeta.getSchemaQualifiedName();
+        result = "server.test2";
+      }
+    };
+    qpsController = testQpsControllerManager.getOrCreate("pojo", invocation);
     Assert.assertEquals("pojo.server", qpsController.getKey());
     Assert.assertTrue(200 == qpsController.getQpsLimit());
-    qpsController = testQpsControllerManager.getOrCreate("pojo.server.tes");
+    new Expectations() {
+      {
+        invocation.getOperationMeta();
+        result = operationMeta;
+
+        operationMeta.getSchemaQualifiedName();
+        result = "server.tes";
+      }
+    };
+    qpsController = testQpsControllerManager.getOrCreate("pojo", invocation);
     Assert.assertEquals("pojo.server", qpsController.getKey());
     Assert.assertTrue(200 == qpsController.getQpsLimit());
   }
@@ -170,31 +283,102 @@ public class QpsControllerManagerTest {
   /**
    * Init testQpsControllerManager to test search function.
    */
-  private void initTestQpsControllerManager(QpsControllerManager 
testQpsControllerManager) {
+  private void initTestQpsControllerManager(QpsControllerManager 
testQpsControllerManager, Invocation invocation,
+      OperationMeta operationMeta) {
     // pojo.server.test
-    QpsController qpsController = 
testQpsControllerManager.getOrCreate("pojo.server.test");
+    new Expectations() {
+      {
+        invocation.getOperationMeta();
+        result = operationMeta;
+        invocation.getSchemaId();
+        result = "server";
+        operationMeta.getSchemaQualifiedName();
+        result = "server.test";
+      }
+    };
+    QpsController qpsController = testQpsControllerManager.getOrCreate("pojo", 
invocation);
     Assert.assertEquals("pojo", qpsController.getKey());
     Assert.assertNull(qpsController.getQpsLimit());
 
     // pojo.server.test2
-    testQpsControllerManager.getOrCreate("pojo.server.test2");
+    new Expectations() {
+      {
+        invocation.getOperationMeta();
+        result = operationMeta;
+        invocation.getSchemaId();
+        result = "server";
+        operationMeta.getSchemaQualifiedName();
+        result = "server.test2";
+      }
+    };
+    testQpsControllerManager.getOrCreate("pojo", invocation);
 
     // pojo.server.tes
-    testQpsControllerManager.getOrCreate("pojo.server.tes");
+    new Expectations() {
+      {
+        invocation.getOperationMeta();
+        result = operationMeta;
+        invocation.getSchemaId();
+        result = "server";
+        operationMeta.getSchemaQualifiedName();
+        result = "server.tes";
+      }
+    };
+    testQpsControllerManager.getOrCreate("pojo", invocation);
 
     // pojo.server2.test
-    testQpsControllerManager.getOrCreate("pojo.server2.test");
+    new Expectations() {
+      {
+        invocation.getOperationMeta();
+        result = operationMeta;
+        invocation.getSchemaId();
+        result = "server2";
+        operationMeta.getSchemaQualifiedName();
+        result = "server2.test";
+      }
+    };
+    testQpsControllerManager.getOrCreate("pojo", invocation);
 
     // pojo.serve.test
-    testQpsControllerManager.getOrCreate("pojo.serve.test");
+    new Expectations() {
+      {
+        invocation.getOperationMeta();
+        result = operationMeta;
+        invocation.getSchemaId();
+        result = "serve";
+        operationMeta.getSchemaQualifiedName();
+        result = "serve.test";
+      }
+    };
+    testQpsControllerManager.getOrCreate("pojo", invocation);
 
     // pojo2.server.test
-    qpsController = testQpsControllerManager.getOrCreate("pojo2.server.test");
+    new Expectations() {
+      {
+        invocation.getOperationMeta();
+        result = operationMeta;
+        invocation.getSchemaId();
+        result = "server";
+        operationMeta.getSchemaQualifiedName();
+        result = "server.test";
+      }
+    };
+    qpsController = testQpsControllerManager.getOrCreate("pojo2", invocation);
     Assert.assertEquals("pojo2", qpsController.getKey());
     Assert.assertNull(qpsController.getQpsLimit());
 
     // poj.server.test
-    qpsController = testQpsControllerManager.getOrCreate("poj.server.test");
+    new Expectations() {
+      {
+        invocation.getOperationMeta();
+        result = operationMeta;
+        invocation.getSchemaId();
+        result = "server";
+        operationMeta.getSchemaQualifiedName();
+        result = "server.test";
+      }
+    };
+    qpsController = testQpsControllerManager.getOrCreate("poj", invocation);
     Assert.assertEquals("poj", qpsController.getKey());
     Assert.assertNull(qpsController.getQpsLimit());
   }
@@ -213,8 +397,7 @@ public class QpsControllerManagerTest {
 
   public static Invocation getMockInvocation(String microserviceName, String 
schemaId, String operationId) {
     return getMockInvocation(
-        getMockOperationMeta(microserviceName, schemaId, operationId)
-    );
+        getMockOperationMeta(microserviceName, schemaId, operationId));
   }
 
   private static Invocation getMockInvocation(OperationMeta mockOperationMeta) 
{
diff --git 
a/handlers/handler-flowcontrol-qps/src/test/java/org/apache/servicecomb/qps/TestConsumerQpsFlowControlHandler.java
 
b/handlers/handler-flowcontrol-qps/src/test/java/org/apache/servicecomb/qps/TestConsumerQpsFlowControlHandler.java
index ea58948..04ab829 100644
--- 
a/handlers/handler-flowcontrol-qps/src/test/java/org/apache/servicecomb/qps/TestConsumerQpsFlowControlHandler.java
+++ 
b/handlers/handler-flowcontrol-qps/src/test/java/org/apache/servicecomb/qps/TestConsumerQpsFlowControlHandler.java
@@ -87,7 +87,9 @@ public class TestConsumerQpsFlowControlHandler {
     String key = "svc.schema.opr";
     QpsController qpsController = new QpsController("key", 12);
     Mockito.when(invocation.getOperationMeta()).thenReturn(operationMeta);
-    Mockito.when(operationMeta.getMicroserviceQualifiedName()).thenReturn(key);
+    
Mockito.when(operationMeta.getSchemaQualifiedName()).thenReturn("schema.opr");
+    Mockito.when(invocation.getSchemaId()).thenReturn("schema");
+    Mockito.when(invocation.getMicroserviceName()).thenReturn("svc");
     setQpsController(key, qpsController);
     new MockUp<QpsController>() {
       @Mock
@@ -115,10 +117,12 @@ public class TestConsumerQpsFlowControlHandler {
 
   @Test
   public void testHandleIsLimitNewRequestAsFalse() throws Exception {
-    String key = "MicroserviceQualifiedName";
-    QpsController qpsController = new QpsController("key", 12);
+    String key = "service.schema.id";
+    QpsController qpsController = new QpsController("service", 12);
+    Mockito.when(invocation.getMicroserviceName()).thenReturn("service");
     Mockito.when(invocation.getOperationMeta()).thenReturn(operationMeta);
-    Mockito.when(operationMeta.getMicroserviceQualifiedName()).thenReturn(key);
+    
+    
Mockito.when(operationMeta.getSchemaQualifiedName()).thenReturn("schema.id");
     setQpsController(key, qpsController);
 
     new MockUp<QpsController>() {
diff --git 
a/handlers/handler-flowcontrol-qps/src/test/java/org/apache/servicecomb/qps/TestProviderQpsFlowControlHandler.java
 
b/handlers/handler-flowcontrol-qps/src/test/java/org/apache/servicecomb/qps/TestProviderQpsFlowControlHandler.java
index 52cf625..d14e6a2 100644
--- 
a/handlers/handler-flowcontrol-qps/src/test/java/org/apache/servicecomb/qps/TestProviderQpsFlowControlHandler.java
+++ 
b/handlers/handler-flowcontrol-qps/src/test/java/org/apache/servicecomb/qps/TestProviderQpsFlowControlHandler.java
@@ -75,6 +75,8 @@ public class TestProviderQpsFlowControlHandler {
         result = "test";
         invocation.getOperationMeta();
         result = QpsControllerManagerTest.getMockOperationMeta("pojo", 
"server", "opr");
+        invocation.getSchemaId();
+        result = "server";
         asyncResp.producerFail((Throwable) any);
         result = new RuntimeException("test error");
       }
@@ -119,7 +121,7 @@ public class TestProviderQpsFlowControlHandler {
     
Mockito.when(invocation.getContext(Const.SRC_MICROSERVICE)).thenReturn("test");
     OperationMeta mockOperationMeta = 
QpsControllerManagerTest.getMockOperationMeta("pojo", "server", "opr");
     Mockito.when(invocation.getOperationMeta()).thenReturn(mockOperationMeta);
-
+    Mockito.when(invocation.getSchemaId()).thenReturn("server");
     new MockUp<QpsController>() {
       @Mock
       public boolean isLimitNewRequest() {
@@ -152,7 +154,7 @@ public class TestProviderQpsFlowControlHandler {
     OperationMeta mockOperationMeta = QpsControllerManagerTest
         .getMockOperationMeta("pojo", "server", "opr");
     Mockito.when(invocation.getOperationMeta()).thenReturn(mockOperationMeta);
-
+    Mockito.when(invocation.getSchemaId()).thenReturn("server");
     new MockUp<QpsController>() {
       @Mock
       public boolean isLimitNewRequest() {

-- 
To stop receiving notification emails like this one, please contact
liu...@apache.org.

Reply via email to