You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by jo...@apache.org on 2022/06/10 16:05:32 UTC

[incubator-shenyu] branch master updated: [ISSUE #3521] task2 test shared thread pool for apache dubbo (#3522)

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

jooks pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new 0f78703f1 [ISSUE #3521] task2 test shared thread pool for apache dubbo (#3522)
0f78703f1 is described below

commit 0f78703f136ac3376b966f89eddff82ef62ca1a4
Author: dragon-zhang <ha...@webuy.ai>
AuthorDate: Sat Jun 11 00:05:24 2022 +0800

    [ISSUE #3521] task2 test shared thread pool for apache dubbo (#3522)
---
 .../src/main/resources/application-local.yml       |  2 +
 .../ApacheDubboPluginSharedThreadPoolTest.java     | 72 ++++++++++++++++++++++
 2 files changed, 74 insertions(+)

diff --git a/shenyu-integrated-test/shenyu-integrated-test-apache-dubbo/src/main/resources/application-local.yml b/shenyu-integrated-test/shenyu-integrated-test-apache-dubbo/src/main/resources/application-local.yml
index 218e1d41e..b6c11e4d2 100644
--- a/shenyu-integrated-test/shenyu-integrated-test-apache-dubbo/src/main/resources/application-local.yml
+++ b/shenyu-integrated-test/shenyu-integrated-test-apache-dubbo/src/main/resources/application-local.yml
@@ -44,6 +44,8 @@ shenyu:
   local:
     enabled: true
     sha512Key: "BA3253876AED6BC22D4A6FF53D8406C6AD864195ED144AB5C87621B6C233B548BAEAE6956DF346EC8C17F5EA10F35EE3CBC514797ED7DDD3145464E2A0BAB413"
+  sharedPool:
+    enable: true
 
 logging:
   level:
diff --git a/shenyu-integrated-test/shenyu-integrated-test-apache-dubbo/src/test/java/org/apache/shenyu/integrated/test/alibaba/dubbo/ApacheDubboPluginSharedThreadPoolTest.java b/shenyu-integrated-test/shenyu-integrated-test-apache-dubbo/src/test/java/org/apache/shenyu/integrated/test/alibaba/dubbo/ApacheDubboPluginSharedThreadPoolTest.java
new file mode 100644
index 000000000..5c5feb096
--- /dev/null
+++ b/shenyu-integrated-test/shenyu-integrated-test-apache-dubbo/src/test/java/org/apache/shenyu/integrated/test/alibaba/dubbo/ApacheDubboPluginSharedThreadPoolTest.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.integrated.test.alibaba.dubbo;
+
+import org.apache.shenyu.common.enums.PluginEnum;
+import org.apache.shenyu.integratedtest.common.AbstractPluginDataInit;
+import org.apache.shenyu.integratedtest.common.dto.DubboTest;
+import org.apache.shenyu.integratedtest.common.dto.ListResp;
+import org.apache.shenyu.integratedtest.common.helper.HttpHelper;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.util.List;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class ApacheDubboPluginSharedThreadPoolTest extends AbstractPluginDataInit {
+    
+    @BeforeAll
+    public static void setup() throws IOException {
+        String pluginResult = initPlugin(PluginEnum.DUBBO.getName(), "{\"register\":\"zookeeper://shenyu-zk:2181\",\"threadpool\": \"shared\"}");
+        assertThat(pluginResult, is("success"));
+    }
+
+    @Test
+    public void testFindById() throws IOException {
+        DubboTest dubboTest = HttpHelper.INSTANCE.getFromGateway("/dubbo/findById?id=1", DubboTest.class);
+        assertEquals("hello world shenyu Apache, findById", dubboTest.getName());
+        assertEquals("1", dubboTest.getId());
+    }
+
+    @Test
+    public void testFindAll() throws IOException {
+        DubboTest dubboTest = HttpHelper.INSTANCE.getFromGateway("/dubbo/findAll", DubboTest.class);
+        assertEquals("hello world shenyu Apache, findAll", dubboTest.getName());
+    }
+
+    @Test
+    public void testInsert() throws IOException {
+        DubboTest req = new DubboTest("1", "insertName");
+        DubboTest dubboTest = HttpHelper.INSTANCE.postGateway("/dubbo/insert", req, DubboTest.class);
+        assertEquals("hello world shenyu Apache Dubbo: insertName", dubboTest.getName());
+        assertEquals("1", dubboTest.getId());
+    }
+
+    @Test
+    public void testFindList() throws IOException {
+        ListResp listResp = HttpHelper.INSTANCE.getFromGateway("/dubbo/findList", ListResp.class);
+        List<DubboTest> users = listResp.getUsers();
+        assertEquals(listResp.getTotal().intValue(), users.size());
+        assertEquals("test", users.get(0).getName());
+        assertEquals("1", users.get(0).getId());
+    }
+}