Skip to content

Commit d5ce271

Browse files
authored
Merge branch 'master' into patch-1
2 parents 73985f6 + 7c99269 commit d5ce271

16 files changed

+409
-278
lines changed

.github/workflows/test.yml

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ defaults:
1616
jobs:
1717
e2e-test:
1818
if: github.repository_owner == 'getsentry'
19-
runs-on: ubuntu-20.04
19+
runs-on: ubuntu-22.04
2020
name: "Sentry self-hosted end-to-end tests"
2121
steps:
2222
- name: Checkout
@@ -37,13 +37,13 @@ jobs:
3737
sudo chmod +x "/usr/local/lib/docker/cli-plugins/docker-compose"
3838
3939
- name: End to end tests
40-
uses: getsentry/action-self-hosted-e2e-tests@03010bd2963edc1f47b6e5e03167a4bc1433ea36
40+
uses: getsentry/action-self-hosted-e2e-tests@main
4141
with:
4242
project_name: self-hosted
4343

4444
unit-test:
4545
if: github.repository_owner == 'getsentry'
46-
runs-on: ubuntu-20.04
46+
runs-on: ubuntu-22.04
4747
name: "unit tests"
4848
steps:
4949
- name: Checkout
@@ -54,12 +54,12 @@ jobs:
5454

5555
integration-test:
5656
if: github.repository_owner == 'getsentry'
57-
runs-on: ubuntu-20.04
58-
name: "integration test"
57+
runs-on: ubuntu-22.04
58+
name: integration test ${{ matrix.compose_version }} - customizations ${{ matrix.customizations }}
5959
strategy:
6060
fail-fast: false
6161
matrix:
62-
test_type: ["initial-install", "customizations"]
62+
customizations: ["disabled", "enabled"]
6363
compose_version: ["v2.0.1", "v2.7.0"]
6464
include:
6565
- compose_version: "v2.0.1"
@@ -68,12 +68,28 @@ jobs:
6868
compose_path: "/usr/local/lib/docker/cli-plugins"
6969
env:
7070
COMPOSE_PROJECT_NAME: self-hosted-${{ strategy.job-index }}
71-
SENTRY_DSN: https://[email protected]/6627632
72-
REPORT_SELF_HOSTED_ISSUES: 1
71+
REPORT_SELF_HOSTED_ISSUES: 0
72+
SELF_HOSTED_TESTING_DSN: ${{ vars.SELF_HOSTED_TESTING_DSN }}
7373
steps:
7474
- name: Checkout
7575
uses: actions/checkout@v4
7676

77+
- name: Setup dev environment
78+
run: |
79+
pip install -r requirements-dev.txt
80+
echo "PY_COLORS=1" >> "$GITHUB_ENV"
81+
### pytest-sentry configuration ###
82+
if [ "$GITHUB_REPOSITORY" = "getsentry/self-hosted" ]; then
83+
echo "PYTEST_SENTRY_DSN=$SELF_HOSTED_TESTING_DSN" >> $GITHUB_ENV
84+
echo "PYTEST_SENTRY_TRACES_SAMPLE_RATE=0" >> $GITHUB_ENV
85+
86+
# This records failures on master to sentry in order to detect flakey tests, as it's
87+
# expected that people have failing tests on their PRs
88+
if [ "$GITHUB_REF" = "refs/heads/master" ]; then
89+
echo "PYTEST_SENTRY_ALWAYS_REPORT=1" >> $GITHUB_ENV
90+
fi
91+
fi
92+
7793
- name: Get Compose
7894
run: |
7995
# Always remove `docker compose` support as that's the newer version
@@ -87,13 +103,29 @@ jobs:
87103
sudo chmod +x "${{ matrix.compose_path }}/docker-compose"
88104
89105
- name: Install self-hosted
90-
run: ./install.sh
106+
uses: nick-fields/retry@v3
107+
with:
108+
timeout_minutes: 10
109+
max_attempts: 3
110+
command: ./install.sh
91111

92112
- name: Integration Test
93-
run: ./integration-test.sh --${{ matrix.test_type }}
113+
run: pytest --cov --junitxml=junit.xml --reruns 3 _integration-test/ --customizations=${{ matrix.customizations }}
94114

95115
- name: Inspect failure
96116
if: failure()
97117
run: |
98118
docker compose ps
99119
docker compose logs
120+
121+
- name: Upload coverage to Codecov
122+
uses: codecov/codecov-action@v4
123+
with:
124+
token: ${{ secrets.CODECOV_TOKEN }}
125+
slug: getsentry/self-hosted
126+
127+
- name: Upload test results to Codecov
128+
if: ${{ !cancelled() }}
129+
uses: codecov/test-results-action@v1
130+
with:
131+
token: ${{ secrets.CODECOV_TOKEN }}

_integration-test/conftest.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import subprocess
2+
import os
3+
import time
4+
import httpx
5+
import pytest
6+
7+
SENTRY_CONFIG_PY = "sentry/sentry.conf.py"
8+
SENTRY_TEST_HOST = os.getenv("SENTRY_TEST_HOST", "http://localhost:9000")
9+
TEST_USER = "[email protected]"
10+
TEST_PASS = "test123TEST"
11+
TIMEOUT_SECONDS = 60
12+
13+
def pytest_addoption(parser):
14+
parser.addoption("--customizations", default="disabled")
15+
16+
@pytest.fixture(scope="session", autouse=True)
17+
def configure_self_hosted_environment(request):
18+
subprocess.run(["docker", "compose", "--ansi", "never", "up", "-d"], check=True)
19+
for i in range(TIMEOUT_SECONDS):
20+
try:
21+
response = httpx.get(SENTRY_TEST_HOST, follow_redirects=True)
22+
except httpx.NetworkError:
23+
time.sleep(1)
24+
else:
25+
if response.status_code == 200:
26+
break
27+
else:
28+
raise AssertionError("timeout waiting for self-hosted to come up")
29+
30+
if request.config.getoption("--customizations") == "enabled":
31+
os.environ['TEST_CUSTOMIZATIONS'] = "enabled"
32+
script_content = '''\
33+
#!/bin/bash
34+
touch /created-by-enhance-image
35+
apt-get update
36+
apt-get install -y gcc libsasl2-dev python-dev libldap2-dev libssl-dev
37+
'''
38+
39+
with open('sentry/enhance-image.sh', 'w') as script_file:
40+
script_file.write(script_content)
41+
# Set executable permissions for the shell script
42+
os.chmod('sentry/enhance-image.sh', 0o755)
43+
44+
# Write content to the requirements.txt file
45+
with open('sentry/requirements.txt', 'w') as req_file:
46+
req_file.write('python-ldap\n')
47+
os.environ['MINIMIZE_DOWNTIME'] = "1"
48+
subprocess.run(["./install.sh"], check=True)
49+
# Create test user
50+
subprocess.run(
51+
[
52+
"docker",
53+
"compose",
54+
"exec",
55+
"-T",
56+
"web",
57+
"sentry",
58+
"createuser",
59+
"--force-update",
60+
"--superuser",
61+
"--email",
62+
TEST_USER,
63+
"--password",
64+
TEST_PASS,
65+
"--no-input",
66+
],
67+
check=True,
68+
text=True,
69+
)
70+
71+
@pytest.fixture()
72+
def setup_backup_restore_env_variables():
73+
os.environ['SENTRY_DOCKER_IO_DIR'] = os.path.join(os.getcwd(), 'sentry')
74+
os.environ['SKIP_USER_CREATION'] = "1"

_integration-test/custom-ca-roots/setup.sh

100644100755
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env bash
12
set -e
23
export COMPOSE_FILE=docker-compose.yml:_integration-test/custom-ca-roots/docker-compose.test.yml
34

@@ -42,4 +43,4 @@ openssl req -x509 -newkey rsa:2048 -nodes -days 1 -keyout $TEST_NGINX_CONF_PATH/
4243

4344
cp _integration-test/custom-ca-roots/test.py sentry/test-custom-ca-roots.py
4445

45-
$dc up -d fixture-custom-ca-roots
46+
docker compose --ansi never up -d fixture-custom-ca-roots

_integration-test/custom-ca-roots/teardown.sh

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env bash
12
$dc rm -s -f -v fixture-custom-ca-roots
23
rm -f certificates/test-custom-ca-roots.crt sentry/test-custom-ca-roots.py
34
unset COMPOSE_FILE

_integration-test/ensure-backup-restore-works.sh

Lines changed: 0 additions & 36 deletions
This file was deleted.

_integration-test/ensure-customizations-not-present.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

_integration-test/ensure-customizations-work.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)