Skip to content

Commit

Permalink
fix: test.sh should use the variable $_group (getsentry#921)
Browse files Browse the repository at this point in the history
  • Loading branch information
BYK authored Apr 12, 2021
1 parent dd5a7d4 commit 257bccc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion install/_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test "${DEBUG:-}" && set -x
log_file="sentry_install_log-`date +'%Y-%m-%d_%H-%M-%S'`.txt"
exec &> >(tee -a "$log_file")

# Work from the onpremise root, no matter which script is called from where.
# Work from /install/ for install.sh, project root otherwise
if [[ "$(basename $0)" = "install.sh" ]]; then
cd "$(dirname $0)/install/"
else
Expand Down
28 changes: 15 additions & 13 deletions test.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env bash
set -e

echo "::group::Setting up variables and helpers ..."
source "$(dirname $0)/install/_lib.sh"

echo "${_group}Setting up variables and helpers ..."
export SENTRY_TEST_HOST="${SENTRY_TEST_HOST:-http://localhost:9000}"
TEST_USER='test@example.com'
TEST_PASS='test123TEST'
Expand Down Expand Up @@ -32,17 +34,17 @@ cleanup () {
echo "Done."
}
trap_with_arg cleanup ERR INT TERM EXIT
echo "::endgroup::"
echo "${_endgroup}"

echo "::group::Starting Sentry for tests ..."
echo "${_group}Starting Sentry for tests ..."
# Disable beacon for e2e tests
echo 'SENTRY_BEACON=False' >> sentry/sentry.conf.py
docker-compose run --rm web createuser --superuser --email $TEST_USER --password $TEST_PASS || true
docker-compose up -d
$dcr web createuser --superuser --email $TEST_USER --password $TEST_PASS || true
$dc up -d
printf "Waiting for Sentry to be up"; timeout 60 bash -c 'until $(curl -Isf -o /dev/null $SENTRY_TEST_HOST); do printf '.'; sleep 0.5; done'
echo "::endgroup::"
echo "${_endgroup}"

echo "::group::Running tests ..."
echo "${_group}Running tests ..."
get_csrf_token () { awk '$6 == "sc" { print $7 }' $COOKIE_FILE; }
sentry_api_request () { curl -s -H 'Accept: application/json; charset=utf-8' -H "Referer: $SENTRY_TEST_HOST" -H 'Content-Type: application/json' -H "X-CSRFToken: $(get_csrf_token)" -b "$COOKIE_FILE" -c "$COOKIE_FILE" "$SENTRY_TEST_HOST/api/0/$1" ${@:2}; }

Expand Down Expand Up @@ -75,9 +77,9 @@ do
echo "$LOGIN_RESPONSE" | grep "$i[,}]" >& /dev/null
echo "Pass."
done
echo "::endgroup::"
echo "${_endgroup}"

echo "::group::Running moar tests !!!"
echo "${_group}Running moar tests !!!"
# Set up initial/required settings (InstallWizard request)
sentry_api_request "internal/options/?query=is:required" -X PUT --data '{"mail.use-tls":false,"mail.username":"","mail.port":25,"system.admin-email":"ben@byk.im","mail.password":"","mail.from":"root@localhost","system.url-prefix":"'"$SENTRY_TEST_HOST"'","auth.allow-registration":false,"beacon.anonymous":true}' > /dev/null

Expand Down Expand Up @@ -112,8 +114,8 @@ do
echo "$EVENT_RESPONSE" | grep "$i[,}]" >& /dev/null
echo "Pass."
done
echo "::endgroup::"
echo "${_endgroup}"

echo "::group::Ensure cleanup crons are working ..."
docker-compose ps | grep -q -- "-cleanup_.\+[[:space:]]\+Up[[:space:]]\+"
echo "::endgroup::"
echo "${_group}Ensure cleanup crons are working ..."
$dc ps | grep -q -- "-cleanup_.\+[[:space:]]\+Up[[:space:]]\+"
echo "${_endgroup}"

0 comments on commit 257bccc

Please sign in to comment.