feat: sentry for arm
Some checks failed
Lock closed issues/PRs / lock (push) Has been cancelled
Test / Sentry self-hosted end-to-end tests (push) Has been cancelled
Test / unit tests (push) Has been cancelled
Test / Sentry upgrade test (push) Has been cancelled
Test / integration test v2.19.0 - customizations disabled (push) Has been cancelled
Test / integration test v2.19.0 - customizations enabled (push) Has been cancelled
Test / integration test v2.26.0 - customizations disabled (push) Has been cancelled
Test / integration test v2.26.0 - customizations enabled (push) Has been cancelled
Some checks failed
Lock closed issues/PRs / lock (push) Has been cancelled
Test / Sentry self-hosted end-to-end tests (push) Has been cancelled
Test / unit tests (push) Has been cancelled
Test / Sentry upgrade test (push) Has been cancelled
Test / integration test v2.19.0 - customizations disabled (push) Has been cancelled
Test / integration test v2.19.0 - customizations enabled (push) Has been cancelled
Test / integration test v2.26.0 - customizations disabled (push) Has been cancelled
Test / integration test v2.26.0 - customizations enabled (push) Has been cancelled
Signed-off-by: 小草林(田梓萱) <xcl@xuegao-tzx.top>
This commit is contained in:
57
_unit-test/_test_setup.sh
Normal file
57
_unit-test/_test_setup.sh
Normal file
@@ -0,0 +1,57 @@
|
||||
set -euo pipefail
|
||||
|
||||
source install/_lib.sh
|
||||
|
||||
_ORIGIN=$(pwd)
|
||||
|
||||
rm -rf /tmp/sentry-self-hosted-test-sandbox.*
|
||||
_SANDBOX="$(mktemp -d /tmp/sentry-self-hosted-test-sandbox.XXX)"
|
||||
|
||||
source install/detect-platform.sh
|
||||
docker build -t sentry-self-hosted-jq-local --platform="$DOCKER_PLATFORM" jq
|
||||
|
||||
report_success() {
|
||||
echo "$(basename $0) - Success 👍"
|
||||
}
|
||||
|
||||
teardown() {
|
||||
test "${DEBUG:-}" || rm -rf "$_SANDBOX"
|
||||
cd "$_ORIGIN"
|
||||
}
|
||||
|
||||
setup() {
|
||||
# Clone the local repo into a temp dir. FWIW `git clone --local` breaks for
|
||||
# me because it depends on hard-linking, which doesn't work across devices,
|
||||
# and I happen to have my workspace and /tmp on separate devices.
|
||||
git -c advice.detachedHead=false clone --depth=1 "file://$_ORIGIN" "$_SANDBOX"
|
||||
|
||||
# Now propagate any local changes from the working copy to the sandbox. This
|
||||
# provides a pretty nice dev experience: edit the files in the working copy,
|
||||
# then run `DEBUG=1 some-test.sh` to leave the sandbox up for interactive
|
||||
# dev/debugging.
|
||||
git status --porcelain | while read line; do
|
||||
# $line here is something like `M some-script.sh`.
|
||||
|
||||
local filepath="$(cut -f2 -d' ' <(echo $line))"
|
||||
local filestatus="$(cut -f1 -d' ' <(echo $line))"
|
||||
|
||||
case $filestatus in
|
||||
D)
|
||||
rm "$_SANDBOX/$filepath"
|
||||
;;
|
||||
A | M | AM | ??)
|
||||
ln -sf "$(realpath $filepath)" "$_SANDBOX/$filepath"
|
||||
;;
|
||||
**)
|
||||
echo "Wuh? $line"
|
||||
exit 77
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
cd "$_SANDBOX"
|
||||
|
||||
trap teardown EXIT
|
||||
}
|
||||
|
||||
setup
|
28
_unit-test/create-docker-volumes-test.sh
Executable file
28
_unit-test/create-docker-volumes-test.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source _unit-test/_test_setup.sh
|
||||
|
||||
get_volumes() {
|
||||
# If grep returns no strings, we still want to return without error
|
||||
docker volume ls --quiet | { grep '^sentry-.*' || true; } | sort
|
||||
}
|
||||
|
||||
# Maybe they exist prior, maybe they don't. Script is idempotent.
|
||||
|
||||
expected_volumes="sentry-clickhouse
|
||||
sentry-data
|
||||
sentry-kafka
|
||||
sentry-postgres
|
||||
sentry-redis
|
||||
sentry-symbolicator"
|
||||
|
||||
before=$(get_volumes)
|
||||
|
||||
test "$before" == "" || test "$before" == "$expected_volumes"
|
||||
|
||||
source install/create-docker-volumes.sh
|
||||
|
||||
after=$(get_volumes)
|
||||
test "$after" == "$expected_volumes"
|
||||
|
||||
report_success
|
27
_unit-test/ensure-relay-credentials-test.sh
Executable file
27
_unit-test/ensure-relay-credentials-test.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source _unit-test/_test_setup.sh
|
||||
source install/dc-detect-version.sh
|
||||
|
||||
# using _file format for these variables since there is a creds defined in dc-detect-version.sh
|
||||
cfg_file=relay/config.yml
|
||||
creds_file=relay/credentials.json
|
||||
|
||||
# Relay files don't exist in a clean clone.
|
||||
test ! -f $cfg_file
|
||||
test ! -f $creds_file
|
||||
|
||||
# Running the install script adds them.
|
||||
source install/ensure-relay-credentials.sh
|
||||
test -f $cfg_file
|
||||
test -f $creds_file
|
||||
test "$(jq -r 'keys[2]' "$creds_file")" = "secret_key"
|
||||
|
||||
# If the files exist we don't touch it.
|
||||
echo GARBAGE >$cfg_file
|
||||
echo MOAR GARBAGE >$creds_file
|
||||
source install/ensure-relay-credentials.sh
|
||||
test "$(cat $cfg_file)" = "GARBAGE"
|
||||
test "$(cat $creds_file)" = "MOAR GARBAGE"
|
||||
|
||||
report_success
|
86
_unit-test/error-handling-test.sh
Executable file
86
_unit-test/error-handling-test.sh
Executable file
@@ -0,0 +1,86 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source _unit-test/_test_setup.sh
|
||||
|
||||
export REPORT_SELF_HOSTED_ISSUES=1
|
||||
|
||||
# This is set up in dc-detect-version.sh, but for
|
||||
# our purposes we don't care about proxies.
|
||||
dbuild="docker build"
|
||||
source install/error-handling.sh
|
||||
|
||||
# mock send_envelope
|
||||
send_envelope() {
|
||||
echo "Test Sending $1"
|
||||
}
|
||||
|
||||
##########################
|
||||
|
||||
export -f send_envelope
|
||||
echo "Testing initial send_event"
|
||||
export log_file=test_log.txt
|
||||
echo "Test Logs" >"$log_file"
|
||||
echo "Error Msg" >>"$log_file"
|
||||
breadcrumbs=$(generate_breadcrumb_json | sed '$d' | $jq -s -c)
|
||||
SEND_EVENT_RESPONSE=$(
|
||||
send_event \
|
||||
"'foo' exited with status 1" \
|
||||
"Test exited with status 1" \
|
||||
"Traceback: ignore me" \
|
||||
"{\"ignore\": \"me\"}" \
|
||||
"$breadcrumbs"
|
||||
)
|
||||
rm "$log_file"
|
||||
expected_filename='sentry-envelope-f73e4da437c42a1d28b86a81ebcff35d'
|
||||
test "$SEND_EVENT_RESPONSE" == "Test Sending $expected_filename"
|
||||
ENVELOPE_CONTENTS=$(cat "/tmp/$expected_filename")
|
||||
test "$ENVELOPE_CONTENTS" == "$(cat _unit-test/snapshots/$expected_filename)"
|
||||
echo "Pass."
|
||||
|
||||
##########################
|
||||
|
||||
echo "Testing send_event duplicate"
|
||||
SEND_EVENT_RESPONSE=$(
|
||||
send_event \
|
||||
"'foo' exited with status 1" \
|
||||
"Test exited with status 1" \
|
||||
"Traceback: ignore me" \
|
||||
"{\"ignore\": \"me\"}" \
|
||||
"$breadcrumbs"
|
||||
)
|
||||
test "$SEND_EVENT_RESPONSE" == "Looks like you've already sent this error to us, we're on it :)"
|
||||
echo "Pass."
|
||||
rm "/tmp/$expected_filename"
|
||||
|
||||
##########################
|
||||
|
||||
echo "Testing cleanup without minimizing downtime"
|
||||
export REPORT_SELF_HOSTED_ISSUES=0
|
||||
export MINIMIZE_DOWNTIME=''
|
||||
export dc=':'
|
||||
echo "Test Logs" >"$log_file"
|
||||
CLEANUP_RESPONSE=$(cleanup ERROR) # the linenumber of this line must match just below
|
||||
rm "$log_file"
|
||||
test "$CLEANUP_RESPONSE" == 'Error in _unit-test/error-handling-test.sh:62.
|
||||
'\''local cmd="${BASH_COMMAND}"'\'' exited with status 0
|
||||
|
||||
Cleaning up...'
|
||||
echo "Pass."
|
||||
|
||||
##########################
|
||||
|
||||
echo "Testing cleanup while minimizing downtime"
|
||||
export REPORT_SELF_HOSTED_ISSUES=0
|
||||
export MINIMIZE_DOWNTIME=1
|
||||
echo "Test Logs" >"$log_file"
|
||||
CLEANUP_RESPONSE=$(cleanup ERROR) # the linenumber of this line must match just below
|
||||
rm "$log_file"
|
||||
test "$CLEANUP_RESPONSE" == 'Error in _unit-test/error-handling-test.sh:76.
|
||||
'\''local cmd="${BASH_COMMAND}"'\'' exited with status 0
|
||||
|
||||
*NOT* cleaning up, to clean your environment run "docker compose stop".'
|
||||
echo "Pass."
|
||||
|
||||
##########################
|
||||
|
||||
report_success
|
17
_unit-test/geoip-test.sh
Executable file
17
_unit-test/geoip-test.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source _unit-test/_test_setup.sh
|
||||
|
||||
mmdb=geoip/GeoLite2-City.mmdb
|
||||
|
||||
# Starts with no mmdb, ends up with empty.
|
||||
test ! -f $mmdb
|
||||
source install/geoip.sh
|
||||
diff -rub $mmdb $mmdb.empty
|
||||
|
||||
# Doesn't clobber existing, though.
|
||||
echo GARBAGE >$mmdb
|
||||
source install/geoip.sh
|
||||
test "$(cat $mmdb)" = "GARBAGE"
|
||||
|
||||
report_success
|
32
_unit-test/js-sdk-assets-test.sh
Executable file
32
_unit-test/js-sdk-assets-test.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source _unit-test/_test_setup.sh
|
||||
source install/dc-detect-version.sh
|
||||
$dcb --force-rm web
|
||||
|
||||
export SETUP_JS_SDK_ASSETS=1
|
||||
|
||||
source install/setup-js-sdk-assets.sh
|
||||
|
||||
sdk_files=$(docker compose run --no-deps --rm -v "sentry-nginx-www:/var/www" nginx ls -lah /var/www/js-sdk/)
|
||||
sdk_tree=$(docker compose run --no-deps --rm -v "sentry-nginx-www:/var/www" nginx tree /var/www/js-sdk/ | tail -n 1)
|
||||
non_empty_file_count=$(docker compose run --no-deps --rm -v "sentry-nginx-www:/var/www" nginx find /var/www/js-sdk/ -type f -size +1k | wc -l)
|
||||
|
||||
# `sdk_files` should contains 5 lines, '4.*', '5.*', '6.*', `7.*` and `8.*`
|
||||
echo $sdk_files
|
||||
total_directories=$(echo "$sdk_files" | grep -c '[45678]\.[0-9]*\.[0-9]*$')
|
||||
echo $total_directories
|
||||
test "5" == "$total_directories"
|
||||
echo "Pass"
|
||||
|
||||
# `sdk_tree` should output "5 directories, 17 files"
|
||||
echo "$sdk_tree"
|
||||
test "5 directories, 17 files" == "$(echo "$sdk_tree")"
|
||||
echo "Pass"
|
||||
|
||||
# Files should all be >1k (ensure they are not empty)
|
||||
echo "Testing file sizes"
|
||||
test "17" == "$non_empty_file_count"
|
||||
echo "Pass"
|
||||
|
||||
report_success
|
@@ -0,0 +1,6 @@
|
||||
{"event_id":"f73e4da437c42a1d28b86a81ebcff35d","dsn":"https://19555c489ded4769978daae92f2346ca@self-hosted.getsentry.net/3"}
|
||||
{"type":"event"}
|
||||
{"level":"error","exception":{"values":[{"type":"Error","value":"Test exited with status 1","stacktrace":{"frames":[{"ignore":"me"}]}}]},"breadcrumbs":{"values":[{"message":"Test Logs","category":"log","level":"info"}]},"fingerprint":["f73e4da437c42a1d28b86a81ebcff35d"]}
|
||||
{"type":"attachment","length":20,"content_type":"text/plain","filename":"install_log.txt"}
|
||||
Test Logs
|
||||
Error Msg
|
Reference in New Issue
Block a user