-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
409 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ defaults: | |
jobs: | ||
e2e-test: | ||
if: github.repository_owner == 'getsentry' | ||
runs-on: ubuntu-20.04 | ||
runs-on: ubuntu-22.04 | ||
name: "Sentry self-hosted end-to-end tests" | ||
steps: | ||
- name: Checkout | ||
|
@@ -37,13 +37,13 @@ jobs: | |
sudo chmod +x "/usr/local/lib/docker/cli-plugins/docker-compose" | ||
- name: End to end tests | ||
uses: getsentry/action-self-hosted-e2e-tests@03010bd2963edc1f47b6e5e03167a4bc1433ea36 | ||
uses: getsentry/action-self-hosted-e2e-tests@main | ||
with: | ||
project_name: self-hosted | ||
|
||
unit-test: | ||
if: github.repository_owner == 'getsentry' | ||
runs-on: ubuntu-20.04 | ||
runs-on: ubuntu-22.04 | ||
name: "unit tests" | ||
steps: | ||
- name: Checkout | ||
|
@@ -54,12 +54,12 @@ jobs: | |
|
||
integration-test: | ||
if: github.repository_owner == 'getsentry' | ||
runs-on: ubuntu-20.04 | ||
name: "integration test" | ||
runs-on: ubuntu-22.04 | ||
name: integration test ${{ matrix.compose_version }} - customizations ${{ matrix.customizations }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
test_type: ["initial-install", "customizations"] | ||
customizations: ["disabled", "enabled"] | ||
compose_version: ["v2.0.1", "v2.7.0"] | ||
include: | ||
- compose_version: "v2.0.1" | ||
|
@@ -68,12 +68,28 @@ jobs: | |
compose_path: "/usr/local/lib/docker/cli-plugins" | ||
env: | ||
COMPOSE_PROJECT_NAME: self-hosted-${{ strategy.job-index }} | ||
SENTRY_DSN: https://[email protected]/6627632 | ||
REPORT_SELF_HOSTED_ISSUES: 1 | ||
REPORT_SELF_HOSTED_ISSUES: 0 | ||
SELF_HOSTED_TESTING_DSN: ${{ vars.SELF_HOSTED_TESTING_DSN }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup dev environment | ||
run: | | ||
pip install -r requirements-dev.txt | ||
echo "PY_COLORS=1" >> "$GITHUB_ENV" | ||
### pytest-sentry configuration ### | ||
if [ "$GITHUB_REPOSITORY" = "getsentry/self-hosted" ]; then | ||
echo "PYTEST_SENTRY_DSN=$SELF_HOSTED_TESTING_DSN" >> $GITHUB_ENV | ||
echo "PYTEST_SENTRY_TRACES_SAMPLE_RATE=0" >> $GITHUB_ENV | ||
# This records failures on master to sentry in order to detect flakey tests, as it's | ||
# expected that people have failing tests on their PRs | ||
if [ "$GITHUB_REF" = "refs/heads/master" ]; then | ||
echo "PYTEST_SENTRY_ALWAYS_REPORT=1" >> $GITHUB_ENV | ||
fi | ||
fi | ||
- name: Get Compose | ||
run: | | ||
# Always remove `docker compose` support as that's the newer version | ||
|
@@ -87,13 +103,29 @@ jobs: | |
sudo chmod +x "${{ matrix.compose_path }}/docker-compose" | ||
- name: Install self-hosted | ||
run: ./install.sh | ||
uses: nick-fields/retry@v3 | ||
with: | ||
timeout_minutes: 10 | ||
max_attempts: 3 | ||
command: ./install.sh | ||
|
||
- name: Integration Test | ||
run: ./integration-test.sh --${{ matrix.test_type }} | ||
run: pytest --cov --junitxml=junit.xml --reruns 3 _integration-test/ --customizations=${{ matrix.customizations }} | ||
|
||
- name: Inspect failure | ||
if: failure() | ||
run: | | ||
docker compose ps | ||
docker compose logs | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
slug: getsentry/self-hosted | ||
|
||
- name: Upload test results to Codecov | ||
if: ${{ !cancelled() }} | ||
uses: codecov/test-results-action@v1 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import subprocess | ||
import os | ||
import time | ||
import httpx | ||
import pytest | ||
|
||
SENTRY_CONFIG_PY = "sentry/sentry.conf.py" | ||
SENTRY_TEST_HOST = os.getenv("SENTRY_TEST_HOST", "https://localhost:9000") | ||
TEST_USER = "[email protected]" | ||
TEST_PASS = "test123TEST" | ||
TIMEOUT_SECONDS = 60 | ||
|
||
def pytest_addoption(parser): | ||
parser.addoption("--customizations", default="disabled") | ||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def configure_self_hosted_environment(request): | ||
subprocess.run(["docker", "compose", "--ansi", "never", "up", "-d"], check=True) | ||
for i in range(TIMEOUT_SECONDS): | ||
try: | ||
response = httpx.get(SENTRY_TEST_HOST, follow_redirects=True) | ||
except httpx.NetworkError: | ||
time.sleep(1) | ||
else: | ||
if response.status_code == 200: | ||
break | ||
else: | ||
raise AssertionError("timeout waiting for self-hosted to come up") | ||
|
||
if request.config.getoption("--customizations") == "enabled": | ||
os.environ['TEST_CUSTOMIZATIONS'] = "enabled" | ||
script_content = '''\ | ||
#!/bin/bash | ||
touch /created-by-enhance-image | ||
apt-get update | ||
apt-get install -y gcc libsasl2-dev python-dev libldap2-dev libssl-dev | ||
''' | ||
|
||
with open('sentry/enhance-image.sh', 'w') as script_file: | ||
script_file.write(script_content) | ||
# Set executable permissions for the shell script | ||
os.chmod('sentry/enhance-image.sh', 0o755) | ||
|
||
# Write content to the requirements.txt file | ||
with open('sentry/requirements.txt', 'w') as req_file: | ||
req_file.write('python-ldap\n') | ||
os.environ['MINIMIZE_DOWNTIME'] = "1" | ||
subprocess.run(["./install.sh"], check=True) | ||
# Create test user | ||
subprocess.run( | ||
[ | ||
"docker", | ||
"compose", | ||
"exec", | ||
"-T", | ||
"web", | ||
"sentry", | ||
"createuser", | ||
"--force-update", | ||
"--superuser", | ||
"--email", | ||
TEST_USER, | ||
"--password", | ||
TEST_PASS, | ||
"--no-input", | ||
], | ||
check=True, | ||
text=True, | ||
) | ||
|
||
@pytest.fixture() | ||
def setup_backup_restore_env_variables(): | ||
os.environ['SENTRY_DOCKER_IO_DIR'] = os.path.join(os.getcwd(), 'sentry') | ||
os.environ['SKIP_USER_CREATION'] = "1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#!/usr/bin/env bash | ||
$dc rm -s -f -v fixture-custom-ca-roots | ||
rm -f certificates/test-custom-ca-roots.crt sentry/test-custom-ca-roots.py | ||
unset COMPOSE_FILE |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.