From 2cee0487548ac3dab355bce9ad688a94781131c4 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Wed, 11 Mar 2026 17:40:53 +0100 Subject: [PATCH] Prevent SDK from invoking `az` during cmd/root tests The SDK upgrade to v0.117.0 changed credential resolution such that Azure CLI auth is attempted even for non-Azure hosts. This causes `az account show` to be invoked during tests that go through auth resolution, adding ~0.5-2.5s per test and writing `.azure/` cache files into the source tree. Clear PATH in auth tests to prevent the SDK from finding `az`. For the bundle loader test, restrict PATH to system directories instead since the bundle loader currently requires a shell to be available (fixing that separately). Co-Authored-By: Claude Opus 4.6 (1M context) --- cmd/root/auth_test.go | 12 ++++++++++-- cmd/root/bundle_test.go | 8 ++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/cmd/root/auth_test.go b/cmd/root/auth_test.go index 6e03e5687e..b6ea9dd5ae 100644 --- a/cmd/root/auth_test.go +++ b/cmd/root/auth_test.go @@ -88,7 +88,8 @@ func TestAccountClientOrPrompt(t *testing.T) { 0o755) require.NoError(t, err) t.Setenv("DATABRICKS_CONFIG_FILE", configFile) - t.Setenv("PATH", "/nothing") + // Clear PATH to prevent the SDK from invoking external tools (e.g. az) during auth resolution. + t.Setenv("PATH", "") t.Run("Prompt if nothing is specified", func(t *testing.T) { expectPrompts(t, accountPromptFn, &config.Config{}) @@ -157,7 +158,8 @@ func TestWorkspaceClientOrPrompt(t *testing.T) { 0o755) require.NoError(t, err) t.Setenv("DATABRICKS_CONFIG_FILE", configFile) - t.Setenv("PATH", "/nothing") + // Clear PATH to prevent the SDK from invoking external tools (e.g. az) during auth resolution. + t.Setenv("PATH", "") t.Run("Prompt if nothing is specified", func(t *testing.T) { expectPrompts(t, workspacePromptFn, &config.Config{}) @@ -248,6 +250,8 @@ func TestMustAccountClientErrorsWithNoDatabricksCfg(t *testing.T) { func TestMustAnyClientCanCreateWorkspaceClient(t *testing.T) { testutil.CleanupEnvironment(t) + // Clear PATH to prevent the SDK from invoking external tools (e.g. az) during auth resolution. + t.Setenv("PATH", "") dir := t.TempDir() configFile := filepath.Join(dir, ".databrickscfg") @@ -276,6 +280,8 @@ func TestMustAnyClientCanCreateWorkspaceClient(t *testing.T) { func TestMustAnyClientCanCreateAccountClient(t *testing.T) { testutil.CleanupEnvironment(t) + // Clear PATH to prevent the SDK from invoking external tools (e.g. az) during auth resolution. + t.Setenv("PATH", "") dir := t.TempDir() configFile := filepath.Join(dir, ".databrickscfg") @@ -305,6 +311,8 @@ func TestMustAnyClientCanCreateAccountClient(t *testing.T) { func TestMustAnyClientWithEmptyDatabricksCfg(t *testing.T) { testutil.CleanupEnvironment(t) + // Clear PATH to prevent the SDK from invoking external tools (e.g. az) during auth resolution. + t.Setenv("PATH", "") dir := t.TempDir() configFile := filepath.Join(dir, ".databrickscfg") diff --git a/cmd/root/bundle_test.go b/cmd/root/bundle_test.go index 4cf63a59b2..8c021fe77f 100644 --- a/cmd/root/bundle_test.go +++ b/cmd/root/bundle_test.go @@ -85,6 +85,14 @@ workspace: func TestBundleConfigureDefault(t *testing.T) { testutil.CleanupEnvironment(t) + // Restrict PATH to system directories to prevent the SDK from invoking + // external tools (e.g. az) during auth resolution. + // Bundle loading requires a shell so PATH cannot be fully cleared. + if runtime.GOOS == "windows" { + t.Setenv("PATH", `C:\Windows\System32`) + } else { + t.Setenv("PATH", "/usr/bin:/bin") + } cmd := emptyCommand(t) diags := setupWithHost(t, cmd, "https://x.com")