You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by xi...@apache.org on 2021/10/08 03:03:06 UTC
[incubator-shenyu] branch master updated: Refactor integration test
for sofa plugin (#2186)
This is an automated email from the ASF dual-hosted git repository.
xiaoyu 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 e720e8d Refactor integration test for sofa plugin (#2186)
e720e8d is described below
commit e720e8df90ccdfac2ee009b7d5497a9778f1606d
Author: Kunshuai Zhu <jo...@gmail.com>
AuthorDate: Thu Oct 7 22:03:01 2021 -0500
Refactor integration test for sofa plugin (#2186)
---
.../shenyu-integrated-test-sofa/docker-compose.yml | 6 +-----
.../src/main/resources/admin-config/schema.sql | 20 --------------------
.../shenyu/integrated/test/sofa/SofaPluginTest.java | 9 +++++++++
3 files changed, 10 insertions(+), 25 deletions(-)
diff --git a/shenyu-integrated-test/shenyu-integrated-test-sofa/docker-compose.yml b/shenyu-integrated-test/shenyu-integrated-test-sofa/docker-compose.yml
index aa7d388..2232468 100644
--- a/shenyu-integrated-test/shenyu-integrated-test-sofa/docker-compose.yml
+++ b/shenyu-integrated-test/shenyu-integrated-test-sofa/docker-compose.yml
@@ -39,10 +39,6 @@ services:
restart: always
networks:
- shenyu
- volumes:
- - type: bind
- source: ./src/main/resources/admin-config/
- target: /opt/sql/
depends_on:
- shenyu-redis
- shenyu-zk
@@ -50,7 +46,7 @@ services:
- 9095:9095
environment:
- SPRING_PROFILES_ACTIVE=h2
- - "shenyu.database.init_script=sql-script/h2/schema.sql;file:/opt/sql/schema.sql"
+ - "shenyu.database.init_script=sql-script/h2/schema.sql"
healthcheck:
test: ["CMD-SHELL", "wget -q -O - http://shenyu-admin:9095/actuator/health | grep UP || exit 1"]
timeout: 2s
diff --git a/shenyu-integrated-test/shenyu-integrated-test-sofa/src/main/resources/admin-config/schema.sql b/shenyu-integrated-test/shenyu-integrated-test-sofa/src/main/resources/admin-config/schema.sql
deleted file mode 100644
index 58b8984..0000000
--- a/shenyu-integrated-test/shenyu-integrated-test-sofa/src/main/resources/admin-config/schema.sql
+++ /dev/null
@@ -1,20 +0,0 @@
--- noinspection SqlNoDataSourceInspectionForFile
-
--- 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.
-
-/** prepare sofa **/
-UPDATE `plugin` SET enabled = 1, config = '{"protocol":"zookeeper","register":"shenyu-zk:2181"}' WHERE id = '11';
diff --git a/shenyu-integrated-test/shenyu-integrated-test-sofa/src/test/java/org/apache/shenyu/integrated/test/sofa/SofaPluginTest.java b/shenyu-integrated-test/shenyu-integrated-test-sofa/src/test/java/org/apache/shenyu/integrated/test/sofa/SofaPluginTest.java
index a3b6ea7..26826f8 100644
--- a/shenyu-integrated-test/shenyu-integrated-test-sofa/src/test/java/org/apache/shenyu/integrated/test/sofa/SofaPluginTest.java
+++ b/shenyu-integrated-test/shenyu-integrated-test-sofa/src/test/java/org/apache/shenyu/integrated/test/sofa/SofaPluginTest.java
@@ -18,10 +18,13 @@
package org.apache.shenyu.integrated.test.sofa;
import com.google.gson.reflect.TypeToken;
+import org.apache.shenyu.common.enums.PluginEnum;
import org.apache.shenyu.integrated.test.sofa.dto.SofaTestData;
import org.apache.shenyu.integratedtest.common.AbstractPluginDataInit;
import org.apache.shenyu.integratedtest.common.dto.AdminResponse;
import org.apache.shenyu.integratedtest.common.helper.HttpHelper;
+import org.hamcrest.Matchers;
+import org.junit.BeforeClass;
import org.junit.Test;
import java.io.IOException;
@@ -31,6 +34,12 @@ import static org.junit.Assert.assertThat;
public class SofaPluginTest extends AbstractPluginDataInit {
+ @BeforeClass
+ public static void setup() throws IOException {
+ String pluginResult = initPlugin(PluginEnum.SOFA.getName(), "{\"protocol\":\"zookeeper\",\"register\":\"shenyu-zk:2181\"}");
+ assertThat(pluginResult, Matchers.is("success"));
+ }
+
@Test
public void testHelloWorld() throws IOException {
AdminResponse<SofaTestData> response = HttpHelper.INSTANCE.getFromGateway("/sofa/findById?id=1001", new TypeToken<AdminResponse<SofaTestData>>() { }.getType());