Skip to content

Commit

Permalink
add external agent integration test
Browse files Browse the repository at this point in the history
Signed-off-by: lilai <lilai23@foxmail.com>
  • Loading branch information
lilai23 committed Jan 16, 2025
1 parent abfc06b commit 6bfe896
Show file tree
Hide file tree
Showing 12 changed files with 363 additions and 965 deletions.
9 changes: 9 additions & 0 deletions .github/actions/common/backend/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,12 @@ runs:
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: install requests
shell: bash
run: |
pip install requests
- name: download agent
uses: actions/cache@v4
with:
path: sermant-agent-*/
key: ${{ runner.os }}-agent-${{ github.run_id }}
949 changes: 0 additions & 949 deletions .github/actions/common/plugin-change-check/action.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .github/actions/scenarios/backend/config/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ description: "Auto test for Backend"
runs:
using: "composite"
steps:
- name: entry
uses: ./.github/actions/common/entry
with:
log-dir: ./logs/backend-config
- name: start backend with zookeeper
shell: bash
env:
Expand Down
11 changes: 1 addition & 10 deletions .github/actions/scenarios/backend/event/memory/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@ description: "Auto test for Backend"
runs:
using: "composite"
steps:
- name: download agent
uses: actions/cache@v4
with:
path: sermant-agent-*/
key: ${{ runner.os }}-agent-${{ github.run_id }}
- name: package dubbo 2.6.0 tests
shell: bash
run: mvn package -Dalibaba.dubbo.version=2.6.0 -DskipTests -P260 --file sermant-integration-tests/dubbo-test/pom.xml
- name: entry
uses: ./.github/actions/common/entry
with:
log-dir: ./logs/backend
log-dir: ./logs/backend-memory
- name: start backend with memory
shell: bash
run: |
Expand All @@ -39,10 +34,6 @@ runs:
shell: bash
run: |
netstat -nlp | grep :28021 | awk '{print $7}' | awk -F "/" '{print $1}' | xargs kill
- name: install requests
shell: bash
run: |
pip install requests
- name: start test
shell: bash
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/scenarios/backend/event/redis/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ runs:
- name: entry
uses: ./.github/actions/common/entry
with:
log-dir: ./logs/backend
log-dir: ./logs/backend-redis
- name: install redis
shell: bash
run: |
Expand Down
235 changes: 235 additions & 0 deletions .github/actions/scenarios/backend/external-agent/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
name: "Test external agent management"
description: "Auto test for external agent"
runs:
using: "composite"
steps:
- name: entry
uses: ./.github/actions/common/entry
with:
log-dir: ./logs/backend-external-agent
- name: compile AgentLoader
shell: bash
run: |
cp sermant-integration-tests/scripts/AgentLoader.java ./
javac -classpath ./:${{ env.JAVA_HOME}}/lib/tools.jar AgentLoader.java
- name: download opentelemetry agent
uses: actions/cache@v4
with:
path: opentelemetry-javaagent.jar
key: ${{ runner.os }}-opentelemetry-javaagent.jar
restore-keys: |
${{ runner.os }}-opentelemetry-javaagent.jar
- name: start backend with zookeeper
shell: bash
env:
DYNAMIC_CONFIG_SERVERADDRESS: 127.0.0.1:2181
DYNAMIC_CONFIG_DYNAMICCONFIGTYPE: ZOOKEEPER
DYNAMIC_CONFIG_ENABLE: true
NETTY_PORT: 6894
SERVER_PORT: 8910
MAX_EFFECTIVE_TIME: 20000
run: |
nohup java -jar sermant-agent-${{ env.sermantVersion }}/server/sermant/sermant-backend-${{ env.sermantVersion }}.jar &
sleep 20
- name: start application with sermant agent without external agent
shell: bash
env:
dynamic.config.serverAddress: 127.0.0.1:2181
dynamic.config.dynamicConfigType: ZOOKEEPER
service.meta.project: TestAgentCore
run: |
nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar \
-Dserver.port=8915 \
-Dagent.config.externalAgent.injection=false \
-Dagent.service.heartbeat.enable=true \
-Dagent.service.gateway.enable=true \
-Devent.enable=true \
-Dgateway.nettyPort=6894 \
-Dheartbeat.interval=5000 \
-jar sermant-agent-${{ env.sermantVersion }}/agent/agentcore-test-application-1.0.0-jar-with-dependencies.jar > ${{ env.logDir }}/agentcore-test.log 2>&1 &
- name: waiting for application start
shell: bash
run: |
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:8915/ping 120
- name: test start with sermant agent without external agent
shell: bash
run: |
export TEST_MODE=startWithoutExternalAgent
python -m unittest ./sermant-integration-tests/scripts/test_backend_external_agent.py
- name: stop application
shell: bash
run: |
netstat -nlp | grep :8915 | awk '{print $7}' | awk -F "/" '{print $1}' | xargs kill
sleep 3
- name: start application with sermant agent and external agent
shell: bash
env:
dynamic.config.serverAddress: 127.0.0.1:2181
dynamic.config.dynamicConfigType: ZOOKEEPER
service.meta.project: TestAgentCore
run: |
nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar \
-Dserver.port=8916 \
-Dagent.config.externalAgent.injection=true \
-Dagent.config.externalAgent.name=OTEL \
-Dagent.config.externalAgent.file=opentelemetry-javaagent.jar \
-Dagent.service.heartbeat.enable=true \
-Dagent.service.gateway.enable=true \
-Devent.enable=true \
-Dgateway.nettyPort=6894 \
-Dheartbeat.interval=5000 \
-jar sermant-agent-${{ env.sermantVersion }}/agent/agentcore-test-application-1.0.0-jar-with-dependencies.jar > ${{ env.logDir }}/agentcore-test.log 2>&1 &
- name: waiting for application start
shell: bash
run: |
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:8916/ping 120
- name: test start with sermant agent and external agent
shell: bash
run: |
export TEST_MODE=startWithExternalAgent
python -m unittest ./sermant-integration-tests/scripts/test_backend_external_agent.py
- name: stop application
shell: bash
run: |
netstat -nlp | grep :8916 | awk '{print $7}' | awk -F "/" '{print $1}' | xargs kill
sleep 3
- name: start application alone
shell: bash
env:
dynamic.config.serverAddress: 127.0.0.1:2181
dynamic.config.dynamicConfigType: ZOOKEEPER
service.meta.project: TestAgentCore
run: |
nohup java -Dserver.port=8917 \
-jar sermant-agent-${{ env.sermantVersion }}/agent/agentcore-test-application-1.0.0-jar-with-dependencies.jar > ${{ env.logDir }}/agentcore-test.log 2>&1 &
- name: waiting for application start
shell: bash
run: |
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:8917/ping 120
sleep 10
- name: dynamic install external agent
shell: bash
run: java -classpath ./:${{ env.JAVA_HOME}}/lib/tools.jar AgentLoader sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar \
command=INSTALL-EXTERNAL-AGENT:OTEL,AGENT_FILE=opentelemetry-javaagent.jar,agent.service.heartbeat.enable=true,agent.service.gateway.enable=true,event.enable=true,gateway.nettyPort=6894,heartbeat.interval=5000
- name: test install external agent by attach in case of sermant agent is not installed
shell: bash
run: |
export TEST_MODE=installByAttach
python -m unittest ./sermant-integration-tests/scripts/test_backend_external_agent.py
- name: stop application
shell: bash
run: |
netstat -nlp | grep :8917 | awk '{print $7}' | awk -F "/" '{print $1}' | xargs kill
sleep 3
- name: start application with sermant agent without external agent
shell: bash
env:
dynamic.config.serverAddress: 127.0.0.1:2181
dynamic.config.dynamicConfigType: ZOOKEEPER
service.meta.project: TestAgentCore
run: |
nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar \
-Dserver.port=8918 \
-Dagent.config.externalAgent.injection=false \
-Dagent.service.heartbeat.enable=true \
-Dagent.service.gateway.enable=true \
-Devent.enable=true \
-Dgateway.nettyPort=6894 \
-Dheartbeat.interval=5000 \
-jar sermant-agent-${{ env.sermantVersion }}/agent/agentcore-test-application-1.0.0-jar-with-dependencies.jar > ${{ env.logDir }}/agentcore-test.log 2>&1 &
- name: waiting for application start
shell: bash
run: |
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:8918/ping 120
- name: dynamic install external agent
shell: bash
run: java -classpath ./:${{ env.JAVA_HOME}}/lib/tools.jar AgentLoader sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar \
command=INSTALL-EXTERNAL-AGENT:OTEL,AGENT_FILE=opentelemetry-javaagent.jar,agent.service.heartbeat.enable=true,agent.service.gateway.enable=true,event.enable=true,gateway.nettyPort=6894
- name: test install external agent by attach in case of sermant agent is installed
shell: bash
run: |
export TEST_MODE=installByAttach
python -m unittest ./sermant-integration-tests/scripts/test_backend_external_agent.py
- name: stop application
shell: bash
run: |
netstat -nlp | grep :8918 | awk '{print $7}' | awk -F "/" '{print $1}' | xargs kill
sleep 3
- name: start application alone
shell: bash
env:
dynamic.config.serverAddress: 127.0.0.1:2181
dynamic.config.dynamicConfigType: ZOOKEEPER
service.meta.project: TestAgentCore
run: |
nohup java -Dserver.port=8919 \
-jar sermant-agent-${{ env.sermantVersion }}/agent/agentcore-test-application-1.0.0-jar-with-dependencies.jar > ${{ env.logDir }}/agentcore-test.log 2>&1 &
- name: waiting for application start
shell: bash
run: |
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:8919/ping 120
sleep 10
- name: dynamic install external agent
shell: bash
run: java -classpath ./:${{ env.JAVA_HOME}}/lib/tools.jar AgentLoader sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar \
agent.config.externalAgent.injection=true,agent.config.externalAgent.name=OTEL,agent.config.externalAgent.file=opentelemetry-javaagent.jar,agent.service.heartbeat.enable=true,agent.service.gateway.enable=true,event.enable=true,gateway.nettyPort=6894,heartbeat.interval=5000
- name: test install external agent by attach in case of sermant agent is not installalled and has set external agent config
shell: bash
run: |
export TEST_MODE=installByAttach
python -m unittest ./sermant-integration-tests/scripts/test_backend_external_agent.py
- name: stop application
shell: bash
run: |
netstat -nlp | grep :8919 | awk '{print $7}' | awk -F "/" '{print $1}' | xargs kill
sleep 3
- name: start application with sermant agent without external agent
shell: bash
env:
dynamic.config.serverAddress: 127.0.0.1:2181
dynamic.config.dynamicConfigType: ZOOKEEPER
service.meta.project: TestAgentCore
run: |
nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar \
-Dserver.port=8920 \
-Dagent.config.externalAgent.injection=false \
-Dagent.service.heartbeat.enable=true \
-Dagent.service.gateway.enable=true \
-Devent.enable=true \
-Dgateway.nettyPort=6894 \
-Dheartbeat.interval=5000 \
-jar sermant-agent-${{ env.sermantVersion }}/agent/agentcore-test-application-1.0.0-jar-with-dependencies.jar > ${{ env.logDir }}/agentcore-test.log 2>&1 &
- name: waiting for application start
shell: bash
run: |
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:8920/ping 120
- name: test install external agent by Sermant Backend
shell: bash
run: |
export TEST_MODE=install
python -m unittest ./sermant-integration-tests/scripts/test_backend_external_agent.py
- name: stop application
shell: bash
run: |
netstat -nlp | grep :8920 | awk '{print $7}' | awk -F "/" '{print $1}' | xargs kill
sleep 3
- name: stop backend
shell: bash
run: |
netstat -nlp | grep :8910 | awk '{print $7}' | awk -F "/" '{print $1}' | xargs kill
- name: exit
if: always()
uses: ./.github/actions/common/exit
with:
processor-keyword: agentcore|backend
- name: if failure then upload error log
uses: actions/upload-artifact@v4
if: ${{ failure() || cancelled() }}
with:
name: (${{ github.job }})-backend-logs
path: |
./*.log
./logs/**
if-no-files-found: warn
retention-days: 2
17 changes: 14 additions & 3 deletions .github/actions/scenarios/backend/hot-plugging/action.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
name: "Test the configuration management of Backend"
name: "Test the plugin hot-plugging in Backend"
description: "Auto test for Backend"
runs:
using: "composite"
steps:
- name: entry
uses: ./.github/actions/common/entry
with:
log-dir: ./logs/backend-hot-plugging
- name: compile AgentLoader
shell: bash
run: |
Expand All @@ -27,8 +31,7 @@ runs:
service.meta.project: TestAgentCore
run: |
nohup java -jar \
sermant-agent-${{ env.sermantVersion }}/agent/agentcore-test-application-1.0.0-jar-with-dependencies.jar > ${{ env.logDir
}}/agentcore-test.log 2>&1 &
sermant-agent-${{ env.sermantVersion }}/agent/agentcore-test-application-1.0.0-jar-with-dependencies.jar > ${{ env.logDir }}/agentcore-test.log 2>&1 &
- name: waiting for agentcore services start
shell: bash
run: |
Expand Down Expand Up @@ -66,6 +69,14 @@ runs:
run: |
export TEST_MODE=unInstall
python -m unittest ./sermant-integration-tests/scripts/test_backend_hot_plugging.py
- name: stop application
shell: bash
run: |
netstat -nlp | grep :8915 | awk '{print $7}' | awk -F "/" '{print $1}' | xargs kill
- name: stop backend
shell: bash
run: |
netstat -nlp | grep :8910 | awk '{print $7}' | awk -F "/" '{print $1}' | xargs kill
- name: exit
if: always()
uses: ./.github/actions/common/exit
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/backend_integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ jobs:
run: |
export ROOT_PATH=$(pwd)
bash ./sermant-integration-tests/scripts/tryDownloadMidware.sh nacos210
- name: cache opentelemetry agent
uses: actions/cache@v4
with:
path: opentelemetry-javaagent.jar
key: ${{ runner.os }}-opentelemetry-javaagent.jar
restore-keys: |
${{ runner.os }}-opentelemetry-javaagent.jar
- name: download opentelemetry agent
run: |
export ROOT_PATH=$(pwd)
bash ./sermant-integration-tests/scripts/tryDownloadMidware.sh otel
build-agent-and-cache:
name: build agent and cache
runs-on: ubuntu-latest
Expand Down Expand Up @@ -102,3 +113,5 @@ jobs:
uses: ./.github/actions/scenarios/backend/config
- name: start hot plugging test
uses: ./.github/actions/scenarios/backend/hot-plugging
- name: start external agent test
uses: ./.github/actions/scenarios/backend/external-agent
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @since 2023-09-08
*/
public class AgentCoreTestApplication {
private static final int SERVER_PORT = 8915;
private static int SERVER_PORT = 8915;

Check failure on line 34 in sermant-integration-tests/agentcore-test/agentcore-test-application/src/main/java/com/example/sermant/agentcore/test/application/AgentCoreTestApplication.java

View workflow job for this annotation

GitHub Actions / Checkstyle

[Checkstyle Check] reported by reviewdog 🐶 Name 'SERVER_PORT' must match pattern '(^[a-rt-z]([a-z0-9]+[A-Z]?)*$)|(^s[a-zA-Z0-9]+$)|(^m[a-zA-Z0-9]+$)'. Raw Output: /home/runner/work/Sermant/Sermant/./sermant-integration-tests/agentcore-test/agentcore-test-application/src/main/java/com/example/sermant/agentcore/test/application/AgentCoreTestApplication.java:34:24: error: Name 'SERVER_PORT' must match pattern '(^[a-rt-z]([a-z0-9]+[A-Z]?)*$)|(^s[a-zA-Z0-9]+$)|(^m[a-zA-Z0-9]+$)'. (com.puppycrawl.tools.checkstyle.checks.naming.StaticVariableNameCheck)

Check failure on line 34 in sermant-integration-tests/agentcore-test/agentcore-test-application/src/main/java/com/example/sermant/agentcore/test/application/AgentCoreTestApplication.java

View workflow job for this annotation

GitHub Actions / Checkstyle

[Checkstyle Check] reported by reviewdog 🐶 '8915' is a magic number. Raw Output: /home/runner/work/Sermant/Sermant/./sermant-integration-tests/agentcore-test/agentcore-test-application/src/main/java/com/example/sermant/agentcore/test/application/AgentCoreTestApplication.java:34:38: error: '8915' is a magic number. (com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck)

/**
* 启动main方法
Expand All @@ -41,6 +41,10 @@ public class AgentCoreTestApplication {
* @throws IllegalAccessException
*/
public static void main(String[] args) throws IOException, IllegalAccessException {
String port = System.getProperty("server.port");
if(port != null && !"".equals(port)) {

Check failure on line 45 in sermant-integration-tests/agentcore-test/agentcore-test-application/src/main/java/com/example/sermant/agentcore/test/application/AgentCoreTestApplication.java

View workflow job for this annotation

GitHub Actions / Checkstyle

[Checkstyle Check] reported by reviewdog 🐶 'if' is not followed by whitespace. Raw Output: /home/runner/work/Sermant/Sermant/./sermant-integration-tests/agentcore-test/agentcore-test-application/src/main/java/com/example/sermant/agentcore/test/application/AgentCoreTestApplication.java:45:9: error: 'if' is not followed by whitespace. (com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAroundCheck)
SERVER_PORT = Integer.parseInt(port);
}
HttpServer server = HttpServer.create(new InetSocketAddress(SERVER_PORT), 0);

// 添加URL路由
Expand Down
Loading

0 comments on commit 6bfe896

Please sign in to comment.