mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
76fcfd733e
Add body in log requests. GRIST_LOG_SKIP_HTTP is a badly named environment variable and its expected values are confusing (to log the requests, you actually have to set its value to "", and setting to "false" actually is equivalent to setting to "true"). We deprecate this env variable in favor of GRIST_LOG_HTTP which is more convenient and understandable: - by default, its undefined, so nothing is logged; - to enable the logs, you just have to set GRIST_LOG_HTTP=true Also this commit removes the default value for GRIST_LOG_SKIP_HTTP, because we don't have to set it to "true" to actually disable the requests logging thanks to GRIST_LOG_HTTP. FlexServer now handles the historical behavior for this deprecated variable. --------- Co-authored-by: Jonathan Perret <j-github@jonathanperret.net>
73 lines
2.1 KiB
Bash
Executable File
73 lines
2.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# This runs browser tests with the server started using docker, to
|
|
# catch any configuration problems.
|
|
# Run with MOCHA_WEBDRIVER_HEADLESS=1 for headless operation.
|
|
# Run with DEBUG=1 for server logs.
|
|
|
|
# Settings for script robustness
|
|
set -o pipefail # trace ERR through pipes
|
|
set -o nounset # same as set -u : treat unset variables as an error
|
|
set -o errtrace # same as set -E: inherit ERR trap in functions
|
|
set -o errexit # same as set -e: exit on command failures
|
|
trap 'cleanup' EXIT
|
|
trap 'echo "Exiting on SIGINT"; exit 1' INT
|
|
trap 'echo "Exiting on SIGTERM"; exit 1' TERM
|
|
|
|
PORT=8585
|
|
DOCKER_CONTAINER=grist-core-test
|
|
DOCKER_PID=""
|
|
|
|
cleanup() {
|
|
return_value=$?
|
|
docker rm -f $DOCKER_CONTAINER
|
|
if [ -n "$DOCKER_PID" ]; then
|
|
wait $DOCKER_PID || echo "docker container gone"
|
|
fi
|
|
echo "Cleaned up docker container, bye."
|
|
exit $return_value
|
|
}
|
|
|
|
GRIST_LOG_LEVEL="error"
|
|
if [[ "${DEBUG:-}" == 1 ]]; then
|
|
GRIST_LOG_LEVEL=""
|
|
GRIST_LOG_HTTP="true"
|
|
GRIST_LOG_HTTP_BODY="true"
|
|
fi
|
|
|
|
docker run --name $DOCKER_CONTAINER --rm \
|
|
--env VERBOSE=${DEBUG:-} \
|
|
-p $PORT:$PORT --env PORT=$PORT \
|
|
--env GRIST_SESSION_COOKIE=grist_test_cookie \
|
|
--env GRIST_TEST_LOGIN=1 \
|
|
--env GRIST_LOG_LEVEL=$GRIST_LOG_LEVEL \
|
|
--env GRIST_LOG_HTTP=${GRIST_LOG_HTTP:-false} \
|
|
--env GRIST_LOG_HTTP_BODY=${GRIST_LOG_HTTP_BODY:-false} \
|
|
--env TEST_SUPPORT_API_KEY=api_key_for_support \
|
|
--env GRIST_TEMPLATE_ORG=templates \
|
|
${TEST_IMAGE:-gristlabs/grist} &
|
|
|
|
DOCKER_PID="$!"
|
|
|
|
echo "[waiting for server]"
|
|
while true; do
|
|
curl -s http://localhost:$PORT/status && break
|
|
sleep 1
|
|
done
|
|
echo ""
|
|
echo "[server found]"
|
|
MOCHA=mocha
|
|
# Test if we have mocha available as a command
|
|
if ! type $MOCHA > /dev/null 2>&1; then
|
|
echo "Mocha not found, using from ./node_modules/.bin/mocha"
|
|
MOCHA=./node_modules/.bin/mocha
|
|
fi
|
|
|
|
TEST_ADD_SAMPLES=1 TEST_ACCOUNT_PASSWORD=not-needed \
|
|
HOME_URL=http://localhost:8585 \
|
|
GRIST_SESSION_COOKIE=grist_test_cookie \
|
|
GRIST_TEST_LOGIN=1 \
|
|
NODE_PATH=_build:_build/stubs \
|
|
LANGUAGE=en_US \
|
|
$MOCHA _build/test/deployment/*.js --slow 6000 -g "${GREP_TESTS:-}" "$@"
|