test: disable Azure CLI telemetry in integration test env#363
Open
gtsiolis wants to merge 1 commit into
Open
Conversation
The Windows integration-test job fails in TestAzStopInterceptionNoOpWhenNotIntercepting during t.TempDir() auto-cleanup: testing.go:1464: TempDir RemoveAll cleanup: unlinkat ...\001: The process cannot access the file because it is being used by another process. The test assertions pass; the failure is in cleanup. The test runs real az commands, and with telemetry enabled az spawns a detached background telemetry-upload process that outlives the invocation and keeps an open handle on the test's temp working dir. Windows refuses to RemoveAll a directory another process holds open (Unix allows it, so only the Windows job flakes). Default AZURE_CORE_COLLECT_TELEMETRY=false in every test env (env.With/env.Without), mirroring the existing UnreachableAnalyticsEndpoint guard, so no uploader spawns and cleanup succeeds. Explicit per-test overrides still win. Fixes PRO-362.
anisaoshafi
approved these changes
Jul 3, 2026
anisaoshafi
left a comment
Collaborator
There was a problem hiding this comment.
Great finding on AZURE_CORE_COLLECT_TELEMETRY, thanks for fixing the flaky windows test 🥇
anisaoshafi
reviewed
Jul 3, 2026
Comment on lines
+30
to
+37
| // DisableAzureTelemetry is the value used to turn the Azure CLI's telemetry off in | ||
| // every test environment. When telemetry is on, `az` spawns a detached background | ||
| // uploader process that outlives the `az` invocation and keeps a handle on its | ||
| // working directory / HOME — which for tests is a t.TempDir(). On Windows that open | ||
| // handle makes t.TempDir()'s RemoveAll cleanup fail ("being used by another process"). | ||
| // Disabling it here prevents that flake and stops tests emitting to Azure's telemetry | ||
| // backend, mirroring UnreachableAnalyticsEndpoint for our own analytics. | ||
| const DisableAzureTelemetry = "false" |
Collaborator
There was a problem hiding this comment.
Could you simplify this explanation?
And potentially remove this variable - I don't see why it's needed when we can use false directly.
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.
Problem
mainis red on the Windows integration-test job.TestAzStopInterceptionNoOpWhenNotInterceptingpasses its assertions but then fails duringt.TempDir()auto-cleanup:(Introduced by #357 — failing run: https://github.com/localstack/lstk/actions/runs/28601912948)
Root cause
The test runs real
azcommands (vialstk az stop-interceptionand a rawaz cloud show). When Azure CLI telemetry is enabled,azspawns a detached background telemetry-upload process that outlives theazinvocation and keeps an open handle on the test's temp working directory (t.TempDir(), dir\001). When Go'st.TempDir()cleanup runsRemoveAllwhile that uploader is still alive, Windows refuses to delete a directory another process holds open. Unix removes directories with open handles, which is why only the Windows job flakes.The codebase already disables this telemetry (
core.collect_telemetry=false) for the isolated Azure config dir insetLstkPrefs, butstop-interceptiondeliberately targets the global~/.azureand doesn't touch telemetry prefs — so under test it runs with telemetry on.Fix
Default
AZURE_CORE_COLLECT_TELEMETRY=falsein every test environment (env.With/env.Without), mirroring the existingUnreachableAnalyticsEndpointguard that already keeps tests off our own analytics backend. It propagates to everyazinvocation (throughrunLstk→azandrunAzRaw), so no uploader spawns → no lingering handle → cleanup succeeds. Explicit per-test overrides still win (exec dedups to the last value).Tests
Added two unit tests on the env helper, matching the existing analytics-endpoint pair:
TestBaseEnvDisablesAzureTelemetry— the default is set by both constructors.TestExplicitAzureTelemetryOverridesDefault— an explicit value wins.Verification note
The failure is Windows-only (
RemoveAllwith an open handle is a no-op on Unix), so it can't be reproduced on macOS/Linux dev machines or the Linux CI shards. The new unit tests guard the mechanism (telemetry disabled in the base env); the Windows CI job on this PR is the end-to-end confirmation.Fixes PRO-362.