From 6a7867ef5f0da26a9c57f6bf792a591bba455c87 Mon Sep 17 00:00:00 2001 From: Daming Date: Fri, 18 Oct 2019 16:57:34 +0800 Subject: [PATCH] [test/plugin] support test cases work with specifying the optional plugins (#3649) * support test cases work with specifying the optional plugins --- test/plugin/run.sh | 49 ++++++++++++------- .../test/helper/vo/CaseConfiguration.java | 9 ++++ .../src/test/resources/configuration-test.yml | 2 + 3 files changed, 43 insertions(+), 17 deletions(-) mode change 100755 => 100644 test/plugin/run.sh diff --git a/test/plugin/run.sh b/test/plugin/run.sh old mode 100755 new mode 100644 index ed2f5357f..007577229 --- a/test/plugin/run.sh +++ b/test/plugin/run.sh @@ -110,6 +110,30 @@ do_cleanup() { [[ -d ${home}/workspace ]] && rm -rf ${home}/workspace } +agent_home_selector() { + running_mode=$1 + with_plugins=$2 + + plugin_dir="optional-plugins" + target_agent_dir="agent_with_optional" + if [[ "${running_mode}" != "with_optional" ]]; then + plugin_dir="bootstrap-plugins" + target_agent_dir="agent_with_bootstrap" + fi + + target_agent_home=${workspace}/${target_agent_dir} + mkdir -p ${target_agent_home} + cp -fur ${agent_home}/* ${target_agent_home} + + with_plugins=`echo $with_plugins |sed -e "s/;/ /g"` + for plugin in ${with_plugins}; + do + mv ${target_agent_home}/${plugin_dir}/${plugin} ${target_agent_home}/plugins/ + [[ $? -ne 0 ]] && exitAndClean 1 + done + _agent_home=${target_agent_home} +} + start_stamp=`date +%s` parse_commandline "$@" @@ -147,23 +171,14 @@ if [[ ! -f $supported_version_file ]]; then fi _agent_home=${agent_home} -mode=`grep "runningMode" ${scenario_home}/configuration.yml |sed -e "s/ //g" |awk -F: '{print $2}'` -if [[ "$mode" == "with_optional" ]]; then - agent_with_optional_home=${home}/workspace/agent_with_optional - if [[ ! -d ${agent_with_optional_home} ]]; then - mkdir -p ${agent_with_optional_home} - cp -r ${agent_home}/* ${agent_with_optional_home} - mv ${agent_with_optional_home}/optional-plugins/* ${agent_with_optional_home}/plugins/ - fi - _agent_home=${agent_with_optional_home} -elif [[ "$mode" == "with_bootstrap" ]]; then - agent_with_bootstrap_home=${home}/workspace/agent_with_bootstrap - if [[ ! -d ${agent_with_bootstrap_home} ]]; then - mkdir -p ${agent_with_bootstrap_home} - cp -r ${agent_home}/* ${agent_with_bootstrap_home} - mv ${agent_with_bootstrap_home}/bootstrap-plugins/* ${agent_with_bootstrap_home}/plugins/ - fi - _agent_home=${agent_with_bootstrap_home} +running_mode=$(grep "^runningMode" ${scenario_home}/configuration.yml |sed -e "s/ //g" |awk -F: '{print $2}') +with_plugins=$(grep "^withPlugins" ${scenario_home}/configuration.yml |sed -e "s/ //g" |awk -F: '{print $2}') + +if [[ -n "${running_mode}" ]]; then + # [[ -z "${with_plugins}" ]] ; then&& exitWithMessage \ + # "'withPlugins' has required configuration when 'runningMode' was set as 'optional_plugins' or 'bootstrap_plugins'" + [[ -z "${with_plugins}" ]] && with_plugins="*.jar" + agent_home_selector ${running_mode} ${with_plugins} fi supported_versions=`grep -v -E "^$|^#" ${supported_version_file}` diff --git a/test/plugin/runner-helper/src/main/java/org/apache/skywalking/plugin/test/helper/vo/CaseConfiguration.java b/test/plugin/runner-helper/src/main/java/org/apache/skywalking/plugin/test/helper/vo/CaseConfiguration.java index f77151b30..cd45b8823 100644 --- a/test/plugin/runner-helper/src/main/java/org/apache/skywalking/plugin/test/helper/vo/CaseConfiguration.java +++ b/test/plugin/runner-helper/src/main/java/org/apache/skywalking/plugin/test/helper/vo/CaseConfiguration.java @@ -31,6 +31,7 @@ public class CaseConfiguration { private List expose; private List depends_on; private String runningMode; + private String withPlugins; public String getType() { return type; @@ -119,4 +120,12 @@ public class CaseConfiguration { public void setRunningMode(String runningMode) { this.runningMode = runningMode; } + + public String getWithPlugins() { + return withPlugins; + } + + public void setWithPlugins(String withPlugins) { + this.withPlugins = withPlugins; + } } diff --git a/test/plugin/runner-helper/src/test/resources/configuration-test.yml b/test/plugin/runner-helper/src/test/resources/configuration-test.yml index 4ce75c9f8..d82c15c4c 100644 --- a/test/plugin/runner-helper/src/test/resources/configuration-test.yml +++ b/test/plugin/runner-helper/src/test/resources/configuration-test.yml @@ -18,6 +18,8 @@ entryService: http://localhost:8080/solrj-7.x-scenario/case/solrj healthCheck: http://localhost:8080/solrj-7.x-scenario/heathcheck startScript: ./bin/startup.sh framework: solrj +runningMode: with_optional +withPlugins: apm-gson-2.x-plugin-*.jar;apm-spring-cloud-gateway-2.x-plugin-*.jar environment: - SOLR_SERVER=http://solr-server:8983 dependencies: