Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AgentCore dynamic installation and uninstallation test: test plug-in, test application, pipeline #1322

Merged
merged 3 commits into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: "Agent-core Common Test"
description: "Auto test for spring common, include nacos dynamic config"
description: "Auto test for agent-core common, include nacos dynamic config"
luanwenfei-venus marked this conversation as resolved.
Show resolved Hide resolved
runs:
using: "composite"
steps:
- name: entry
uses: ./.github/actions/common/entry
with:
log-dir: ./logs/agentcore-test
log-dir: ./logs/agentcore-test/dynamic-config
- name: start applications
shell: bash
env:
Expand All @@ -23,7 +23,7 @@ runs:
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:8915/ping 120
- name: agentcore test module start
shell: bash
run: mvn test --file sermant-integration-tests/agentcore-test/agentcore-integration-test/pom.xml
run: mvn test -Dagentcore.test.type=DYNAMIC_CONFIG --file sermant-integration-tests/agentcore-test/agentcore-integration-test/pom.xml
- name: exit
if: always()
uses: ./.github/actions/common/exit
Expand Down
92 changes: 92 additions & 0 deletions .github/actions/scenarios/agentcore/dynamic/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: "Agent-core Dynamic Test"
description: "Auto test for agent-core dynamic"
luanwenfei-venus marked this conversation as resolved.
Show resolved Hide resolved
runs:
using: "composite"
steps:
- name: entry
uses: ./.github/actions/common/entry
with:
log-dir: ./logs/agentcore-test/dynamic
- name: compile AgentLoader
shell: bash
run: |
cp sermant-integration-tests/scripts/AgentLoader.java ./
javac -classpath ./:${{ env.JAVA_HOME}}/lib/tools.jar AgentLoader.java
- name: start applications
shell: bash
env:
dynamic.config.serverAddress: 127.0.0.1:2181
dynamic.config.dynamicConfigType: ZOOKEEPER
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 &
- name: waiting for agentcore services start
shell: bash
run: |
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:8915/ping 120
- name: (install agent) modify plugins file
shell: bash
run: |
sed -i '/dynamic-test-first-plugin/d' sermant-agent-${{ env.sermantVersion }}/agent/config/plugins.yaml
sed -i '/dynamic-test-second-plugin/d' sermant-agent-${{ env.sermantVersion }}/agent/config/plugins.yaml
sed -i '/ passive:/a \ - dynamic-test-first-plugin' sermant-agent-${{ env.sermantVersion }}/agent/config/plugins.yaml
sed -i '/ passive:/a \ - dynamic-test-second-plugin' sermant-agent-${{ env.sermantVersion }}/agent/config/plugins.yaml
- name: (install agent) dynamic install agent
shell: bash
run: java -classpath ./:${{ env.JAVA_HOME}}/lib/tools.jar AgentLoader sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar
- name: Sleep for 5 Seconds
shell: bash
run: sleep 5
- name: (install plugin) dynamic install plugin
shell: bash
run: java -classpath ./:${{ env.JAVA_HOME}}/lib/tools.jar AgentLoader sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar command=INSTALL-PLUGINS:dynamic-test-first-plugin/dynamic-test-second-plugin
- name: Sleep for 5 Seconds
shell: bash
run: sleep 5
- name: (install plugin) test install plugin
shell: bash
run: mvn test -Dagentcore.test.type=INSTALL_PLUGIN --file sermant-integration-tests/agentcore-test/agentcore-integration-test/pom.xml
- name: (uninstall plugin) dynamic uninstall plugin
shell: bash
run: java -classpath ./:${{ env.JAVA_HOME}}/lib/tools.jar AgentLoader sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar command=UNINSTALL-PLUGINS:dynamic-test-first-plugin
- name: Sleep for 5 Seconds
shell: bash
run: sleep 5
- name: (uninstall plugin) test uninstall plugin
shell: bash
run: mvn test -Dagentcore.test.type=UNINSTALL_PLUGIN --file sermant-integration-tests/agentcore-test/agentcore-integration-test/pom.xml
- name: (uninstall agent) dynamic uninstall agent
shell: bash
run: java -classpath ./:${{ env.JAVA_HOME}}/lib/tools.jar AgentLoader sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar command=UNINSTALL-AGENT
- name: Sleep for 5 Seconds
shell: bash
run: sleep 5
- name: (uninstall agent) test uninstall agent
shell: bash
run: mvn test -Dagentcore.test.type=UNINSTALL_AGENT --file sermant-integration-tests/agentcore-test/agentcore-integration-test/pom.xml
- name: (reinstall agent) dynamic reinstall agent
shell: bash
run: java -classpath ./:${{ env.JAVA_HOME}}/lib/tools.jar AgentLoader sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar command=INSTALL-PLUGINS:dynamic-test-first-plugin/dynamic-test-second-plugin
- name: Sleep for 5 Seconds
shell: bash
run: sleep 5
- name: (reinstall agent) test reinstall agent
shell: bash
run: mvn test -Dagentcore.test.type=REINSTALL_AGENT --file sermant-integration-tests/agentcore-test/agentcore-integration-test/pom.xml
- name: exit
if: always()
uses: ./.github/actions/common/exit
with:
processor-keyword: agentcore
- name: if failure then upload error log
uses: actions/upload-artifact@v3
if: ${{ failure() || cancelled() }}
with:
name: agentcore-test-logs
path: |
./*.log
./logs/**
if-no-files-found: warn
retention-days: 2
27 changes: 23 additions & 4 deletions .github/workflows/agentcore_integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,15 @@ jobs:
- name: move test plugin
run: |
mkdir -p sermant-agent-${{ env.sermantVersion }}/agent/pluginPackage/agentcore-test-plugin/plugin
mkdir -p sermant-agent-${{ env.sermantVersion }}/agent/pluginPackage/dynamic-test-first-plugin/plugin
mkdir -p sermant-agent-${{ env.sermantVersion }}/agent/pluginPackage/dynamic-test-second-plugin/plugin
cp ./sermant-integration-tests/agentcore-test/agentcore-test-plugin/target/agentcore-test-plugin-1.0.0.jar sermant-agent-${{ env.sermantVersion }}/agent/pluginPackage/agentcore-test-plugin/plugin/
cp ./sermant-integration-tests/agentcore-test/dynamic-test-first-plugin/target/dynamic-test-first-plugin-1.0.0.jar sermant-agent-${{ env.sermantVersion }}/agent/pluginPackage/dynamic-test-first-plugin/plugin/
cp ./sermant-integration-tests/agentcore-test/dynamic-test-second-plugin/target/dynamic-test-second-plugin-1.0.0.jar sermant-agent-${{ env.sermantVersion }}/agent/pluginPackage/dynamic-test-second-plugin/plugin/
cp ./sermant-integration-tests/agentcore-test/agentcore-test-application/target/agentcore-test-application-1.0.0-jar-with-dependencies.jar sermant-agent-${{ env.sermantVersion }}/agent/
sed -i '/plugins:/a \ - agentcore-test-plugin' sermant-agent-${{ env.sermantVersion }}/agent/config/plugins.yaml
test-for-agentcore:
name: Test for agentcore
test-for-agentcore-common:
name: Test for agentcore common
runs-on: ubuntu-latest
needs: [ build-agent-and-cache, download-midwares-and-cache ]
steps:
Expand All @@ -93,7 +97,22 @@ jobs:
echo "javaVersion=8" >> $GITHUB_ENV
- name: common operations
uses: ./.github/actions/common/agentcore
- name: start agentcore test
uses: ./.github/actions/scenarios/agentcore
- name: start agentcore common test
uses: ./.github/actions/scenarios/agentcore/agentcore-common
test-for-agentcore-dynamic:
name: Test for agentcore dynamic
runs-on: ubuntu-latest
needs: [build-agent-and-cache, download-midwares-and-cache]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 100
- name: set java version to environment
run: |
echo "javaVersion=8" >> $GITHUB_ENV
- name: common operations
uses: ./.github/actions/common/agentcore
- name: start dynamic test
uses: ./.github/actions/scenarios/agentcore/dynamic


Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<maven.surefire.plugin.version>3.0.0</maven.surefire.plugin.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -55,15 +56,14 @@
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (C) 2023-2023 Huawei Technologies Co., Ltd. All rights reserved.
*
* Licensed 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 com.huaweicloud.agentcore.test.request.dynamic;

import com.huaweicloud.agentcore.test.request.utils.RequestUtils;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;

import java.io.IOException;

/**
* 动态安装插件测试方法,采用http请求调用方式测试
*
* @author tangle
* @since 2023-09-26
*/
@EnabledIfSystemProperty(named = "agentcore.test.type", matches = "INSTALL_PLUGIN")
public class DynamicInstallPluginTest {
@Test
public void testInstallPlugin() throws IOException {
RequestUtils.testRequest("http://127.0.0.1:8915/testInstallPlugin");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (C) 2023-2023 Huawei Technologies Co., Ltd. All rights reserved.
*
* Licensed 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 com.huaweicloud.agentcore.test.request.dynamic;

import com.huaweicloud.agentcore.test.request.utils.RequestUtils;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;

import java.io.IOException;

/**
* 动态重装Agent测试方法,采用http请求调用方式测试
*
* @author tangle
* @since 2023-09-26
*/
@EnabledIfSystemProperty(named = "agentcore.test.type", matches = "REINSTALL_AGENT")
public class DynamicReInstallAgentTest {
@Test
public void testInstallPlugin() throws IOException {
RequestUtils.testRequest("http://127.0.0.1:8915/testReInstallAgent");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (C) 2023-2023 Huawei Technologies Co., Ltd. All rights reserved.
*
* Licensed 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 com.huaweicloud.agentcore.test.request.dynamic;

import com.huaweicloud.agentcore.test.request.utils.RequestUtils;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;

import java.io.IOException;

/**
* 动态卸载Agent测试方法,采用http请求调用方式测试
*
* @author tangle
* @since 2023-09-26
*/
@EnabledIfSystemProperty(named = "agentcore.test.type", matches = "UNINSTALL_AGENT")
public class DynamicUninstallAgentTest {
@Test
public void testInstallPlugin() throws IOException {
RequestUtils.testRequest("http://127.0.0.1:8915/testUninstallAgent");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (C) 2023-2023 Huawei Technologies Co., Ltd. All rights reserved.
*
* Licensed 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 com.huaweicloud.agentcore.test.request.dynamic;

import com.huaweicloud.agentcore.test.request.utils.RequestUtils;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;

import java.io.IOException;

/**
* 动态卸载插件测试方法,采用http请求调用方式测试
*
* @author tangle
* @since 2023-09-26
*/
@EnabledIfSystemProperty(named = "agentcore.test.type", matches = "UNINSTALL_PLUGIN")
public class DynamicUninstallPluginTest {
@Test
public void testInstallPlugin() throws IOException {
RequestUtils.testRequest("http://127.0.0.1:8915/testUninstallPlugin");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (C) 2023-2023 Huawei Technologies Co., Ltd. All rights reserved.
*
* Licensed 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 com.huaweicloud.agentcore.test.request.dynamicconfig;

import com.huaweicloud.agentcore.test.request.utils.RequestUtils;

import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
import org.junit.jupiter.api.Test;

import java.io.IOException;

/**
* 动态配置测试方法,采用http请求调用方式测试
*
* @author tangle
* @since 2023-09-07
*/
@EnabledIfSystemProperty(named = "agentcore.test.type", matches = "DYNAMIC_CONFIG")
public class DynamicConfigTest {
@Test
public void testDynamicConfig() throws IOException {
RequestUtils.testRequest("http://127.0.0.1:8915/testDynamicConfig");
}
}
Loading