Add hammer selftest smoke-test subcommand#11
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a
hammer selftestsubcommand: a dependency-free smoke test that drivesthe real load engine against an in-process HTTP server and verifies the
behaviors an agent relies on.
Exits
0when all checks pass,1otherwise.-jsonemits machine-readableresults so CI/agents can assert on the binary's health before relying on it.
Why
hammeris meant to be driven by agents.selftestlets an agent confirm afreshly installed/updated binary actually works (request path, accounting,
status classification,
-ok, SLO checks, header propagation, both profileformats) without needing an external target or network — complementing the
updateself-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 servercapture.
go test -race ./...,go vet,gofmtall clean; package coverage84.8%.
🤖 Generated with Claude Code