Skip to content

test: keep unit tests and Harbor runs from sending usage events - #1732

Merged
sarayev merged 3 commits into
mainfrom
fix/disable-telemetry-in-tests
Nov 22, 2026
Merged

sarayev merged 3 commits into
mainfrom
fix/disable-telemetry-in-tests

Conversation

@sarayev

@sarayev sarayev commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Problem

Usage events from our own test runs show up in Prod as real usage. Unit tests in core and blocks run the real CLI, its bins and core's tracked entry points (runSecretCli, runConfigCli, writeSpec, ...). CI runs report ci: true and are filtered out, but a developer's or coding agent's local run has no CI marker. Each fixture is a new temp app, so one machine looks like one installation with a new project per test. Since the 1.0 RCs, four such installations account for most generate:spec, secret, generate:client, dev:stop, docs and config events.

Harbor also sets BLOCKS_DISABLE_TELEMETRY, which nothing reads since #1606, so Harbor runs aren't opted out either.

Issue #, if available:

Changes

  • scripts/test-telemetry-off.env sets CDK_DISABLE_CLI_TELEMETRY=1. The core and blocks test scripts load it with node --env-file, which works on Windows too and applies to every test process. A value already set in the environment wins. Tests that check telemetry clear the variable themselves, as before.
  • telemetry.test.ts: two --telemetry-file tests ("handles path with spaces", "skips pre-existing file atomically") sent their event to the default endpoint. The suite now points them at a closed local port.
  • Harbor (harbor-agent-check.yml, Dockerfile, verify.py, calibrate.py): BLOCKS_DISABLE_TELEMETRY → CDK_DISABLE_CLI_TELEMETRY.

The published packages don't change; the changeset exists because the guard requires one for any change under a package.

Validation

Each package's npm test was run with CI unset, a throwaway HOME, and BLOCKS_TELEMETRY_ENDPOINT pointed at a local collector, so every event a test would send to the default endpoint was counted:

before after
core 9 events (generate:spec ×7, deploy ×2) 0
blocks 48 events (secret ×12, dev ×9, generate:client ×8, dev:stop ×8, docs ×6, config ×5) 0
every other package 0 0

Test results are unchanged: core 3307 pass, blocks 680 + 52 pass. scripts/ci/harbor-*.test.mjs: 37 pass. Changeset guards and the license-header check pass.

Checklist

  • PR description included
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Unit tests in core and blocks run the real CLI, its bins and core's tracked
entry points. On a developer's machine there is no CI marker, so every run sent
real usage events (about 57 per run of the two suites: secret, config, docs,
dev, dev:stop, generate:client, generate:spec and deploy), counted as real usage.

- Both test scripts load scripts/test-telemetry-off.env with node --env-file,
  which sets CDK_DISABLE_CLI_TELEMETRY=1 for every test process. Tests that
  check telemetry clear it themselves, as before.
- Two --telemetry-file tests in telemetry.test.ts sent their event to the
  default endpoint; the suite now points them at a closed local port.
- Harbor set BLOCKS_DISABLE_TELEMETRY, which nothing reads any more; it now sets
  CDK_DISABLE_CLI_TELEMETRY.
@sarayev
sarayev disabled auto-merge November 20, 2026 19:58
@sarayev
sarayev enabled auto-merge (squash) November 20, 2026 19:58

This branch had an error being deployed

1 failed and 1 inactive deployments
e2e — c763f346 Deployed Nov 22, 2026 by sarayev via E2E Teardown Verify #7847
agent-bench — c763f346 Deployed Nov 22, 2026 by sarayev via bench / summary #6855
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.

2 participants