Files
grafana/e2e/run-suite
T

152 lines
3.9 KiB
Bash
Raw Normal View History

2022-01-12 22:15:29 +04:00
#!/usr/bin/env bash
2020-07-10 16:09:21 +02:00
set -xeo pipefail
. scripts/grafana-server/variables
2022-01-12 22:15:29 +04:00
if ((BASH_VERSINFO[0] < 4)); then
echo "Bash ver >= 4 is needed to run this script"
echo "Please upgrade your bash - run 'brew install bash' if you use Homebrew on MacOS"
exit 1;
fi
2020-07-10 16:09:21 +02:00
HOST=${HOST:-$DEFAULT_HOST}
PORT=${PORT:-$DEFAULT_PORT}
echo -e "Starting Cypress scenarios"
args=("$@")
CMD="cypress run --browser=chrome"
PARAMS=""
CLEANUP=""
2022-01-12 22:15:29 +04:00
declare -A env=(
[BASE_URL]=${BASE_URL:-"http://$HOST:$PORT"}
[SLOWMO]=0
)
testFilesForSingleSuite="*.spec.ts"
rootForEnterpriseSuite="./e2e/extensions-suite"
rootForScenesSuite="./e2e/scenes"
2022-01-12 22:15:29 +04:00
declare -A cypressConfig=(
[screenshotsFolder]=./e2e/"${args[0]}"/screenshots
[fixturesFolder]=./e2e/cypress/fixtures
[videosFolder]=./e2e/"${args[0]}"/videos
[downloadsFolder]=./e2e/cypress/downloads
[fileServerFolder]=./e2e/cypress
[specPattern]=./e2e/*-suite/*spec.ts
2022-01-12 22:15:29 +04:00
[defaultCommandTimeout]=30000
[viewportWidth]=1920
[viewportHeight]=1080
[trashAssetsBeforeRuns]=false
[reporter]=./e2e/log-reporter.js
[baseUrl]=${BASE_URL:-"http://$HOST:$PORT"}
2022-01-12 22:15:29 +04:00
)
case "$1" in
2021-11-24 15:16:51 +01:00
"debug")
echo -e "Debug mode"
2022-01-12 22:15:29 +04:00
env[SLOWMO]=1
2021-11-24 15:16:51 +01:00
PARAMS="--no-exit"
;;
"dev")
echo "Dev mode"
CMD="cypress open"
2021-11-24 15:16:51 +01:00
;;
2022-01-12 22:15:29 +04:00
"benchmark")
echo "Benchmark"
PARAMS="--headed --no-runner-ui"
2022-01-12 22:15:29 +04:00
env[BENCHMARK_PLUGIN_ENABLED]=true
env[BENCHMARK_PLUGIN_RESULTS_FOLDER]=./e2e/benchmarks/"${args[1]}"/results
2022-01-12 22:15:29 +04:00
cypressConfig[video]=false
cypressConfig[screenshotsFolder]=./e2e/benchmarks/"${args[1]}"/screenshots
cypressConfig[specPattern]=./e2e/benchmarks/"${args[1]}"/$testFilesForSingleSuite
2022-01-12 22:15:29 +04:00
;;
"enterprise")
echo "Enterprise"
2024-06-18 14:32:19 +02:00
env[SMTP_PLUGIN_ENABLED]=true
CLEANUP="rm -rf ./e2e/extensions-suite"
SETUP="cp -Lr ./e2e/extensions ./e2e/extensions-suite"
enterpriseSuite=$(basename "${args[1]}")
case "$2" in
"debug")
echo -e "Debug mode"
env[SLOWMO]=1
PARAMS="--no-exit"
enterpriseSuite=$(basename "${args[2]}")
;;
"dev")
echo "Dev mode"
CMD="cypress open"
enterpriseSuite=$(basename "${args[2]}")
;;
esac
cypressConfig[specPattern]=$rootForEnterpriseSuite/$enterpriseSuite/*-suite/*.spec.ts
$CLEANUP && $SETUP
;;
2021-11-24 15:16:51 +01:00
"")
;;
"scenes")
env[SCENES]=true
cypressConfig[specPattern]=$rootForScenesSuite/*/$testFilesForSingleSuite
cypressConfig[video]=false
case "$2" in
"debug")
echo -e "Debug mode"
env[SLOWMO]=1
PARAMS="--no-exit"
enterpriseSuite=$(basename "${args[2]}")
;;
"dev")
echo "Dev mode"
CMD="cypress open"
enterpriseSuite=$(basename "${args[2]}")
;;
esac
;;
"scenes/"*)
cypressConfig[specPattern]=./e2e/"${args[0]}"/$testFilesForSingleSuite
cypressConfig[video]=${args[1]}
env[SCENES]=true
;;
2024-06-18 14:32:19 +02:00
"enterprise-smtp")
env[SMTP_PLUGIN_ENABLED]=true
cypressConfig[specPattern]=./e2e/extensions/enterprise/smtp-suite/$testFilesForSingleSuite
cypressConfig[video]=${args[1]}
;;
2021-11-24 15:16:51 +01:00
*)
cypressConfig[specPattern]=./e2e/"${args[0]}"/$testFilesForSingleSuite
cypressConfig[video]=${args[1]}
2021-11-24 15:16:51 +01:00
;;
esac
2022-01-12 22:15:29 +04:00
function join () {
local -n map=$1
local delimiter=","
local res=""
for key in "${!map[@]}"
do
value=${map[$key]}
if [ -z "${res}" ]; then
res=$key=$value
else
res=$res$delimiter$key=$value
fi
done
echo "$res"
}
export TZ="Pacific/Honolulu"
2022-01-12 22:15:29 +04:00
yarn run $CMD --env "$(join env)" \
2022-01-12 22:15:29 +04:00
--config "$(join cypressConfig)" \
$PARAMS
$CLEANUP