Conversation
- POST /config and POST /stop now check Authorization: Bearer <token> when API_AUTH_TOKEN env var is set; returns 401 if missing/invalid. Fully backwards-compatible: when unset, endpoints remain open. - POST /stop sends stop signal to all workers, aborts handles, and transitions node_state to "idle". Returns JSON summary with last known RPS and worker count. - Updated help text to document API_AUTH_TOKEN and POST /stop. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- YamlMetadata gains an optional `tenant` field (metadata.tenant in YAML).
Backwards-compatible: omit the field and behaviour is unchanged.
- Five Prometheus metrics now carry a `tenant` label alongside `region`:
REQUEST_TOTAL, REQUEST_STATUS_CODES, CONCURRENT_REQUESTS,
REQUEST_DURATION_SECONDS, REQUEST_ERRORS_BY_CATEGORY,
SCENARIO_REQUESTS_TOTAL. Empty string when no tenant is set.
- WorkerConfig and ScenarioWorkerConfig gain a `tenant: String` field
threaded through all worker-spawning sites (config-watcher, startup,
standby, scenario paths) and all metric recording call sites.
- TestState tracks the active tenant; GET /health exposes it as
`"tenant": null | "acme"` so the web layer can see who owns the node.
- POST /stop accepts an optional JSON body `{"tenant": "acme"}`.
When supplied, the endpoint returns 409 Conflict if the active test
belongs to a different tenant, preventing one client from stopping
another client's test. Omit the body to stop unconditionally.
- Metrics updater resets RPS delta tracking when the active tenant
changes, preventing phantom RPS spikes at test boundaries.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…olations - Move `new_tenant` extraction before worker spawning block so all three ScenarioWorkerConfig/WorkerConfig sites can reference it - Collapse rustfmt two-line splits: current_tenant, active, curr_requests, and tenant:.clone().unwrap_or_default() in struct literal Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Split REQUEST_TOTAL chained calls in worker.rs to match rustfmt style - Reformat body_bytes/stop_tenant block and curr_requests chain in main.rs to match rustfmt's expected indentation - Replace test_realistic_user_pool httpbin.org dependency with wiremock mock server to eliminate CI flakiness from live endpoint unavailability Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
All 4 metric helpers used the old label arity after tenant was added. Workers write with &["local", ""] but reads used &["local"] causing InconsistentCardinality panics in prometheus. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- test_mixed_methods_scenario: mock all 4 methods locally; fix the buggy assertion that panicked on out-of-bounds index when fewer than 4 steps were returned (change OR to assert_eq!(len, 4)) - test_case_insensitive_methods: mock GET /get and POST /post locally so the case-folding logic in executor.rs is tested without a live network dependency Co-Authored-By: Claude Opus 4.6 <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.
Summary
POST /configandPOST /stop— when the env var is set both endpoints requireAuthorization: Bearer <token>; 401 on mismatch. Backwards-compatible: when unset, endpoints are open (closes Security: Authenticate POST /config endpoint #91)POST /stopendpoint — stops all workers, transitions node to idle, returns JSON summary (closes Add POST /stop endpoint for test cancellation #93)metadata.tenantin the YAML config and every request metric gets atenantlabel so per-tenant request counts are queryable for billingPOST /stop {"tenant": "acme"}returns 409 Conflict if a different tenant's test is active, preventing one client from stopping another's testWhat changed
src/yaml_config.rsYamlMetadatagainspub tenant: Option<String>— optional, fully backwards-compatiblesrc/metrics.rsFive metrics now carry a
"tenant"label alongside"region":REQUEST_TOTAL— primary billing counterREQUEST_STATUS_CODESCONCURRENT_REQUESTSREQUEST_DURATION_SECONDSREQUEST_ERRORS_BY_CATEGORYSCENARIO_REQUESTS_TOTALsrc/worker.rsWorkerConfigandScenarioWorkerConfiggainpub tenant: Stringsrc/main.rsTestStatetrackstenant: Option<String>for the active run"tenant": null | "acme"POST /config— auth check before body consumptionPOST /stop— optional{"tenant": "..."}body; 409 if tenant mismatch; clears tenant on stopAuth behaviour
API_AUTH_TOKENset?POST /stop tenant scoping
{"tenant":"acme"}"acme"{"tenant":"acme"}"other"or noneYAML example
Prometheus query for billing
Test plan
POST /configwith tenant YAML → GET /health shows"tenant": "acme"tenant="acme"label onrequests_totalPOST /stop {"tenant":"acme"}stops correct testPOST /stop {"tenant":"other"}returns 409 when different tenant activePOST /stop(no body) stops regardless of tenantRelated issues
🤖 Generated with Claude Code