2022-01-12 12:15:29 -06:00
|
|
|
#!/usr/bin/env bash
|
2020-07-10 09:09:21 -05:00
|
|
|
set -xeo pipefail
|
2020-03-13 08:34:25 -05:00
|
|
|
|
2022-01-20 11:01:00 -06:00
|
|
|
. scripts/grafana-server/variables
|
2020-03-13 08:34:25 -05:00
|
|
|
|
2022-01-12 12:15:29 -06: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 09:09:21 -05:00
|
|
|
HOST=${HOST:-$DEFAULT_HOST}
|
|
|
|
PORT=${PORT:-$DEFAULT_PORT}
|
|
|
|
|
2020-03-13 08:34:25 -05:00
|
|
|
echo -e "Starting Cypress scenarios"
|
|
|
|
|
2021-11-24 04:20:11 -06:00
|
|
|
args=("$@")
|
|
|
|
|
2020-03-16 08:35:55 -05:00
|
|
|
CMD="start"
|
|
|
|
PARAMS=""
|
2022-01-12 12:15:29 -06:00
|
|
|
|
|
|
|
declare -A env=(
|
|
|
|
[BASE_URL]=${BASE_URL:-"http://$HOST:$PORT"}
|
|
|
|
[SLOWMO]=0
|
|
|
|
)
|
|
|
|
|
|
|
|
testFilesForSingleSuite="*.spec.ts"
|
|
|
|
|
|
|
|
declare -A cypressConfig=(
|
|
|
|
[integrationFolder]=../../e2e
|
|
|
|
[screenshotsFolder]=../../e2e/"${args[0]}"/screenshots
|
|
|
|
[videosFolder]=../../e2e/"${args[0]}"/videos
|
|
|
|
[fileServerFolder]=./cypress
|
|
|
|
[testFiles]=*-suite/*spec.ts
|
|
|
|
[defaultCommandTimeout]=30000
|
|
|
|
[viewportWidth]=1920
|
|
|
|
[viewportHeight]=1080
|
|
|
|
[trashAssetsBeforeRuns]=false
|
|
|
|
[videoUploadOnPasses]=false
|
2022-11-29 03:59:12 -06:00
|
|
|
[reporter]=../../e2e/log-reporter.js
|
2022-01-12 12:15:29 -06:00
|
|
|
)
|
|
|
|
|
2020-03-16 08:35:55 -05:00
|
|
|
|
2020-03-13 12:48:38 -05:00
|
|
|
cd packages/grafana-e2e
|
2020-03-13 08:34:25 -05:00
|
|
|
|
2022-01-12 12:15:29 -06:00
|
|
|
case "$1" in
|
2021-11-24 08:16:51 -06:00
|
|
|
"debug")
|
|
|
|
echo -e "Debug mode"
|
2022-01-12 12:15:29 -06:00
|
|
|
env[SLOWMO]=1
|
2021-11-24 08:16:51 -06:00
|
|
|
PARAMS="--no-exit"
|
|
|
|
;;
|
|
|
|
"dev")
|
|
|
|
echo "Dev mode"
|
|
|
|
CMD="open"
|
|
|
|
;;
|
2022-01-12 12:15:29 -06:00
|
|
|
"benchmark")
|
|
|
|
echo "Benchmark"
|
|
|
|
PARAMS="--headed"
|
|
|
|
CMD="start-benchmark"
|
|
|
|
env[BENCHMARK_PLUGIN_ENABLED]=true
|
|
|
|
env[BENCHMARK_PLUGIN_RESULTS_FOLDER]=../../e2e/benchmarks/"${args[1]}"/results
|
|
|
|
cypressConfig[video]=false
|
|
|
|
cypressConfig[integrationFolder]=../../e2e/benchmarks/"${args[1]}"
|
|
|
|
cypressConfig[screenshotsFolder]=../../e2e/benchmarks/"${args[1]}"/screenshots
|
|
|
|
cypressConfig[testFiles]=$testFilesForSingleSuite
|
|
|
|
;;
|
2021-11-24 08:16:51 -06:00
|
|
|
"")
|
|
|
|
;;
|
|
|
|
*)
|
2022-01-12 12:15:29 -06:00
|
|
|
cypressConfig[integrationFolder]=../../e2e/"${args[0]}"
|
|
|
|
cypressConfig[testFiles]=$testFilesForSingleSuite
|
2022-11-08 04:27:54 -06:00
|
|
|
cypressConfig[video]=${args[1]}
|
2021-11-24 08:16:51 -06:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2022-01-12 12:15:29 -06: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"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
yarn $CMD --env "$(join env)" \
|
|
|
|
--config "$(join cypressConfig)" \
|
2020-03-16 08:35:55 -05:00
|
|
|
$PARAMS
|