You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(telemetry): consistent invocation ID per run and add telemetry test infra
- root.go: set invocation ID only when empty so all API requests in one CLI run
share the same invocation_id (fixes multiple IDs when gateway PreRun calls
ValidateAPIKey then connection PreRun overwrote telemetry)
- pkg/cmd: add TestInvocationIDPersistsAcrossMultipleInitTelemetryCalls (fails
without fix, passes with it)
- test/acceptance: recording proxy (StartRecordingProxy, AssertTelemetryConsistent,
RunListenWithTimeout, RunWithEnv, NewCLIRunnerWithConfigPath/NoCI), telemetry_test.go
proxy-based tests, TestTelemetryInvocationIDConsistentWhenValidateAPIKeyInPreRun,
TestTelemetryListenProxy in listen_test.go, README section
Made-with: Cursor
Copy file name to clipboardExpand all lines: test/acceptance/README.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,12 @@ These tests require browser-based authentication via `hookdeck login` and must b
18
18
19
19
**Why Manual?** These tests access endpoints (like `/teams`) that require CLI authentication keys obtained through interactive browser login, which aren't available to CI service accounts.
20
20
21
+
### Recording proxy (telemetry tests)
22
+
23
+
Some tests (e.g. `TestTelemetryGatewayConnectionListProxy` in `telemetry_test.go`) use a **recording proxy**: the CLI is run with `--api-base` pointing at a local HTTP server that forwards every request to the real Hookdeck API and records method, path, and the `X-Hookdeck-CLI-Telemetry` header. The same `CLIRunner` and `go run main.go` flow are used as in other acceptance tests; only the API base URL is overridden so traffic goes through the proxy. This verifies that a single CLI run sends consistent telemetry (same `invocation_id` and `command_path`) on all API calls. Helpers: `StartRecordingProxy`, `AssertTelemetryConsistent`.
24
+
25
+
**Login telemetry test (TestTelemetryLoginProxy)** uses the same proxy approach: it runs `hookdeck login --api-key KEY` with `--api-base` set to the proxy, and asserts exactly one recorded request (GET `/2025-07-01/cli-auth/validate`) with consistent telemetry. It uses **HOOKDECK_CLI_TESTING_CLI_KEY** (not the API/CI key), because the validate endpoint accepts CLI keys from interactive login; if unset, the test is skipped. Other telemetry tests still use the normal API key via `NewCLIRunner`.
require.NotEmpty(t, apiKey, "HOOKDECK_CLI_TESTING_API_KEY must be set")
260
+
projectRoot, err:=filepath.Abs("../..")
261
+
require.NoError(t, err, "Failed to get project root path")
262
+
return&CLIRunner{
263
+
t: t,
264
+
apiKey: apiKey,
265
+
projectRoot: projectRoot,
266
+
configPath: configPath,
267
+
}
268
+
}
269
+
89
270
// getAcceptanceAPIKey returns the API key for the current acceptance slice.
90
271
// When ACCEPTANCE_SLICE=1 and HOOKDECK_CLI_TESTING_API_KEY_2 is set, use it; when ACCEPTANCE_SLICE=2 and HOOKDECK_CLI_TESTING_API_KEY_3 is set, use that; else HOOKDECK_CLI_TESTING_API_KEY.
0 commit comments