From 002a161f96d9496f51f23ea352cee9a9e1aeee85 Mon Sep 17 00:00:00 2001 From: Daming Date: Wed, 9 Oct 2019 14:54:06 +0800 Subject: [PATCH] improves script (#3579) --- Jenkinsfile-Agent-Test | 2 +- test/plugin/run.sh | 32 +++++++++++++++++++++++++------- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile-Agent-Test b/Jenkinsfile-Agent-Test index 341575cce7..b4412b16b1 100755 --- a/Jenkinsfile-Agent-Test +++ b/Jenkinsfile-Agent-Test @@ -51,7 +51,7 @@ pipeline { stage('Compile plugin-test tools Codes') { steps { - sh './mvnw -f test/plugin/pom.xml -Pagent clean package -DskipTests -Dbuild_id=${BUILD_ID} docker:build' + sh './mvnw -f test/plugin/pom.xml clean package -DskipTests -Dbuild_id=${BUILD_ID} docker:build' } } diff --git a/test/plugin/run.sh b/test/plugin/run.sh index 46f3f3d0b8..b11fc67d39 100644 --- a/test/plugin/run.sh +++ b/test/plugin/run.sh @@ -17,24 +17,35 @@ # limitations under the License. home="$(cd "$(dirname $0)"; pwd)" -scenario_name="empty" +scenario_name="" parallel_run_size=1 +force_build="off" build_id="latest" - mvnw=${home}/../../mvnw agent_home=${home}"/../../skywalking-agent" scenarios_home="${home}/scenarios" -_positionals=() + +print_help() { + echo "Usage: run.sh [OPTION] SCENARIO [SCENARIO]" + echo -e "\t-f, --force_build \t\t do force to build Plugin-Test tools and images" + echo -e "\t--build_id, \t\t\t specify Plugin_Test's image tag. Defalt: latest" + echo -e "\t--parallel_run_size, \t\t parallel size of test cases. Default: 1" +} + parse_commandline() { _positionals_count=0 while test $# -gt 0 do _key="$1" case "$_key" in + -f|--force_build) + force_build="on" + shift + ;; --build_id) - test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1 + test $# -lt 2 && exitWithMessage "Missing value for the optional argument '$_key'." build_id="$2" shift ;; @@ -42,7 +53,7 @@ parse_commandline() { build_id="${_key##--build_id=}" ;; --parallel_run_size) - test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1 + test $# -lt 2 && exitWithMessage "Missing value for the optional argument '$_key'." parallel_run_size="$2" shift ;; @@ -93,9 +104,15 @@ waitForAvailable() { exitAndClean 1 fi } -parse_commandline "$@" start_stamp=`date +%s` ### start +parse_commandline "$@" + +if [[ ! -d ${agent_home} ]]; then + echo "[WARN] SkyWalking Agent not exists" + ${mvnw} -f ${home}/../../pom.xml -Pagent -DskipTests clean package +fi +[[ "$force_build" == "on" ]] && ${mvnw} -f ${home}/pom.xml clean package -DskipTests -Dbuild_id=${build_id} docker:build workspace="${home}/workspace/${scenario_name}" task_state_house="${workspace}/.states" @@ -104,7 +121,8 @@ mkdir -p ${task_state_house} plugin_autotest_helper="${home}/dist/plugin-autotest-helper.jar" if [[ ! -f ${plugin_autotest_helper} ]]; then - exitWithMessage "plugin autotest helper not exist!" + exitWithMessage "Plugin autotest tools not exists, Please re-try it with '-f'" + print_helper fi echo "start submit job"