Skip to content

test/ci: Add optimize endpoint + trim image build to amd64-only with PR SHA push#7869

Draft
joshuarli wants to merge 9 commits intomasterfrom
test-optimize-endpoint
Draft

test/ci: Add optimize endpoint + trim image build to amd64-only with PR SHA push#7869
joshuarli wants to merge 9 commits intomasterfrom
test-optimize-endpoint

Conversation

@joshuarli
Copy link
Copy Markdown
Member

@joshuarli joshuarli commented Apr 11, 2026

Summary

Two related changes to make Snuba PRs testable against Sentry's shuffle-tests workflow.

1. POST /tests/{dataset}/optimize endpoint

Adds a new test-mode endpoint that calls OPTIMIZE TABLE … FINAL on every ClickHouse table in a dataset.

ClickHouse's ReplacingMergeTree deduplicates rows (tombstones from deletions, replacement rows from group merge/unmerge) in the background. Under high parallel load (e.g. 16-shard test runs), background merges lag significantly, causing test assertions to see stale data.

OPTIMIZE TABLE FINAL forces immediate synchronous deduplication, making ClickHouse state consistent for subsequent queries.

Usage from Sentry tests:

requests.post(f"{settings.SENTRY_SNUBA}/tests/events/optimize")
requests.post(f"{settings.SENTRY_SNUBA}/tests/groupedmessage/optimize")

2. Image workflow: amd64-only + SHA tag on PRs

  • Drop arm64 from all build jobs — CI runners are all amd64; arm64 doubles build time with no benefit
  • Push ghcr.io/getsentry/snuba:{sha} on PRsassemble now runs on pull_request events, so the SHA-tagged image is available for Sentry's devservices to reference
  • nightly tag still only applied on master pushes
  • Collapse 2-entry matrices into single jobs
  • self-hosted-end-to-end now depends on assemble

Why the image change is needed: PRs previously built {sha}-amd64 + {sha}-arm64 but no merged manifest — the assemble job was gated to master only. Sentry's devservices config references ghcr.io/getsentry/snuba:{sha} which didn't exist for PR builds.

Test plan

  • Optimize endpoint returns 200 and ClickHouse deduplication takes effect
  • CI builds and pushes ghcr.io/getsentry/snuba:{sha} on this PR
  • nightly is NOT re-tagged on a PR build
  • nightly IS re-tagged after merge to master

Adds POST /tests/<dataset>/optimize which calls OPTIMIZE TABLE … FINAL
on every ClickHouse table belonging to that dataset.

ClickHouse's ReplacingMergeTree deduplicates rows (tombstones from
deletions, replacement rows from group merge/unmerge) in the background.
Under high parallel load, background merges lag significantly, causing
test assertions to see stale data.

OPTIMIZE TABLE FINAL forces immediate synchronous deduplication.

Usage from Sentry tests:
    requests.post(f"{settings.SENTRY_SNUBA}/tests/events/optimize")
    requests.post(f"{settings.SENTRY_SNUBA}/tests/groupedmessage/optimize")
Changes:
- Remove arm64 from all build jobs (amd64-only); CI runners are all amd64
  and building arm64 doubles build time with no benefit for CI
- Make `assemble` run on PRs (not just master/release) so that
  ghcr.io/getsentry/snuba:{sha} is available for Sentry's devservices
  to reference in integration tests and local development overrides
- `nightly` tag is still only applied on master pushes
- Collapse multi-matrix jobs into single jobs (no matrix needed for one arch)
- `self-hosted-end-to-end` now depends on `assemble` so the SHA image
  is guaranteed to exist before the e2e run
@joshuarli joshuarli changed the title feat(tests): Add /tests/{dataset}/optimize endpoint test/ci: Add optimize endpoint + trim image build to amd64-only with PR SHA push Apr 11, 2026
@joshuarli joshuarli force-pushed the test-optimize-endpoint branch from 2e86853 to 70577b4 Compare April 11, 2026 18:13
joshuarli added a commit to getsentry/sentry that referenced this pull request Apr 11, 2026
Points all snuba devservices dependencies at the test-optimize-endpoint
PR branch (getsentry/snuba#7869) which:
1. Adds POST /tests/{dataset}/optimize for synchronous ClickHouse dedup
2. Pins the image to 48d65526d...-amd64 which includes the endpoint

Reverts to master once the PR is merged and nightly is cut.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant