Skip to content

Commit 746031d

Browse files
Integration test improvements (#2858)
* integration test improvements
1 parent 7691add commit 746031d

File tree

5 files changed

+50
-53
lines changed

5 files changed

+50
-53
lines changed

.github/workflows/test.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,17 @@ jobs:
5959
strategy:
6060
fail-fast: false
6161
matrix:
62+
test_type: ["initial-install", "customizations"]
63+
compose_version: ["v2.0.1", "v2.7.0"]
6264
include:
6365
- compose_version: "v2.0.1"
6466
compose_path: "/usr/local/lib/docker/cli-plugins"
6567
- compose_version: "v2.7.0"
6668
compose_path: "/usr/local/lib/docker/cli-plugins"
6769
env:
6870
COMPOSE_PROJECT_NAME: self-hosted-${{ strategy.job-index }}
71+
SENTRY_DSN: https://[email protected]/6627632
72+
REPORT_SELF_HOSTED_ISSUES: 1
6973
steps:
7074
- name: Checkout
7175
uses: actions/checkout@v4
@@ -82,8 +86,11 @@ jobs:
8286
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"
8387
sudo chmod +x "${{ matrix.compose_path }}/docker-compose"
8488
89+
- name: Install self-hosted
90+
run: ./install.sh
91+
8592
- name: Integration Test
86-
run: ./integration-test.sh
93+
run: ./integration-test.sh --${{ matrix.test_type }}
8794

8895
- name: Inspect failure
8996
if: failure()

_integration-test/run.sh

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,23 @@
11
#!/usr/bin/env bash
22
set -ex
33

4-
source install/_lib.sh
5-
source install/dc-detect-version.sh
6-
74
echo "${_group}Setting up variables and helpers ..."
85
export SENTRY_TEST_HOST="${SENTRY_TEST_HOST:-http://localhost:9000}"
96
TEST_USER='[email protected]'
107
TEST_PASS='test123TEST'
118
COOKIE_FILE=$(mktemp)
129

13-
# Courtesy of https://stackoverflow.com/a/2183063/90297
14-
trap_with_arg() {
15-
func="$1"
16-
shift
17-
for sig; do
18-
trap "$func $sig "'$LINENO' "$sig"
19-
done
20-
}
21-
22-
DID_TEAR_DOWN=0
23-
# the teardown function will be the exit point
24-
teardown() {
25-
if [ "$DID_TEAR_DOWN" -eq 1 ]; then
26-
return 0
27-
fi
28-
DID_TEAR_DOWN=1
29-
30-
if [ "$1" != "EXIT" ]; then
31-
echo "An error occurred, caught SIG$1 on line $2"
32-
fi
33-
34-
echo "Tearing down ..."
35-
rm $COOKIE_FILE
36-
echo "Done."
37-
}
38-
trap_with_arg teardown ERR INT TERM EXIT
10+
trap_with_arg cleanup ERR INT TERM EXIT
3911
echo "${_endgroup}"
4012

4113
echo "${_group}Starting Sentry for tests ..."
4214
# Disable beacon for e2e tests
4315
echo 'SENTRY_BEACON=False' >>$SENTRY_CONFIG_PY
44-
echo y | $dcr web createuser --force-update --superuser --email $TEST_USER --password $TEST_PASS
4516
$dc up -d
46-
printf "Waiting for Sentry to be up"
4717
timeout 90 bash -c 'until $(curl -Isf -o /dev/null $SENTRY_TEST_HOST); do printf '.'; sleep 0.5; done'
18+
# DC exec here is faster, tests run on the slower side and using exec would provide a boost
19+
echo y | $dc exec web sentry createuser --force-update --superuser --email $TEST_USER --password $TEST_PASS
20+
printf "Waiting for Sentry to be up"
4821
echo ""
4922
echo "${_endgroup}"
5023

install/error-handling.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
echo "${_group}Setting up error handling ..."
22

3-
export SENTRY_DSN='https://[email protected]/3'
4-
export SENTRY_ORG=self-hosted
5-
export SENTRY_PROJECT=installer
3+
if [ -z "${SENTRY_DSN:-}" ]; then
4+
export SENTRY_DSN='https://19555c489ded4769978daae92f2346ca@self-hosted.getsentry.net/3'
5+
fi
66

77
$dbuild -t sentry-self-hosted-jq-local --platform="$DOCKER_PLATFORM" jq
88

99
jq="docker run --rm -i sentry-self-hosted-jq-local"
10-
sentry_cli="docker run --rm -v /tmp:/work -e SENTRY_ORG=$SENTRY_ORG -e SENTRY_PROJECT=$SENTRY_PROJECT -e SENTRY_DSN=$SENTRY_DSN getsentry/sentry-cli"
10+
sentry_cli="docker run --rm -v /tmp:/work -e SENTRY_DSN=$SENTRY_DSN getsentry/sentry-cli"
1111

1212
send_envelope() {
1313
# Send envelope

integration-test.sh

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,40 @@
11
#!/usr/bin/env bash
22
set -ex
33

4+
source install/_lib.sh
5+
source install/detect-platform.sh
6+
source install/dc-detect-version.sh
7+
source install/error-handling.sh
8+
49
echo "Reset customizations"
510
rm -f sentry/enhance-image.sh
611
rm -f sentry/requirements.txt
7-
export REPORT_SELF_HOSTED_ISSUES=0
812

9-
echo "Testing initial install"
10-
./install.sh
11-
_integration-test/run.sh
12-
_integration-test/ensure-customizations-not-present.sh
13-
_integration-test/ensure-backup-restore-works.sh
13+
test_option="$1"
14+
export MINIMIZE_DOWNTIME=0
1415

15-
echo "Make customizations"
16-
cat <<EOT >sentry/enhance-image.sh
16+
if [[ "$test_option" == "--initial-install" ]]; then
17+
echo "Testing initial install"
18+
source _integration-test/run.sh
19+
source _integration-test/ensure-customizations-not-present.sh
20+
source _integration-test/ensure-backup-restore-works.sh
21+
elif [[ "$test_option" == "--customizations" ]]; then
22+
echo "Testing customizations"
23+
$dc up -d
24+
echo "Making customizations"
25+
cat <<EOT >sentry/enhance-image.sh
1726
#!/bin/bash
1827
touch /created-by-enhance-image
1928
apt-get update
2029
apt-get install -y gcc libsasl2-dev python-dev libldap2-dev libssl-dev
2130
EOT
22-
chmod +x sentry/enhance-image.sh
23-
printf "python-ldap" >sentry/requirements.txt
31+
chmod +x sentry/enhance-image.sh
32+
printf "python-ldap" >sentry/requirements.txt
2433

25-
echo "Testing in-place upgrade and customizations"
26-
./install.sh --minimize-downtime
27-
_integration-test/run.sh
28-
_integration-test/ensure-customizations-work.sh
29-
_integration-test/ensure-backup-restore-works.sh
34+
echo "Testing in-place upgrade and customizations"
35+
export MINIMIZE_DOWNTIME=1
36+
./install.sh
37+
source _integration-test/run.sh
38+
source _integration-test/ensure-customizations-work.sh
39+
source _integration-test/ensure-backup-restore-works.sh
40+
fi

test.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
# This file runs in https://github.com/getsentry/sentry/blob/fe4795f5eae9e0d7c33e0ecb736c9d1369535eca/docker/cloudbuild.yaml#L59
4+
export MINIMIZE_DOWNTIME=0
5+
export REPORT_SELF_HOSTED_ISSUES=1
56

6-
_integration-test/run.sh
7+
# This file runs in https://github.com/getsentry/sentry/blob/fe4795f5eae9e0d7c33e0ecb736c9d1369535eca/docker/cloudbuild.yaml#L59
8+
source install/_lib.sh
9+
source install/detect-platform.sh
10+
source install/dc-detect-version.sh
11+
source install/error-handling.sh
12+
source _integration-test/run.sh

0 commit comments

Comments
 (0)