mirror of
https://github.com/block/buzz.git
synced 2026-11-24 10:12:19 +00:00
feat(test-client): add buzz-acceptance relay probe (#9767)
## Summary
Adds `buzz-acceptance`, a third binary in `buzz-test-client` (next to
`buzz-loadgen`). One run checks the relay's core jobs once against one
relay and exits. It is meant to run on a schedule (for example a
Kubernetes CronJob) or as a deployment step (for example an Argo
Rollouts `job` analysis against the canary Service).
Checks, in order:
| Check | Stages |
|---|---|
| `relay_info` | `nip11` (the response must be a NIP-11 document) |
| `connect_auth` | `ws_connect`, `nip42_auth` |
| `channel_create` | `create` (a private, per-run channel with a 1 h
TTL) |
| `publish` | `ok` |
| `fanout` | `connect_second`, `subscribe`, `publish`, `receive` |
| `history` | `req_eose` (the published event is in a fresh REQ, intact)
|
| `access_control` | `unauthenticated_rejected`,
`pubkey_mismatch_rejected` |
| `cleanup` | `connect`, `delete_channel` (on a fresh connection) |
`access_control` passes only on the relay's own denial reasons:
`auth-required:` for a write on a socket that sent the NIP-FI assertion
but skipped NIP-42 AUTH, and `invalid: event pubkey does not match
authenticated identity` for a write signed by another key. A closed
socket or any other reason fails the stage.
`fanout` reads the listener while the publish waits for its OK, so
`receive` measures delivery (publish → arrival on the second socket),
not the publisher's acknowledgement.
`fanout` and `history` verify the event they get back (`Event::verify`:
id and signature against its content). An event the relay corrupted
under its original id fails the stage.
A channel is never stranded on purpose. If the create times out or the
socket drops, the probe keeps the channel id and `cleanup` deletes it
over a fresh connection. A failed cleanup names the channel. The TTL
archives any channel a killed run leaves behind.
Output:
- A JSON report on stdout: each check's result, the stage that failed,
and each completed stage's duration.
- Optional DogStatsD metrics (`--statsd-addr`): `<prefix>.runs`,
`<prefix>.run.seconds`, `<prefix>.check.runs{check,result,stage}`,
`<prefix>.check.seconds{check,result}`,
`<prefix>.stage.seconds{check,stage}`. Every series also carries
`relay_version` (from NIP-11) and any `--tag k:v`.
- Exit code 0 when every check passed, 1 when a check failed, 2 when the
probe could not run or send its metrics.
A check whose prerequisite failed is reported as `skipped`, so each
failure is counted once, at its cause, and every run reports the same
set of checks.
### NIP-FI
On a relay that enforces NIP-FI, pass `--assertion-file` (a regular
file, at most 16 KiB; a FIFO or larger file fails the connection at
once). The probe reads the file before every connection and sends it as
`Nostr-Federated-Identity: Bearer …`. Another process (for example a
sidecar) keeps it fresh. How the assertion is minted is deployment
configuration and stays out of this repo.
## What got simpler
Nothing got simpler. This adds one binary. It reuses `buzz-ws-client`
and the crate's existing dependencies, and adds no new crate and no new
dependency (`clap` gains its `env` feature).
## Testing
- Unit tests drive the probe against a scripted relay: a publisher OK
that arrives 600 ms after delivery (`receive` stays under 300 ms), a
refusal with the wrong reason and a closed socket (both fail
`access_control`), an unanswered create and a socket lost after create
(both still delete that exact channel), and a failed cleanup (the error
names the channel). Also: metric lines and tags, one datagram per line,
stage timeout, assertion file limits, and an unreachable relay.
- `tests/e2e_acceptance.rs` runs in CI's Relay E2E lane against a live
relay. It runs the shared runner and the binary itself: exit 0 with JSON
and datagrams on a pass, exit 1 when a check fails, exit 2 when the
probe cannot run.
## Follow-ups (not in this PR)
- Image and CronJob / Rollouts wiring.
- Before the probe can gate a canary: a dial override that keeps the
canonical Host and signed relay URL (like `buzz-loadgen`'s
`connect_addr`).
- Before it can gate a promotion: a build identifier from the relay.
`relay_version` is the Cargo package version, which several image builds
can share.
- Confirm the delete took effect: read the channel back after
`delete_channel` returns `OK true`. This needs a stable relay read
contract for deleted channels. Until then the 1 h TTL bounds any channel
a silent delete failure leaves behind. The scheduled deployment can also
sweep stale probe channels at start.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
Signed-off-by: Luke Tornquist <tornquist@squareup.com>
Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2
.github/workflows/_ci-relay.yml
vendored
2
.github/workflows/_ci-relay.yml
vendored
@@ -692,7 +692,7 @@ jobs:
|
||||
./scripts/start-relay-for-tests.sh --no-build
|
||||
- name: Relay E2E tests
|
||||
run: |
|
||||
cargo test -p buzz-test-client --test e2e_persona --test e2e_team_catalog --test e2e_nostr_interop --test e2e_thread_roots --test e2e_project -- --ignored --nocapture
|
||||
cargo test -p buzz-test-client --test e2e_persona --test e2e_team_catalog --test e2e_nostr_interop --test e2e_thread_roots --test e2e_project --test e2e_acceptance -- --ignored --nocapture
|
||||
cargo test -p buzz-test-client --test e2e_relay invite -- --ignored --nocapture
|
||||
cargo test -p buzz-test-client --test e2e_relay nip43_membership_snapshots_are_rejected -- --ignored --nocapture
|
||||
cargo test -p buzz-test-client --test e2e_relay nip_ia_archive_snapshots_are_rejected -- --ignored --nocapture
|
||||
|
||||
Reference in New Issue
Block a user