diff --git a/integtest.sh b/integtest.sh index 47577bca8..094e339bc 100755 --- a/integtest.sh +++ b/integtest.sh @@ -17,6 +17,7 @@ function usage() { 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 "-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 "-e ENV_VAR\t, no defaults, specify potential ENV_VAR in integtest.sh, separate by comma(,) if adding multiple (-e \"CYPRESS_NO_COMMAND_LOG=1,SOME_PARAMS=2\")" echo -e "-c CREDENTIAL\t(usename:password), no defaults, effective when SECURITY_ENABLED=true." echo -e "-t TEST_COMPONENTS\t(OpenSearch-Dashboards reportsDashboards etc.), optional, specify test components, separate with space, else test everything." echo -e "-v VERSION\t, no defaults, indicates the OpenSearch version to test." @@ -26,7 +27,7 @@ function usage() { echo "--------------------------------------------------------------------------" } -while getopts ":hb:p:s:c:t:v:o:r:" arg; do +while getopts ":hb:p:s:e:c:t:v:o:r:" arg; do case $arg in h) usage @@ -41,6 +42,9 @@ while getopts ":hb:p:s:c:t:v:o:r:" arg; do s) SECURITY_ENABLED=$OPTARG ;; + e) + ENV_VAR=$OPTARG + ;; c) CREDENTIAL=$OPTARG ;; @@ -84,6 +88,11 @@ then SECURITY_ENABLED="true" fi +if [ -n "$ENV_VAR" ]; then + echo "User defined ENV_VAR for the run: $ENV_VAR" + ENV_VAR=,$ENV_VAR +fi + if [ -z "$REMOTE_CYPRESS_ENABLED" ] then REMOTE_CYPRESS_ENABLED="true" @@ -130,9 +139,11 @@ fi if [ "$SECURITY_ENABLED" = "true" ] then - echo "run security enabled tests" - yarn cypress:run-with-security --browser "$BROWSER_PATH" --spec "$TEST_FILES" + cmd="yarn cypress:run --env SECURITY_ENABLED=true,openSearchUrl=https://localhost:9200,AGGREGATION_VIEW=true,WAIT_FOR_LOADER_BUFFER_MS=3000$ENV_VAR --browser \"$BROWSER_PATH\" --spec \"$TEST_FILES\"" + echo "run security enabled tests: $cmd" + eval $cmd else - echo "run security disabled tests" - yarn cypress:run-without-security --browser "$BROWSER_PATH" --spec "$TEST_FILES" + cmd="$ENV_VAR yarn cypress:run --env SECURITY_ENABLED=false$ENV_VAR --browser \"$BROWSER_PATH\" --spec \"$TEST_FILES\"" + echo "run security disabled tests: $cmd" + eval $cmd fi diff --git a/package.json b/package.json index ef0873d03..c4aea112d 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "cypress:open": "cypress open", + "cypress:run": "env TZ=America/Los_Angeles NO_COLOR=1 cypress run --headless", "cypress:run-without-security": "env TZ=America/Los_Angeles NO_COLOR=1 cypress run --headless --env SECURITY_ENABLED=false", "cypress:run-with-security": "env TZ=America/Los_Angeles NO_COLOR=1 cypress run --headless --env SECURITY_ENABLED=true,openSearchUrl=https://localhost:9200,WAIT_FOR_LOADER_BUFFER_MS=3000", "cypress:run-with-security-and-aggregation-view": "env TZ=America/Los_Angeles NO_COLOR=1 cypress run --headless --env SECURITY_ENABLED=true,openSearchUrl=https://localhost:9200,AGGREGATION_VIEW=true,WAIT_FOR_LOADER_BUFFER_MS=3000",