From f18a9709a733fc2a9153d6dc5d4343c555fd1258 Mon Sep 17 00:00:00 2001 From: Hubert Deng Date: Tue, 31 Dec 2024 14:46:02 -0800 Subject: [PATCH] feat(devservices): Docker compose backend tests use devservices (#81941) 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 --- ...ckend.yml => test_devservices_backend.yml} | 85 +++++++------------ devservices/config.yml | 35 ++++++++ src/sentry/testutils/pytest/relay.py | 7 +- 3 files changed, 70 insertions(+), 57 deletions(-) rename .github/workflows/{test_docker_compose_backend.yml => test_devservices_backend.yml} (75%) diff --git a/.github/workflows/test_docker_compose_backend.yml b/.github/workflows/test_devservices_backend.yml similarity index 75% rename from .github/workflows/test_docker_compose_backend.yml rename to .github/workflows/test_devservices_backend.yml index 179b1efee17362..ec3f0ae5645eab 100644 --- a/.github/workflows/test_docker_compose_backend.yml +++ b/.github/workflows/test_devservices_backend.yml @@ -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: @@ -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: @@ -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 @@ -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 @@ -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: | @@ -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 @@ -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: | @@ -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 @@ -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: | @@ -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: @@ -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: @@ -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 @@ -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: | @@ -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 diff --git a/devservices/config.yml b/devservices/config.yml index 37df3d3780a1b8..f4cf7a263b0160 100644 --- a/devservices/config.yml +++ b/devservices/config.yml @@ -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: @@ -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: @@ -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: diff --git a/src/sentry/testutils/pytest/relay.py b/src/sentry/testutils/pytest/relay.py index 76dff65c2da813..5bff85dcf2cd53 100644 --- a/src/sentry/testutils/pytest/relay.py +++ b/src/sentry/testutils/pytest/relay.py @@ -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 @@ -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, } @@ -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"}},