You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by zh...@apache.org on 2022/06/14 12:08:43 UTC
[incubator-shenyu] branch master updated: [ISSUE #3521] add integration tests for grpc shared thread pool (#3561)
This is an automated email from the ASF dual-hosted git repository.
zhangzicheng 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 74057a028 [ISSUE #3521] add integration tests for grpc shared thread pool (#3561)
74057a028 is described below
commit 74057a02888b77284e66fe1cdd3fc9b235d73f37
Author: SongTao Zhuang <51...@users.noreply.github.com>
AuthorDate: Tue Jun 14 20:08:37 2022 +0800
[ISSUE #3521] add integration tests for grpc shared thread pool (#3561)
* add: integration tests for grpc shared thread pool
---
.../src/main/resources/application-local.yml | 2 +
.../test/grpc/GrpcPluginSharedThreadPoolTest.java | 62 ++++++++++++++++++++++
2 files changed, 64 insertions(+)
diff --git a/shenyu-integrated-test/shenyu-integrated-test-grpc/src/main/resources/application-local.yml b/shenyu-integrated-test/shenyu-integrated-test-grpc/src/main/resources/application-local.yml
index c01633968..b2074ba0a 100644
--- a/shenyu-integrated-test/shenyu-integrated-test-grpc/src/main/resources/application-local.yml
+++ b/shenyu-integrated-test/shenyu-integrated-test-grpc/src/main/resources/application-local.yml
@@ -58,6 +58,8 @@ shenyu:
local:
enabled: true
sha512Key: "BA3253876AED6BC22D4A6FF53D8406C6AD864195ED144AB5C87621B6C233B548BAEAE6956DF346EC8C17F5EA10F35EE3CBC514797ED7DDD3145464E2A0BAB413"
+ sharedPool:
+ enable: true
logging:
level:
diff --git a/shenyu-integrated-test/shenyu-integrated-test-grpc/src/test/java/org/apache/shenyu/integrated/test/grpc/GrpcPluginSharedThreadPoolTest.java b/shenyu-integrated-test/shenyu-integrated-test-grpc/src/test/java/org/apache/shenyu/integrated/test/grpc/GrpcPluginSharedThreadPoolTest.java
new file mode 100644
index 000000000..f90435ea9
--- /dev/null
+++ b/shenyu-integrated-test/shenyu-integrated-test-grpc/src/test/java/org/apache/shenyu/integrated/test/grpc/GrpcPluginSharedThreadPoolTest.java
@@ -0,0 +1,62 @@
+/*
+ * 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.grpc;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+import org.apache.shenyu.common.enums.PluginEnum;
+import org.apache.shenyu.common.utils.GsonUtils;
+import org.apache.shenyu.integratedtest.common.AbstractPluginDataInit;
+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.Map;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class GrpcPluginSharedThreadPoolTest extends AbstractPluginDataInit {
+
+ @BeforeAll
+ public static void setup() throws IOException {
+ String pluginResult = initPlugin(PluginEnum.GRPC.getName(), "{\"register\":\"zookeeper://shenyu-zk:2181\",\"threadpool\": \"shared\"}");
+ assertThat(pluginResult, is("success"));
+ }
+
+ @Test
+ public void testHelloWorld() throws Exception {
+ JsonObject request = buildGrpcRequest();
+ JsonArray response = HttpHelper.INSTANCE.postGateway("/grpc/echo", request, JsonArray.class);
+ Map<String, Object> result = GsonUtils.getInstance().toObjectMap(response.get(0).toString(), Object.class);
+ assertEquals("ReceivedHELLO", result.get("message"));
+ }
+
+ private JsonObject buildGrpcRequest() {
+ JsonArray jsonArray = new JsonArray();
+ JsonObject child = new JsonObject();
+ child.addProperty("message", "hello rpc");
+ jsonArray.add(child);
+ JsonObject jsonObject = new JsonObject();
+ jsonObject.add("data", jsonArray);
+ return jsonObject;
+ }
+
+}