From 7196e9a169fdaf395b2b8e11fb33cec76e1aaa11 Mon Sep 17 00:00:00 2001 From: Anan Zhuang Date: Mon, 18 Oct 2021 06:44:12 +0000 Subject: [PATCH] add a script to run bwc test This script is usd to run bwc tests on a remote cluster. It will first pull opensearch-dashboards-functional-test repo. Then move the required cypress test in and run the bwc tests. partically solved: https://github.com/opensearch-project/opensearch-build/issues/705 Signed-off-by: Anan Zhuang --- bwc.sh | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/bwc.sh b/bwc.sh index e6c83a653425..3bf9b3527fbd 100755 --- a/bwc.sh +++ b/bwc.sh @@ -4,7 +4,7 @@ set -e function usage() { echo "" - echo "This script is used to run integration tests for plugin installed on a remote OpenSearch/Dashboards cluster." + echo "This script is used to run bwc tests on a remote OpenSearch/Dashboards cluster." echo "--------------------------------------------------------------------------" echo "Usage: $0 [args]" echo "" @@ -12,28 +12,28 @@ function usage() { echo "None" echo "" echo "Optional arguments:" - echo -e "-b BIND_ADDRESS\t, defaults to localhost | 127.0.0.1, can be changed to any IP or domain name for the cluster location." + echo -e "-a BIND_ADDRESS\t, defaults to localhost | 127.0.0.1, can be changed to any IP or domain name for the cluster location." echo -e "-p BIND_PORT\t, defaults to 9200 or 5601 depends on OpenSearch or Dashboards, can be changed to any port for the cluster location." - echo -e "-s SECURITY_ENABLED\t(true | false), defaults to true. Specify the OpenSearch/Dashboards have security enabled or not." + echo -e "-b BUNDLED_OSD\t(true | false), defaults to true. Specify the usage of bundled Dashboards or not." echo -e "-c CREDENTIAL\t(usename:password), no defaults, effective when SECURITY_ENABLED=true." echo -e "-h\tPrint this message." echo "--------------------------------------------------------------------------" } -while getopts ":hb:p:s:c:" arg; do +while getopts ":ha:p:b:c:" arg; do case $arg in h) usage exit 1 ;; - b) + a) BIND_ADDRESS=$OPTARG ;; p) BIND_PORT=$OPTARG ;; - s) - SECURITY_ENABLED=$OPTARG + b) + BUNDLED_OSD=$OPTARG ;; c) CREDENTIAL=$OPTARG @@ -61,9 +61,9 @@ then BIND_PORT="5601" fi -if [ -z "$SECURITY_ENABLED" ] +if [ -z "$BUNDLED_OSD" ] then - SECURITY_ENABLED="true" + BUNDLED_OSD="true" fi if [ -z "$CREDENTIAL" ] @@ -73,18 +73,27 @@ then PASSWORD=`echo $CREDENTIAL | awk -F ':' '{print $2}'` fi -mkdir bwc-tmp -git clone https://github.com/opensearch-project/opensearch-dashboards-functional-test bwc-tmp -rm -rf bwc-tmp/cypress -cp -r cypress bwc-tmp -cd bwc-tmp +cwd=$(pwd) +dir="bwc-tmp" +if [ -d "$dir" ]; then + rm -rf "$dir" + echo "bwc-tmp exists and needs to be removed" +fi + +mkdir "$dir" +git clone https://github.com/opensearch-project/opensearch-dashboards-functional-test "$dir" +rm -rf "$dir/cypress" +cp -r cypress "$dir" +cd "$dir" npm install -if [ $SECURITY_ENABLED = "true" ] +if [ $BUNDLED_OSD = "true" ] then echo "run security enabled tests" - npx cypress run --spec "/bwc-tmp/cypress/integration/bundled-osd/*.js" + npx cypress run --spec "$cwd/bwc-tmp/cypress/integration/bundled-osd/*.js" else - npx cypress run --spec "/bwc-tmp/cypress/integration/osd/*.js" -fi \ No newline at end of file + npx cypress run --spec "$cwd/bwc-tmp/cypress/integration/osd/*.js" +fi + +rm -rf "$cwd/$dir" \ No newline at end of file