Skip to content

Commit

Permalink
feat(devservices): Docker compose backend tests use devservices (#81941)
Browse files Browse the repository at this point in the history
This allows us to measure the stability of devservices for sentry
backend tests. Changing the cadence of this scheduled job to hourly
again, as we need more data here. Will check devinfra metrics to get a
better sense of how well this is working in CI
  • Loading branch information
hubertdeng123 authored Dec 31, 2024
1 parent 8f5df00 commit f5727d9
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 57 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: test-docker-compose-backend
name: test-devservices-backend

on:
schedule:
- cron: '0 0 * * *'

- cron: '0 * * * *'
# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
concurrency:
Expand All @@ -13,9 +12,11 @@ concurrency:
# hack for https://github.com/actions/cache/issues/810#issuecomment-1222550359
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 3
USE_NEW_DEVSERVICES: 1
IS_DEV: 1

jobs:
docker-compose-api-docs:
devservices-api-docs:
name: api docs test
runs-on: ubuntu-24.04
steps:
Expand All @@ -31,9 +32,7 @@ jobs:
id: setup

- name: Bring up devservices
run: |
docker network create sentry
docker compose -f devservices/docker-compose-testing.yml up -d redis postgres snuba clickhouse
run: devservices up

- name: Run API docs tests
# install ts-node for ts build scripts to execute properly without potentially installing
Expand All @@ -44,11 +43,9 @@ jobs:
- name: Inspect failure
if: failure()
run: |
docker compose -f devservices/docker-compose-testing.yml ps
docker compose -f devservices/docker-compose-testing.yml logs --tail 1000
run: devservices logs

docker-compose-backend-test:
devservices-backend-test:
name: backend test
runs-on: ubuntu-24.04
timeout-minutes: 60
Expand All @@ -73,13 +70,11 @@ jobs:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Setup sentry env
id: setup
uses: ./.github/actions/test-setup-sentry-devservices

- name: Bring up devservices
run: |
docker network create sentry
echo "BIGTABLE_EMULATOR_HOST=127.0.0.1:8086" >> $GITHUB_ENV
docker compose -f devservices/docker-compose-testing.yml up -d
run: devservices up --mode backend-ci

- name: Run backend test (${{ steps.setup.outputs.matrix-instance-number }} of ${{ steps.setup.outputs.matrix-instance-total }})
run: |
Expand Down Expand Up @@ -107,11 +102,9 @@ jobs:

- name: Inspect failure
if: failure()
run: |
docker compose -f devservices/docker-compose-testing.yml ps
docker compose -f devservices/docker-compose-testing.yml logs --tail 1000
run: devservices logs

docker-compose-backend-migration-tests:
devservices-backend-migration-tests:
name: backend migration tests
runs-on: ubuntu-24.04
timeout-minutes: 30
Expand All @@ -127,9 +120,7 @@ jobs:
id: setup

- name: Bring up devservices
run: |
docker network create sentry
docker compose -f devservices/docker-compose-testing.yml up -d redis postgres snuba clickhouse
run: devservices up

- name: run tests
run: |
Expand All @@ -146,11 +137,9 @@ jobs:

- name: Inspect failure
if: failure()
run: |
docker compose -f devservices/docker-compose-testing.yml ps
docker compose -f devservices/docker-compose-testing.yml logs --tail 1000
run: devservices logs

docker-compose-cli:
devservices-cli:
name: cli test
runs-on: ubuntu-24.04
timeout-minutes: 10
Expand All @@ -165,9 +154,7 @@ jobs:
id: setup

- name: Bring up devservices
run: |
docker network create sentry
docker compose -f devservices/docker-compose-testing.yml up -d redis postgres
run: devservices up --mode migrations

- name: Run test
run: |
Expand All @@ -184,11 +171,9 @@ jobs:

- name: Inspect failure
if: failure()
run: |
docker compose -f devservices/docker-compose-testing.yml ps
docker compose -f devservices/docker-compose-testing.yml logs --tail 1000
run: devservices logs

docker-compose-migration:
devservices-migration:
name: check migration
runs-on: ubuntu-24.04
strategy:
Expand All @@ -204,9 +189,7 @@ jobs:
id: setup

- name: Bring up devservices
run: |
docker network create sentry
docker compose -f devservices/docker-compose-testing.yml up -d redis postgres
run: devservices up --mode migrations

- name: Migration & lockfile checks
env:
Expand All @@ -217,11 +200,9 @@ jobs:
- name: Inspect failure
if: failure()
run: |
docker compose -f devservices/docker-compose-testing.yml ps
docker compose -f devservices/docker-compose-testing.yml logs --tail 1000
run: devservices logs

docker-compose-monolith-dbs:
devservices-monolith-dbs:
name: monolith-dbs test
runs-on: ubuntu-24.04
timeout-minutes: 20
Expand All @@ -236,9 +217,7 @@ jobs:
id: setup

- name: Bring up devservices
run: |
docker network create sentry
docker compose -f devservices/docker-compose-testing.yml up -d redis postgres
run: devservices up --mode migrations

- name: Run test
run: |
Expand All @@ -265,24 +244,22 @@ jobs:

- name: Inspect failure
if: failure()
run: |
docker compose -f devservices/docker-compose-testing.yml ps
docker compose -f devservices/docker-compose-testing.yml logs --tail 1000
run: devservices logs

# This check runs once all dependent jobs have passed
# It symbolizes that all required Backend checks have succesfully passed (Or skipped)
# This step is the only required backend check
docker-compose-backend-required-check:
devservices-backend-required-check:
needs:
[
docker-compose-api-docs,
docker-compose-backend-test,
docker-compose-backend-migration-tests,
docker-compose-cli,
docker-compose-migration,
docker-compose-monolith-dbs,
devservices-api-docs,
devservices-backend-test,
devservices-backend-migration-tests,
devservices-cli,
devservices-migration,
devservices-monolith-dbs,
]
name: Docker Compose Backend
name: Devservices Backend
# This is necessary since a failed/skipped dependent job would cause this job to be skipped
if: always()
runs-on: ubuntu-24.04
Expand Down
35 changes: 35 additions & 0 deletions devservices/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ x-sentry-service-config:
repo_name: sentry-shared-redis
branch: main
repo_link: https://github.com/getsentry/sentry-shared-redis.git
symbolicator:
description: A symbolication service for native stacktraces and minidumps with symbol server support
remote:
repo_name: symbolicator
branch: master
repo_link: https://github.com/getsentry/symbolicator.git
mode: default
bigtable:
description: Bigtable emulator
redis-cluster:
description: Redis cluster used for testing
chartcuterie:
description: Chartcuterie is a service that generates charts
remote:
Expand All @@ -43,6 +54,7 @@ x-sentry-service-config:
migrations: [postgres, redis]
acceptance-ci: [postgres, snuba, chartcuterie]
taskbroker: [snuba, postgres, relay, taskbroker]
backend-ci: [snuba, postgres, redis, bigtable, redis-cluster, symbolicator]

services:
postgres:
Expand Down Expand Up @@ -76,6 +88,29 @@ services:
labels:
- orchestrator=devservices
restart: unless-stopped
bigtable:
image: 'ghcr.io/getsentry/cbtemulator:d28ad6b63e461e8c05084b8c83f1c06627068c04'
ports:
- '127.0.0.1:8086:8086'
networks:
- devservices
extra_hosts:
- host.docker.internal:host-gateway
redis-cluster:
image: ghcr.io/getsentry/docker-redis-cluster:7.0.10
ports:
- '127.0.0.1:7000:7000'
- '127.0.0.1:7001:7001'
- '127.0.0.1:7002:7002'
- '127.0.0.1:7003:7003'
- '127.0.0.1:7004:7004'
- '127.0.0.1:7005:7005'
networks:
- devservices
extra_hosts:
- host.docker.internal:host-gateway
environment:
- IP=0.0.0.0

networks:
devservices:
Expand Down
7 changes: 4 additions & 3 deletions src/sentry/testutils/pytest/relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def relay_server_setup(live_server, tmpdir_factory):
relay_port = 33331

redis_db = TEST_REDIS_DB
use_new_dev_services = environ.get("USE_NEW_DEVSERVICES", "0") == "1"
from sentry.relay import projectconfig_cache
from sentry.relay.projectconfig_cache.redis import RedisProjectConfigCache

Expand All @@ -80,8 +81,8 @@ def relay_server_setup(live_server, tmpdir_factory):
template_vars = {
"SENTRY_HOST": f"http://host.docker.internal:{port}/",
"RELAY_PORT": relay_port,
"KAFKA_HOST": "sentry_kafka",
"REDIS_HOST": "sentry_redis",
"KAFKA_HOST": "kafka-kafka-1" if use_new_dev_services else "sentry_kafka",
"REDIS_HOST": "redis-redis-1" if use_new_dev_services else "sentry_redis",
"REDIS_DB": redis_db,
}

Expand All @@ -106,7 +107,7 @@ def relay_server_setup(live_server, tmpdir_factory):
options = {
"image": RELAY_TEST_IMAGE,
"ports": {"%s/tcp" % relay_port: relay_port},
"network": "sentry",
"network": "devservices" if use_new_dev_services else "sentry",
"detach": True,
"name": container_name,
"volumes": {config_path: {"bind": "/etc/relay"}},
Expand Down

0 comments on commit f5727d9

Please sign in to comment.