hero_service: standard tests, E2E test harness, and CLI tool #29
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
With
HeroRpcServerandHeroUiServer(from #27) standardizing how all Hero services start, bind sockets, and expose endpoints, we can now build standard tooling on top.1. Standard Test Helpers
Ship reusable test functions in
hero_service::testthat any service can import in its integration tests:These would connect to
~/hero/var/sockets/{service_name}.sockvia HTTP and validate responses.2. E2E Test Harness
A test runner that starts server + ui, runs all standard tests, then service-specific tests:
3.
hero_serviceCLI BinaryA binary in
hero_rpcthat provides standardized commands across all services:This replaces per-repo Makefile targets with a single tool that knows the conventions.
4. Standardize Makefile Targets
With
hero_serviceCLI, Makefiles become thin wrappers:Implementation Priority
hero_service::test) — highest value, enables CIhero_serviceCLI binary — developer ergonomicsImplementation Context
This issue builds on the unified server lifecycle from #27. Here's what exists now and what needs to be built.
Current State (from #27)
hero_servicecrate (inhero_rpcrepo, branchdevelopment_home27):HeroRpcServer— RPC server builder with mandatory endpoints (/health,/openrpc.json,/.well-known/heroservice.json)HeroUiServer— UI server builder (no mandatory endpoint injection)HeroServer— base: Unix socket binding, graceful shutdown, lifecycle CLIHeroLifecycle— hero_init process management (run/start/stop/status/logs)LifecycleCommand— clap enum with standard CLI subcommandsserve_unix()— shared UDS accept loop helperNoServeArgs— empty args for simple servicesSocket convention:
~/hero/var/sockets/{service_name}.sockMandatory endpoints (HeroRpcServer only):
GET /health→{"status":"ok","service":"...","version":"..."}GET /openrpc.json→ the spec passed at constructionGET /.well-known/heroservice.json→{"protocol":"openrpc","name":"...","version":"...","description":"..."}Services already migrated:
hero_inspector_server→HeroRpcServerhero_inspector_ui→HeroUiServerhero_osis_server→HeroRpcServer(single socket,_contextin params)hero_osis_ui→HeroUiServerhero_init (forked from zinit, at
lhumina_code/hero_init, branchdevelopment_home27):hero_init_sdk— Rust SDK for hero_init process supervisor~/hero/var/sockets/hero_init_server.sockHERO_INIT_SOCKETKey Files
hero_rpc/crates/service/src/hero_server.rshero_rpc/crates/service/src/lifecycle.rshero_rpc/crates/service/src/cli.rshero_rpc/crates/service/src/lib.rshero_rpc/crates/service/Cargo.tomlWhat to Build
1. Test helpers (
hero_service::testmodule)Add a new module
hero_rpc/crates/service/src/test.rswith:These connect to
~/hero/var/sockets/{service_name}.sockvia HTTP over UDS (using hyper + hyperlocal or similar). They're meant for integration tests in service repos.2. Service harness (
hero_service::test::ServiceHarness)Starts service binaries as child processes, waits for their sockets to appear, runs standard endpoint tests automatically, provides
rpc_callfor service-specific tests.3.
hero_serviceCLI binaryNew binary in
hero_rpc/crates/service/(or a newhero_rpc/crates/hero_service_cli/crate):Uses
hero_init_sdkfor lifecycle,hero_service::testfor testing, and HTTP over UDS for endpoint checks.Dependencies Available
Already in
hero_serviceCargo.toml:axum,hyper,hyper-util,tower— for HTTP over UDShero_init_sdk— for lifecycle managementserde_json— for JSON parsingdirs— for socket path resolutionclap— for CLIMay need to add:
hyperlocal— for HTTP client over Unix sockets (test helpers)tokio::process— for spawning service binaries (harness)