This is an automated email from the ASF dual-hosted git repository.
xiaoyu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/shenyu-client-dotnet.git
The following commit(s) were added to refs/heads/main by this push:
new b6625f9 [ISSUE #31] Support integration test for http registration
(#32)
b6625f9 is described below
commit b6625f99fe0408d088946af860ea615a8bfb2dbd
Author: Han Gao <[email protected]>
AuthorDate: Fri Aug 12 14:41:56 2022 +0800
[ISSUE #31] Support integration test for http registration (#32)
* Support integration test
* small fix
* fix dockerfile issue
* sleep 30s to wait docker up
* small fix
* small fix
* add license header
---
.github/workflows/code-coverage.yml | 13 +---
.../{code-coverage.yml => integration-test.yml} | 46 +++++++------
.gitignore | 9 +--
ShenyuClient.sln | 48 +++++++++-----
build/docker-compose-consul.yml | 74 +++++++++++++++++++++
build/docker-compose-http.yml | 77 ++++++++++++++++++++++
build/docker-compose-nacos.yml | 74 +++++++++++++++++++++
build/docker-compose-zookeeper.yml | 74 +++++++++++++++++++++
.../Registers/ShenyuHttpRegister.cs | 7 +-
.../Apache.ShenYu.Client.Tests.csproj | 2 +-
.../Utils/IpUtilsTest.cs | 0
.../Apache.ShenYu.IntegrationTests.csproj} | 60 ++++++++---------
.../HttpIntegrationTest.cs | 54 +++++++++++++++
examples/AspNetCoreExample/Dockerfile | 27 ++++++++
examples/AspNetCoreExample/appsettings.json | 9 +--
15 files changed, 481 insertions(+), 93 deletions(-)
diff --git a/.github/workflows/code-coverage.yml
b/.github/workflows/code-coverage.yml
index 032c44f..a2377e1 100644
--- a/.github/workflows/code-coverage.yml
+++ b/.github/workflows/code-coverage.yml
@@ -35,18 +35,9 @@ jobs:
with:
dotnet-version: 5.0.406
- # - name: Restore dependencies
- # run: dotnet restore
-
- # - name: Build
- # run: dotnet build --no-restore /p:ContinuousIntegrationBuild=true
-
- # - name: Unit Test with dotnet
- # if: env.SKIP_CI != 'true'
- # run: dotnet test --no-build --verbosity normal
/p:CollectCoverage=true /p:CoverletOutputFormat=opencover
-
- name: Unit Test with dotnet
- run: dotnet test --collect:"XPlat Code Coverage"
--results-directory:"TestResults" --configuration Release
+ run: |
+ dotnet test
./client/Tests/Apache.ShenYu.Client.Tests/Apache.ShenYu.Client.Tests.csproj
--collect:"XPlat Code Coverage" --results-directory:"TestResults"
--configuration Release
- name: Install report tool
run: dotnet tool install -g dotnet-reportgenerator-globaltool
diff --git a/.github/workflows/code-coverage.yml
b/.github/workflows/integration-test.yml
similarity index 57%
copy from .github/workflows/code-coverage.yml
copy to .github/workflows/integration-test.yml
index 032c44f..27f81d7 100644
--- a/.github/workflows/code-coverage.yml
+++ b/.github/workflows/integration-test.yml
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-name: code-coverage
+name: integration-test
on:
pull_request:
@@ -22,37 +22,43 @@ on:
- main
jobs:
- build:
+ integration-test:
+ strategy:
+ matrix:
+ case:
+ - http
+ # - zookeeper
+ # - consul
+ # - nacos
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
+
- name: Set Skip Env Var
uses: ./.github/actions/skip-ci
+
- name: Setup .NET Core SDK
uses: actions/[email protected]
with:
dotnet-version: 5.0.406
- # - name: Restore dependencies
- # run: dotnet restore
-
- # - name: Build
- # run: dotnet build --no-restore /p:ContinuousIntegrationBuild=true
-
- # - name: Unit Test with dotnet
- # if: env.SKIP_CI != 'true'
- # run: dotnet test --no-build --verbosity normal
/p:CollectCoverage=true /p:CoverletOutputFormat=opencover
-
- - name: Unit Test with dotnet
- run: dotnet test --collect:"XPlat Code Coverage"
--results-directory:"TestResults" --configuration Release
+ - name: Build with dotnet
+ if: env.SKIP_CI != 'true'
+ run: dotnet build --configuration Release
- - name: Install report tool
- run: dotnet tool install -g dotnet-reportgenerator-globaltool
+ - name: Build docker image for dotnet example
+ run: |
+ cd ./examples/AspNetCoreExample/
+ docker build -t dotnet-example .
- - name: Merging test results
- run: reportgenerator -reports:TestResults/**/*.xml
-targetdir:TestResults -reporttypes:Cobertura
+ - name: Start Docker Compose
+ run: docker-compose -f ./build/docker-compose-${{ matrix.case }}.yml
up -d
- - name: Codecov
- uses: codecov/codecov-action@v3
+ # replace with check health step
+ - name: Run tests
+ run: |
+ sleep 30s
+ cd client/Tests/Apache.ShenYu.IntegrationTests
+ dotnet test
diff --git a/.gitignore b/.gitignore
index 6329edf..731ac61 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,6 +17,7 @@ cobertura.ser
.settings/
.project
.classpath
+.vscode
# idea ignore
.idea/
@@ -262,7 +263,7 @@ ClientBin/
*.publishsettings
orleans.codegen.cs
-# Including strong name files can present a security risk
+# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
@@ -358,7 +359,7 @@ __pycache__/
# OpenCover UI analysis results
OpenCover/
-# Azure Stream Analytics local run output
+# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
@@ -367,5 +368,5 @@ ASALocalRun/
# NVidia Nsight GPU debugger configuration file
*.nvuser
-# MFractors (Xamarin productivity tool) working folder
-.mfractor/
\ No newline at end of file
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
diff --git a/ShenyuClient.sln b/ShenyuClient.sln
index d181c2a..3fb25b2 100644
--- a/ShenyuClient.sln
+++ b/ShenyuClient.sln
@@ -7,14 +7,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "client",
"client", "{91252D
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.ShenYu.Client",
"client\Apache.ShenYu.Client\Apache.ShenYu.Client.csproj",
"{91D50BB4-2A2A-4958-A254-8E7615516411}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") =
"Apache.ShenYu.Client.Tests",
"client\Apache.ShenYu.Client.Tests\Apache.ShenYu.Client.Tests.csproj",
"{B807F1BF-5757-4243-A962-9A47D5EB55A6}"
-EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples",
"{B0929019-98BA-4CBB-AA73-DD3E7AAD7CB9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNetCoreExample",
"examples\AspNetCoreExample\AspNetCoreExample.csproj",
"{863FF829-2DCB-4366-A1C2-167B6E5C8618}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") =
"Apache.ShenYu.AspNetCore",
"client\Apache.ShenYu.AspNetCore\Apache.ShenYu.AspNetCore.csproj",
"{07B172F6-22EE-4D97-A124-B36078266631}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests",
"{0BD742B3-94AD-47D5-93E6-B105960A5470}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") =
"Apache.ShenYu.Client.Tests",
"client\Tests\Apache.ShenYu.Client.Tests\Apache.ShenYu.Client.Tests.csproj",
"{4A5AA134-EF14-4229-8284-69DFFADC3404}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") =
"Apache.ShenYu.IntegrationTests",
"client\Tests\Apache.ShenYu.IntegrationTests\Apache.ShenYu.IntegrationTests.csproj",
"{C15E50FD-EBF6-4DC5-8374-20D64A248BF6}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -40,18 +44,6 @@ Global
{91D50BB4-2A2A-4958-A254-8E7615516411}.Release|x64.Build.0 =
Release|Any CPU
{91D50BB4-2A2A-4958-A254-8E7615516411}.Release|x86.ActiveCfg =
Release|Any CPU
{91D50BB4-2A2A-4958-A254-8E7615516411}.Release|x86.Build.0 =
Release|Any CPU
- {B807F1BF-5757-4243-A962-9A47D5EB55A6}.Debug|Any CPU.ActiveCfg
= Debug|Any CPU
- {B807F1BF-5757-4243-A962-9A47D5EB55A6}.Debug|Any CPU.Build.0 =
Debug|Any CPU
- {B807F1BF-5757-4243-A962-9A47D5EB55A6}.Debug|x64.ActiveCfg =
Debug|Any CPU
- {B807F1BF-5757-4243-A962-9A47D5EB55A6}.Debug|x64.Build.0 =
Debug|Any CPU
- {B807F1BF-5757-4243-A962-9A47D5EB55A6}.Debug|x86.ActiveCfg =
Debug|Any CPU
- {B807F1BF-5757-4243-A962-9A47D5EB55A6}.Debug|x86.Build.0 =
Debug|Any CPU
- {B807F1BF-5757-4243-A962-9A47D5EB55A6}.Release|Any
CPU.ActiveCfg = Release|Any CPU
- {B807F1BF-5757-4243-A962-9A47D5EB55A6}.Release|Any CPU.Build.0
= Release|Any CPU
- {B807F1BF-5757-4243-A962-9A47D5EB55A6}.Release|x64.ActiveCfg =
Release|Any CPU
- {B807F1BF-5757-4243-A962-9A47D5EB55A6}.Release|x64.Build.0 =
Release|Any CPU
- {B807F1BF-5757-4243-A962-9A47D5EB55A6}.Release|x86.ActiveCfg =
Release|Any CPU
- {B807F1BF-5757-4243-A962-9A47D5EB55A6}.Release|x86.Build.0 =
Release|Any CPU
{863FF829-2DCB-4366-A1C2-167B6E5C8618}.Debug|Any CPU.ActiveCfg
= Debug|Any CPU
{863FF829-2DCB-4366-A1C2-167B6E5C8618}.Debug|Any CPU.Build.0 =
Debug|Any CPU
{863FF829-2DCB-4366-A1C2-167B6E5C8618}.Debug|x64.ActiveCfg =
Debug|Any CPU
@@ -76,11 +68,37 @@ Global
{07B172F6-22EE-4D97-A124-B36078266631}.Release|x64.Build.0 =
Release|Any CPU
{07B172F6-22EE-4D97-A124-B36078266631}.Release|x86.ActiveCfg =
Release|Any CPU
{07B172F6-22EE-4D97-A124-B36078266631}.Release|x86.Build.0 =
Release|Any CPU
+ {4A5AA134-EF14-4229-8284-69DFFADC3404}.Debug|Any CPU.ActiveCfg
= Debug|Any CPU
+ {4A5AA134-EF14-4229-8284-69DFFADC3404}.Debug|Any CPU.Build.0 =
Debug|Any CPU
+ {4A5AA134-EF14-4229-8284-69DFFADC3404}.Debug|x64.ActiveCfg =
Debug|Any CPU
+ {4A5AA134-EF14-4229-8284-69DFFADC3404}.Debug|x64.Build.0 =
Debug|Any CPU
+ {4A5AA134-EF14-4229-8284-69DFFADC3404}.Debug|x86.ActiveCfg =
Debug|Any CPU
+ {4A5AA134-EF14-4229-8284-69DFFADC3404}.Debug|x86.Build.0 =
Debug|Any CPU
+ {4A5AA134-EF14-4229-8284-69DFFADC3404}.Release|Any
CPU.ActiveCfg = Release|Any CPU
+ {4A5AA134-EF14-4229-8284-69DFFADC3404}.Release|Any CPU.Build.0
= Release|Any CPU
+ {4A5AA134-EF14-4229-8284-69DFFADC3404}.Release|x64.ActiveCfg =
Release|Any CPU
+ {4A5AA134-EF14-4229-8284-69DFFADC3404}.Release|x64.Build.0 =
Release|Any CPU
+ {4A5AA134-EF14-4229-8284-69DFFADC3404}.Release|x86.ActiveCfg =
Release|Any CPU
+ {4A5AA134-EF14-4229-8284-69DFFADC3404}.Release|x86.Build.0 =
Release|Any CPU
+ {C15E50FD-EBF6-4DC5-8374-20D64A248BF6}.Debug|Any CPU.ActiveCfg
= Debug|Any CPU
+ {C15E50FD-EBF6-4DC5-8374-20D64A248BF6}.Debug|Any CPU.Build.0 =
Debug|Any CPU
+ {C15E50FD-EBF6-4DC5-8374-20D64A248BF6}.Debug|x64.ActiveCfg =
Debug|Any CPU
+ {C15E50FD-EBF6-4DC5-8374-20D64A248BF6}.Debug|x64.Build.0 =
Debug|Any CPU
+ {C15E50FD-EBF6-4DC5-8374-20D64A248BF6}.Debug|x86.ActiveCfg =
Debug|Any CPU
+ {C15E50FD-EBF6-4DC5-8374-20D64A248BF6}.Debug|x86.Build.0 =
Debug|Any CPU
+ {C15E50FD-EBF6-4DC5-8374-20D64A248BF6}.Release|Any
CPU.ActiveCfg = Release|Any CPU
+ {C15E50FD-EBF6-4DC5-8374-20D64A248BF6}.Release|Any CPU.Build.0
= Release|Any CPU
+ {C15E50FD-EBF6-4DC5-8374-20D64A248BF6}.Release|x64.ActiveCfg =
Release|Any CPU
+ {C15E50FD-EBF6-4DC5-8374-20D64A248BF6}.Release|x64.Build.0 =
Release|Any CPU
+ {C15E50FD-EBF6-4DC5-8374-20D64A248BF6}.Release|x86.ActiveCfg =
Release|Any CPU
+ {C15E50FD-EBF6-4DC5-8374-20D64A248BF6}.Release|x86.Build.0 =
Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{91D50BB4-2A2A-4958-A254-8E7615516411} =
{91252D3C-1AEC-4C52-A2C8-091A907CF4E7}
- {B807F1BF-5757-4243-A962-9A47D5EB55A6} =
{91252D3C-1AEC-4C52-A2C8-091A907CF4E7}
{863FF829-2DCB-4366-A1C2-167B6E5C8618} =
{B0929019-98BA-4CBB-AA73-DD3E7AAD7CB9}
{07B172F6-22EE-4D97-A124-B36078266631} =
{91252D3C-1AEC-4C52-A2C8-091A907CF4E7}
+ {0BD742B3-94AD-47D5-93E6-B105960A5470} =
{91252D3C-1AEC-4C52-A2C8-091A907CF4E7}
+ {4A5AA134-EF14-4229-8284-69DFFADC3404} =
{0BD742B3-94AD-47D5-93E6-B105960A5470}
+ {C15E50FD-EBF6-4DC5-8374-20D64A248BF6} =
{0BD742B3-94AD-47D5-93E6-B105960A5470}
EndGlobalSection
EndGlobal
diff --git a/build/docker-compose-consul.yml b/build/docker-compose-consul.yml
new file mode 100644
index 0000000..bf2c814
--- /dev/null
+++ b/build/docker-compose-consul.yml
@@ -0,0 +1,74 @@
+# 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.
+
+version: "3.9"
+services:
+ shenyu-admin:
+ image: apache/shenyu-admin:latest
+ container_name: shenyu-admin
+ restart: always
+ networks:
+ - shenyu
+ ports:
+ - "9095:9095"
+ environment:
+ - SPRING_PROFILES_ACTIVE=h2
+ - 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
+ retries: 30
+
+ shenyu-bootstrap:
+ container_name: shenyu-bootstrap
+ image: apache/shenyu-bootstrap:latest
+ restart: always
+ deploy:
+ resources:
+ limits:
+ memory: 2048M
+ environment:
+ - shenyu.sync.websocket.urls=ws://shenyu-admin:9095/websocket
+ depends_on:
+ shenyu-admin:
+ condition: service_healthy
+ ports:
+ - "9195:9195"
+ - "8090:8090"
+ networks:
+ - shenyu
+ healthcheck:
+ test: [ "CMD", "wget", "http://shenyu-bootstrap:9195/actuator/health" ]
+ timeout: 2s
+ retries: 30
+
+ shenyu-dotnet-example:
+ container_name: dotnet-example
+ image: dotnet-example:latest
+ restart: always
+ environment:
+ - Shenyu__Register__ServerList=http://shenyu-admin:9095
+ depends_on:
+ shenyu-admin:
+ condition: service_healthy
+ ports:
+ - "5000:5000"
+ networks:
+ - shenyu
+
+networks:
+ shenyu:
+ name: shenyu
diff --git a/build/docker-compose-http.yml b/build/docker-compose-http.yml
new file mode 100644
index 0000000..ffc1f08
--- /dev/null
+++ b/build/docker-compose-http.yml
@@ -0,0 +1,77 @@
+# 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.
+
+version: "3.9"
+services:
+ shenyu-admin:
+ image: apache/shenyu-admin:latest
+ container_name: shenyu-admin
+ restart: always
+ networks:
+ - shenyu
+ ports:
+ - "9095:9095"
+ environment:
+ - SPRING_PROFILES_ACTIVE=h2
+ - 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
+ retries: 30
+
+ shenyu-bootstrap:
+ container_name: shenyu-bootstrap
+ image: apache/shenyu-bootstrap:latest
+ restart: always
+ deploy:
+ resources:
+ limits:
+ memory: 2048M
+ environment:
+ - shenyu.sync.websocket.urls=ws://shenyu-admin:9095/websocket
+ depends_on:
+ shenyu-admin:
+ condition: service_healthy
+ ports:
+ - "9195:9195"
+ - "8090:8090"
+ networks:
+ - shenyu
+ healthcheck:
+ test: [ "CMD", "wget", "http://shenyu-bootstrap:9195/actuator/health" ]
+ timeout: 2s
+ retries: 30
+
+ shenyu-dotnet-example:
+ container_name: dotnet-example
+ image: dotnet-example:latest
+ restart: always
+ environment:
+ - Shenyu__Register__ServerList=http://shenyu-admin:9095
+ - Shenyu__Register__RegisterType=http
+ - Shenyu__Register__Props__UserName=admin
+ - Shenyu__Register__Props__Password=123456
+ depends_on:
+ shenyu-admin:
+ condition: service_healthy
+ ports:
+ - "5000:5000"
+ networks:
+ - shenyu
+
+networks:
+ shenyu:
+ name: shenyu
diff --git a/build/docker-compose-nacos.yml b/build/docker-compose-nacos.yml
new file mode 100644
index 0000000..bf2c814
--- /dev/null
+++ b/build/docker-compose-nacos.yml
@@ -0,0 +1,74 @@
+# 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.
+
+version: "3.9"
+services:
+ shenyu-admin:
+ image: apache/shenyu-admin:latest
+ container_name: shenyu-admin
+ restart: always
+ networks:
+ - shenyu
+ ports:
+ - "9095:9095"
+ environment:
+ - SPRING_PROFILES_ACTIVE=h2
+ - 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
+ retries: 30
+
+ shenyu-bootstrap:
+ container_name: shenyu-bootstrap
+ image: apache/shenyu-bootstrap:latest
+ restart: always
+ deploy:
+ resources:
+ limits:
+ memory: 2048M
+ environment:
+ - shenyu.sync.websocket.urls=ws://shenyu-admin:9095/websocket
+ depends_on:
+ shenyu-admin:
+ condition: service_healthy
+ ports:
+ - "9195:9195"
+ - "8090:8090"
+ networks:
+ - shenyu
+ healthcheck:
+ test: [ "CMD", "wget", "http://shenyu-bootstrap:9195/actuator/health" ]
+ timeout: 2s
+ retries: 30
+
+ shenyu-dotnet-example:
+ container_name: dotnet-example
+ image: dotnet-example:latest
+ restart: always
+ environment:
+ - Shenyu__Register__ServerList=http://shenyu-admin:9095
+ depends_on:
+ shenyu-admin:
+ condition: service_healthy
+ ports:
+ - "5000:5000"
+ networks:
+ - shenyu
+
+networks:
+ shenyu:
+ name: shenyu
diff --git a/build/docker-compose-zookeeper.yml
b/build/docker-compose-zookeeper.yml
new file mode 100644
index 0000000..bf2c814
--- /dev/null
+++ b/build/docker-compose-zookeeper.yml
@@ -0,0 +1,74 @@
+# 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.
+
+version: "3.9"
+services:
+ shenyu-admin:
+ image: apache/shenyu-admin:latest
+ container_name: shenyu-admin
+ restart: always
+ networks:
+ - shenyu
+ ports:
+ - "9095:9095"
+ environment:
+ - SPRING_PROFILES_ACTIVE=h2
+ - 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
+ retries: 30
+
+ shenyu-bootstrap:
+ container_name: shenyu-bootstrap
+ image: apache/shenyu-bootstrap:latest
+ restart: always
+ deploy:
+ resources:
+ limits:
+ memory: 2048M
+ environment:
+ - shenyu.sync.websocket.urls=ws://shenyu-admin:9095/websocket
+ depends_on:
+ shenyu-admin:
+ condition: service_healthy
+ ports:
+ - "9195:9195"
+ - "8090:8090"
+ networks:
+ - shenyu
+ healthcheck:
+ test: [ "CMD", "wget", "http://shenyu-bootstrap:9195/actuator/health" ]
+ timeout: 2s
+ retries: 30
+
+ shenyu-dotnet-example:
+ container_name: dotnet-example
+ image: dotnet-example:latest
+ restart: always
+ environment:
+ - Shenyu__Register__ServerList=http://shenyu-admin:9095
+ depends_on:
+ shenyu-admin:
+ condition: service_healthy
+ ports:
+ - "5000:5000"
+ networks:
+ - shenyu
+
+networks:
+ shenyu:
+ name: shenyu
diff --git a/client/Apache.ShenYu.Client/Registers/ShenyuHttpRegister.cs
b/client/Apache.ShenYu.Client/Registers/ShenyuHttpRegister.cs
index 1cdaa63..272e3a0 100644
--- a/client/Apache.ShenYu.Client/Registers/ShenyuHttpRegister.cs
+++ b/client/Apache.ShenYu.Client/Registers/ShenyuHttpRegister.cs
@@ -91,9 +91,12 @@ namespace Apache.ShenYu.Client.Registers
{
var builder = new UriBuilder(server)
{
- Path = Constants.LoginPath, Query =
$"userName={this._userName}&password={this._password}"
+ Path = Constants.LoginPath,
+ Query = $"userName={this._userName}&password={this._password}"
};
- var resp = await this._client.GetStringAsync(builder.ToString());
+ var str = builder.ToString();
+ System.Console.WriteLine(str);
+ var resp = await this._client.GetStringAsync(str);
var jObject = JObject.Parse(resp);
var token = jObject.SelectToken("$.data.token")?.ToString();
diff --git
a/client/Apache.ShenYu.Client.Tests/Apache.ShenYu.Client.Tests.csproj
b/client/Tests/Apache.ShenYu.Client.Tests/Apache.ShenYu.Client.Tests.csproj
similarity index 90%
copy from client/Apache.ShenYu.Client.Tests/Apache.ShenYu.Client.Tests.csproj
copy to
client/Tests/Apache.ShenYu.Client.Tests/Apache.ShenYu.Client.Tests.csproj
index efc5b74..00bf51e 100644
--- a/client/Apache.ShenYu.Client.Tests/Apache.ShenYu.Client.Tests.csproj
+++ b/client/Tests/Apache.ShenYu.Client.Tests/Apache.ShenYu.Client.Tests.csproj
@@ -26,7 +26,7 @@
</ItemGroup>
<ItemGroup>
- <ProjectReference
Include="..\Apache.ShenYu.Client\Apache.ShenYu.Client.csproj" />
+ <ProjectReference
Include="..\..\Apache.ShenYu.Client\Apache.ShenYu.Client.csproj" />
</ItemGroup>
</Project>
diff --git a/client/Apache.ShenYu.Client.Tests/Utils/IpUtilsTest.cs
b/client/Tests/Apache.ShenYu.Client.Tests/Utils/IpUtilsTest.cs
similarity index 100%
rename from client/Apache.ShenYu.Client.Tests/Utils/IpUtilsTest.cs
rename to client/Tests/Apache.ShenYu.Client.Tests/Utils/IpUtilsTest.cs
diff --git
a/client/Apache.ShenYu.Client.Tests/Apache.ShenYu.Client.Tests.csproj
b/client/Tests/Apache.ShenYu.IntegrationTests/Apache.ShenYu.IntegrationTests.csproj
similarity index 77%
rename from client/Apache.ShenYu.Client.Tests/Apache.ShenYu.Client.Tests.csproj
rename to
client/Tests/Apache.ShenYu.IntegrationTests/Apache.ShenYu.IntegrationTests.csproj
index efc5b74..3d179f4 100644
--- a/client/Apache.ShenYu.Client.Tests/Apache.ShenYu.Client.Tests.csproj
+++
b/client/Tests/Apache.ShenYu.IntegrationTests/Apache.ShenYu.IntegrationTests.csproj
@@ -1,32 +1,28 @@
-<Project Sdk="Microsoft.NET.Sdk">
-
- <PropertyGroup>
- <TargetFramework>net5</TargetFramework>
- <Version>2.5.0</Version>
- <FileVersion>$(Version)</FileVersion>
- <Company>Apache Software Foundation</Company>
- <Copyright>$(Company)</Copyright>
- <Title>Apache.ShenYu.Client.Tests</Title>
- <RootNamespace>$(Title)</RootNamespace>
- <IsPackable>false</IsPackable>
- <LangVersion>7.3</LangVersion>
- </PropertyGroup>
-
- <ItemGroup>
- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
- <PackageReference Include="xunit" Version="2.4.1" />
- <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
- <IncludeAssets>runtime; build; native; contentfiles; analyzers;
buildtransitive</IncludeAssets>
- <PrivateAssets>all</PrivateAssets>
- </PackageReference>
- <PackageReference Include="coverlet.collector" Version="3.1.0">
- <IncludeAssets>runtime; build; native; contentfiles; analyzers;
buildtransitive</IncludeAssets>
- <PrivateAssets>all</PrivateAssets>
- </PackageReference>
- </ItemGroup>
-
- <ItemGroup>
- <ProjectReference
Include="..\Apache.ShenYu.Client\Apache.ShenYu.Client.csproj" />
- </ItemGroup>
-
-</Project>
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>net5.0</TargetFramework>
+ <Version>2.5.0</Version>
+ <FileVersion>$(Version)</FileVersion>
+ <Company>Apache Software Foundation</Company>
+ <Copyright>$(Company)</Copyright>
+ <Title>Apache.ShenYu.Client.Tests</Title>
+ <RootNamespace>$(Title)</RootNamespace>
+ <IsPackable>false</IsPackable>
+ <LangVersion>7.3</LangVersion>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
+ <PackageReference Include="xunit" Version="2.4.1" />
+ <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
+ <IncludeAssets>runtime; build; native; contentfiles; analyzers;
buildtransitive</IncludeAssets>
+ <PrivateAssets>all</PrivateAssets>
+ </PackageReference>
+ <PackageReference Include="coverlet.collector" Version="3.0.2">
+ <IncludeAssets>runtime; build; native; contentfiles; analyzers;
buildtransitive</IncludeAssets>
+ <PrivateAssets>all</PrivateAssets>
+ </PackageReference>
+ </ItemGroup>
+
+</Project>
diff --git a/client/Tests/Apache.ShenYu.IntegrationTests/HttpIntegrationTest.cs
b/client/Tests/Apache.ShenYu.IntegrationTests/HttpIntegrationTest.cs
new file mode 100644
index 0000000..79b665e
--- /dev/null
+++ b/client/Tests/Apache.ShenYu.IntegrationTests/HttpIntegrationTest.cs
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.Net.Http;
+using System.Threading.Tasks;
+using Newtonsoft.Json;
+using Xunit;
+
+namespace Apache.ShenYu.IntegrationTests
+{
+ public class HttpIntegrationTest : IDisposable
+ {
+ private HttpClient _client;
+
+ public HttpIntegrationTest()
+ {
+ this._client = new HttpClient();
+ this._client.BaseAddress = new Uri("http://localhost:9195");
+ }
+
+ public void Dispose()
+ {
+ this._client?.Dispose();
+ }
+
+ [Fact]
+ public async Task HttpTest()
+ {
+ var resp = await this._client.GetAsync("/dotnet/template/hello");
+ Assert.Equal(HttpStatusCode.OK, resp.StatusCode);
+
+ string responseBody = await resp.Content.ReadAsStringAsync();
+ var body =
JsonConvert.DeserializeObject<List<object>>(responseBody);
+ Assert.Equal(5, body.Count);
+ }
+ }
+}
diff --git a/examples/AspNetCoreExample/Dockerfile
b/examples/AspNetCoreExample/Dockerfile
new file mode 100644
index 0000000..2f1527c
--- /dev/null
+++ b/examples/AspNetCoreExample/Dockerfile
@@ -0,0 +1,27 @@
+# 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.
+
+# FROM mcr.microsoft.com/dotnet/aspnet:3.1-focal AS base
+FROM mcr.microsoft.com/dotnet/sdk:3.1-focal AS build
+WORKDIR /app
+EXPOSE 5000
+
+ENV ASPNETCORE_URLS=http://+:5000
+
+# FROM base AS final
+WORKDIR /app
+# COPY --from=publish /app/publish .
+ADD ./bin/Release/netcoreapp3.1/ /app
+ENTRYPOINT ["dotnet", "AspNetCoreExample.dll"]
diff --git a/examples/AspNetCoreExample/appsettings.json
b/examples/AspNetCoreExample/appsettings.json
index 0b08c84..2c5199b 100644
--- a/examples/AspNetCoreExample/appsettings.json
+++ b/examples/AspNetCoreExample/appsettings.json
@@ -8,18 +8,11 @@
},
"Shenyu": {
"Register": {
- "ServerList": "",
+ "ServerList": "http://localhost:9095",
"RegisterType": "http",
- // consul, zookeeper, http
"Props": {
"UserName": "admin",
"Password": "123456"
- // "Name": "shenyuAdmin",
- // "Id": "shenyuAdmin",
- // "Port": 8500,
- // "Tags": "tag1, tag2",
- // "PreferAgentAddress": false,
- // "EnableTagOverride": false
}
},
"Client": {