From ca95dc2daa2612432734ee4285fce246e6fdb496 Mon Sep 17 00:00:00 2001 From: "denis.bilenko" Date: Tue, 13 Oct 2026 13:11:33 +0000 Subject: [PATCH 1/7] acceptance: discover local DMS connection settings automatically --- acceptance/README.md | 17 +++ acceptance/acceptance_test.go | 8 +- acceptance/internal/dms_litebox_settings.go | 111 ++++++++++++++++ .../internal/dms_litebox_settings_test.go | 119 ++++++++++++++++++ 4 files changed, 253 insertions(+), 2 deletions(-) create mode 100644 acceptance/internal/dms_litebox_settings.go create mode 100644 acceptance/internal/dms_litebox_settings_test.go diff --git a/acceptance/README.md b/acceptance/README.md index 9cd4d2ed0a0..b8646b22727 100644 --- a/acceptance/README.md +++ b/acceptance/README.md @@ -15,6 +15,23 @@ The cloud run is keyed off `CLOUD_ENV`; see `getSkipReason` in `acceptance/accep To run tests against a real workspace: `deco env run -i -n aws-prod-ucws -- ` (requires the `deco` tool and access to a test env). +## Local DMS LITE tests + +Start `//bundle/metadata-service/test:cli-testenv-bin` with `bin/lite up` in Universe, +then run `go test ./acceptance -run 'TestDmsAcc/bundle/dms/no-drift$' -v -count=1`. +The runner finds the enclosing Universe Git checkout and reads +`bundle/metadata-service/test/.lite/cli-endpoints.json` for the gateway URLs and +client certificate paths. This works regardless of where the CLI checkout is nested +inside Universe. If the CLI checkout is outside Universe, set `DMS_CLI_ENDPOINTS_FILE` +to the discovery file's path. + +Explicit `DMS_LITEBOX_URL`, `DMS_LITEBOX_WORKSPACE_URL`, `DMS_LITEBOX_CERT`, +`DMS_LITEBOX_KEY`, and `DMS_LITEBOX_CA` values override the file's settings. +Local `TestAccept` runs also discover this file automatically, using Go mocks when +no settings are found. Cloud runs do not read the file. +The discovery file does not guarantee the fixture is running; +restart LITE to refresh it after stopping the environment. + ## Authoring To author a test, diff --git a/acceptance/acceptance_test.go b/acceptance/acceptance_test.go index 5fa69b1d069..61266ca7991 100644 --- a/acceptance/acceptance_test.go +++ b/acceptance/acceptance_test.go @@ -152,16 +152,20 @@ var Scripts = map[string]bool{ } func TestAccept(t *testing.T) { + if os.Getenv("CLOUD_ENV") == "" { + internal.ConfigureDMSLiteboxFromFile(t) + } testAccept(t, InprocessMode, nil, false) } // TestDmsAcc runs acceptance tests against local DMS, selected with go test -run. // The in-process runner skips unrelated tool builds and old CLI downloads. func TestDmsAcc(t *testing.T) { + require.Empty(t, os.Getenv("CLOUD_ENV"), "Litebox must not use a cloud workspace") + internal.ConfigureDMSLiteboxFromFile(t) if os.Getenv("DMS_LITEBOX_URL") == "" { - t.Skip("DMS_LITEBOX_URL is not set") + t.Skip("No local DMS settings found; start the LITE fixture or set DMS_CLI_ENDPOINTS_FILE") } - require.Empty(t, os.Getenv("CLOUD_ENV"), "Litebox must not use a cloud workspace") testAccept(t, true, nil, true) } diff --git a/acceptance/internal/dms_litebox_settings.go b/acceptance/internal/dms_litebox_settings.go new file mode 100644 index 00000000000..df5f8d35b5b --- /dev/null +++ b/acceptance/internal/dms_litebox_settings.go @@ -0,0 +1,111 @@ +package internal + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "os" + "path/filepath" + "testing" + + "github.com/databricks/cli/libs/env" + "github.com/databricks/cli/libs/folders" + "github.com/stretchr/testify/require" +) + +const dmsEndpointsFileEnv = "DMS_CLI_ENDPOINTS_FILE" + +var dmsLiteboxSettingsKeys = []string{ + "DMS_LITEBOX_URL", "DMS_LITEBOX_WORKSPACE_URL", "DMS_LITEBOX_CERT", "DMS_LITEBOX_KEY", "DMS_LITEBOX_CA", +} + +// ConfigureDMSLiteboxFromFile fills missing LITE settings from the local fixture's discovery file. +func ConfigureDMSLiteboxFromFile(t *testing.T) { + t.Helper() + dir, err := os.Getwd() + require.NoError(t, err) + settings, err := loadDMSLiteboxSettings(t.Context(), dir) + require.NoError(t, err) + for _, key := range dmsLiteboxSettingsKeys { + if env.Get(t.Context(), key) == "" && settings[key] != "" { + t.Setenv(key, settings[key]) + } + } +} + +func loadDMSLiteboxSettings(ctx context.Context, dir string) (map[string]string, error) { + settings := make(map[string]string, len(dmsLiteboxSettingsKeys)) + complete := true + for _, key := range dmsLiteboxSettingsKeys { + settings[key] = env.Get(ctx, key) + complete = complete && settings[key] != "" + } + if complete { + return settings, nil + } + + file := env.Get(ctx, dmsEndpointsFileEnv) + explicit := file != "" + if !explicit { + var err error + file, err = findDMSLiteboxSettings(dir) + if err != nil { + return nil, err + } + if file == "" { + return settings, nil + } + } + if !filepath.IsAbs(file) { + file = filepath.Join(dir, file) + } + data, err := os.ReadFile(file) + if !explicit && errors.Is(err, os.ErrNotExist) { + return settings, nil + } + if err != nil { + return nil, fmt.Errorf("read DMS LITE settings %s: %w", filepath.ToSlash(file), err) + } + var config struct { + URL string `json:"url"` + WorkspaceURL string `json:"workspace_url"` + Cert string `json:"cert"` + Key string `json:"key"` + CA string `json:"ca"` + } + if err := json.Unmarshal(data, &config); err != nil { + return nil, fmt.Errorf("parse DMS LITE settings %s: %w", filepath.ToSlash(file), err) + } + defaults := []string{config.URL, config.WorkspaceURL, config.Cert, config.Key, config.CA} + for i, key := range dmsLiteboxSettingsKeys { + if settings[key] == "" { + settings[key] = defaults[i] + } + } + return settings, nil +} + +func findDMSLiteboxSettings(dir string) (string, error) { + for { + root, err := folders.FindDirWithLeaf(dir, ".git") + if errors.Is(err, os.ErrNotExist) { + return "", nil + } + if err != nil { + return "", fmt.Errorf("find Git checkout for DMS LITE settings: %w", err) + } + fixture := filepath.Join(root, "bundle", "metadata-service", "test") + info, err := os.Stat(fixture) + if err == nil && info.IsDir() { + return filepath.Join(fixture, ".lite", "cli-endpoints.json"), nil + } + if err != nil && !errors.Is(err, os.ErrNotExist) { + return "", fmt.Errorf("find DMS LITE fixture: %w", err) + } + dir = filepath.Dir(root) + if dir == root { + return "", nil + } + } +} diff --git a/acceptance/internal/dms_litebox_settings_test.go b/acceptance/internal/dms_litebox_settings_test.go new file mode 100644 index 00000000000..ee56e2d3669 --- /dev/null +++ b/acceptance/internal/dms_litebox_settings_test.go @@ -0,0 +1,119 @@ +package internal + +import ( + "context" + "encoding/json" + "os" + "path/filepath" + "testing" + + "github.com/databricks/cli/libs/env" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func emptyDMSLiteboxSettingsContext(t *testing.T) context.Context { + t.Helper() + ctx := env.Set(t.Context(), dmsEndpointsFileEnv, "") + for _, key := range dmsLiteboxSettingsKeys { + ctx = env.Set(ctx, key, "") + } + return ctx +} + +func writeDMSLiteboxSettings(t *testing.T, file string) { + t.Helper() + data, err := json.Marshal(map[string]string{ + "url": "https://127.0.0.1:12345", "workspace_url": "https://127.0.0.1:12346", + "cert": "certificate.crt", "key": "certificate.key", "ca": "ca.crt", + }) + require.NoError(t, err) + require.NoError(t, os.MkdirAll(filepath.Dir(file), 0o755)) + require.NoError(t, os.WriteFile(file, data, 0o600)) +} + +func TestDMSLiteboxSettingsDiscovery(t *testing.T) { + for _, nested := range []bool{false, true} { + name := "inside Universe checkout" + if nested { + name = "inside arbitrarily located nested CLI checkout" + } + t.Run(name, func(t *testing.T) { + root := t.TempDir() + require.NoError(t, os.Mkdir(filepath.Join(root, ".git"), 0o755)) + file := filepath.Join(root, "bundle", "metadata-service", "test", ".lite", "cli-endpoints.json") + writeDMSLiteboxSettings(t, file) + dir := filepath.Join(root, "somewhere", "cli", "acceptance", "internal") + require.NoError(t, os.MkdirAll(dir, 0o755)) + if nested { + require.NoError(t, os.Mkdir(filepath.Join(root, "somewhere", "cli", ".git"), 0o755)) + } + found, err := findDMSLiteboxSettings(dir) + require.NoError(t, err) + assert.Equal(t, file, found) + settings, err := loadDMSLiteboxSettings(emptyDMSLiteboxSettingsContext(t), dir) + require.NoError(t, err) + assert.Equal(t, "https://127.0.0.1:12345", settings["DMS_LITEBOX_URL"]) + assert.Equal(t, "https://127.0.0.1:12346", settings["DMS_LITEBOX_WORKSPACE_URL"]) + assert.Equal(t, "certificate.crt", settings["DMS_LITEBOX_CERT"]) + assert.Equal(t, "certificate.key", settings["DMS_LITEBOX_KEY"]) + assert.Equal(t, "ca.crt", settings["DMS_LITEBOX_CA"]) + }) + } +} + +func TestDMSLiteboxSettingsExplicitFileAndOverrides(t *testing.T) { + dir := t.TempDir() + file := filepath.Join(dir, "custom", "settings.json") + writeDMSLiteboxSettings(t, file) + for _, path := range []string{file, filepath.Join("custom", "settings.json")} { + ctx := env.Set(emptyDMSLiteboxSettingsContext(t), dmsEndpointsFileEnv, path) + ctx = env.Set(ctx, "DMS_LITEBOX_URL", "https://127.0.0.1:54321") + settings, err := loadDMSLiteboxSettings(ctx, dir) + require.NoError(t, err) + assert.Equal(t, "https://127.0.0.1:54321", settings["DMS_LITEBOX_URL"]) + assert.Equal(t, "https://127.0.0.1:12346", settings["DMS_LITEBOX_WORKSPACE_URL"]) + assert.Equal(t, "ca.crt", settings["DMS_LITEBOX_CA"]) + } +} + +func TestDMSLiteboxSettingsAbsent(t *testing.T) { + dir := t.TempDir() + // A fixture-shaped directory without a Git checkout must not enable LITE. + writeDMSLiteboxSettings(t, filepath.Join(dir, "bundle", "metadata-service", "test", ".lite", "cli-endpoints.json")) + settings, err := loadDMSLiteboxSettings(emptyDMSLiteboxSettingsContext(t), dir) + require.NoError(t, err) + assert.Empty(t, settings["DMS_LITEBOX_URL"]) + require.NoError(t, os.Mkdir(filepath.Join(dir, ".git"), 0o755)) + require.NoError(t, os.Remove(filepath.Join(dir, "bundle", "metadata-service", "test", ".lite", "cli-endpoints.json"))) + settings, err = loadDMSLiteboxSettings(emptyDMSLiteboxSettingsContext(t), dir) + require.NoError(t, err) + assert.Empty(t, settings["DMS_LITEBOX_URL"]) +} + +func TestDMSLiteboxSettingsInvalidFile(t *testing.T) { + for _, content := range []string{"missing", "{", `{"url":42}`} { + t.Run(content, func(t *testing.T) { + dir := t.TempDir() + file := filepath.Join(dir, "settings.json") + if content != "missing" { + require.NoError(t, os.WriteFile(file, []byte(content), 0o600)) + } + ctx := env.Set(emptyDMSLiteboxSettingsContext(t), dmsEndpointsFileEnv, file) + _, err := loadDMSLiteboxSettings(ctx, dir) + assert.ErrorContains(t, err, "DMS LITE settings") + }) + } +} + +func TestDMSLiteboxSettingsExplicitEnvironmentNeedsNoFile(t *testing.T) { + ctx := env.Set(emptyDMSLiteboxSettingsContext(t), dmsEndpointsFileEnv, "missing.json") + for _, key := range dmsLiteboxSettingsKeys { + ctx = env.Set(ctx, key, "explicit") + } + settings, err := loadDMSLiteboxSettings(ctx, t.TempDir()) + require.NoError(t, err) + for _, key := range dmsLiteboxSettingsKeys { + assert.Equal(t, "explicit", settings[key]) + } +} From cef22c8ac28840e76332455a0a6f023bcf3fddce Mon Sep 17 00:00:00 2001 From: "denis.bilenko" Date: Tue, 13 Oct 2026 13:30:25 +0000 Subject: [PATCH 2/7] acceptance: use one local DMS gateway URL --- acceptance/README.md | 6 +++--- acceptance/internal/dms_litebox.go | 6 +----- acceptance/internal/dms_litebox_settings.go | 13 ++++++------- .../internal/dms_litebox_settings_test.go | 18 +++++++++--------- 4 files changed, 19 insertions(+), 24 deletions(-) diff --git a/acceptance/README.md b/acceptance/README.md index b8646b22727..77ee2f1f89b 100644 --- a/acceptance/README.md +++ b/acceptance/README.md @@ -20,13 +20,13 @@ To run tests against a real workspace: `deco env run -i -n aws-prod-ucws -- Date: Tue, 13 Oct 2026 13:51:21 +0000 Subject: [PATCH 3/7] acceptance: simplify local DMS settings discovery --- acceptance/README.md | 10 +- acceptance/internal/dms_litebox_settings.go | 103 ++++++--------- .../internal/dms_litebox_settings_test.go | 119 ------------------ 3 files changed, 42 insertions(+), 190 deletions(-) delete mode 100644 acceptance/internal/dms_litebox_settings_test.go diff --git a/acceptance/README.md b/acceptance/README.md index 77ee2f1f89b..32dfc768757 100644 --- a/acceptance/README.md +++ b/acceptance/README.md @@ -19,11 +19,11 @@ To run tests against a real workspace: `deco env run -i -n aws-prod-ucws -- Date: Tue, 13 Oct 2026 14:01:30 +0000 Subject: [PATCH 4/7] acc: read DMS LITE connection settings only from file --- acceptance/README.md | 4 +- acceptance/acceptance_test.go | 6 +-- acceptance/internal/dms_litebox.go | 31 +++++------- acceptance/internal/dms_litebox_settings.go | 55 +++++++++------------ 4 files changed, 38 insertions(+), 58 deletions(-) diff --git a/acceptance/README.md b/acceptance/README.md index 32dfc768757..e79aaf0ffbc 100644 --- a/acceptance/README.md +++ b/acceptance/README.md @@ -25,8 +25,8 @@ gateway URL and client certificate paths. This works both when the CLI is nested inside Universe and when it is synced into Universe. If the CLI checkout is outside Universe, set `DMS_CLI_ENDPOINTS_FILE` to the discovery file's path. -Explicit `DMS_LITEBOX_URL`, `DMS_LITEBOX_CERT`, `DMS_LITEBOX_KEY`, and -`DMS_LITEBOX_CA` values override the file's settings. +Set `DMS_CLI_ENDPOINTS_FILE` to use a different settings file; the old +`DMS_LITEBOX_*` connection variables are not used. Local `TestAccept` runs also discover this file automatically, using Go mocks when no settings are found. Cloud runs do not read the file. The discovery file does not guarantee the fixture is running; diff --git a/acceptance/acceptance_test.go b/acceptance/acceptance_test.go index 61266ca7991..343bc23e7d1 100644 --- a/acceptance/acceptance_test.go +++ b/acceptance/acceptance_test.go @@ -152,9 +152,6 @@ var Scripts = map[string]bool{ } func TestAccept(t *testing.T) { - if os.Getenv("CLOUD_ENV") == "" { - internal.ConfigureDMSLiteboxFromFile(t) - } testAccept(t, InprocessMode, nil, false) } @@ -162,8 +159,7 @@ func TestAccept(t *testing.T) { // The in-process runner skips unrelated tool builds and old CLI downloads. func TestDmsAcc(t *testing.T) { require.Empty(t, os.Getenv("CLOUD_ENV"), "Litebox must not use a cloud workspace") - internal.ConfigureDMSLiteboxFromFile(t) - if os.Getenv("DMS_LITEBOX_URL") == "" { + if !internal.HasDMSLiteboxSettings(t) { t.Skip("No local DMS settings found; start the LITE fixture or set DMS_CLI_ENDPOINTS_FILE") } testAccept(t, true, nil, true) diff --git a/acceptance/internal/dms_litebox.go b/acceptance/internal/dms_litebox.go index 456e18e1f16..07248560e8e 100644 --- a/acceptance/internal/dms_litebox.go +++ b/acceptance/internal/dms_litebox.go @@ -13,7 +13,6 @@ import ( "testing" "time" - "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/testserver" "github.com/stretchr/testify/require" ) @@ -27,24 +26,22 @@ var liteboxPermissionTypes = []string{"directories", "files", "notebooks", "work // to its shared fakes, retaining request recording and mocks for other APIs. func configureDMSLitebox(t *testing.T, server *testserver.Server) { t.Helper() - endpoint := env.Get(t.Context(), "DMS_LITEBOX_URL") - if endpoint == "" { + if os.Getenv("CLOUD_ENV") != "" { return } - dmsURL := liteboxURL(t, "DMS_LITEBOX_URL") + settings := loadDMSLiteboxSettings(t) + if settings == nil { + return + } + dmsURL := liteboxURL(t, settings.URL) - certFile, keyFile := env.Get(t.Context(), "DMS_LITEBOX_CERT"), env.Get(t.Context(), "DMS_LITEBOX_KEY") - caFile := env.Get(t.Context(), "DMS_LITEBOX_CA") - require.NotEmpty(t, certFile, "DMS_LITEBOX_CERT is required with DMS_LITEBOX_URL") - require.NotEmpty(t, keyFile, "DMS_LITEBOX_KEY is required with DMS_LITEBOX_URL") - require.NotEmpty(t, caFile, "DMS_LITEBOX_CA is required with DMS_LITEBOX_URL") - cert, err := tls.LoadX509KeyPair(certFile, keyFile) + cert, err := tls.LoadX509KeyPair(settings.Cert, settings.Key) require.NoError(t, err, "load Litebox client certificate and key") - pem, err := os.ReadFile(caFile) - require.NoError(t, err, "read DMS_LITEBOX_CA") + pem, err := os.ReadFile(settings.CA) + require.NoError(t, err, "read Litebox CA certificate") roots := x509.NewCertPool() require.True(t, roots.AppendCertsFromPEM(pem), "invalid Litebox certificate") - // Both upstreams must use LITE's test certificate for *.svc.cluster.local. + // The LITE gateway uses the service's test certificate. transport := &http.Transport{ TLSClientConfig: &tls.Config{ MinVersion: tls.VersionTLS12, @@ -91,16 +88,14 @@ func configureDMSLitebox(t *testing.T, server *testserver.Server) { routeLitebox(server, handler) } -func liteboxURL(t *testing.T, name string) *url.URL { +func liteboxURL(t *testing.T, endpoint string) *url.URL { t.Helper() - endpoint := env.Get(t.Context(), name) - require.NotEmpty(t, endpoint, "%s is required with DMS_LITEBOX_URL", name) u, err := url.Parse(endpoint) - require.NoError(t, err, "invalid %s", name) + require.NoError(t, err, "invalid DMS LITE gateway URL") ip := net.ParseIP(u.Hostname()) require.True(t, u.Scheme == "https" && (u.Hostname() == "localhost" || (ip != nil && ip.IsLoopback())) && u.User == nil && u.RawQuery == "" && u.Fragment == "" && (u.Path == "" || u.Path == "/"), - "%s must be an HTTPS loopback origin", name) + "DMS LITE gateway URL must be an HTTPS loopback origin") return u } diff --git a/acceptance/internal/dms_litebox_settings.go b/acceptance/internal/dms_litebox_settings.go index be4f83b51a2..f6adb3ef669 100644 --- a/acceptance/internal/dms_litebox_settings.go +++ b/acceptance/internal/dms_litebox_settings.go @@ -7,33 +7,32 @@ import ( "path/filepath" "testing" - "github.com/databricks/cli/libs/env" "github.com/stretchr/testify/require" ) -// ConfigureDMSLiteboxFromFile fills missing LITE settings from the local fixture's discovery file. -func ConfigureDMSLiteboxFromFile(t *testing.T) { +type dmsLiteboxSettings struct { + URL string `json:"url"` + Cert string `json:"cert"` + Key string `json:"key"` + CA string `json:"ca"` +} + +// HasDMSLiteboxSettings reports whether the local fixture has a settings file. +func HasDMSLiteboxSettings(t *testing.T) bool { t.Helper() - ctx := t.Context() - keys := []string{"DMS_LITEBOX_URL", "DMS_LITEBOX_CERT", "DMS_LITEBOX_KEY", "DMS_LITEBOX_CA"} - missing := false - for _, key := range keys { - if env.Get(ctx, key) == "" { - missing = true - } - } - if !missing { - return - } + return loadDMSLiteboxSettings(t) != nil +} +func loadDMSLiteboxSettings(t *testing.T) *dmsLiteboxSettings { + t.Helper() acceptanceDir, err := os.Getwd() require.NoError(t, err) - file := env.Get(ctx, "DMS_CLI_ENDPOINTS_FILE") + file := os.Getenv("DMS_CLI_ENDPOINTS_FILE") explicit := file != "" if !explicit { file = findDMSLiteboxSettings(t, filepath.Dir(acceptanceDir)) if file == "" { - return + return nil } } if !filepath.IsAbs(file) { @@ -41,26 +40,16 @@ func ConfigureDMSLiteboxFromFile(t *testing.T) { } data, err := os.ReadFile(file) if !explicit && errors.Is(err, os.ErrNotExist) { - return + return nil } require.NoError(t, err, "read DMS LITE settings %s", file) - var settings struct { - URL string `json:"url"` - Cert string `json:"cert"` - Key string `json:"key"` - CA string `json:"ca"` - } + var settings dmsLiteboxSettings require.NoError(t, json.Unmarshal(data, &settings), "parse DMS LITE settings %s", file) - for _, setting := range []struct{ key, value string }{ - {"DMS_LITEBOX_URL", settings.URL}, - {"DMS_LITEBOX_CERT", settings.Cert}, - {"DMS_LITEBOX_KEY", settings.Key}, - {"DMS_LITEBOX_CA", settings.CA}, - } { - if env.Get(ctx, setting.key) == "" && setting.value != "" { - t.Setenv(setting.key, setting.value) - } - } + require.NotEmpty(t, settings.URL, "DMS LITE settings %s: url is required", file) + require.NotEmpty(t, settings.Cert, "DMS LITE settings %s: cert is required", file) + require.NotEmpty(t, settings.Key, "DMS LITE settings %s: key is required", file) + require.NotEmpty(t, settings.CA, "DMS LITE settings %s: ca is required", file) + return &settings } func findDMSLiteboxSettings(t *testing.T, dir string) string { From f456124edb5cea58df3b6a0a8b234c925f25b6b0 Mon Sep 17 00:00:00 2001 From: "denis.bilenko" Date: Tue, 13 Oct 2026 14:18:55 +0000 Subject: [PATCH 5/7] acc: use context environment for DMS settings --- acceptance/internal/dms_litebox.go | 3 ++- acceptance/internal/dms_litebox_settings.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/acceptance/internal/dms_litebox.go b/acceptance/internal/dms_litebox.go index 07248560e8e..80215ae7673 100644 --- a/acceptance/internal/dms_litebox.go +++ b/acceptance/internal/dms_litebox.go @@ -13,6 +13,7 @@ import ( "testing" "time" + "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/testserver" "github.com/stretchr/testify/require" ) @@ -26,7 +27,7 @@ var liteboxPermissionTypes = []string{"directories", "files", "notebooks", "work // to its shared fakes, retaining request recording and mocks for other APIs. func configureDMSLitebox(t *testing.T, server *testserver.Server) { t.Helper() - if os.Getenv("CLOUD_ENV") != "" { + if env.Get(t.Context(), "CLOUD_ENV") != "" { return } settings := loadDMSLiteboxSettings(t) diff --git a/acceptance/internal/dms_litebox_settings.go b/acceptance/internal/dms_litebox_settings.go index f6adb3ef669..e020c934e57 100644 --- a/acceptance/internal/dms_litebox_settings.go +++ b/acceptance/internal/dms_litebox_settings.go @@ -7,6 +7,7 @@ import ( "path/filepath" "testing" + "github.com/databricks/cli/libs/env" "github.com/stretchr/testify/require" ) @@ -27,7 +28,7 @@ func loadDMSLiteboxSettings(t *testing.T) *dmsLiteboxSettings { t.Helper() acceptanceDir, err := os.Getwd() require.NoError(t, err) - file := os.Getenv("DMS_CLI_ENDPOINTS_FILE") + file := env.Get(t.Context(), "DMS_CLI_ENDPOINTS_FILE") explicit := file != "" if !explicit { file = findDMSLiteboxSettings(t, filepath.Dir(acceptanceDir)) From d5dce32f90bf6ed891a253ce0c8402dbf71f2ac4 Mon Sep 17 00:00:00 2001 From: "denis.bilenko" Date: Tue, 13 Oct 2026 14:24:58 +0000 Subject: [PATCH 6/7] acc: use TestAccept for local DMS coverage --- acceptance/README.md | 4 ++-- acceptance/acceptance_test.go | 10 ---------- acceptance/internal/dms_litebox_settings.go | 6 ------ 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/acceptance/README.md b/acceptance/README.md index e79aaf0ffbc..c4597dff406 100644 --- a/acceptance/README.md +++ b/acceptance/README.md @@ -18,7 +18,7 @@ To run tests against a real workspace: `deco env run -i -n aws-prod-ucws -- Date: Tue, 13 Oct 2026 14:59:57 +0000 Subject: [PATCH 7/7] acc: simplify local DMS test setup --- acceptance/README.md | 17 ----------------- acceptance/internal/dms_litebox.go | 4 ---- 2 files changed, 21 deletions(-) diff --git a/acceptance/README.md b/acceptance/README.md index c4597dff406..9cd4d2ed0a0 100644 --- a/acceptance/README.md +++ b/acceptance/README.md @@ -15,23 +15,6 @@ The cloud run is keyed off `CLOUD_ENV`; see `getSkipReason` in `acceptance/accep To run tests against a real workspace: `deco env run -i -n aws-prod-ucws -- ` (requires the `deco` tool and access to a test env). -## Local DMS LITE tests - -Start `//bundle/metadata-service/test:cli-testenv-bin` with `bin/lite up` in Universe, -then run `go test ./acceptance -run 'TestAccept/bundle/dms/no-drift$' -v -count=1`. -The runner starts at the CLI root and searches its ancestors for -`bundle/metadata-service/test/.lite/cli-endpoints.json`. The file provides the -gateway URL and client certificate paths. This works both when the CLI is nested -inside Universe and when it is synced into Universe. If the CLI checkout is -outside Universe, set `DMS_CLI_ENDPOINTS_FILE` to the discovery file's path. - -Set `DMS_CLI_ENDPOINTS_FILE` to use a different settings file; the old -`DMS_LITEBOX_*` connection variables are not used. -Local `TestAccept` runs discover this file automatically, using Go mocks when -no settings are found. Cloud runs do not read the file. -The discovery file does not guarantee the fixture is running; -restart LITE to refresh it after stopping the environment. - ## Authoring To author a test, diff --git a/acceptance/internal/dms_litebox.go b/acceptance/internal/dms_litebox.go index 80215ae7673..b59a172e06a 100644 --- a/acceptance/internal/dms_litebox.go +++ b/acceptance/internal/dms_litebox.go @@ -13,7 +13,6 @@ import ( "testing" "time" - "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/testserver" "github.com/stretchr/testify/require" ) @@ -27,9 +26,6 @@ var liteboxPermissionTypes = []string{"directories", "files", "notebooks", "work // to its shared fakes, retaining request recording and mocks for other APIs. func configureDMSLitebox(t *testing.T, server *testserver.Server) { t.Helper() - if env.Get(t.Context(), "CLOUD_ENV") != "" { - return - } settings := loadDMSLiteboxSettings(t) if settings == nil { return