From 2af4ea8cdb2d9b14b3d5ea26bc35a6bbe98e1dd8 Mon Sep 17 00:00:00 2001 From: Daming Date: Mon, 14 Oct 2019 20:01:48 +0800 Subject: [PATCH] support plugin testcases run with optional/bootstap plugins (#3617) --- test/plugin/run.sh | 22 ++++++++++++++++++- .../plugin/test/helper/ConfigurationImpl.java | 7 ++++++ .../test/helper/vo/CaseConfiguration.java | 9 ++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/test/plugin/run.sh b/test/plugin/run.sh index efcfe6b00..dadd9477b 100644 --- a/test/plugin/run.sh +++ b/test/plugin/run.sh @@ -146,6 +146,26 @@ if [[ ! -f $supported_version_file ]]; then exitWithMessage "cannot found 'support-version.list' in directory ${scenario_name}" fi +_agent_home=${agent_home} +mode=`grep "runningMode" ${scenario_home}/configuration.yml |sed -e "s/\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} +fi + supported_versions=`grep -v -E "^$|^#" ${supported_version_file}` for version in ${supported_versions} do @@ -172,7 +192,7 @@ do -Dscenario.name=${scenario_name} \ -Dscenario.version=${version} \ -Doutput.dir=${case_work_base} \ - -Dagent.dir=${agent_home} \ + -Dagent.dir=${_agent_home} \ -Ddocker.image.version=${build_id} \ ${plugin_runner_helper} 1>${case_work_logs_dir}/helper.log diff --git a/test/plugin/runner-helper/src/main/java/org/apache/skywalking/plugin/test/helper/ConfigurationImpl.java b/test/plugin/runner-helper/src/main/java/org/apache/skywalking/plugin/test/helper/ConfigurationImpl.java index 9984e20e5..915236b56 100644 --- a/test/plugin/runner-helper/src/main/java/org/apache/skywalking/plugin/test/helper/ConfigurationImpl.java +++ b/test/plugin/runner-helper/src/main/java/org/apache/skywalking/plugin/test/helper/ConfigurationImpl.java @@ -20,6 +20,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; +import com.google.common.base.Strings; import org.apache.skywalking.plugin.test.helper.exception.ConfigureFileNotFoundException; import org.apache.skywalking.plugin.test.helper.util.StringUtils; import org.apache.skywalking.plugin.test.helper.vo.CaseConfiguration; @@ -37,6 +38,12 @@ public class ConfigurationImpl implements IConfiguration { this.configuration = new Yaml().loadAs(new FileReader(new File(configureFile)), CaseConfiguration.class); this.scenarioHome = System.getProperty("scenario.home"); + if (!Strings.isNullOrEmpty(this.configuration.getRunningMode())) { + String runningMode = this.configuration.getRunningMode(); + if (!runningMode.matches("default|with_optional|with_bootstrap")) { + throw new RuntimeException("RunningMode (" + runningMode + ") is not defined."); + } + } } @Override 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 a0df82eb3..f77151b30 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 @@ -30,6 +30,7 @@ public class CaseConfiguration { private List environment; private List expose; private List depends_on; + private String runningMode; public String getType() { return type; @@ -110,4 +111,12 @@ public class CaseConfiguration { public void setDepends_on(List depends_on) { this.depends_on = depends_on; } + + public String getRunningMode() { + return runningMode; + } + + public void setRunningMode(String runningMode) { + this.runningMode = runningMode; + } }