Skip to content

Add hammer selftest smoke-test subcommand#11

Merged
chenchaoyi merged 1 commit into
masterfrom
claude/selftest-command
Jun 24, 2026
Merged

Add hammer selftest smoke-test subcommand#11
chenchaoyi merged 1 commit into
masterfrom
claude/selftest-command

Conversation

@chenchaoyi

Copy link
Copy Markdown
Owner

What

Adds a hammer selftest subcommand: a dependency-free smoke test that drives
the real load engine against an in-process HTTP server and verifies the
behaviors an agent relies on.

$ hammer selftest
hammer selftest

  PASS  load: 200 OK accounting
  PASS  errors: 5xx counted as failures
  PASS  extra-ok: -ok code suppresses error
  PASS  slo: p95 threshold pass/fail
  PASS  request: headers + content-type propagate
  PASS  profile: array and stream forms agree

6 passed, 0 failed

Exits 0 when all checks pass, 1 otherwise. -json emits machine-readable
results so CI/agents can assert on the binary's health before relying on it.

Why

hammer is meant to be driven by agents. selftest lets an agent confirm a
freshly installed/updated binary actually works (request path, accounting,
status classification, -ok, SLO checks, header propagation, both profile
formats) without needing an external target or network — complementing the
update self-management command.

Tests

New selftest_test.go: all-pass run + exit code, JSON shape, -h, bad flag,
the failing-report exit/detail path, statusCount, and the in-process server
capture. go test -race ./..., go vet, gofmt all clean; package coverage
84.8%.

🤖 Generated with Claude Code

A new `selftest` subcommand exercises the real load engine against an
in-process HTTP server — no network and no external target required. It
asserts the things an agent depends on actually work in this binary:

- 200 OK request accounting (sent/received/errors/error_rate/latency samples)
- 5xx responses classified as errors
- the `-ok` override turning a 4xx into a success
- SLO threshold evaluation firing both pass and fail on one run
- per-call headers and the inferred Content-Type reaching the server
- JSON-array and object-stream profile forms parsing to the same calls

Exits 0 when every check passes, 1 otherwise; `-json` emits machine-readable
results. Wired into the subcommand dispatch alongside `update`, documented in
the usage banner and README, and covered by tests (all-pass, JSON shape, help,
bad flag, failing-report exit code, server capture).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@chenchaoyi chenchaoyi merged commit 128bbd0 into master Jun 24, 2026
1 check passed
@chenchaoyi chenchaoyi deleted the claude/selftest-command branch June 24, 2026 08:08
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