Skip to content

Commit 19d6edf

Browse files
authored
ci: Add test for symbolicator pipeline (#1916)
Fixes #1888 This integration test: uploads a symbol file, which indicates where to find the symbols for the minidump uploads a sample minidump, which creates an event we can check for This test is based on the test here: https://github.com/getsentry/sentry/blob/28f4f36b4adc3d39ea80f2f1864cff8e311b6af3/tests/symbolicator/test_minidump_full.py#L72
1 parent a48d379 commit 19d6edf

File tree

4 files changed

+1233
-4
lines changed

4 files changed

+1233
-4
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ jobs:
6868
sudo mkdir -p "${{ matrix.compose_path }}"
6969
sudo curl -L https://github.com/docker/compose/releases/download/${{ matrix.compose_version }}/docker-compose-`uname -s`-`uname -m` -o "${{ matrix.compose_path }}/docker-compose"
7070
sudo chmod +x "${{ matrix.compose_path }}/docker-compose"
71+
- name: Install sentry-cli
72+
run: curl -sL https://sentry.io/get-cli/ | sh
7173

7274
- name: Integration Test
7375
run: ./integration-test.sh

_integration-test/run.sh

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ echo "${_endgroup}"
5151

5252
echo "${_group}Running tests ..."
5353
get_csrf_token() { awk '$6 == "sc" { print $7 }' $COOKIE_FILE; }
54-
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}; }
54+
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/$1" ${@:2}; }
5555

5656
login() {
5757
INITIAL_AUTH_REDIRECT=$(curl -sL -o /dev/null $SENTRY_TEST_HOST -w %{url_effective})
@@ -85,9 +85,9 @@ echo "${_endgroup}"
8585

8686
echo "${_group}Running moar tests !!!"
8787
# Set up initial/required settings (InstallWizard request)
88-
sentry_api_request "internal/options/?query=is:required" -X PUT --data '{"mail.use-tls":false,"mail.username":"","mail.port":25,"system.admin-email":"[email protected]","mail.password":"","system.url-prefix":"'"$SENTRY_TEST_HOST"'","auth.allow-registration":false,"beacon.anonymous":true}' >/dev/null
88+
sentry_api_request "api/0/internal/options/?query=is:required" -X PUT --data '{"mail.use-tls":false,"mail.username":"","mail.port":25,"system.admin-email":"[email protected]","mail.password":"","system.url-prefix":"'"$SENTRY_TEST_HOST"'","auth.allow-registration":false,"beacon.anonymous":true}' >/dev/null
8989

90-
SENTRY_DSN=$(sentry_api_request "projects/sentry/internal/keys/" | awk 'BEGIN { RS=",|:{\n"; FS="\""; } $2 == "public" && $4 ~ "^http" { print $4; exit; }')
90+
SENTRY_DSN=$(sentry_api_request "api/0/projects/sentry/internal/keys/" | jq -r '.[0].dsn.public')
9191
# We ignore the protocol and the host as we already know those
9292
DSN_PIECES=($(echo $SENTRY_DSN | sed -ne 's|^https\{0,1\}://\([0-9a-z]\{1,\}\)@[^/]\{1,\}/\([0-9]\{1,\}\)$|\1 \2|p' | tr ' ' '\n'))
9393
SENTRY_KEY=${DSN_PIECES[0]}
@@ -101,7 +101,7 @@ TEST_EVENT_ID=$(
101101
echo "Creating test event..."
102102
curl -sf --data '{"event_id": "'"$TEST_EVENT_ID"'","level":"error","message":"a failure","extra":{"object":"42"}}' -H 'Content-Type: application/json' -H "X-Sentry-Auth: Sentry sentry_version=7, sentry_key=$SENTRY_KEY, sentry_client=test-bash/0.1" "$SENTRY_TEST_HOST/api/$PROJECT_ID/store/" -o /dev/null
103103

104-
EVENT_PATH="projects/sentry/internal/events/$TEST_EVENT_ID/"
104+
EVENT_PATH="api/0/projects/sentry/internal/events/$TEST_EVENT_ID/"
105105
export -f sentry_api_request get_csrf_token
106106
export SENTRY_TEST_HOST COOKIE_FILE EVENT_PATH
107107
printf "Getting the test event back"
@@ -130,6 +130,42 @@ cat debug.log
130130
echo '------------------------------------------'
131131
echo "${_endgroup}"
132132

133+
echo "${_group}Test symbolicator works ..."
134+
SENTRY_ORG="${SENTRY_ORG:-sentry}"
135+
SENTRY_PROJECT="${SENTRY_PROJECT:-native}"
136+
SENTRY_TEAM="${SENTRY_TEAM:-sentry}"
137+
# First set up a new project if it doesn't exist already
138+
PROJECT_JSON=$(jq -n -c --arg name "$SENTRY_PROJECT" --arg slug "$SENTRY_PROJECT" '$ARGS.named')
139+
NATIVE_PROJECT_ID=$(sentry_api_request "api/0/teams/$SENTRY_ORG/$SENTRY_TEAM/projects/" | jq -r '.[]|select(.slug == "'"$SENTRY_PROJECT"'")|.id')
140+
if [ -z "${NATIVE_PROJECT_ID}" ]; then
141+
NATIVE_PROJECT_ID=$(sentry_api_request "api/0/teams/$SENTRY_ORG/$SENTRY_TEAM/projects/" -X POST --data "$PROJECT_JSON" | jq -r '. // null | .id')
142+
fi
143+
# Set up sentry-cli command
144+
SCOPES=$(jq -n -c --argjson scopes '["event:admin", "event:read", "member:read", "org:read", "team:read", "project:read", "project:write", "team:write"]' '$ARGS.named')
145+
SENTRY_AUTH_TOKEN=$(sentry_api_request "api/0/api-tokens/" -X POST --data "$SCOPES" | jq -r '.token')
146+
SENTRY_DSN=$(sentry_api_request "api/0/projects/sentry/native/keys/" | jq -r '.[0].dsn.secret')
147+
# Then upload the symbols to that project (note the container mounts pwd to /work)
148+
SENTRY_URL="$SENTRY_TEST_HOST" sentry-cli upload-dif --org "$SENTRY_ORG" --project "$SENTRY_PROJECT" --auth-token "$SENTRY_AUTH_TOKEN" windows.sym
149+
# Get public key for minidump upload
150+
PUBLIC_KEY=$(sentry_api_request "api/0/projects/sentry/native/keys/" | jq -r '.[0].public')
151+
# Upload the minidump to be processed, this returns the event ID of the crash dump
152+
EVENT_ID=$(sentry_api_request "api/$NATIVE_PROJECT_ID/minidump/?sentry_key=$PUBLIC_KEY" -X POST -F '[email protected]' | sed 's/\-//g')
153+
# We have to wait for the item to be processed
154+
for i in {0..60..10}; do
155+
EVENT_PROCESSED=$(sentry_api_request "api/0/projects/$SENTRY_ORG/$SENTRY_PROJECT/events/" | jq -r '.[]|select(.id == "'"$EVENT_ID"'")|.id')
156+
if [ -z "$EVENT_PROCESSED" ]; then
157+
sleep $i
158+
else
159+
break
160+
fi
161+
done
162+
if [ -z "$EVENT_PROCESSED" ]; then
163+
echo "Hm, the event $EVENT_ID didn't exist... listing events that do exist:"
164+
sentry_api_request "api/0/projects/$SENTRY_ORG/$SENTRY_PROJECT/events/" | jq .
165+
exit 1
166+
fi
167+
echo "${_endgroup}"
168+
133169
echo "${_group}Test custom CAs work ..."
134170
source ./custom-ca-roots/setup.sh
135171
$dcr --no-deps web python3 /etc/sentry/test-custom-ca-roots.py

_integration-test/windows.dmp

21.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)