Tests: Add boilerplate code to support e2e tests on enterprise (#61959)

* Add e2e boilerplate for enterprise tests

* Remove enterprise symlink file

* Add tsconfig to e2e extensions folder and gitignore

* Update run-suite to use extensions folder

* Remove unnecessary tsconfig file

* Update e2e enterprise paths on gitignore

* Copy symlinked e2e enterprise files on run-suite

* Add cleanup command to run-suite

* Improve cleanup and setup for enterprise e2e tests

* Update e2e path for enterprise tests on gitignore

* Support to run different e2e tests for each license
This commit is contained in:
Guilherme Caulada 2023-01-26 18:04:13 -03:00 committed by GitHub
parent a5a85e0398
commit 9a25a03e49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 2 deletions

2
.gitignore vendored
View File

@ -157,6 +157,8 @@ compilation-stats.json
/e2e/benchmarks/**/results/*
/e2e/benchmarks/**/results
/e2e/build_results.zip
/e2e/extensions
/e2e/extensions-suite
# grafana server
/scripts/grafana-server/server.log

View File

@ -18,6 +18,7 @@ args=("$@")
CMD="start"
PARAMS=""
CLEANUP=""
declare -A env=(
[BASE_URL]=${BASE_URL:-"http://$HOST:$PORT"}
@ -25,6 +26,7 @@ declare -A env=(
)
testFilesForSingleSuite="*.spec.ts"
rootForEnterpriseSuite="extensions-suite"
declare -A cypressConfig=(
[integrationFolder]=../../e2e
@ -64,6 +66,27 @@ case "$1" in
cypressConfig[screenshotsFolder]=../../e2e/benchmarks/"${args[1]}"/screenshots
cypressConfig[testFiles]=$testFilesForSingleSuite
;;
"enterprise")
echo "Enterprise"
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="open"
enterpriseSuite=$(basename "${args[2]}")
;;
esac
cypressConfig[testFiles]=$rootForEnterpriseSuite/$enterpriseSuite/*-suite/*.spec.ts
$CLEANUP && $SETUP
;;
"")
;;
*)
@ -96,3 +119,5 @@ function join () {
yarn $CMD --env "$(join env)" \
--config "$(join cypressConfig)" \
$PARAMS
$CLEANUP

View File

@ -2,11 +2,21 @@
. scripts/grafana-server/variables
LICENSE_PATH=""
if [ "$1" = "enterprise" ]; then
if [ "$2" != "dev" ] && [ "$2" != "debug" ]; then
LICENSE_PATH=$2/license.jwt
else
LICENSE_PATH=$3/license.jwt
fi
fi
if [ "$BASE_URL" != "" ]; then
echo -e "BASE_URL set, skipping starting server"
else
# Start it in the background
./scripts/grafana-server/start-server 2>&1 > scripts/grafana-server/server.log &
./scripts/grafana-server/start-server $LICENSE_PATH 2>&1 > scripts/grafana-server/server.log &
./scripts/grafana-server/wait-for-grafana
fi

View File

@ -13,6 +13,9 @@
"e2e:debug": "./e2e/start-and-run-suite debug",
"e2e:dev": "./e2e/start-and-run-suite dev",
"e2e:benchmark:live": "./e2e/start-and-run-suite benchmark live",
"e2e:enterprise": "./e2e/start-and-run-suite enterprise",
"e2e:enterprise:dev": "./e2e/start-and-run-suite enterprise dev",
"e2e:enterprise:debug": "./e2e/start-and-run-suite enterprise debug",
"test": "jest --notify --watch",
"test:coverage": "jest --coverage",
"test:coverage:changes": "jest --coverage --changedSince=origin/main",

View File

@ -48,7 +48,8 @@ $RUNDIR/bin/"$ARCH"grafana-server \
--pidfile=$RUNDIR/pid \
cfg:server.http_port=$PORT \
cfg:server.router_logging=1 \
cfg:app_mode=development
cfg:app_mode=development \
cfg:enterprise.license_path=$1
# 2>&1 > $RUNDIR/output.log &
# cfg:log.level=debug \