From 6e93dc1e08ce5a57f94af12c958736bb1682bff0 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Thu, 12 Dec 2024 16:57:36 +0100 Subject: [PATCH 01/24] Add test to confirm integration tests use build tags --- .vscode/settings.json | 3 +- integration/verify_build_tags_test.go | 56 +++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 integration/verify_build_tags_test.go diff --git a/.vscode/settings.json b/.vscode/settings.json index a7830d4ae9..bf7894cda6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,7 +9,8 @@ ], "go.useLanguageServer": true, "gopls": { - "formatting.gofumpt": true + "formatting.gofumpt": true, + "buildFlags": ["-tags=integration"] }, "files.trimTrailingWhitespace": true, "files.insertFinalNewline": true, diff --git a/integration/verify_build_tags_test.go b/integration/verify_build_tags_test.go new file mode 100644 index 0000000000..ee937484d3 --- /dev/null +++ b/integration/verify_build_tags_test.go @@ -0,0 +1,56 @@ +package integration + +import ( + "go/parser" + "go/token" + "os" + "path/filepath" + "strings" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +// TestVerifyBuildTags checks that all test files in the integration package specify the "integration" build tag. +// This ensures that `go test ./...` doesn't run integration tests. +func TestVerifyBuildTags(t *testing.T) { + err := filepath.Walk(".", func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + + // Skip directories. + if info.IsDir() { + return nil + } + + // Skip this file. + if path == "verify_build_tags_test.go" { + return nil + } + + // Skip files that are not test files. + if !strings.HasSuffix(info.Name(), "_test.go") { + return nil + } + + fset := token.NewFileSet() + file, err := parser.ParseFile(fset, path, nil, parser.ParseComments) + require.NoError(t, err) + + // Check for the "integration" build tag in the file comments. + found := false + for _, comment := range file.Comments { + if strings.Contains(comment.Text(), "+build integration") { + found = true + break + } + } + + assert.True(t, found, "File %s does not specify the 'integration' build tag", path) + return nil + }) + + require.NoError(t, err) +} From 65184fdf6a82ffbc369a36d9f9558f2d799536d0 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Thu, 12 Dec 2024 20:35:39 +0100 Subject: [PATCH 02/24] Build tag --- integration/verify_build_tags_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/integration/verify_build_tags_test.go b/integration/verify_build_tags_test.go index ee937484d3..ca4b1bdffb 100644 --- a/integration/verify_build_tags_test.go +++ b/integration/verify_build_tags_test.go @@ -1,3 +1,5 @@ +//go:build !integration + package integration import ( From e236c8a54546a08e5415fcf83ab4d200769dde1d Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Thu, 12 Dec 2024 21:08:32 +0100 Subject: [PATCH 03/24] Move fs integration tests --- internal/fs_cat_test.go => integration/cmd/fs/cat_test.go | 4 +++- .../cmd/fs/completion_test.go | 4 +++- internal/fs_cp_test.go => integration/cmd/fs/cp_test.go | 4 +++- {internal => integration/cmd/fs}/helpers.go | 2 +- internal/fs_ls_test.go => integration/cmd/fs/ls_test.go | 4 +++- internal/fs_mkdir_test.go => integration/cmd/fs/mkdir_test.go | 4 +++- internal/fs_rm_test.go => integration/cmd/fs/rm_test.go | 4 +++- 7 files changed, 19 insertions(+), 7 deletions(-) rename internal/fs_cat_test.go => integration/cmd/fs/cat_test.go (98%) rename internal/completer_test.go => integration/cmd/fs/completion_test.go (95%) rename internal/fs_cp_test.go => integration/cmd/fs/cp_test.go (99%) rename {internal => integration/cmd/fs}/helpers.go (99%) rename internal/fs_ls_test.go => integration/cmd/fs/ls_test.go (99%) rename internal/fs_mkdir_test.go => integration/cmd/fs/mkdir_test.go (99%) rename internal/fs_rm_test.go => integration/cmd/fs/rm_test.go (99%) diff --git a/internal/fs_cat_test.go b/integration/cmd/fs/cat_test.go similarity index 98% rename from internal/fs_cat_test.go rename to integration/cmd/fs/cat_test.go index e14121feaf..20c6dba6bb 100644 --- a/internal/fs_cat_test.go +++ b/integration/cmd/fs/cat_test.go @@ -1,4 +1,6 @@ -package internal +//go:build integration + +package fs import ( "context" diff --git a/internal/completer_test.go b/integration/cmd/fs/completion_test.go similarity index 95% rename from internal/completer_test.go rename to integration/cmd/fs/completion_test.go index 52a1f6c08b..f27c7e068e 100644 --- a/internal/completer_test.go +++ b/integration/cmd/fs/completion_test.go @@ -1,4 +1,6 @@ -package internal +//go:build integration + +package fs import ( "context" diff --git a/internal/fs_cp_test.go b/integration/cmd/fs/cp_test.go similarity index 99% rename from internal/fs_cp_test.go rename to integration/cmd/fs/cp_test.go index 16318d5c15..29bc97d07d 100644 --- a/internal/fs_cp_test.go +++ b/integration/cmd/fs/cp_test.go @@ -1,4 +1,6 @@ -package internal +//go:build integration + +package fs import ( "context" diff --git a/internal/helpers.go b/integration/cmd/fs/helpers.go similarity index 99% rename from internal/helpers.go rename to integration/cmd/fs/helpers.go index d57e9b9c2c..1c5bdd4a9f 100644 --- a/internal/helpers.go +++ b/integration/cmd/fs/helpers.go @@ -1,4 +1,4 @@ -package internal +package fs import ( "errors" diff --git a/internal/fs_ls_test.go b/integration/cmd/fs/ls_test.go similarity index 99% rename from internal/fs_ls_test.go rename to integration/cmd/fs/ls_test.go index d56fc8bb00..c60af9ab50 100644 --- a/internal/fs_ls_test.go +++ b/integration/cmd/fs/ls_test.go @@ -1,4 +1,6 @@ -package internal +//go:build integration + +package fs import ( "context" diff --git a/internal/fs_mkdir_test.go b/integration/cmd/fs/mkdir_test.go similarity index 99% rename from internal/fs_mkdir_test.go rename to integration/cmd/fs/mkdir_test.go index 197f5d4b5d..ffbdd5ad6f 100644 --- a/internal/fs_mkdir_test.go +++ b/integration/cmd/fs/mkdir_test.go @@ -1,4 +1,6 @@ -package internal +//go:build integration + +package fs import ( "context" diff --git a/internal/fs_rm_test.go b/integration/cmd/fs/rm_test.go similarity index 99% rename from internal/fs_rm_test.go rename to integration/cmd/fs/rm_test.go index 1af779fd27..ba061803dc 100644 --- a/internal/fs_rm_test.go +++ b/integration/cmd/fs/rm_test.go @@ -1,4 +1,6 @@ -package internal +//go:build integration + +package fs import ( "context" From b1d4197c10bdc2a768e1e720d5154007c74cfa14 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Thu, 12 Dec 2024 21:10:20 +0100 Subject: [PATCH 04/24] Assert on first line --- integration/verify_build_tags_test.go | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/integration/verify_build_tags_test.go b/integration/verify_build_tags_test.go index ca4b1bdffb..31ad95d7a6 100644 --- a/integration/verify_build_tags_test.go +++ b/integration/verify_build_tags_test.go @@ -1,10 +1,7 @@ -//go:build !integration - package integration import ( - "go/parser" - "go/token" + "bufio" "os" "path/filepath" "strings" @@ -37,20 +34,14 @@ func TestVerifyBuildTags(t *testing.T) { return nil } - fset := token.NewFileSet() - file, err := parser.ParseFile(fset, path, nil, parser.ParseComments) + f, err := os.Open(path) require.NoError(t, err) + defer f.Close() - // Check for the "integration" build tag in the file comments. - found := false - for _, comment := range file.Comments { - if strings.Contains(comment.Text(), "+build integration") { - found = true - break - } - } - - assert.True(t, found, "File %s does not specify the 'integration' build tag", path) + // Read the first line + scanner := bufio.NewScanner(f) + scanner.Scan() + assert.Equal(t, "//go:build integration", scanner.Text(), "File %s does not specify the 'integration' build tag", path) return nil }) From 0aeca5d89a9e243e73229d61d2e2c2f0c6f71308 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Thu, 12 Dec 2024 21:32:25 +0100 Subject: [PATCH 05/24] Move more tests --- .golangci.yaml | 3 + .../cmd/alerts}/alerts_test.go | 0 {internal => integration/cmd/api}/api_test.go | 0 .../cmd/auth/describe_test.go | 0 .../cmd/clusters}/clusters_test.go | 0 integration/cmd/fs/cat_test.go | 2 +- integration/cmd/fs/completion_test.go | 2 +- integration/cmd/fs/cp_test.go | 2 +- integration/cmd/fs/helpers.go | 2 +- integration/cmd/fs/ls_test.go | 2 +- integration/cmd/fs/mkdir_test.go | 2 +- integration/cmd/fs/rm_test.go | 2 +- .../cmd/jobs}/jobs_test.go | 2 +- .../testdata}/create_job_without_workers.json | 0 .../cmd/repos}/repos_test.go | 0 .../cmd/secrets}/secrets_test.go | 0 .../storage_credentials_test.go | 0 .../cmd/sync}/sync_test.go | 0 .../cmd}/unknown_command_test.go | 4 +- .../cmd/version}/version_test.go | 0 .../testdata/import_dir/a/b/c/file-b | 0 .../cmd/workspace}/testdata/import_dir/file-a | 0 .../testdata/import_dir/jupyterNotebook.ipynb | 0 .../testdata/import_dir/pyNotebook.py | 0 .../testdata/import_dir/rNotebook.r | 0 .../testdata/import_dir/scalaNotebook.scala | 0 .../testdata/import_dir/sqlNotebook.sql | 0 .../cmd/workspace}/workspace_test.go | 0 .../libs/filer}/filer_test.go | 4 +- integration/libs/filer/helpers.go | 75 +++++++++++++++++++ .../libs/filer}/testdata/notebooks/py1.ipynb | 0 .../libs/filer}/testdata/notebooks/py2.ipynb | 0 .../libs/filer}/testdata/notebooks/r1.ipynb | 0 .../libs/filer}/testdata/notebooks/r2.ipynb | 0 .../filer}/testdata/notebooks/scala1.ipynb | 0 .../filer}/testdata/notebooks/scala2.ipynb | 0 .../libs/filer}/testdata/notebooks/sql1.ipynb | 0 .../libs/filer}/testdata/notebooks/sql2.ipynb | 0 .../libs/git}/git_clone_test.go | 4 +- .../libs/git}/git_fetch_test.go | 4 +- .../libs/locker}/locker_test.go | 4 +- .../libs/tags}/tags_test.go | 4 +- internal/{ => bundle}/init_test.go | 2 +- .../databricks_template_schema.json | 0 .../field-does-not-exist/template/bar.tmpl | 0 45 files changed, 105 insertions(+), 15 deletions(-) rename {internal => integration/cmd/alerts}/alerts_test.go (100%) rename {internal => integration/cmd/api}/api_test.go (100%) rename internal/auth_describe_test.go => integration/cmd/auth/describe_test.go (100%) rename {internal => integration/cmd/clusters}/clusters_test.go (100%) rename {internal => integration/cmd/jobs}/jobs_test.go (90%) rename {internal/testjsons => integration/cmd/jobs/testdata}/create_job_without_workers.json (100%) rename {internal => integration/cmd/repos}/repos_test.go (100%) rename {internal => integration/cmd/secrets}/secrets_test.go (100%) rename {internal => integration/cmd/storage_credentials}/storage_credentials_test.go (100%) rename {internal => integration/cmd/sync}/sync_test.go (100%) rename {internal => integration/cmd}/unknown_command_test.go (89%) rename {internal => integration/cmd/version}/version_test.go (100%) rename {internal => integration/cmd/workspace}/testdata/import_dir/a/b/c/file-b (100%) rename {internal => integration/cmd/workspace}/testdata/import_dir/file-a (100%) rename {internal => integration/cmd/workspace}/testdata/import_dir/jupyterNotebook.ipynb (100%) rename {internal => integration/cmd/workspace}/testdata/import_dir/pyNotebook.py (100%) rename {internal => integration/cmd/workspace}/testdata/import_dir/rNotebook.r (100%) rename {internal => integration/cmd/workspace}/testdata/import_dir/scalaNotebook.scala (100%) rename {internal => integration/cmd/workspace}/testdata/import_dir/sqlNotebook.sql (100%) rename {internal => integration/cmd/workspace}/workspace_test.go (100%) rename {internal => integration/libs/filer}/filer_test.go (99%) create mode 100644 integration/libs/filer/helpers.go rename {internal => integration/libs/filer}/testdata/notebooks/py1.ipynb (100%) rename {internal => integration/libs/filer}/testdata/notebooks/py2.ipynb (100%) rename {internal => integration/libs/filer}/testdata/notebooks/r1.ipynb (100%) rename {internal => integration/libs/filer}/testdata/notebooks/r2.ipynb (100%) rename {internal => integration/libs/filer}/testdata/notebooks/scala1.ipynb (100%) rename {internal => integration/libs/filer}/testdata/notebooks/scala2.ipynb (100%) rename {internal => integration/libs/filer}/testdata/notebooks/sql1.ipynb (100%) rename {internal => integration/libs/filer}/testdata/notebooks/sql2.ipynb (100%) rename {internal => integration/libs/git}/git_clone_test.go (97%) rename {internal => integration/libs/git}/git_fetch_test.go (99%) rename {internal => integration/libs/locker}/locker_test.go (99%) rename {internal => integration/libs/tags}/tags_test.go (99%) rename internal/{ => bundle}/init_test.go (99%) rename internal/{ => bundle}/testdata/init/field-does-not-exist/databricks_template_schema.json (100%) rename internal/{ => bundle}/testdata/init/field-does-not-exist/template/bar.tmpl (100%) diff --git a/.golangci.yaml b/.golangci.yaml index 9e69e51463..4775d14388 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -36,3 +36,6 @@ linters-settings: # local-prefixes: github.com/databricks/cli issues: exclude-dirs-use-default: false # recommended by docs https://golangci-lint.run/usage/false-positives/ +run: + build-tags: + - integration diff --git a/internal/alerts_test.go b/integration/cmd/alerts/alerts_test.go similarity index 100% rename from internal/alerts_test.go rename to integration/cmd/alerts/alerts_test.go diff --git a/internal/api_test.go b/integration/cmd/api/api_test.go similarity index 100% rename from internal/api_test.go rename to integration/cmd/api/api_test.go diff --git a/internal/auth_describe_test.go b/integration/cmd/auth/describe_test.go similarity index 100% rename from internal/auth_describe_test.go rename to integration/cmd/auth/describe_test.go diff --git a/internal/clusters_test.go b/integration/cmd/clusters/clusters_test.go similarity index 100% rename from internal/clusters_test.go rename to integration/cmd/clusters/clusters_test.go diff --git a/integration/cmd/fs/cat_test.go b/integration/cmd/fs/cat_test.go index 20c6dba6bb..6dfc4a2235 100644 --- a/integration/cmd/fs/cat_test.go +++ b/integration/cmd/fs/cat_test.go @@ -1,6 +1,6 @@ //go:build integration -package fs +package fs_integration import ( "context" diff --git a/integration/cmd/fs/completion_test.go b/integration/cmd/fs/completion_test.go index f27c7e068e..c340804fbf 100644 --- a/integration/cmd/fs/completion_test.go +++ b/integration/cmd/fs/completion_test.go @@ -1,6 +1,6 @@ //go:build integration -package fs +package fs_integration import ( "context" diff --git a/integration/cmd/fs/cp_test.go b/integration/cmd/fs/cp_test.go index 29bc97d07d..5dcbc2044f 100644 --- a/integration/cmd/fs/cp_test.go +++ b/integration/cmd/fs/cp_test.go @@ -1,6 +1,6 @@ //go:build integration -package fs +package fs_integration import ( "context" diff --git a/integration/cmd/fs/helpers.go b/integration/cmd/fs/helpers.go index 1c5bdd4a9f..f4c2938c14 100644 --- a/integration/cmd/fs/helpers.go +++ b/integration/cmd/fs/helpers.go @@ -1,4 +1,4 @@ -package fs +package fs_integration import ( "errors" diff --git a/integration/cmd/fs/ls_test.go b/integration/cmd/fs/ls_test.go index c60af9ab50..36d95547f0 100644 --- a/integration/cmd/fs/ls_test.go +++ b/integration/cmd/fs/ls_test.go @@ -1,6 +1,6 @@ //go:build integration -package fs +package fs_integration import ( "context" diff --git a/integration/cmd/fs/mkdir_test.go b/integration/cmd/fs/mkdir_test.go index ffbdd5ad6f..a64c7d9cbb 100644 --- a/integration/cmd/fs/mkdir_test.go +++ b/integration/cmd/fs/mkdir_test.go @@ -1,6 +1,6 @@ //go:build integration -package fs +package fs_integration import ( "context" diff --git a/integration/cmd/fs/rm_test.go b/integration/cmd/fs/rm_test.go index ba061803dc..ced98fe67d 100644 --- a/integration/cmd/fs/rm_test.go +++ b/integration/cmd/fs/rm_test.go @@ -1,6 +1,6 @@ //go:build integration -package fs +package fs_integration import ( "context" diff --git a/internal/jobs_test.go b/integration/cmd/jobs/jobs_test.go similarity index 90% rename from internal/jobs_test.go rename to integration/cmd/jobs/jobs_test.go index 2781323e6a..146930ea60 100644 --- a/internal/jobs_test.go +++ b/integration/cmd/jobs/jobs_test.go @@ -18,7 +18,7 @@ func TestAccCreateJob(t *testing.T) { if env != "azure" { t.Skipf("Not running test on cloud %s", env) } - stdout, stderr := testcli.RequireSuccessfulRun(t, "jobs", "create", "--json", "@testjsons/create_job_without_workers.json", "--log-level=debug") + stdout, stderr := testcli.RequireSuccessfulRun(t, "jobs", "create", "--json", "@testdata/create_job_without_workers.json", "--log-level=debug") assert.Empty(t, stderr.String()) var output map[string]int err := json.Unmarshal(stdout.Bytes(), &output) diff --git a/internal/testjsons/create_job_without_workers.json b/integration/cmd/jobs/testdata/create_job_without_workers.json similarity index 100% rename from internal/testjsons/create_job_without_workers.json rename to integration/cmd/jobs/testdata/create_job_without_workers.json diff --git a/internal/repos_test.go b/integration/cmd/repos/repos_test.go similarity index 100% rename from internal/repos_test.go rename to integration/cmd/repos/repos_test.go diff --git a/internal/secrets_test.go b/integration/cmd/secrets/secrets_test.go similarity index 100% rename from internal/secrets_test.go rename to integration/cmd/secrets/secrets_test.go diff --git a/internal/storage_credentials_test.go b/integration/cmd/storage_credentials/storage_credentials_test.go similarity index 100% rename from internal/storage_credentials_test.go rename to integration/cmd/storage_credentials/storage_credentials_test.go diff --git a/internal/sync_test.go b/integration/cmd/sync/sync_test.go similarity index 100% rename from internal/sync_test.go rename to integration/cmd/sync/sync_test.go diff --git a/internal/unknown_command_test.go b/integration/cmd/unknown_command_test.go similarity index 89% rename from internal/unknown_command_test.go rename to integration/cmd/unknown_command_test.go index 96cb4fa5e8..3062e979b4 100644 --- a/internal/unknown_command_test.go +++ b/integration/cmd/unknown_command_test.go @@ -1,4 +1,6 @@ -package internal +//go:build integration + +package cmd_integration import ( "testing" diff --git a/internal/version_test.go b/integration/cmd/version/version_test.go similarity index 100% rename from internal/version_test.go rename to integration/cmd/version/version_test.go diff --git a/internal/testdata/import_dir/a/b/c/file-b b/integration/cmd/workspace/testdata/import_dir/a/b/c/file-b similarity index 100% rename from internal/testdata/import_dir/a/b/c/file-b rename to integration/cmd/workspace/testdata/import_dir/a/b/c/file-b diff --git a/internal/testdata/import_dir/file-a b/integration/cmd/workspace/testdata/import_dir/file-a similarity index 100% rename from internal/testdata/import_dir/file-a rename to integration/cmd/workspace/testdata/import_dir/file-a diff --git a/internal/testdata/import_dir/jupyterNotebook.ipynb b/integration/cmd/workspace/testdata/import_dir/jupyterNotebook.ipynb similarity index 100% rename from internal/testdata/import_dir/jupyterNotebook.ipynb rename to integration/cmd/workspace/testdata/import_dir/jupyterNotebook.ipynb diff --git a/internal/testdata/import_dir/pyNotebook.py b/integration/cmd/workspace/testdata/import_dir/pyNotebook.py similarity index 100% rename from internal/testdata/import_dir/pyNotebook.py rename to integration/cmd/workspace/testdata/import_dir/pyNotebook.py diff --git a/internal/testdata/import_dir/rNotebook.r b/integration/cmd/workspace/testdata/import_dir/rNotebook.r similarity index 100% rename from internal/testdata/import_dir/rNotebook.r rename to integration/cmd/workspace/testdata/import_dir/rNotebook.r diff --git a/internal/testdata/import_dir/scalaNotebook.scala b/integration/cmd/workspace/testdata/import_dir/scalaNotebook.scala similarity index 100% rename from internal/testdata/import_dir/scalaNotebook.scala rename to integration/cmd/workspace/testdata/import_dir/scalaNotebook.scala diff --git a/internal/testdata/import_dir/sqlNotebook.sql b/integration/cmd/workspace/testdata/import_dir/sqlNotebook.sql similarity index 100% rename from internal/testdata/import_dir/sqlNotebook.sql rename to integration/cmd/workspace/testdata/import_dir/sqlNotebook.sql diff --git a/internal/workspace_test.go b/integration/cmd/workspace/workspace_test.go similarity index 100% rename from internal/workspace_test.go rename to integration/cmd/workspace/workspace_test.go diff --git a/internal/filer_test.go b/integration/libs/filer/filer_test.go similarity index 99% rename from internal/filer_test.go rename to integration/libs/filer/filer_test.go index 4b7a0b53eb..de0ea10d46 100644 --- a/internal/filer_test.go +++ b/integration/libs/filer/filer_test.go @@ -1,4 +1,6 @@ -package internal +//go:build integration + +package filer_integration import ( "bytes" diff --git a/integration/libs/filer/helpers.go b/integration/libs/filer/helpers.go new file mode 100644 index 0000000000..d6011e9391 --- /dev/null +++ b/integration/libs/filer/helpers.go @@ -0,0 +1,75 @@ +package filer_integration + +import ( + "errors" + "net/http" + "os" + "path" + "path/filepath" + + "github.com/databricks/cli/internal/acc" + "github.com/databricks/cli/internal/testutil" + + "github.com/databricks/cli/libs/filer" + "github.com/databricks/databricks-sdk-go/apierr" + "github.com/stretchr/testify/require" +) + +func setupLocalFiler(t testutil.TestingT) (filer.Filer, string) { + t.Log(testutil.GetEnvOrSkipTest(t, "CLOUD_ENV")) + + tmp := t.TempDir() + f, err := filer.NewLocalClient(tmp) + require.NoError(t, err) + + return f, path.Join(filepath.ToSlash(tmp)) +} + +func setupWsfsFiler(t testutil.TestingT) (filer.Filer, string) { + ctx, wt := acc.WorkspaceTest(t) + + tmpdir := acc.TemporaryWorkspaceDir(wt) + f, err := filer.NewWorkspaceFilesClient(wt.W, tmpdir) + require.NoError(t, err) + + // Check if we can use this API here, skip test if we cannot. + _, err = f.Read(ctx, "we_use_this_call_to_test_if_this_api_is_enabled") + var aerr *apierr.APIError + if errors.As(err, &aerr) && aerr.StatusCode == http.StatusBadRequest { + t.Skip(aerr.Message) + } + + return f, tmpdir +} + +func setupWsfsExtensionsFiler(t testutil.TestingT) (filer.Filer, string) { + _, wt := acc.WorkspaceTest(t) + + tmpdir := acc.TemporaryWorkspaceDir(wt) + f, err := filer.NewWorkspaceFilesExtensionsClient(wt.W, tmpdir) + require.NoError(t, err) + return f, tmpdir +} + +func setupDbfsFiler(t testutil.TestingT) (filer.Filer, string) { + _, wt := acc.WorkspaceTest(t) + + tmpdir := acc.TemporaryDbfsDir(wt) + f, err := filer.NewDbfsClient(wt.W, tmpdir) + require.NoError(t, err) + return f, path.Join("dbfs:/", tmpdir) +} + +func setupUcVolumesFiler(t testutil.TestingT) (filer.Filer, string) { + _, wt := acc.WorkspaceTest(t) + + if os.Getenv("TEST_METASTORE_ID") == "" { + t.Skip("Skipping tests that require a UC Volume when metastore id is not set.") + } + + tmpdir := acc.TemporaryVolume(wt) + f, err := filer.NewFilesClient(wt.W, tmpdir) + require.NoError(t, err) + + return f, path.Join("dbfs:/", tmpdir) +} diff --git a/internal/testdata/notebooks/py1.ipynb b/integration/libs/filer/testdata/notebooks/py1.ipynb similarity index 100% rename from internal/testdata/notebooks/py1.ipynb rename to integration/libs/filer/testdata/notebooks/py1.ipynb diff --git a/internal/testdata/notebooks/py2.ipynb b/integration/libs/filer/testdata/notebooks/py2.ipynb similarity index 100% rename from internal/testdata/notebooks/py2.ipynb rename to integration/libs/filer/testdata/notebooks/py2.ipynb diff --git a/internal/testdata/notebooks/r1.ipynb b/integration/libs/filer/testdata/notebooks/r1.ipynb similarity index 100% rename from internal/testdata/notebooks/r1.ipynb rename to integration/libs/filer/testdata/notebooks/r1.ipynb diff --git a/internal/testdata/notebooks/r2.ipynb b/integration/libs/filer/testdata/notebooks/r2.ipynb similarity index 100% rename from internal/testdata/notebooks/r2.ipynb rename to integration/libs/filer/testdata/notebooks/r2.ipynb diff --git a/internal/testdata/notebooks/scala1.ipynb b/integration/libs/filer/testdata/notebooks/scala1.ipynb similarity index 100% rename from internal/testdata/notebooks/scala1.ipynb rename to integration/libs/filer/testdata/notebooks/scala1.ipynb diff --git a/internal/testdata/notebooks/scala2.ipynb b/integration/libs/filer/testdata/notebooks/scala2.ipynb similarity index 100% rename from internal/testdata/notebooks/scala2.ipynb rename to integration/libs/filer/testdata/notebooks/scala2.ipynb diff --git a/internal/testdata/notebooks/sql1.ipynb b/integration/libs/filer/testdata/notebooks/sql1.ipynb similarity index 100% rename from internal/testdata/notebooks/sql1.ipynb rename to integration/libs/filer/testdata/notebooks/sql1.ipynb diff --git a/internal/testdata/notebooks/sql2.ipynb b/integration/libs/filer/testdata/notebooks/sql2.ipynb similarity index 100% rename from internal/testdata/notebooks/sql2.ipynb rename to integration/libs/filer/testdata/notebooks/sql2.ipynb diff --git a/internal/git_clone_test.go b/integration/libs/git/git_clone_test.go similarity index 97% rename from internal/git_clone_test.go rename to integration/libs/git/git_clone_test.go index d5e6762dde..b9b0a1a69a 100644 --- a/internal/git_clone_test.go +++ b/integration/libs/git/git_clone_test.go @@ -1,4 +1,6 @@ -package internal +//go:build integration + +package git_integration import ( "context" diff --git a/internal/git_fetch_test.go b/integration/libs/git/git_fetch_test.go similarity index 99% rename from internal/git_fetch_test.go rename to integration/libs/git/git_fetch_test.go index e692970c77..ecde0f3e90 100644 --- a/internal/git_fetch_test.go +++ b/integration/libs/git/git_fetch_test.go @@ -1,4 +1,6 @@ -package internal +//go:build integration + +package git_integration import ( "os" diff --git a/internal/locker_test.go b/integration/libs/locker/locker_test.go similarity index 99% rename from internal/locker_test.go rename to integration/libs/locker/locker_test.go index 87f74e9d85..3e92d23ee1 100644 --- a/internal/locker_test.go +++ b/integration/libs/locker/locker_test.go @@ -1,4 +1,6 @@ -package internal +//go:build integration + +package locker_integration import ( "context" diff --git a/internal/tags_test.go b/integration/libs/tags/tags_test.go similarity index 99% rename from internal/tags_test.go rename to integration/libs/tags/tags_test.go index ea2c0db052..78e9599e2c 100644 --- a/internal/tags_test.go +++ b/integration/libs/tags/tags_test.go @@ -1,4 +1,6 @@ -package internal +//go:build integration + +package tags_integration import ( "strings" diff --git a/internal/init_test.go b/internal/bundle/init_test.go similarity index 99% rename from internal/init_test.go rename to internal/bundle/init_test.go index e2d96b3e15..dfb3a48f37 100644 --- a/internal/init_test.go +++ b/internal/bundle/init_test.go @@ -1,4 +1,4 @@ -package internal +package bundle import ( "context" diff --git a/internal/testdata/init/field-does-not-exist/databricks_template_schema.json b/internal/bundle/testdata/init/field-does-not-exist/databricks_template_schema.json similarity index 100% rename from internal/testdata/init/field-does-not-exist/databricks_template_schema.json rename to internal/bundle/testdata/init/field-does-not-exist/databricks_template_schema.json diff --git a/internal/testdata/init/field-does-not-exist/template/bar.tmpl b/internal/bundle/testdata/init/field-does-not-exist/template/bar.tmpl similarity index 100% rename from internal/testdata/init/field-does-not-exist/template/bar.tmpl rename to internal/bundle/testdata/init/field-does-not-exist/template/bar.tmpl From dfd0bd05642b5857618db2db3460885d73c3098b Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Thu, 12 Dec 2024 21:59:36 +0100 Subject: [PATCH 06/24] Add build tags and package names --- integration/cmd/alerts/alerts_test.go | 4 +- integration/cmd/api/api_test.go | 4 +- integration/cmd/auth/describe_test.go | 4 +- integration/cmd/clusters/clusters_test.go | 4 +- integration/cmd/fs/helpers.go | 2 + integration/cmd/jobs/jobs_test.go | 4 +- integration/cmd/repos/repos_test.go | 6 +- integration/cmd/secrets/secrets_test.go | 4 +- .../storage_credentials_test.go | 4 +- integration/cmd/sync/sync_test.go | 4 +- integration/cmd/version/version_test.go | 4 +- integration/cmd/workspace/workspace_test.go | 4 +- integration/libs/filer/helpers.go | 2 + integration/verify_build_tags_test.go | 58 +++++++++++++++---- 14 files changed, 86 insertions(+), 22 deletions(-) diff --git a/integration/cmd/alerts/alerts_test.go b/integration/cmd/alerts/alerts_test.go index d7be16d8bb..c44895484b 100644 --- a/integration/cmd/alerts/alerts_test.go +++ b/integration/cmd/alerts/alerts_test.go @@ -1,4 +1,6 @@ -package internal +//go:build integration + +package alerts_integration import ( "testing" diff --git a/integration/cmd/api/api_test.go b/integration/cmd/api/api_test.go index 1c7312ddbd..4f501557e6 100644 --- a/integration/cmd/api/api_test.go +++ b/integration/cmd/api/api_test.go @@ -1,4 +1,6 @@ -package internal +//go:build integration + +package api_integration import ( "encoding/json" diff --git a/integration/cmd/auth/describe_test.go b/integration/cmd/auth/describe_test.go index e0b335c592..c0044826f1 100644 --- a/integration/cmd/auth/describe_test.go +++ b/integration/cmd/auth/describe_test.go @@ -1,4 +1,6 @@ -package internal +//go:build integration + +package auth_integration import ( "context" diff --git a/integration/cmd/clusters/clusters_test.go b/integration/cmd/clusters/clusters_test.go index cc1b2aa07c..1c533ba7d5 100644 --- a/integration/cmd/clusters/clusters_test.go +++ b/integration/cmd/clusters/clusters_test.go @@ -1,4 +1,6 @@ -package internal +//go:build integration + +package clusters_integration import ( "fmt" diff --git a/integration/cmd/fs/helpers.go b/integration/cmd/fs/helpers.go index f4c2938c14..53a02d6232 100644 --- a/integration/cmd/fs/helpers.go +++ b/integration/cmd/fs/helpers.go @@ -1,3 +1,5 @@ +//go:build integration + package fs_integration import ( diff --git a/integration/cmd/jobs/jobs_test.go b/integration/cmd/jobs/jobs_test.go index 146930ea60..cec77bf3b0 100644 --- a/integration/cmd/jobs/jobs_test.go +++ b/integration/cmd/jobs/jobs_test.go @@ -1,4 +1,6 @@ -package internal +//go:build integration + +package jobs_integration import ( "encoding/json" diff --git a/integration/cmd/repos/repos_test.go b/integration/cmd/repos/repos_test.go index a89217fe1f..9237127653 100644 --- a/integration/cmd/repos/repos_test.go +++ b/integration/cmd/repos/repos_test.go @@ -1,4 +1,6 @@ -package internal +//go:build integration + +package repos_integration import ( "context" @@ -15,6 +17,8 @@ import ( "github.com/stretchr/testify/require" ) +const repoUrl = "https://github.com/databricks/databricks-empty-ide-project.git" + func synthesizeTemporaryRepoPath(t *testing.T, w *databricks.WorkspaceClient, ctx context.Context) string { me, err := w.CurrentUser.Me(ctx) require.NoError(t, err) diff --git a/integration/cmd/secrets/secrets_test.go b/integration/cmd/secrets/secrets_test.go index 0ad9cece71..5366e34cef 100644 --- a/integration/cmd/secrets/secrets_test.go +++ b/integration/cmd/secrets/secrets_test.go @@ -1,4 +1,6 @@ -package internal +//go:build integration + +package secrets_integration import ( "context" diff --git a/integration/cmd/storage_credentials/storage_credentials_test.go b/integration/cmd/storage_credentials/storage_credentials_test.go index b7fe1aa56a..b7addc92ab 100644 --- a/integration/cmd/storage_credentials/storage_credentials_test.go +++ b/integration/cmd/storage_credentials/storage_credentials_test.go @@ -1,4 +1,6 @@ -package internal +//go:build integration + +package storage_credentials_integration import ( "testing" diff --git a/integration/cmd/sync/sync_test.go b/integration/cmd/sync/sync_test.go index 9fff6055b3..ae40235c0d 100644 --- a/integration/cmd/sync/sync_test.go +++ b/integration/cmd/sync/sync_test.go @@ -1,4 +1,6 @@ -package internal +//go:build integration + +package sync_integration import ( "context" diff --git a/integration/cmd/version/version_test.go b/integration/cmd/version/version_test.go index 5c5c3a1005..f303d9f370 100644 --- a/integration/cmd/version/version_test.go +++ b/integration/cmd/version/version_test.go @@ -1,4 +1,6 @@ -package internal +//go:build integration + +package version_integration import ( "encoding/json" diff --git a/integration/cmd/workspace/workspace_test.go b/integration/cmd/workspace/workspace_test.go index f16245aa29..9582e02f09 100644 --- a/integration/cmd/workspace/workspace_test.go +++ b/integration/cmd/workspace/workspace_test.go @@ -1,4 +1,6 @@ -package internal +//go:build integration + +package workspace_integration import ( "context" diff --git a/integration/libs/filer/helpers.go b/integration/libs/filer/helpers.go index d6011e9391..effe8d585b 100644 --- a/integration/libs/filer/helpers.go +++ b/integration/libs/filer/helpers.go @@ -1,3 +1,5 @@ +//go:build integration + package filer_integration import ( diff --git a/integration/verify_build_tags_test.go b/integration/verify_build_tags_test.go index 31ad95d7a6..6d9f0fd7d3 100644 --- a/integration/verify_build_tags_test.go +++ b/integration/verify_build_tags_test.go @@ -1,7 +1,8 @@ package integration import ( - "bufio" + "go/scanner" + "go/token" "os" "path/filepath" "strings" @@ -11,8 +12,50 @@ import ( "github.com/stretchr/testify/require" ) -// TestVerifyBuildTags checks that all test files in the integration package specify the "integration" build tag. -// This ensures that `go test ./...` doesn't run integration tests. +func verifyIntegrationTest(t *testing.T, path string) { + var s scanner.Scanner + fset := token.NewFileSet() + src, err := os.ReadFile(path) + require.NoError(t, err) + file := fset.AddFile(path, fset.Base(), len(src)) + s.Init(file, src, nil, scanner.ScanComments) + + var buildTag string + var packageName string + + var tok token.Token + var lit string + + // Keep scanning until we find the package name and build tag. + for tok != token.EOF && (buildTag == "" || packageName == "") { + _, tok, lit = s.Scan() + switch tok { + case token.PACKAGE: + _, tok, lit = s.Scan() + if tok == token.IDENT { + packageName = lit + } + case token.COMMENT: + if strings.HasPrefix(lit, "//go:build ") { + buildTag = strings.TrimPrefix(lit, "//go:build ") + } + case token.EOF: + break + } + } + + // Verify that the build tag is present. + assert.Equal(t, "integration", buildTag, "File %s does not specify the 'integration' build tag", path) + + // Verify that the package name matches the expected format. + expected := filepath.Base(filepath.Dir(path)) + "_integration" + assert.Equal(t, expected, packageName, "File %s package name '%s' does not match directory name '%s'", path, packageName, expected) +} + +// TestVerifyBuildTags checks that all test files in the integration package specify the "integration" build tag +// and that the package name matches the basename of the containing directory with "_integration" appended. +// +// We enforce this package name to avoid package name aliasing. func TestVerifyBuildTags(t *testing.T) { err := filepath.Walk(".", func(path string, info os.FileInfo, err error) error { if err != nil { @@ -34,14 +77,7 @@ func TestVerifyBuildTags(t *testing.T) { return nil } - f, err := os.Open(path) - require.NoError(t, err) - defer f.Close() - - // Read the first line - scanner := bufio.NewScanner(f) - scanner.Scan() - assert.Equal(t, "//go:build integration", scanner.Text(), "File %s does not specify the 'integration' build tag", path) + verifyIntegrationTest(t, path) return nil }) From 5196a533588ced9b40ec4c798d934defd8c0fc7a Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Thu, 12 Dec 2024 22:02:34 +0100 Subject: [PATCH 07/24] Fix up missing helper --- internal/bundle/init_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/bundle/init_test.go b/internal/bundle/init_test.go index dfb3a48f37..b94b658037 100644 --- a/internal/bundle/init_test.go +++ b/internal/bundle/init_test.go @@ -67,8 +67,8 @@ func TestAccBundleInitOnMlopsStacks(t *testing.T) { testcli.RequireSuccessfulRun(t, "bundle", "init", "mlops-stacks", "--output-dir", tmpDir2, "--config-file", filepath.Join(tmpDir1, "config.json")) // Assert that the README.md file was created - assert.FileExists(t, filepath.Join(tmpDir2, "repo_name", projectName, "README.md")) - assertLocalFileContents(t, filepath.Join(tmpDir2, "repo_name", projectName, "README.md"), fmt.Sprintf("# %s", projectName)) + contents := testutil.ReadFile(t, filepath.Join(tmpDir2, "repo_name", projectName, "README.md")) + assert.Contains(t, contents, fmt.Sprintf("# %s", projectName)) // Validate the stack testutil.Chdir(t, filepath.Join(tmpDir2, "repo_name", projectName)) @@ -163,6 +163,7 @@ func TestAccBundleInitHelpers(t *testing.T) { testcli.RequireSuccessfulRun(t, "bundle", "init", tmpDir, "--output-dir", tmpDir2) // Assert that the helper function was correctly computed. - assertLocalFileContents(t, filepath.Join(tmpDir2, "foo.txt"), test.expected) + contents := testutil.ReadFile(t, filepath.Join(tmpDir2, "foo.txt")) + assert.Contains(t, contents, test.expected) } } From 0df9154dfbd1416b8a74e9f051f3668fe8c4caf5 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Thu, 12 Dec 2024 22:07:05 +0100 Subject: [PATCH 08/24] Move bundle integration tests --- {internal => integration}/bundle/artifacts_test.go | 4 +++- {internal => integration}/bundle/basic_test.go | 4 +++- {internal => integration}/bundle/bind_resource_test.go | 4 +++- .../artifact_path_with_volume/databricks_template_schema.json | 0 .../artifact_path_with_volume/template/databricks.yml.tmpl | 0 .../bundle/bundles/basic/databricks_template_schema.json | 0 .../bundle/bundles/basic/template/databricks.yml.tmpl | 0 .../bundle/bundles/basic/template/hello_world.py | 0 .../bundle/bundles/clusters/databricks_template_schema.json | 0 .../bundle/bundles/clusters/template/databricks.yml.tmpl | 0 .../bundle/bundles/clusters/template/hello_world.py | 0 .../bundle/bundles/dashboards/databricks_template_schema.json | 0 .../bundle/bundles/dashboards/template/dashboard.lvdash.json | 0 .../bundle/bundles/dashboards/template/databricks.yml.tmpl | 0 .../databricks_template_schema.json | 0 .../bundles/deploy_then_remove_resources/template/bar.py | 0 .../deploy_then_remove_resources/template/databricks.yml.tmpl | 0 .../bundles/deploy_then_remove_resources/template/foo.py | 0 .../deploy_then_remove_resources/template/resources.yml.tmpl | 0 .../bundles/job_metadata/databricks_template_schema.json | 0 .../bundle/bundles/job_metadata/template/a/b/bar.py | 0 .../bundles/job_metadata/template/a/b/resources.yml.tmpl | 0 .../bundle/bundles/job_metadata/template/databricks.yml.tmpl | 0 .../bundle/bundles/job_metadata/template/foo.py | 0 .../bundles/python_wheel_task/databricks_template_schema.json | 0 .../bundles/python_wheel_task/template/databricks.yml.tmpl | 0 .../bundle/bundles/python_wheel_task/template/setup.py.tmpl | 0 .../python_wheel_task/template/{{.project_name}}/__init__.py | 0 .../python_wheel_task/template/{{.project_name}}/__main__.py | 0 .../databricks_template_schema.json | 0 .../template/databricks.yml.tmpl | 0 .../python_wheel_task_with_cluster/template/setup.py.tmpl | 0 .../template/{{.project_name}}/__init__.py | 0 .../template/{{.project_name}}/__main__.py | 0 .../databricks_template_schema.json | 0 .../template/databricks.yml.tmpl | 0 .../template/setup.py.tmpl | 0 .../template/{{.project_name}}/__init__.py | 0 .../template/{{.project_name}}/__main__.py | 0 .../bundles/recreate_pipeline/databricks_template_schema.json | 0 .../bundles/recreate_pipeline/template/databricks.yml.tmpl | 0 .../bundle/bundles/recreate_pipeline/template/nb.sql | 0 .../bundles/spark_jar_task/databricks_template_schema.json | 0 .../bundles/spark_jar_task/template/databricks.yml.tmpl | 0 .../template/{{.project_name}}/META-INF/MANIFEST.MF | 0 .../spark_jar_task/template/{{.project_name}}/PrintArgs.java | 0 .../bundle/bundles/uc_schema/databricks_template_schema.json | 0 .../bundle/bundles/uc_schema/template/databricks.yml.tmpl | 0 .../bundle/bundles/uc_schema/template/nb.sql | 0 .../bundle/bundles/uc_schema/template/schema.yml.tmpl | 0 .../bundle/bundles/volume/databricks_template_schema.json | 0 .../bundle/bundles/volume/template/databricks.yml.tmpl | 0 .../bundle/bundles/volume/template/nb.sql | 0 .../bundles/with_includes/databricks_template_schema.json | 0 .../bundle/bundles/with_includes/template/databricks.yml.tmpl | 0 {internal => integration}/bundle/clusters_test.go | 4 +++- {internal => integration}/bundle/dashboards_test.go | 4 +++- {internal => integration}/bundle/deploy_test.go | 4 +++- .../bundle/deploy_then_remove_resources_test.go | 4 +++- {internal => integration}/bundle/deploy_to_shared_test.go | 4 +++- {internal => integration}/bundle/deployment_state_test.go | 4 +++- {internal => integration}/bundle/destroy_test.go | 4 +++- {internal => integration}/bundle/empty_bundle_test.go | 4 +++- {internal => integration}/bundle/environments_test.go | 4 +++- {internal => integration}/bundle/generate_job_test.go | 4 +++- {internal => integration}/bundle/generate_pipeline_test.go | 4 +++- {internal => integration}/bundle/helpers.go | 4 +++- {internal => integration}/bundle/init_test.go | 4 +++- {internal => integration}/bundle/job_metadata_test.go | 4 +++- .../bundle/local_state_staleness_test.go | 4 +++- {internal => integration}/bundle/python_wheel_test.go | 4 +++- {internal => integration}/bundle/spark_jar_test.go | 4 +++- .../init/field-does-not-exist/databricks_template_schema.json | 0 .../testdata/init/field-does-not-exist/template/bar.tmpl | 0 {internal => integration}/bundle/validate_test.go | 4 +++- 75 files changed, 63 insertions(+), 21 deletions(-) rename {internal => integration}/bundle/artifacts_test.go (99%) rename {internal => integration}/bundle/basic_test.go (95%) rename {internal => integration}/bundle/bind_resource_test.go (99%) rename {internal => integration}/bundle/bundles/artifact_path_with_volume/databricks_template_schema.json (100%) rename {internal => integration}/bundle/bundles/artifact_path_with_volume/template/databricks.yml.tmpl (100%) rename {internal => integration}/bundle/bundles/basic/databricks_template_schema.json (100%) rename {internal => integration}/bundle/bundles/basic/template/databricks.yml.tmpl (100%) rename {internal => integration}/bundle/bundles/basic/template/hello_world.py (100%) rename {internal => integration}/bundle/bundles/clusters/databricks_template_schema.json (100%) rename {internal => integration}/bundle/bundles/clusters/template/databricks.yml.tmpl (100%) rename {internal => integration}/bundle/bundles/clusters/template/hello_world.py (100%) rename {internal => integration}/bundle/bundles/dashboards/databricks_template_schema.json (100%) rename {internal => integration}/bundle/bundles/dashboards/template/dashboard.lvdash.json (100%) rename {internal => integration}/bundle/bundles/dashboards/template/databricks.yml.tmpl (100%) rename {internal => integration}/bundle/bundles/deploy_then_remove_resources/databricks_template_schema.json (100%) rename {internal => integration}/bundle/bundles/deploy_then_remove_resources/template/bar.py (100%) rename {internal => integration}/bundle/bundles/deploy_then_remove_resources/template/databricks.yml.tmpl (100%) rename {internal => integration}/bundle/bundles/deploy_then_remove_resources/template/foo.py (100%) rename {internal => integration}/bundle/bundles/deploy_then_remove_resources/template/resources.yml.tmpl (100%) rename {internal => integration}/bundle/bundles/job_metadata/databricks_template_schema.json (100%) rename {internal => integration}/bundle/bundles/job_metadata/template/a/b/bar.py (100%) rename {internal => integration}/bundle/bundles/job_metadata/template/a/b/resources.yml.tmpl (100%) rename {internal => integration}/bundle/bundles/job_metadata/template/databricks.yml.tmpl (100%) rename {internal => integration}/bundle/bundles/job_metadata/template/foo.py (100%) rename {internal => integration}/bundle/bundles/python_wheel_task/databricks_template_schema.json (100%) rename {internal => integration}/bundle/bundles/python_wheel_task/template/databricks.yml.tmpl (100%) rename {internal => integration}/bundle/bundles/python_wheel_task/template/setup.py.tmpl (100%) rename {internal => integration}/bundle/bundles/python_wheel_task/template/{{.project_name}}/__init__.py (100%) rename {internal => integration}/bundle/bundles/python_wheel_task/template/{{.project_name}}/__main__.py (100%) rename {internal => integration}/bundle/bundles/python_wheel_task_with_cluster/databricks_template_schema.json (100%) rename {internal => integration}/bundle/bundles/python_wheel_task_with_cluster/template/databricks.yml.tmpl (100%) rename {internal => integration}/bundle/bundles/python_wheel_task_with_cluster/template/setup.py.tmpl (100%) rename {internal => integration}/bundle/bundles/python_wheel_task_with_cluster/template/{{.project_name}}/__init__.py (100%) rename {internal => integration}/bundle/bundles/python_wheel_task_with_cluster/template/{{.project_name}}/__main__.py (100%) rename {internal => integration}/bundle/bundles/python_wheel_task_with_environments/databricks_template_schema.json (100%) rename {internal => integration}/bundle/bundles/python_wheel_task_with_environments/template/databricks.yml.tmpl (100%) rename {internal => integration}/bundle/bundles/python_wheel_task_with_environments/template/setup.py.tmpl (100%) rename {internal => integration}/bundle/bundles/python_wheel_task_with_environments/template/{{.project_name}}/__init__.py (100%) rename {internal => integration}/bundle/bundles/python_wheel_task_with_environments/template/{{.project_name}}/__main__.py (100%) rename {internal => integration}/bundle/bundles/recreate_pipeline/databricks_template_schema.json (100%) rename {internal => integration}/bundle/bundles/recreate_pipeline/template/databricks.yml.tmpl (100%) rename {internal => integration}/bundle/bundles/recreate_pipeline/template/nb.sql (100%) rename {internal => integration}/bundle/bundles/spark_jar_task/databricks_template_schema.json (100%) rename {internal => integration}/bundle/bundles/spark_jar_task/template/databricks.yml.tmpl (100%) rename {internal => integration}/bundle/bundles/spark_jar_task/template/{{.project_name}}/META-INF/MANIFEST.MF (100%) rename {internal => integration}/bundle/bundles/spark_jar_task/template/{{.project_name}}/PrintArgs.java (100%) rename {internal => integration}/bundle/bundles/uc_schema/databricks_template_schema.json (100%) rename {internal => integration}/bundle/bundles/uc_schema/template/databricks.yml.tmpl (100%) rename {internal => integration}/bundle/bundles/uc_schema/template/nb.sql (100%) rename {internal => integration}/bundle/bundles/uc_schema/template/schema.yml.tmpl (100%) rename {internal => integration}/bundle/bundles/volume/databricks_template_schema.json (100%) rename {internal => integration}/bundle/bundles/volume/template/databricks.yml.tmpl (100%) rename {internal => integration}/bundle/bundles/volume/template/nb.sql (100%) rename {internal => integration}/bundle/bundles/with_includes/databricks_template_schema.json (100%) rename {internal => integration}/bundle/bundles/with_includes/template/databricks.yml.tmpl (100%) rename {internal => integration}/bundle/clusters_test.go (96%) rename {internal => integration}/bundle/dashboards_test.go (97%) rename {internal => integration}/bundle/deploy_test.go (99%) rename {internal => integration}/bundle/deploy_then_remove_resources_test.go (97%) rename {internal => integration}/bundle/deploy_to_shared_test.go (94%) rename {internal => integration}/bundle/deployment_state_test.go (98%) rename {internal => integration}/bundle/destroy_test.go (97%) rename {internal => integration}/bundle/empty_bundle_test.go (93%) rename {internal => integration}/bundle/environments_test.go (95%) rename {internal => integration}/bundle/generate_job_test.go (98%) rename {internal => integration}/bundle/generate_pipeline_test.go (98%) rename {internal => integration}/bundle/helpers.go (99%) rename {internal => integration}/bundle/init_test.go (99%) rename {internal => integration}/bundle/job_metadata_test.go (98%) rename {internal => integration}/bundle/local_state_staleness_test.go (97%) rename {internal => integration}/bundle/python_wheel_test.go (97%) rename {internal => integration}/bundle/spark_jar_test.go (98%) rename {internal => integration}/bundle/testdata/init/field-does-not-exist/databricks_template_schema.json (100%) rename {internal => integration}/bundle/testdata/init/field-does-not-exist/template/bar.tmpl (100%) rename {internal => integration}/bundle/validate_test.go (96%) diff --git a/internal/bundle/artifacts_test.go b/integration/bundle/artifacts_test.go similarity index 99% rename from internal/bundle/artifacts_test.go rename to integration/bundle/artifacts_test.go index 7c8954a0cc..05c8411d91 100644 --- a/internal/bundle/artifacts_test.go +++ b/integration/bundle/artifacts_test.go @@ -1,4 +1,6 @@ -package bundle +//go:build integration + +package bundle_integration import ( "fmt" diff --git a/internal/bundle/basic_test.go b/integration/bundle/basic_test.go similarity index 95% rename from internal/bundle/basic_test.go rename to integration/bundle/basic_test.go index 13da6da9ba..5012f07266 100644 --- a/internal/bundle/basic_test.go +++ b/integration/bundle/basic_test.go @@ -1,4 +1,6 @@ -package bundle +//go:build integration + +package bundle_integration import ( "os" diff --git a/internal/bundle/bind_resource_test.go b/integration/bundle/bind_resource_test.go similarity index 99% rename from internal/bundle/bind_resource_test.go rename to integration/bundle/bind_resource_test.go index 7f8151ee9a..44502d376a 100644 --- a/internal/bundle/bind_resource_test.go +++ b/integration/bundle/bind_resource_test.go @@ -1,4 +1,6 @@ -package bundle +//go:build integration + +package bundle_integration import ( "fmt" diff --git a/internal/bundle/bundles/artifact_path_with_volume/databricks_template_schema.json b/integration/bundle/bundles/artifact_path_with_volume/databricks_template_schema.json similarity index 100% rename from internal/bundle/bundles/artifact_path_with_volume/databricks_template_schema.json rename to integration/bundle/bundles/artifact_path_with_volume/databricks_template_schema.json diff --git a/internal/bundle/bundles/artifact_path_with_volume/template/databricks.yml.tmpl b/integration/bundle/bundles/artifact_path_with_volume/template/databricks.yml.tmpl similarity index 100% rename from internal/bundle/bundles/artifact_path_with_volume/template/databricks.yml.tmpl rename to integration/bundle/bundles/artifact_path_with_volume/template/databricks.yml.tmpl diff --git a/internal/bundle/bundles/basic/databricks_template_schema.json b/integration/bundle/bundles/basic/databricks_template_schema.json similarity index 100% rename from internal/bundle/bundles/basic/databricks_template_schema.json rename to integration/bundle/bundles/basic/databricks_template_schema.json diff --git a/internal/bundle/bundles/basic/template/databricks.yml.tmpl b/integration/bundle/bundles/basic/template/databricks.yml.tmpl similarity index 100% rename from internal/bundle/bundles/basic/template/databricks.yml.tmpl rename to integration/bundle/bundles/basic/template/databricks.yml.tmpl diff --git a/internal/bundle/bundles/basic/template/hello_world.py b/integration/bundle/bundles/basic/template/hello_world.py similarity index 100% rename from internal/bundle/bundles/basic/template/hello_world.py rename to integration/bundle/bundles/basic/template/hello_world.py diff --git a/internal/bundle/bundles/clusters/databricks_template_schema.json b/integration/bundle/bundles/clusters/databricks_template_schema.json similarity index 100% rename from internal/bundle/bundles/clusters/databricks_template_schema.json rename to integration/bundle/bundles/clusters/databricks_template_schema.json diff --git a/internal/bundle/bundles/clusters/template/databricks.yml.tmpl b/integration/bundle/bundles/clusters/template/databricks.yml.tmpl similarity index 100% rename from internal/bundle/bundles/clusters/template/databricks.yml.tmpl rename to integration/bundle/bundles/clusters/template/databricks.yml.tmpl diff --git a/internal/bundle/bundles/clusters/template/hello_world.py b/integration/bundle/bundles/clusters/template/hello_world.py similarity index 100% rename from internal/bundle/bundles/clusters/template/hello_world.py rename to integration/bundle/bundles/clusters/template/hello_world.py diff --git a/internal/bundle/bundles/dashboards/databricks_template_schema.json b/integration/bundle/bundles/dashboards/databricks_template_schema.json similarity index 100% rename from internal/bundle/bundles/dashboards/databricks_template_schema.json rename to integration/bundle/bundles/dashboards/databricks_template_schema.json diff --git a/internal/bundle/bundles/dashboards/template/dashboard.lvdash.json b/integration/bundle/bundles/dashboards/template/dashboard.lvdash.json similarity index 100% rename from internal/bundle/bundles/dashboards/template/dashboard.lvdash.json rename to integration/bundle/bundles/dashboards/template/dashboard.lvdash.json diff --git a/internal/bundle/bundles/dashboards/template/databricks.yml.tmpl b/integration/bundle/bundles/dashboards/template/databricks.yml.tmpl similarity index 100% rename from internal/bundle/bundles/dashboards/template/databricks.yml.tmpl rename to integration/bundle/bundles/dashboards/template/databricks.yml.tmpl diff --git a/internal/bundle/bundles/deploy_then_remove_resources/databricks_template_schema.json b/integration/bundle/bundles/deploy_then_remove_resources/databricks_template_schema.json similarity index 100% rename from internal/bundle/bundles/deploy_then_remove_resources/databricks_template_schema.json rename to integration/bundle/bundles/deploy_then_remove_resources/databricks_template_schema.json diff --git a/internal/bundle/bundles/deploy_then_remove_resources/template/bar.py b/integration/bundle/bundles/deploy_then_remove_resources/template/bar.py similarity index 100% rename from internal/bundle/bundles/deploy_then_remove_resources/template/bar.py rename to integration/bundle/bundles/deploy_then_remove_resources/template/bar.py diff --git a/internal/bundle/bundles/deploy_then_remove_resources/template/databricks.yml.tmpl b/integration/bundle/bundles/deploy_then_remove_resources/template/databricks.yml.tmpl similarity index 100% rename from internal/bundle/bundles/deploy_then_remove_resources/template/databricks.yml.tmpl rename to integration/bundle/bundles/deploy_then_remove_resources/template/databricks.yml.tmpl diff --git a/internal/bundle/bundles/deploy_then_remove_resources/template/foo.py b/integration/bundle/bundles/deploy_then_remove_resources/template/foo.py similarity index 100% rename from internal/bundle/bundles/deploy_then_remove_resources/template/foo.py rename to integration/bundle/bundles/deploy_then_remove_resources/template/foo.py diff --git a/internal/bundle/bundles/deploy_then_remove_resources/template/resources.yml.tmpl b/integration/bundle/bundles/deploy_then_remove_resources/template/resources.yml.tmpl similarity index 100% rename from internal/bundle/bundles/deploy_then_remove_resources/template/resources.yml.tmpl rename to integration/bundle/bundles/deploy_then_remove_resources/template/resources.yml.tmpl diff --git a/internal/bundle/bundles/job_metadata/databricks_template_schema.json b/integration/bundle/bundles/job_metadata/databricks_template_schema.json similarity index 100% rename from internal/bundle/bundles/job_metadata/databricks_template_schema.json rename to integration/bundle/bundles/job_metadata/databricks_template_schema.json diff --git a/internal/bundle/bundles/job_metadata/template/a/b/bar.py b/integration/bundle/bundles/job_metadata/template/a/b/bar.py similarity index 100% rename from internal/bundle/bundles/job_metadata/template/a/b/bar.py rename to integration/bundle/bundles/job_metadata/template/a/b/bar.py diff --git a/internal/bundle/bundles/job_metadata/template/a/b/resources.yml.tmpl b/integration/bundle/bundles/job_metadata/template/a/b/resources.yml.tmpl similarity index 100% rename from internal/bundle/bundles/job_metadata/template/a/b/resources.yml.tmpl rename to integration/bundle/bundles/job_metadata/template/a/b/resources.yml.tmpl diff --git a/internal/bundle/bundles/job_metadata/template/databricks.yml.tmpl b/integration/bundle/bundles/job_metadata/template/databricks.yml.tmpl similarity index 100% rename from internal/bundle/bundles/job_metadata/template/databricks.yml.tmpl rename to integration/bundle/bundles/job_metadata/template/databricks.yml.tmpl diff --git a/internal/bundle/bundles/job_metadata/template/foo.py b/integration/bundle/bundles/job_metadata/template/foo.py similarity index 100% rename from internal/bundle/bundles/job_metadata/template/foo.py rename to integration/bundle/bundles/job_metadata/template/foo.py diff --git a/internal/bundle/bundles/python_wheel_task/databricks_template_schema.json b/integration/bundle/bundles/python_wheel_task/databricks_template_schema.json similarity index 100% rename from internal/bundle/bundles/python_wheel_task/databricks_template_schema.json rename to integration/bundle/bundles/python_wheel_task/databricks_template_schema.json diff --git a/internal/bundle/bundles/python_wheel_task/template/databricks.yml.tmpl b/integration/bundle/bundles/python_wheel_task/template/databricks.yml.tmpl similarity index 100% rename from internal/bundle/bundles/python_wheel_task/template/databricks.yml.tmpl rename to integration/bundle/bundles/python_wheel_task/template/databricks.yml.tmpl diff --git a/internal/bundle/bundles/python_wheel_task/template/setup.py.tmpl b/integration/bundle/bundles/python_wheel_task/template/setup.py.tmpl similarity index 100% rename from internal/bundle/bundles/python_wheel_task/template/setup.py.tmpl rename to integration/bundle/bundles/python_wheel_task/template/setup.py.tmpl diff --git a/internal/bundle/bundles/python_wheel_task/template/{{.project_name}}/__init__.py b/integration/bundle/bundles/python_wheel_task/template/{{.project_name}}/__init__.py similarity index 100% rename from internal/bundle/bundles/python_wheel_task/template/{{.project_name}}/__init__.py rename to integration/bundle/bundles/python_wheel_task/template/{{.project_name}}/__init__.py diff --git a/internal/bundle/bundles/python_wheel_task/template/{{.project_name}}/__main__.py b/integration/bundle/bundles/python_wheel_task/template/{{.project_name}}/__main__.py similarity index 100% rename from internal/bundle/bundles/python_wheel_task/template/{{.project_name}}/__main__.py rename to integration/bundle/bundles/python_wheel_task/template/{{.project_name}}/__main__.py diff --git a/internal/bundle/bundles/python_wheel_task_with_cluster/databricks_template_schema.json b/integration/bundle/bundles/python_wheel_task_with_cluster/databricks_template_schema.json similarity index 100% rename from internal/bundle/bundles/python_wheel_task_with_cluster/databricks_template_schema.json rename to integration/bundle/bundles/python_wheel_task_with_cluster/databricks_template_schema.json diff --git a/internal/bundle/bundles/python_wheel_task_with_cluster/template/databricks.yml.tmpl b/integration/bundle/bundles/python_wheel_task_with_cluster/template/databricks.yml.tmpl similarity index 100% rename from internal/bundle/bundles/python_wheel_task_with_cluster/template/databricks.yml.tmpl rename to integration/bundle/bundles/python_wheel_task_with_cluster/template/databricks.yml.tmpl diff --git a/internal/bundle/bundles/python_wheel_task_with_cluster/template/setup.py.tmpl b/integration/bundle/bundles/python_wheel_task_with_cluster/template/setup.py.tmpl similarity index 100% rename from internal/bundle/bundles/python_wheel_task_with_cluster/template/setup.py.tmpl rename to integration/bundle/bundles/python_wheel_task_with_cluster/template/setup.py.tmpl diff --git a/internal/bundle/bundles/python_wheel_task_with_cluster/template/{{.project_name}}/__init__.py b/integration/bundle/bundles/python_wheel_task_with_cluster/template/{{.project_name}}/__init__.py similarity index 100% rename from internal/bundle/bundles/python_wheel_task_with_cluster/template/{{.project_name}}/__init__.py rename to integration/bundle/bundles/python_wheel_task_with_cluster/template/{{.project_name}}/__init__.py diff --git a/internal/bundle/bundles/python_wheel_task_with_cluster/template/{{.project_name}}/__main__.py b/integration/bundle/bundles/python_wheel_task_with_cluster/template/{{.project_name}}/__main__.py similarity index 100% rename from internal/bundle/bundles/python_wheel_task_with_cluster/template/{{.project_name}}/__main__.py rename to integration/bundle/bundles/python_wheel_task_with_cluster/template/{{.project_name}}/__main__.py diff --git a/internal/bundle/bundles/python_wheel_task_with_environments/databricks_template_schema.json b/integration/bundle/bundles/python_wheel_task_with_environments/databricks_template_schema.json similarity index 100% rename from internal/bundle/bundles/python_wheel_task_with_environments/databricks_template_schema.json rename to integration/bundle/bundles/python_wheel_task_with_environments/databricks_template_schema.json diff --git a/internal/bundle/bundles/python_wheel_task_with_environments/template/databricks.yml.tmpl b/integration/bundle/bundles/python_wheel_task_with_environments/template/databricks.yml.tmpl similarity index 100% rename from internal/bundle/bundles/python_wheel_task_with_environments/template/databricks.yml.tmpl rename to integration/bundle/bundles/python_wheel_task_with_environments/template/databricks.yml.tmpl diff --git a/internal/bundle/bundles/python_wheel_task_with_environments/template/setup.py.tmpl b/integration/bundle/bundles/python_wheel_task_with_environments/template/setup.py.tmpl similarity index 100% rename from internal/bundle/bundles/python_wheel_task_with_environments/template/setup.py.tmpl rename to integration/bundle/bundles/python_wheel_task_with_environments/template/setup.py.tmpl diff --git a/internal/bundle/bundles/python_wheel_task_with_environments/template/{{.project_name}}/__init__.py b/integration/bundle/bundles/python_wheel_task_with_environments/template/{{.project_name}}/__init__.py similarity index 100% rename from internal/bundle/bundles/python_wheel_task_with_environments/template/{{.project_name}}/__init__.py rename to integration/bundle/bundles/python_wheel_task_with_environments/template/{{.project_name}}/__init__.py diff --git a/internal/bundle/bundles/python_wheel_task_with_environments/template/{{.project_name}}/__main__.py b/integration/bundle/bundles/python_wheel_task_with_environments/template/{{.project_name}}/__main__.py similarity index 100% rename from internal/bundle/bundles/python_wheel_task_with_environments/template/{{.project_name}}/__main__.py rename to integration/bundle/bundles/python_wheel_task_with_environments/template/{{.project_name}}/__main__.py diff --git a/internal/bundle/bundles/recreate_pipeline/databricks_template_schema.json b/integration/bundle/bundles/recreate_pipeline/databricks_template_schema.json similarity index 100% rename from internal/bundle/bundles/recreate_pipeline/databricks_template_schema.json rename to integration/bundle/bundles/recreate_pipeline/databricks_template_schema.json diff --git a/internal/bundle/bundles/recreate_pipeline/template/databricks.yml.tmpl b/integration/bundle/bundles/recreate_pipeline/template/databricks.yml.tmpl similarity index 100% rename from internal/bundle/bundles/recreate_pipeline/template/databricks.yml.tmpl rename to integration/bundle/bundles/recreate_pipeline/template/databricks.yml.tmpl diff --git a/internal/bundle/bundles/recreate_pipeline/template/nb.sql b/integration/bundle/bundles/recreate_pipeline/template/nb.sql similarity index 100% rename from internal/bundle/bundles/recreate_pipeline/template/nb.sql rename to integration/bundle/bundles/recreate_pipeline/template/nb.sql diff --git a/internal/bundle/bundles/spark_jar_task/databricks_template_schema.json b/integration/bundle/bundles/spark_jar_task/databricks_template_schema.json similarity index 100% rename from internal/bundle/bundles/spark_jar_task/databricks_template_schema.json rename to integration/bundle/bundles/spark_jar_task/databricks_template_schema.json diff --git a/internal/bundle/bundles/spark_jar_task/template/databricks.yml.tmpl b/integration/bundle/bundles/spark_jar_task/template/databricks.yml.tmpl similarity index 100% rename from internal/bundle/bundles/spark_jar_task/template/databricks.yml.tmpl rename to integration/bundle/bundles/spark_jar_task/template/databricks.yml.tmpl diff --git a/internal/bundle/bundles/spark_jar_task/template/{{.project_name}}/META-INF/MANIFEST.MF b/integration/bundle/bundles/spark_jar_task/template/{{.project_name}}/META-INF/MANIFEST.MF similarity index 100% rename from internal/bundle/bundles/spark_jar_task/template/{{.project_name}}/META-INF/MANIFEST.MF rename to integration/bundle/bundles/spark_jar_task/template/{{.project_name}}/META-INF/MANIFEST.MF diff --git a/internal/bundle/bundles/spark_jar_task/template/{{.project_name}}/PrintArgs.java b/integration/bundle/bundles/spark_jar_task/template/{{.project_name}}/PrintArgs.java similarity index 100% rename from internal/bundle/bundles/spark_jar_task/template/{{.project_name}}/PrintArgs.java rename to integration/bundle/bundles/spark_jar_task/template/{{.project_name}}/PrintArgs.java diff --git a/internal/bundle/bundles/uc_schema/databricks_template_schema.json b/integration/bundle/bundles/uc_schema/databricks_template_schema.json similarity index 100% rename from internal/bundle/bundles/uc_schema/databricks_template_schema.json rename to integration/bundle/bundles/uc_schema/databricks_template_schema.json diff --git a/internal/bundle/bundles/uc_schema/template/databricks.yml.tmpl b/integration/bundle/bundles/uc_schema/template/databricks.yml.tmpl similarity index 100% rename from internal/bundle/bundles/uc_schema/template/databricks.yml.tmpl rename to integration/bundle/bundles/uc_schema/template/databricks.yml.tmpl diff --git a/internal/bundle/bundles/uc_schema/template/nb.sql b/integration/bundle/bundles/uc_schema/template/nb.sql similarity index 100% rename from internal/bundle/bundles/uc_schema/template/nb.sql rename to integration/bundle/bundles/uc_schema/template/nb.sql diff --git a/internal/bundle/bundles/uc_schema/template/schema.yml.tmpl b/integration/bundle/bundles/uc_schema/template/schema.yml.tmpl similarity index 100% rename from internal/bundle/bundles/uc_schema/template/schema.yml.tmpl rename to integration/bundle/bundles/uc_schema/template/schema.yml.tmpl diff --git a/internal/bundle/bundles/volume/databricks_template_schema.json b/integration/bundle/bundles/volume/databricks_template_schema.json similarity index 100% rename from internal/bundle/bundles/volume/databricks_template_schema.json rename to integration/bundle/bundles/volume/databricks_template_schema.json diff --git a/internal/bundle/bundles/volume/template/databricks.yml.tmpl b/integration/bundle/bundles/volume/template/databricks.yml.tmpl similarity index 100% rename from internal/bundle/bundles/volume/template/databricks.yml.tmpl rename to integration/bundle/bundles/volume/template/databricks.yml.tmpl diff --git a/internal/bundle/bundles/volume/template/nb.sql b/integration/bundle/bundles/volume/template/nb.sql similarity index 100% rename from internal/bundle/bundles/volume/template/nb.sql rename to integration/bundle/bundles/volume/template/nb.sql diff --git a/internal/bundle/bundles/with_includes/databricks_template_schema.json b/integration/bundle/bundles/with_includes/databricks_template_schema.json similarity index 100% rename from internal/bundle/bundles/with_includes/databricks_template_schema.json rename to integration/bundle/bundles/with_includes/databricks_template_schema.json diff --git a/internal/bundle/bundles/with_includes/template/databricks.yml.tmpl b/integration/bundle/bundles/with_includes/template/databricks.yml.tmpl similarity index 100% rename from internal/bundle/bundles/with_includes/template/databricks.yml.tmpl rename to integration/bundle/bundles/with_includes/template/databricks.yml.tmpl diff --git a/internal/bundle/clusters_test.go b/integration/bundle/clusters_test.go similarity index 96% rename from internal/bundle/clusters_test.go rename to integration/bundle/clusters_test.go index d79ded0b7d..93427d0a68 100644 --- a/internal/bundle/clusters_test.go +++ b/integration/bundle/clusters_test.go @@ -1,4 +1,6 @@ -package bundle +//go:build integration + +package bundle_integration import ( "fmt" diff --git a/internal/bundle/dashboards_test.go b/integration/bundle/dashboards_test.go similarity index 97% rename from internal/bundle/dashboards_test.go rename to integration/bundle/dashboards_test.go index 82ed419b4b..3fe1a18c63 100644 --- a/internal/bundle/dashboards_test.go +++ b/integration/bundle/dashboards_test.go @@ -1,4 +1,6 @@ -package bundle +//go:build integration + +package bundle_integration import ( "fmt" diff --git a/internal/bundle/deploy_test.go b/integration/bundle/deploy_test.go similarity index 99% rename from internal/bundle/deploy_test.go rename to integration/bundle/deploy_test.go index 038705c37c..254b4ef82a 100644 --- a/internal/bundle/deploy_test.go +++ b/integration/bundle/deploy_test.go @@ -1,4 +1,6 @@ -package bundle +//go:build integration + +package bundle_integration import ( "context" diff --git a/internal/bundle/deploy_then_remove_resources_test.go b/integration/bundle/deploy_then_remove_resources_test.go similarity index 97% rename from internal/bundle/deploy_then_remove_resources_test.go rename to integration/bundle/deploy_then_remove_resources_test.go index 0cc7ab92d4..b6d8b3c444 100644 --- a/internal/bundle/deploy_then_remove_resources_test.go +++ b/integration/bundle/deploy_then_remove_resources_test.go @@ -1,4 +1,6 @@ -package bundle +//go:build integration + +package bundle_integration import ( "os" diff --git a/internal/bundle/deploy_to_shared_test.go b/integration/bundle/deploy_to_shared_test.go similarity index 94% rename from internal/bundle/deploy_to_shared_test.go rename to integration/bundle/deploy_to_shared_test.go index 7b8d570293..283f00b0b6 100644 --- a/internal/bundle/deploy_to_shared_test.go +++ b/integration/bundle/deploy_to_shared_test.go @@ -1,4 +1,6 @@ -package bundle +//go:build integration + +package bundle_integration import ( "fmt" diff --git a/internal/bundle/deployment_state_test.go b/integration/bundle/deployment_state_test.go similarity index 98% rename from internal/bundle/deployment_state_test.go rename to integration/bundle/deployment_state_test.go index caa72d0a23..1cac3642fe 100644 --- a/internal/bundle/deployment_state_test.go +++ b/integration/bundle/deployment_state_test.go @@ -1,4 +1,6 @@ -package bundle +//go:build integration + +package bundle_integration import ( "os" diff --git a/internal/bundle/destroy_test.go b/integration/bundle/destroy_test.go similarity index 97% rename from internal/bundle/destroy_test.go rename to integration/bundle/destroy_test.go index dad9c0874e..fa506dc3e5 100644 --- a/internal/bundle/destroy_test.go +++ b/integration/bundle/destroy_test.go @@ -1,4 +1,6 @@ -package bundle +//go:build integration + +package bundle_integration import ( "errors" diff --git a/internal/bundle/empty_bundle_test.go b/integration/bundle/empty_bundle_test.go similarity index 93% rename from internal/bundle/empty_bundle_test.go rename to integration/bundle/empty_bundle_test.go index 36883ae001..4f65558df2 100644 --- a/internal/bundle/empty_bundle_test.go +++ b/integration/bundle/empty_bundle_test.go @@ -1,4 +1,6 @@ -package bundle +//go:build integration + +package bundle_integration import ( "fmt" diff --git a/internal/bundle/environments_test.go b/integration/bundle/environments_test.go similarity index 95% rename from internal/bundle/environments_test.go rename to integration/bundle/environments_test.go index 7c5b6db893..8c329c9be9 100644 --- a/internal/bundle/environments_test.go +++ b/integration/bundle/environments_test.go @@ -1,4 +1,6 @@ -package bundle +//go:build integration + +package bundle_integration import ( "testing" diff --git a/internal/bundle/generate_job_test.go b/integration/bundle/generate_job_test.go similarity index 98% rename from internal/bundle/generate_job_test.go rename to integration/bundle/generate_job_test.go index b254dac8c8..3a27e6ba22 100644 --- a/internal/bundle/generate_job_test.go +++ b/integration/bundle/generate_job_test.go @@ -1,4 +1,6 @@ -package bundle +//go:build integration + +package bundle_integration import ( "context" diff --git a/internal/bundle/generate_pipeline_test.go b/integration/bundle/generate_pipeline_test.go similarity index 98% rename from internal/bundle/generate_pipeline_test.go rename to integration/bundle/generate_pipeline_test.go index 96d8d28285..d235d6c5d1 100644 --- a/internal/bundle/generate_pipeline_test.go +++ b/integration/bundle/generate_pipeline_test.go @@ -1,4 +1,6 @@ -package bundle +//go:build integration + +package bundle_integration import ( "context" diff --git a/internal/bundle/helpers.go b/integration/bundle/helpers.go similarity index 99% rename from internal/bundle/helpers.go rename to integration/bundle/helpers.go index 0512de8732..14cf9da2fb 100644 --- a/internal/bundle/helpers.go +++ b/integration/bundle/helpers.go @@ -1,4 +1,6 @@ -package bundle +//go:build integration + +package bundle_integration import ( "bytes" diff --git a/internal/bundle/init_test.go b/integration/bundle/init_test.go similarity index 99% rename from internal/bundle/init_test.go rename to integration/bundle/init_test.go index b94b658037..d72d0948ce 100644 --- a/internal/bundle/init_test.go +++ b/integration/bundle/init_test.go @@ -1,4 +1,6 @@ -package bundle +//go:build integration + +package bundle_integration import ( "context" diff --git a/internal/bundle/job_metadata_test.go b/integration/bundle/job_metadata_test.go similarity index 98% rename from internal/bundle/job_metadata_test.go rename to integration/bundle/job_metadata_test.go index de11d89a6f..93b341b096 100644 --- a/internal/bundle/job_metadata_test.go +++ b/integration/bundle/job_metadata_test.go @@ -1,4 +1,6 @@ -package bundle +//go:build integration + +package bundle_integration import ( "context" diff --git a/internal/bundle/local_state_staleness_test.go b/integration/bundle/local_state_staleness_test.go similarity index 97% rename from internal/bundle/local_state_staleness_test.go rename to integration/bundle/local_state_staleness_test.go index 1c025b47a4..070da2a59e 100644 --- a/internal/bundle/local_state_staleness_test.go +++ b/integration/bundle/local_state_staleness_test.go @@ -1,4 +1,6 @@ -package bundle +//go:build integration + +package bundle_integration import ( "context" diff --git a/internal/bundle/python_wheel_test.go b/integration/bundle/python_wheel_test.go similarity index 97% rename from internal/bundle/python_wheel_test.go rename to integration/bundle/python_wheel_test.go index 1d8647396a..9258ccfcf5 100644 --- a/internal/bundle/python_wheel_test.go +++ b/integration/bundle/python_wheel_test.go @@ -1,4 +1,6 @@ -package bundle +//go:build integration + +package bundle_integration import ( "testing" diff --git a/internal/bundle/spark_jar_test.go b/integration/bundle/spark_jar_test.go similarity index 98% rename from internal/bundle/spark_jar_test.go rename to integration/bundle/spark_jar_test.go index c2402deb60..8bdf9394f9 100644 --- a/internal/bundle/spark_jar_test.go +++ b/integration/bundle/spark_jar_test.go @@ -1,4 +1,6 @@ -package bundle +//go:build integration + +package bundle_integration import ( "context" diff --git a/internal/bundle/testdata/init/field-does-not-exist/databricks_template_schema.json b/integration/bundle/testdata/init/field-does-not-exist/databricks_template_schema.json similarity index 100% rename from internal/bundle/testdata/init/field-does-not-exist/databricks_template_schema.json rename to integration/bundle/testdata/init/field-does-not-exist/databricks_template_schema.json diff --git a/internal/bundle/testdata/init/field-does-not-exist/template/bar.tmpl b/integration/bundle/testdata/init/field-does-not-exist/template/bar.tmpl similarity index 100% rename from internal/bundle/testdata/init/field-does-not-exist/template/bar.tmpl rename to integration/bundle/testdata/init/field-does-not-exist/template/bar.tmpl diff --git a/internal/bundle/validate_test.go b/integration/bundle/validate_test.go similarity index 96% rename from internal/bundle/validate_test.go rename to integration/bundle/validate_test.go index 0942275bc5..b2b8c3dea5 100644 --- a/internal/bundle/validate_test.go +++ b/integration/bundle/validate_test.go @@ -1,4 +1,6 @@ -package bundle +//go:build integration + +package bundle_integration import ( "context" From 2fd75ec0d3f271ce235072f621976d12a3787e47 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Thu, 12 Dec 2024 22:08:56 +0100 Subject: [PATCH 09/24] Remove unused functions --- integration/cmd/fs/helpers.go | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/integration/cmd/fs/helpers.go b/integration/cmd/fs/helpers.go index 53a02d6232..b544c0a08c 100644 --- a/integration/cmd/fs/helpers.go +++ b/integration/cmd/fs/helpers.go @@ -3,8 +3,6 @@ package fs_integration import ( - "errors" - "net/http" "os" "path" "path/filepath" @@ -13,7 +11,6 @@ import ( "github.com/databricks/cli/internal/testutil" "github.com/databricks/cli/libs/filer" - "github.com/databricks/databricks-sdk-go/apierr" "github.com/stretchr/testify/require" ) @@ -27,32 +24,6 @@ func setupLocalFiler(t testutil.TestingT) (filer.Filer, string) { return f, path.Join(filepath.ToSlash(tmp)) } -func setupWsfsFiler(t testutil.TestingT) (filer.Filer, string) { - ctx, wt := acc.WorkspaceTest(t) - - tmpdir := acc.TemporaryWorkspaceDir(wt) - f, err := filer.NewWorkspaceFilesClient(wt.W, tmpdir) - require.NoError(t, err) - - // Check if we can use this API here, skip test if we cannot. - _, err = f.Read(ctx, "we_use_this_call_to_test_if_this_api_is_enabled") - var aerr *apierr.APIError - if errors.As(err, &aerr) && aerr.StatusCode == http.StatusBadRequest { - t.Skip(aerr.Message) - } - - return f, tmpdir -} - -func setupWsfsExtensionsFiler(t testutil.TestingT) (filer.Filer, string) { - _, wt := acc.WorkspaceTest(t) - - tmpdir := acc.TemporaryWorkspaceDir(wt) - f, err := filer.NewWorkspaceFilesExtensionsClient(wt.W, tmpdir) - require.NoError(t, err) - return f, tmpdir -} - func setupDbfsFiler(t testutil.TestingT) (filer.Filer, string) { _, wt := acc.WorkspaceTest(t) From b7fb0abedeb0c486eca19f6cf2c4a031afb60723 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Thu, 12 Dec 2024 22:11:01 +0100 Subject: [PATCH 10/24] Move remaining integration tests --- .../assumptions}/dashboard_assumptions_test.go | 4 +++- .../python/python_tasks_test.go | 4 +++- .../testdata/my_test_code-0.0.1-py3-none-any.whl | Bin {internal => integration}/python/testdata/spark.py | 0 {internal => integration}/python/testdata/test.py | 0 5 files changed, 6 insertions(+), 2 deletions(-) rename {internal => integration/assumptions}/dashboard_assumptions_test.go (98%) rename {internal => integration}/python/python_tasks_test.go (99%) rename {internal => integration}/python/testdata/my_test_code-0.0.1-py3-none-any.whl (100%) rename {internal => integration}/python/testdata/spark.py (100%) rename {internal => integration}/python/testdata/test.py (100%) diff --git a/internal/dashboard_assumptions_test.go b/integration/assumptions/dashboard_assumptions_test.go similarity index 98% rename from internal/dashboard_assumptions_test.go rename to integration/assumptions/dashboard_assumptions_test.go index 906efa7819..4c6722e27b 100644 --- a/internal/dashboard_assumptions_test.go +++ b/integration/assumptions/dashboard_assumptions_test.go @@ -1,4 +1,6 @@ -package internal +//go:build integration + +package assumptions_integration import ( "encoding/base64" diff --git a/internal/python/python_tasks_test.go b/integration/python/python_tasks_test.go similarity index 99% rename from internal/python/python_tasks_test.go rename to integration/python/python_tasks_test.go index 36efa4a1b8..afbe5c9d77 100644 --- a/internal/python/python_tasks_test.go +++ b/integration/python/python_tasks_test.go @@ -1,4 +1,6 @@ -package python +//go:build integration + +package python_integration import ( "bytes" diff --git a/internal/python/testdata/my_test_code-0.0.1-py3-none-any.whl b/integration/python/testdata/my_test_code-0.0.1-py3-none-any.whl similarity index 100% rename from internal/python/testdata/my_test_code-0.0.1-py3-none-any.whl rename to integration/python/testdata/my_test_code-0.0.1-py3-none-any.whl diff --git a/internal/python/testdata/spark.py b/integration/python/testdata/spark.py similarity index 100% rename from internal/python/testdata/spark.py rename to integration/python/testdata/spark.py diff --git a/internal/python/testdata/test.py b/integration/python/testdata/test.py similarity index 100% rename from internal/python/testdata/test.py rename to integration/python/testdata/test.py From 23b15f7ca799ae7b69d5c83fe4fc5c1d6e5dd3b7 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Thu, 12 Dec 2024 22:15:15 +0100 Subject: [PATCH 11/24] Use build tag in Make target --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d10332c385..23859a0eea 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,6 @@ vendor: @go mod vendor integration: - gotestsum --format github-actions --rerun-fails --jsonfile output.json --packages "./internal/..." -- -run "TestAcc.*" -parallel 4 -timeout=2h + gotestsum --format github-actions --rerun-fails --jsonfile output.json --packages "./integration/..." -- -tags integration -parallel 4 -timeout=2h .PHONY: fmt lint lintcheck test testonly coverage build snapshot vendor integration From b8a34decf516ff5b8ca3fddbba875ee9710075b0 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Thu, 12 Dec 2024 22:27:07 +0100 Subject: [PATCH 12/24] Add brief README about integration tests --- integration/README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 integration/README.md diff --git a/integration/README.md b/integration/README.md new file mode 100644 index 0000000000..b82159f944 --- /dev/null +++ b/integration/README.md @@ -0,0 +1,35 @@ +# Integration tests + +This directory contains integration tests for the project. + +The tree structure generally mirrors the source code tree structure. + +Requirements for new files in this directory: +* Every integration test file **must** use the `integration` build tag +* Every package **must** be named after its directory with `_integration` appended + * Requiring a different package name for integration tests avoids aliasing with the main package. + +## Running integration tests + +Integration tests require the following environment variables: +* `CLOUD_ENV` - set to the cloud environment to use (e.g. `aws`, `azure`, `gcp`) +* `DATABRICKS_HOST` - set to the Databricks workspace to use +* `DATABRICKS_TOKEN` - set to the Databricks token to use + +Optional environment variables: +* `TEST_DEFAULT_WAREHOUSE_ID` - set to the default warehouse ID to use +* `TEST_METASTORE_ID` - set to the metastore ID to use +* `TEST_INSTANCE_POOL_ID` - set to the instance pool ID to use +* `TEST_BRICKS_CLUSTER_ID` - set to the cluster ID to use + +To run all integration tests, use the following command: + +```bash +go test -tags=integration ./... +``` + +Alternatively: + +```bash +make integration +``` From f687f3b82201df80b3e99be74c50e3792160d49f Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Thu, 12 Dec 2024 22:32:32 +0100 Subject: [PATCH 13/24] Mention requirement enforcement --- integration/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/integration/README.md b/integration/README.md index b82159f944..92d8273e49 100644 --- a/integration/README.md +++ b/integration/README.md @@ -9,6 +9,8 @@ Requirements for new files in this directory: * Every package **must** be named after its directory with `_integration` appended * Requiring a different package name for integration tests avoids aliasing with the main package. +These requirements are enforced by a unit test in this directory. + ## Running integration tests Integration tests require the following environment variables: From d7500537c739c2496dd649e2c817c431b982322e Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Fri, 13 Dec 2024 09:28:28 +0100 Subject: [PATCH 14/24] Skip auth describe failure test --- integration/cmd/auth/describe_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/integration/cmd/auth/describe_test.go b/integration/cmd/auth/describe_test.go index c0044826f1..3db8b9ffcc 100644 --- a/integration/cmd/auth/describe_test.go +++ b/integration/cmd/auth/describe_test.go @@ -37,6 +37,8 @@ func TestAuthDescribeSuccess(t *testing.T) { func TestAuthDescribeFailure(t *testing.T) { t.Log(testutil.GetEnvOrSkipTest(t, "CLOUD_ENV")) + t.Skipf("Skipping because of https://github.com/databricks/cli/issues/2010") + stdout, _ := testcli.RequireSuccessfulRun(t, "auth", "describe", "--profile", "nonexistent") outStr := stdout.String() From db905cc73d4e969dc213a57408bc7cd798c2276c Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Fri, 13 Dec 2024 12:35:22 +0100 Subject: [PATCH 15/24] Remove build tags --- integration/assumptions/dashboard_assumptions_test.go | 2 -- integration/bundle/artifacts_test.go | 2 -- integration/bundle/basic_test.go | 2 -- integration/bundle/bind_resource_test.go | 2 -- integration/bundle/clusters_test.go | 2 -- integration/bundle/dashboards_test.go | 2 -- integration/bundle/deploy_test.go | 2 -- integration/bundle/deploy_then_remove_resources_test.go | 2 -- integration/bundle/deploy_to_shared_test.go | 2 -- integration/bundle/deployment_state_test.go | 2 -- integration/bundle/destroy_test.go | 2 -- integration/bundle/empty_bundle_test.go | 2 -- integration/bundle/environments_test.go | 2 -- integration/bundle/generate_job_test.go | 2 -- integration/bundle/generate_pipeline_test.go | 2 -- integration/bundle/helpers.go | 2 -- integration/bundle/init_test.go | 2 -- integration/bundle/job_metadata_test.go | 2 -- integration/bundle/local_state_staleness_test.go | 2 -- integration/bundle/python_wheel_test.go | 2 -- integration/bundle/spark_jar_test.go | 2 -- integration/bundle/validate_test.go | 2 -- integration/cmd/alerts/alerts_test.go | 2 -- integration/cmd/api/api_test.go | 2 -- integration/cmd/auth/describe_test.go | 2 -- integration/cmd/clusters/clusters_test.go | 2 -- integration/cmd/fs/cat_test.go | 2 -- integration/cmd/fs/completion_test.go | 2 -- integration/cmd/fs/cp_test.go | 2 -- integration/cmd/fs/helpers.go | 2 -- integration/cmd/fs/ls_test.go | 2 -- integration/cmd/fs/mkdir_test.go | 2 -- integration/cmd/fs/rm_test.go | 2 -- integration/cmd/jobs/jobs_test.go | 2 -- integration/cmd/repos/repos_test.go | 2 -- integration/cmd/secrets/secrets_test.go | 2 -- integration/cmd/storage_credentials/storage_credentials_test.go | 2 -- integration/cmd/sync/sync_test.go | 2 -- integration/cmd/unknown_command_test.go | 2 -- integration/cmd/version/version_test.go | 2 -- integration/cmd/workspace/workspace_test.go | 2 -- integration/libs/filer/filer_test.go | 2 -- integration/libs/filer/helpers.go | 2 -- integration/libs/git/git_clone_test.go | 2 -- integration/libs/git/git_fetch_test.go | 2 -- integration/libs/locker/locker_test.go | 2 -- integration/libs/tags/tags_test.go | 2 -- integration/python/python_tasks_test.go | 2 -- 48 files changed, 96 deletions(-) diff --git a/integration/assumptions/dashboard_assumptions_test.go b/integration/assumptions/dashboard_assumptions_test.go index 4c6722e27b..fb384463a2 100644 --- a/integration/assumptions/dashboard_assumptions_test.go +++ b/integration/assumptions/dashboard_assumptions_test.go @@ -1,5 +1,3 @@ -//go:build integration - package assumptions_integration import ( diff --git a/integration/bundle/artifacts_test.go b/integration/bundle/artifacts_test.go index 05c8411d91..9b4dfefd01 100644 --- a/integration/bundle/artifacts_test.go +++ b/integration/bundle/artifacts_test.go @@ -1,5 +1,3 @@ -//go:build integration - package bundle_integration import ( diff --git a/integration/bundle/basic_test.go b/integration/bundle/basic_test.go index 5012f07266..2c170a3514 100644 --- a/integration/bundle/basic_test.go +++ b/integration/bundle/basic_test.go @@ -1,5 +1,3 @@ -//go:build integration - package bundle_integration import ( diff --git a/integration/bundle/bind_resource_test.go b/integration/bundle/bind_resource_test.go index 44502d376a..9bdb3d6350 100644 --- a/integration/bundle/bind_resource_test.go +++ b/integration/bundle/bind_resource_test.go @@ -1,5 +1,3 @@ -//go:build integration - package bundle_integration import ( diff --git a/integration/bundle/clusters_test.go b/integration/bundle/clusters_test.go index 93427d0a68..42f09e4a04 100644 --- a/integration/bundle/clusters_test.go +++ b/integration/bundle/clusters_test.go @@ -1,5 +1,3 @@ -//go:build integration - package bundle_integration import ( diff --git a/integration/bundle/dashboards_test.go b/integration/bundle/dashboards_test.go index 3fe1a18c63..995704d65a 100644 --- a/integration/bundle/dashboards_test.go +++ b/integration/bundle/dashboards_test.go @@ -1,5 +1,3 @@ -//go:build integration - package bundle_integration import ( diff --git a/integration/bundle/deploy_test.go b/integration/bundle/deploy_test.go index 254b4ef82a..5738e6b0e5 100644 --- a/integration/bundle/deploy_test.go +++ b/integration/bundle/deploy_test.go @@ -1,5 +1,3 @@ -//go:build integration - package bundle_integration import ( diff --git a/integration/bundle/deploy_then_remove_resources_test.go b/integration/bundle/deploy_then_remove_resources_test.go index b6d8b3c444..324c471174 100644 --- a/integration/bundle/deploy_then_remove_resources_test.go +++ b/integration/bundle/deploy_then_remove_resources_test.go @@ -1,5 +1,3 @@ -//go:build integration - package bundle_integration import ( diff --git a/integration/bundle/deploy_to_shared_test.go b/integration/bundle/deploy_to_shared_test.go index 283f00b0b6..9eaa768d8f 100644 --- a/integration/bundle/deploy_to_shared_test.go +++ b/integration/bundle/deploy_to_shared_test.go @@ -1,5 +1,3 @@ -//go:build integration - package bundle_integration import ( diff --git a/integration/bundle/deployment_state_test.go b/integration/bundle/deployment_state_test.go index 1cac3642fe..83e812a452 100644 --- a/integration/bundle/deployment_state_test.go +++ b/integration/bundle/deployment_state_test.go @@ -1,5 +1,3 @@ -//go:build integration - package bundle_integration import ( diff --git a/integration/bundle/destroy_test.go b/integration/bundle/destroy_test.go index fa506dc3e5..1b5669c66d 100644 --- a/integration/bundle/destroy_test.go +++ b/integration/bundle/destroy_test.go @@ -1,5 +1,3 @@ -//go:build integration - package bundle_integration import ( diff --git a/integration/bundle/empty_bundle_test.go b/integration/bundle/empty_bundle_test.go index 4f65558df2..07c39815b8 100644 --- a/integration/bundle/empty_bundle_test.go +++ b/integration/bundle/empty_bundle_test.go @@ -1,5 +1,3 @@ -//go:build integration - package bundle_integration import ( diff --git a/integration/bundle/environments_test.go b/integration/bundle/environments_test.go index 8c329c9be9..4729d860ac 100644 --- a/integration/bundle/environments_test.go +++ b/integration/bundle/environments_test.go @@ -1,5 +1,3 @@ -//go:build integration - package bundle_integration import ( diff --git a/integration/bundle/generate_job_test.go b/integration/bundle/generate_job_test.go index 3a27e6ba22..96ee5598c3 100644 --- a/integration/bundle/generate_job_test.go +++ b/integration/bundle/generate_job_test.go @@ -1,5 +1,3 @@ -//go:build integration - package bundle_integration import ( diff --git a/integration/bundle/generate_pipeline_test.go b/integration/bundle/generate_pipeline_test.go index d235d6c5d1..394189017a 100644 --- a/integration/bundle/generate_pipeline_test.go +++ b/integration/bundle/generate_pipeline_test.go @@ -1,5 +1,3 @@ -//go:build integration - package bundle_integration import ( diff --git a/integration/bundle/helpers.go b/integration/bundle/helpers.go index 14cf9da2fb..f1fba3d688 100644 --- a/integration/bundle/helpers.go +++ b/integration/bundle/helpers.go @@ -1,5 +1,3 @@ -//go:build integration - package bundle_integration import ( diff --git a/integration/bundle/init_test.go b/integration/bundle/init_test.go index d72d0948ce..06a2931f43 100644 --- a/integration/bundle/init_test.go +++ b/integration/bundle/init_test.go @@ -1,5 +1,3 @@ -//go:build integration - package bundle_integration import ( diff --git a/integration/bundle/job_metadata_test.go b/integration/bundle/job_metadata_test.go index 93b341b096..ff88a1d222 100644 --- a/integration/bundle/job_metadata_test.go +++ b/integration/bundle/job_metadata_test.go @@ -1,5 +1,3 @@ -//go:build integration - package bundle_integration import ( diff --git a/integration/bundle/local_state_staleness_test.go b/integration/bundle/local_state_staleness_test.go index 070da2a59e..c38c482ee0 100644 --- a/integration/bundle/local_state_staleness_test.go +++ b/integration/bundle/local_state_staleness_test.go @@ -1,5 +1,3 @@ -//go:build integration - package bundle_integration import ( diff --git a/integration/bundle/python_wheel_test.go b/integration/bundle/python_wheel_test.go index 9258ccfcf5..ea9c0bf5ba 100644 --- a/integration/bundle/python_wheel_test.go +++ b/integration/bundle/python_wheel_test.go @@ -1,5 +1,3 @@ -//go:build integration - package bundle_integration import ( diff --git a/integration/bundle/spark_jar_test.go b/integration/bundle/spark_jar_test.go index 8bdf9394f9..c25397fa4b 100644 --- a/integration/bundle/spark_jar_test.go +++ b/integration/bundle/spark_jar_test.go @@ -1,5 +1,3 @@ -//go:build integration - package bundle_integration import ( diff --git a/integration/bundle/validate_test.go b/integration/bundle/validate_test.go index b2b8c3dea5..1547ba51d0 100644 --- a/integration/bundle/validate_test.go +++ b/integration/bundle/validate_test.go @@ -1,5 +1,3 @@ -//go:build integration - package bundle_integration import ( diff --git a/integration/cmd/alerts/alerts_test.go b/integration/cmd/alerts/alerts_test.go index c44895484b..ba362b8369 100644 --- a/integration/cmd/alerts/alerts_test.go +++ b/integration/cmd/alerts/alerts_test.go @@ -1,5 +1,3 @@ -//go:build integration - package alerts_integration import ( diff --git a/integration/cmd/api/api_test.go b/integration/cmd/api/api_test.go index 4f501557e6..8a2c592865 100644 --- a/integration/cmd/api/api_test.go +++ b/integration/cmd/api/api_test.go @@ -1,5 +1,3 @@ -//go:build integration - package api_integration import ( diff --git a/integration/cmd/auth/describe_test.go b/integration/cmd/auth/describe_test.go index 3db8b9ffcc..8d56de2aa3 100644 --- a/integration/cmd/auth/describe_test.go +++ b/integration/cmd/auth/describe_test.go @@ -1,5 +1,3 @@ -//go:build integration - package auth_integration import ( diff --git a/integration/cmd/clusters/clusters_test.go b/integration/cmd/clusters/clusters_test.go index 1c533ba7d5..dc2a367ae3 100644 --- a/integration/cmd/clusters/clusters_test.go +++ b/integration/cmd/clusters/clusters_test.go @@ -1,5 +1,3 @@ -//go:build integration - package clusters_integration import ( diff --git a/integration/cmd/fs/cat_test.go b/integration/cmd/fs/cat_test.go index 6dfc4a2235..a6ccb37d3c 100644 --- a/integration/cmd/fs/cat_test.go +++ b/integration/cmd/fs/cat_test.go @@ -1,5 +1,3 @@ -//go:build integration - package fs_integration import ( diff --git a/integration/cmd/fs/completion_test.go b/integration/cmd/fs/completion_test.go index c340804fbf..8b68ed559c 100644 --- a/integration/cmd/fs/completion_test.go +++ b/integration/cmd/fs/completion_test.go @@ -1,5 +1,3 @@ -//go:build integration - package fs_integration import ( diff --git a/integration/cmd/fs/cp_test.go b/integration/cmd/fs/cp_test.go index 5dcbc2044f..ee3de547dd 100644 --- a/integration/cmd/fs/cp_test.go +++ b/integration/cmd/fs/cp_test.go @@ -1,5 +1,3 @@ -//go:build integration - package fs_integration import ( diff --git a/integration/cmd/fs/helpers.go b/integration/cmd/fs/helpers.go index b544c0a08c..37a2b5de70 100644 --- a/integration/cmd/fs/helpers.go +++ b/integration/cmd/fs/helpers.go @@ -1,5 +1,3 @@ -//go:build integration - package fs_integration import ( diff --git a/integration/cmd/fs/ls_test.go b/integration/cmd/fs/ls_test.go index 36d95547f0..235827d3bb 100644 --- a/integration/cmd/fs/ls_test.go +++ b/integration/cmd/fs/ls_test.go @@ -1,5 +1,3 @@ -//go:build integration - package fs_integration import ( diff --git a/integration/cmd/fs/mkdir_test.go b/integration/cmd/fs/mkdir_test.go index a64c7d9cbb..b1b96f4ac8 100644 --- a/integration/cmd/fs/mkdir_test.go +++ b/integration/cmd/fs/mkdir_test.go @@ -1,5 +1,3 @@ -//go:build integration - package fs_integration import ( diff --git a/integration/cmd/fs/rm_test.go b/integration/cmd/fs/rm_test.go index ced98fe67d..521f097fb9 100644 --- a/integration/cmd/fs/rm_test.go +++ b/integration/cmd/fs/rm_test.go @@ -1,5 +1,3 @@ -//go:build integration - package fs_integration import ( diff --git a/integration/cmd/jobs/jobs_test.go b/integration/cmd/jobs/jobs_test.go index cec77bf3b0..bee4cad9e5 100644 --- a/integration/cmd/jobs/jobs_test.go +++ b/integration/cmd/jobs/jobs_test.go @@ -1,5 +1,3 @@ -//go:build integration - package jobs_integration import ( diff --git a/integration/cmd/repos/repos_test.go b/integration/cmd/repos/repos_test.go index 9237127653..8c1b812c76 100644 --- a/integration/cmd/repos/repos_test.go +++ b/integration/cmd/repos/repos_test.go @@ -1,5 +1,3 @@ -//go:build integration - package repos_integration import ( diff --git a/integration/cmd/secrets/secrets_test.go b/integration/cmd/secrets/secrets_test.go index 5366e34cef..6dc4db7c82 100644 --- a/integration/cmd/secrets/secrets_test.go +++ b/integration/cmd/secrets/secrets_test.go @@ -1,5 +1,3 @@ -//go:build integration - package secrets_integration import ( diff --git a/integration/cmd/storage_credentials/storage_credentials_test.go b/integration/cmd/storage_credentials/storage_credentials_test.go index b7addc92ab..ca9e4234e6 100644 --- a/integration/cmd/storage_credentials/storage_credentials_test.go +++ b/integration/cmd/storage_credentials/storage_credentials_test.go @@ -1,5 +1,3 @@ -//go:build integration - package storage_credentials_integration import ( diff --git a/integration/cmd/sync/sync_test.go b/integration/cmd/sync/sync_test.go index ae40235c0d..4e6f989ddb 100644 --- a/integration/cmd/sync/sync_test.go +++ b/integration/cmd/sync/sync_test.go @@ -1,5 +1,3 @@ -//go:build integration - package sync_integration import ( diff --git a/integration/cmd/unknown_command_test.go b/integration/cmd/unknown_command_test.go index 3062e979b4..4b10ef2db1 100644 --- a/integration/cmd/unknown_command_test.go +++ b/integration/cmd/unknown_command_test.go @@ -1,5 +1,3 @@ -//go:build integration - package cmd_integration import ( diff --git a/integration/cmd/version/version_test.go b/integration/cmd/version/version_test.go index f303d9f370..e567c98137 100644 --- a/integration/cmd/version/version_test.go +++ b/integration/cmd/version/version_test.go @@ -1,5 +1,3 @@ -//go:build integration - package version_integration import ( diff --git a/integration/cmd/workspace/workspace_test.go b/integration/cmd/workspace/workspace_test.go index 9582e02f09..d650d5458a 100644 --- a/integration/cmd/workspace/workspace_test.go +++ b/integration/cmd/workspace/workspace_test.go @@ -1,5 +1,3 @@ -//go:build integration - package workspace_integration import ( diff --git a/integration/libs/filer/filer_test.go b/integration/libs/filer/filer_test.go index de0ea10d46..0936748a2a 100644 --- a/integration/libs/filer/filer_test.go +++ b/integration/libs/filer/filer_test.go @@ -1,5 +1,3 @@ -//go:build integration - package filer_integration import ( diff --git a/integration/libs/filer/helpers.go b/integration/libs/filer/helpers.go index effe8d585b..d6011e9391 100644 --- a/integration/libs/filer/helpers.go +++ b/integration/libs/filer/helpers.go @@ -1,5 +1,3 @@ -//go:build integration - package filer_integration import ( diff --git a/integration/libs/git/git_clone_test.go b/integration/libs/git/git_clone_test.go index b9b0a1a69a..91707fff05 100644 --- a/integration/libs/git/git_clone_test.go +++ b/integration/libs/git/git_clone_test.go @@ -1,5 +1,3 @@ -//go:build integration - package git_integration import ( diff --git a/integration/libs/git/git_fetch_test.go b/integration/libs/git/git_fetch_test.go index ecde0f3e90..fce987a2b1 100644 --- a/integration/libs/git/git_fetch_test.go +++ b/integration/libs/git/git_fetch_test.go @@ -1,5 +1,3 @@ -//go:build integration - package git_integration import ( diff --git a/integration/libs/locker/locker_test.go b/integration/libs/locker/locker_test.go index 3e92d23ee1..020374ffa6 100644 --- a/integration/libs/locker/locker_test.go +++ b/integration/libs/locker/locker_test.go @@ -1,5 +1,3 @@ -//go:build integration - package locker_integration import ( diff --git a/integration/libs/tags/tags_test.go b/integration/libs/tags/tags_test.go index 78e9599e2c..3f146c3e4e 100644 --- a/integration/libs/tags/tags_test.go +++ b/integration/libs/tags/tags_test.go @@ -1,5 +1,3 @@ -//go:build integration - package tags_integration import ( diff --git a/integration/python/python_tasks_test.go b/integration/python/python_tasks_test.go index afbe5c9d77..d819b068a1 100644 --- a/integration/python/python_tasks_test.go +++ b/integration/python/python_tasks_test.go @@ -1,5 +1,3 @@ -//go:build integration - package python_integration import ( From 99f8413fa3995a28b59ef36cf28ec3f68206802a Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Fri, 13 Dec 2024 12:59:56 +0100 Subject: [PATCH 16/24] Add TestMain to every integration test package --- integration/assumptions/main_test.go | 13 +++ integration/bundle/main_test.go | 13 +++ integration/cmd/alerts/main_test.go | 13 +++ integration/cmd/api/main_test.go | 13 +++ integration/cmd/auth/main_test.go | 13 +++ integration/cmd/clusters/main_test.go | 13 +++ integration/cmd/fs/main_test.go | 13 +++ integration/cmd/jobs/main_test.go | 13 +++ integration/cmd/main_test.go | 13 +++ integration/cmd/repos/main_test.go | 13 +++ integration/cmd/secrets/main_test.go | 13 +++ .../cmd/storage_credentials/main_test.go | 13 +++ integration/cmd/sync/main_test.go | 13 +++ integration/cmd/version/main_test.go | 13 +++ integration/cmd/workspace/main_test.go | 13 +++ integration/enforce_convention_test.go | 108 ++++++++++++++++++ integration/internal/main.go | 20 ++++ integration/libs/filer/main_test.go | 13 +++ integration/libs/git/main_test.go | 13 +++ integration/libs/locker/main_test.go | 13 +++ integration/libs/tags/main_test.go | 13 +++ integration/python/main_test.go | 13 +++ integration/verify_build_tags_test.go | 85 -------------- 23 files changed, 388 insertions(+), 85 deletions(-) create mode 100644 integration/assumptions/main_test.go create mode 100644 integration/bundle/main_test.go create mode 100644 integration/cmd/alerts/main_test.go create mode 100644 integration/cmd/api/main_test.go create mode 100644 integration/cmd/auth/main_test.go create mode 100644 integration/cmd/clusters/main_test.go create mode 100644 integration/cmd/fs/main_test.go create mode 100644 integration/cmd/jobs/main_test.go create mode 100644 integration/cmd/main_test.go create mode 100644 integration/cmd/repos/main_test.go create mode 100644 integration/cmd/secrets/main_test.go create mode 100644 integration/cmd/storage_credentials/main_test.go create mode 100644 integration/cmd/sync/main_test.go create mode 100644 integration/cmd/version/main_test.go create mode 100644 integration/cmd/workspace/main_test.go create mode 100644 integration/enforce_convention_test.go create mode 100644 integration/internal/main.go create mode 100644 integration/libs/filer/main_test.go create mode 100644 integration/libs/git/main_test.go create mode 100644 integration/libs/locker/main_test.go create mode 100644 integration/libs/tags/main_test.go create mode 100644 integration/python/main_test.go delete mode 100644 integration/verify_build_tags_test.go diff --git a/integration/assumptions/main_test.go b/integration/assumptions/main_test.go new file mode 100644 index 0000000000..b048e9795f --- /dev/null +++ b/integration/assumptions/main_test.go @@ -0,0 +1,13 @@ +package assumptions_integration + +import ( + "testing" + + "github.com/databricks/cli/integration/internal" +) + +// TestMain is the entrypoint executed by the test runner. +// See [internal.Main] for prerequisites for running integration tests. +func TestMain(m *testing.M) { + internal.Main(m) +} diff --git a/integration/bundle/main_test.go b/integration/bundle/main_test.go new file mode 100644 index 0000000000..04300ed6a9 --- /dev/null +++ b/integration/bundle/main_test.go @@ -0,0 +1,13 @@ +package bundle_integration + +import ( + "testing" + + "github.com/databricks/cli/integration/internal" +) + +// TestMain is the entrypoint executed by the test runner. +// See [internal.Main] for prerequisites for running integration tests. +func TestMain(m *testing.M) { + internal.Main(m) +} diff --git a/integration/cmd/alerts/main_test.go b/integration/cmd/alerts/main_test.go new file mode 100644 index 0000000000..e92588957f --- /dev/null +++ b/integration/cmd/alerts/main_test.go @@ -0,0 +1,13 @@ +package alerts_integration + +import ( + "testing" + + "github.com/databricks/cli/integration/internal" +) + +// TestMain is the entrypoint executed by the test runner. +// See [internal.Main] for prerequisites for running integration tests. +func TestMain(m *testing.M) { + internal.Main(m) +} diff --git a/integration/cmd/api/main_test.go b/integration/cmd/api/main_test.go new file mode 100644 index 0000000000..440746ba7b --- /dev/null +++ b/integration/cmd/api/main_test.go @@ -0,0 +1,13 @@ +package api_integration + +import ( + "testing" + + "github.com/databricks/cli/integration/internal" +) + +// TestMain is the entrypoint executed by the test runner. +// See [internal.Main] for prerequisites for running integration tests. +func TestMain(m *testing.M) { + internal.Main(m) +} diff --git a/integration/cmd/auth/main_test.go b/integration/cmd/auth/main_test.go new file mode 100644 index 0000000000..20d43c5b11 --- /dev/null +++ b/integration/cmd/auth/main_test.go @@ -0,0 +1,13 @@ +package auth_integration + +import ( + "testing" + + "github.com/databricks/cli/integration/internal" +) + +// TestMain is the entrypoint executed by the test runner. +// See [internal.Main] for prerequisites for running integration tests. +func TestMain(m *testing.M) { + internal.Main(m) +} diff --git a/integration/cmd/clusters/main_test.go b/integration/cmd/clusters/main_test.go new file mode 100644 index 0000000000..72d7028be9 --- /dev/null +++ b/integration/cmd/clusters/main_test.go @@ -0,0 +1,13 @@ +package clusters_integration + +import ( + "testing" + + "github.com/databricks/cli/integration/internal" +) + +// TestMain is the entrypoint executed by the test runner. +// See [internal.Main] for prerequisites for running integration tests. +func TestMain(m *testing.M) { + internal.Main(m) +} diff --git a/integration/cmd/fs/main_test.go b/integration/cmd/fs/main_test.go new file mode 100644 index 0000000000..a48cca594f --- /dev/null +++ b/integration/cmd/fs/main_test.go @@ -0,0 +1,13 @@ +package fs_integration + +import ( + "testing" + + "github.com/databricks/cli/integration/internal" +) + +// TestMain is the entrypoint executed by the test runner. +// See [internal.Main] for prerequisites for running integration tests. +func TestMain(m *testing.M) { + internal.Main(m) +} diff --git a/integration/cmd/jobs/main_test.go b/integration/cmd/jobs/main_test.go new file mode 100644 index 0000000000..b35d6e38be --- /dev/null +++ b/integration/cmd/jobs/main_test.go @@ -0,0 +1,13 @@ +package jobs_integration + +import ( + "testing" + + "github.com/databricks/cli/integration/internal" +) + +// TestMain is the entrypoint executed by the test runner. +// See [internal.Main] for prerequisites for running integration tests. +func TestMain(m *testing.M) { + internal.Main(m) +} diff --git a/integration/cmd/main_test.go b/integration/cmd/main_test.go new file mode 100644 index 0000000000..d60a5f1109 --- /dev/null +++ b/integration/cmd/main_test.go @@ -0,0 +1,13 @@ +package cmd_integration + +import ( + "testing" + + "github.com/databricks/cli/integration/internal" +) + +// TestMain is the entrypoint executed by the test runner. +// See [internal.Main] for prerequisites for running integration tests. +func TestMain(m *testing.M) { + internal.Main(m) +} diff --git a/integration/cmd/repos/main_test.go b/integration/cmd/repos/main_test.go new file mode 100644 index 0000000000..ff54fd6861 --- /dev/null +++ b/integration/cmd/repos/main_test.go @@ -0,0 +1,13 @@ +package repos_integration + +import ( + "testing" + + "github.com/databricks/cli/integration/internal" +) + +// TestMain is the entrypoint executed by the test runner. +// See [internal.Main] for prerequisites for running integration tests. +func TestMain(m *testing.M) { + internal.Main(m) +} diff --git a/integration/cmd/secrets/main_test.go b/integration/cmd/secrets/main_test.go new file mode 100644 index 0000000000..5f7f35e85b --- /dev/null +++ b/integration/cmd/secrets/main_test.go @@ -0,0 +1,13 @@ +package secrets_integration + +import ( + "testing" + + "github.com/databricks/cli/integration/internal" +) + +// TestMain is the entrypoint executed by the test runner. +// See [internal.Main] for prerequisites for running integration tests. +func TestMain(m *testing.M) { + internal.Main(m) +} diff --git a/integration/cmd/storage_credentials/main_test.go b/integration/cmd/storage_credentials/main_test.go new file mode 100644 index 0000000000..67529a907c --- /dev/null +++ b/integration/cmd/storage_credentials/main_test.go @@ -0,0 +1,13 @@ +package storage_credentials_integration + +import ( + "testing" + + "github.com/databricks/cli/integration/internal" +) + +// TestMain is the entrypoint executed by the test runner. +// See [internal.Main] for prerequisites for running integration tests. +func TestMain(m *testing.M) { + internal.Main(m) +} diff --git a/integration/cmd/sync/main_test.go b/integration/cmd/sync/main_test.go new file mode 100644 index 0000000000..865790a65f --- /dev/null +++ b/integration/cmd/sync/main_test.go @@ -0,0 +1,13 @@ +package sync_integration + +import ( + "testing" + + "github.com/databricks/cli/integration/internal" +) + +// TestMain is the entrypoint executed by the test runner. +// See [internal.Main] for prerequisites for running integration tests. +func TestMain(m *testing.M) { + internal.Main(m) +} diff --git a/integration/cmd/version/main_test.go b/integration/cmd/version/main_test.go new file mode 100644 index 0000000000..fd65408596 --- /dev/null +++ b/integration/cmd/version/main_test.go @@ -0,0 +1,13 @@ +package version_integration + +import ( + "testing" + + "github.com/databricks/cli/integration/internal" +) + +// TestMain is the entrypoint executed by the test runner. +// See [internal.Main] for prerequisites for running integration tests. +func TestMain(m *testing.M) { + internal.Main(m) +} diff --git a/integration/cmd/workspace/main_test.go b/integration/cmd/workspace/main_test.go new file mode 100644 index 0000000000..427b4d0059 --- /dev/null +++ b/integration/cmd/workspace/main_test.go @@ -0,0 +1,13 @@ +package workspace_integration + +import ( + "testing" + + "github.com/databricks/cli/integration/internal" +) + +// TestMain is the entrypoint executed by the test runner. +// See [internal.Main] for prerequisites for running integration tests. +func TestMain(m *testing.M) { + internal.Main(m) +} diff --git a/integration/enforce_convention_test.go b/integration/enforce_convention_test.go new file mode 100644 index 0000000000..eff05d8368 --- /dev/null +++ b/integration/enforce_convention_test.go @@ -0,0 +1,108 @@ +package integration + +import ( + "go/ast" + "go/parser" + "go/token" + "os" + "path/filepath" + "strings" + "testing" + "text/template" + + "golang.org/x/exp/maps" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func enumeratePackages(t *testing.T) map[string]*ast.Package { + pkgmap := make(map[string]*ast.Package) + err := filepath.Walk(".", func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + + // Skip files. + if !info.IsDir() { + return nil + } + + // Skip the root directory and the "internal" directory. + if path == "." || strings.HasPrefix(path, "internal") { + return nil + } + + // Parse the package + fset := token.NewFileSet() + pkgs, err := parser.ParseDir(fset, path, nil, parser.AllErrors) + require.NoError(t, err) + if len(pkgs) == 0 { + return nil + } + + // Expect one package per directory. + vs := maps.Values(pkgs) + require.Len(t, vs, 1, "Directory %s contains more than one package", path) + pkgmap[path] = vs[0] + return nil + }) + require.NoError(t, err) + return pkgmap +} + +// TestEnforcePackageNames checks that all integration test package names use the "_integration" suffix. +// We enforce this package name to avoid package name aliasing. +func TestEnforcePackageNames(t *testing.T) { + pkgmap := enumeratePackages(t) + for _, pkg := range pkgmap { + assert.True(t, strings.HasSuffix(pkg.Name, "_integration"), "Package name %s does not end with _integration", pkg.Name) + } +} + +var mainTestTemplate = template.Must(template.New("main_test").Parse( + `package {{.Name}} + +import ( + "testing" + + "github.com/databricks/cli/integration/internal" +) + +// TestMain is the entrypoint executed by the test runner. +// See [internal.Main] for prerequisites for running integration tests. +func TestMain(m *testing.M) { + internal.Main(m) +} +`)) + +func TestEnforceMainTest(t *testing.T) { + pkgmap := enumeratePackages(t) + for dir, pkg := range pkgmap { + found := false + for _, file := range maps.Keys(pkg.Files) { + if filepath.Base(file) == "main_test.go" { + found = true + break + } + } + + // Expect a "main_test.go" file in each package. + assert.True(t, found, "Directory %s does not contain a main_test.go file", dir) + } +} + +func TestWriteMainTest(t *testing.T) { + t.Skip("Uncomment to write main_test.go files") + + pkgmap := enumeratePackages(t) + for dir, pkg := range pkgmap { + // Write a "main_test.go" file to the package. + // This file is required to run the integration tests. + f, err := os.Create(filepath.Join(dir, "main_test.go")) + require.NoError(t, err) + defer f.Close() + err = mainTestTemplate.Execute(f, pkg) + require.NoError(t, err) + } +} diff --git a/integration/internal/main.go b/integration/internal/main.go new file mode 100644 index 0000000000..6d69dcf70e --- /dev/null +++ b/integration/internal/main.go @@ -0,0 +1,20 @@ +package internal + +import ( + "fmt" + "os" + "testing" +) + +// Main is the entry point for integration tests. +// We use this for all integration tests defined in this subtree to ensure +// they are not inadvertently executed when calling `go test ./...`. +func Main(m *testing.M) { + value := os.Getenv("CLOUD_ENV") + if value == "" { + fmt.Println("CLOUD_ENV is not set, skipping integration tests") + return + } + + m.Run() +} diff --git a/integration/libs/filer/main_test.go b/integration/libs/filer/main_test.go new file mode 100644 index 0000000000..1e419574dd --- /dev/null +++ b/integration/libs/filer/main_test.go @@ -0,0 +1,13 @@ +package filer_integration + +import ( + "testing" + + "github.com/databricks/cli/integration/internal" +) + +// TestMain is the entrypoint executed by the test runner. +// See [internal.Main] for prerequisites for running integration tests. +func TestMain(m *testing.M) { + internal.Main(m) +} diff --git a/integration/libs/git/main_test.go b/integration/libs/git/main_test.go new file mode 100644 index 0000000000..1a7aa1fbba --- /dev/null +++ b/integration/libs/git/main_test.go @@ -0,0 +1,13 @@ +package git_integration + +import ( + "testing" + + "github.com/databricks/cli/integration/internal" +) + +// TestMain is the entrypoint executed by the test runner. +// See [internal.Main] for prerequisites for running integration tests. +func TestMain(m *testing.M) { + internal.Main(m) +} diff --git a/integration/libs/locker/main_test.go b/integration/libs/locker/main_test.go new file mode 100644 index 0000000000..f4036e96f7 --- /dev/null +++ b/integration/libs/locker/main_test.go @@ -0,0 +1,13 @@ +package locker_integration + +import ( + "testing" + + "github.com/databricks/cli/integration/internal" +) + +// TestMain is the entrypoint executed by the test runner. +// See [internal.Main] for prerequisites for running integration tests. +func TestMain(m *testing.M) { + internal.Main(m) +} diff --git a/integration/libs/tags/main_test.go b/integration/libs/tags/main_test.go new file mode 100644 index 0000000000..e692176215 --- /dev/null +++ b/integration/libs/tags/main_test.go @@ -0,0 +1,13 @@ +package tags_integration + +import ( + "testing" + + "github.com/databricks/cli/integration/internal" +) + +// TestMain is the entrypoint executed by the test runner. +// See [internal.Main] for prerequisites for running integration tests. +func TestMain(m *testing.M) { + internal.Main(m) +} diff --git a/integration/python/main_test.go b/integration/python/main_test.go new file mode 100644 index 0000000000..e0bdef3cdd --- /dev/null +++ b/integration/python/main_test.go @@ -0,0 +1,13 @@ +package python_integration + +import ( + "testing" + + "github.com/databricks/cli/integration/internal" +) + +// TestMain is the entrypoint executed by the test runner. +// See [internal.Main] for prerequisites for running integration tests. +func TestMain(m *testing.M) { + internal.Main(m) +} diff --git a/integration/verify_build_tags_test.go b/integration/verify_build_tags_test.go deleted file mode 100644 index 6d9f0fd7d3..0000000000 --- a/integration/verify_build_tags_test.go +++ /dev/null @@ -1,85 +0,0 @@ -package integration - -import ( - "go/scanner" - "go/token" - "os" - "path/filepath" - "strings" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func verifyIntegrationTest(t *testing.T, path string) { - var s scanner.Scanner - fset := token.NewFileSet() - src, err := os.ReadFile(path) - require.NoError(t, err) - file := fset.AddFile(path, fset.Base(), len(src)) - s.Init(file, src, nil, scanner.ScanComments) - - var buildTag string - var packageName string - - var tok token.Token - var lit string - - // Keep scanning until we find the package name and build tag. - for tok != token.EOF && (buildTag == "" || packageName == "") { - _, tok, lit = s.Scan() - switch tok { - case token.PACKAGE: - _, tok, lit = s.Scan() - if tok == token.IDENT { - packageName = lit - } - case token.COMMENT: - if strings.HasPrefix(lit, "//go:build ") { - buildTag = strings.TrimPrefix(lit, "//go:build ") - } - case token.EOF: - break - } - } - - // Verify that the build tag is present. - assert.Equal(t, "integration", buildTag, "File %s does not specify the 'integration' build tag", path) - - // Verify that the package name matches the expected format. - expected := filepath.Base(filepath.Dir(path)) + "_integration" - assert.Equal(t, expected, packageName, "File %s package name '%s' does not match directory name '%s'", path, packageName, expected) -} - -// TestVerifyBuildTags checks that all test files in the integration package specify the "integration" build tag -// and that the package name matches the basename of the containing directory with "_integration" appended. -// -// We enforce this package name to avoid package name aliasing. -func TestVerifyBuildTags(t *testing.T) { - err := filepath.Walk(".", func(path string, info os.FileInfo, err error) error { - if err != nil { - return err - } - - // Skip directories. - if info.IsDir() { - return nil - } - - // Skip this file. - if path == "verify_build_tags_test.go" { - return nil - } - - // Skip files that are not test files. - if !strings.HasSuffix(info.Name(), "_test.go") { - return nil - } - - verifyIntegrationTest(t, path) - return nil - }) - - require.NoError(t, err) -} From d7b534ac43443a15dbad2ad457f1e3afe2fe27fa Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Fri, 13 Dec 2024 13:00:57 +0100 Subject: [PATCH 17/24] Remove build tag from lint configuration --- .golangci.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 4775d14388..9e69e51463 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -36,6 +36,3 @@ linters-settings: # local-prefixes: github.com/databricks/cli issues: exclude-dirs-use-default: false # recommended by docs https://golangci-lint.run/usage/false-positives/ -run: - build-tags: - - integration From d9e15edca23ee3b4a529063256589a80771c1ce7 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Fri, 13 Dec 2024 13:01:21 +0100 Subject: [PATCH 18/24] Remove build tag from Makefile target --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 23859a0eea..8b33e447c4 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,6 @@ vendor: @go mod vendor integration: - gotestsum --format github-actions --rerun-fails --jsonfile output.json --packages "./integration/..." -- -tags integration -parallel 4 -timeout=2h + gotestsum --format github-actions --rerun-fails --jsonfile output.json --packages "./integration/..." -- -parallel 4 -timeout=2h .PHONY: fmt lint lintcheck test testonly coverage build snapshot vendor integration From b4e4dc2be8d953305d4083451d8a1ea69f0e3b46 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Fri, 13 Dec 2024 13:25:50 +0100 Subject: [PATCH 19/24] Don't export the deprecated ast.Package type --- integration/enforce_convention_test.go | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/integration/enforce_convention_test.go b/integration/enforce_convention_test.go index eff05d8368..50a1be595c 100644 --- a/integration/enforce_convention_test.go +++ b/integration/enforce_convention_test.go @@ -1,7 +1,6 @@ package integration import ( - "go/ast" "go/parser" "go/token" "os" @@ -16,8 +15,13 @@ import ( "github.com/stretchr/testify/require" ) -func enumeratePackages(t *testing.T) map[string]*ast.Package { - pkgmap := make(map[string]*ast.Package) +type packageInfo struct { + Name string + Files []string +} + +func enumeratePackages(t *testing.T) map[string]packageInfo { + pkgmap := make(map[string]packageInfo) err := filepath.Walk(".", func(path string, info os.FileInfo, err error) error { if err != nil { return err @@ -33,18 +37,22 @@ func enumeratePackages(t *testing.T) map[string]*ast.Package { return nil } - // Parse the package fset := token.NewFileSet() - pkgs, err := parser.ParseDir(fset, path, nil, parser.AllErrors) + pkgs, err := parser.ParseDir(fset, path, nil, parser.ParseComments) require.NoError(t, err) if len(pkgs) == 0 { return nil } // Expect one package per directory. - vs := maps.Values(pkgs) - require.Len(t, vs, 1, "Directory %s contains more than one package", path) - pkgmap[path] = vs[0] + require.Len(t, pkgs, 1, "Directory %s contains more than one package", path) + v := maps.Values(pkgs)[0] + + // Record the package. + pkgmap[path] = packageInfo{ + Name: v.Name, + Files: maps.Keys(v.Files), + } return nil }) require.NoError(t, err) @@ -80,7 +88,7 @@ func TestEnforceMainTest(t *testing.T) { pkgmap := enumeratePackages(t) for dir, pkg := range pkgmap { found := false - for _, file := range maps.Keys(pkg.Files) { + for _, file := range pkg.Files { if filepath.Base(file) == "main_test.go" { found = true break From 763898144c8da107881efb3b2a87c9299914bab5 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Fri, 13 Dec 2024 13:31:27 +0100 Subject: [PATCH 20/24] Revert vscode settings --- .vscode/settings.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index bf7894cda6..a7830d4ae9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,8 +9,7 @@ ], "go.useLanguageServer": true, "gopls": { - "formatting.gofumpt": true, - "buildFlags": ["-tags=integration"] + "formatting.gofumpt": true }, "files.trimTrailingWhitespace": true, "files.insertFinalNewline": true, From b3b653704a42d952e9328b19ec0569f4eae02940 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Fri, 13 Dec 2024 13:31:34 +0100 Subject: [PATCH 21/24] Update README --- integration/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration/README.md b/integration/README.md index 92d8273e49..a7409d365d 100644 --- a/integration/README.md +++ b/integration/README.md @@ -5,9 +5,9 @@ This directory contains integration tests for the project. The tree structure generally mirrors the source code tree structure. Requirements for new files in this directory: -* Every integration test file **must** use the `integration` build tag * Every package **must** be named after its directory with `_integration` appended * Requiring a different package name for integration tests avoids aliasing with the main package. +* Every integration test package **must** include a `main_test.go` file. These requirements are enforced by a unit test in this directory. @@ -27,7 +27,7 @@ Optional environment variables: To run all integration tests, use the following command: ```bash -go test -tags=integration ./... +go test ./integration/... ``` Alternatively: From 3b5c252a946879d77095d0299dcb9e8f7b3653ea Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Fri, 13 Dec 2024 13:55:59 +0100 Subject: [PATCH 22/24] Update package name requirement --- integration/README.md | 2 +- integration/assumptions/dashboard_assumptions_test.go | 2 +- integration/assumptions/main_test.go | 2 +- integration/bundle/artifacts_test.go | 2 +- integration/bundle/basic_test.go | 2 +- integration/bundle/bind_resource_test.go | 2 +- integration/bundle/clusters_test.go | 2 +- integration/bundle/dashboards_test.go | 2 +- integration/bundle/deploy_test.go | 2 +- integration/bundle/deploy_then_remove_resources_test.go | 2 +- integration/bundle/deploy_to_shared_test.go | 2 +- integration/bundle/deployment_state_test.go | 2 +- integration/bundle/destroy_test.go | 2 +- integration/bundle/empty_bundle_test.go | 2 +- integration/bundle/environments_test.go | 2 +- integration/bundle/generate_job_test.go | 2 +- integration/bundle/generate_pipeline_test.go | 2 +- integration/bundle/helpers.go | 2 +- integration/bundle/init_test.go | 2 +- integration/bundle/job_metadata_test.go | 2 +- integration/bundle/local_state_staleness_test.go | 2 +- integration/bundle/main_test.go | 2 +- integration/bundle/python_wheel_test.go | 2 +- integration/bundle/spark_jar_test.go | 2 +- integration/bundle/validate_test.go | 2 +- integration/cmd/alerts/alerts_test.go | 2 +- integration/cmd/alerts/main_test.go | 2 +- integration/cmd/api/api_test.go | 2 +- integration/cmd/api/main_test.go | 2 +- integration/cmd/auth/describe_test.go | 2 +- integration/cmd/auth/main_test.go | 2 +- integration/cmd/clusters/clusters_test.go | 2 +- integration/cmd/clusters/main_test.go | 2 +- integration/cmd/fs/cat_test.go | 2 +- integration/cmd/fs/completion_test.go | 2 +- integration/cmd/fs/cp_test.go | 2 +- integration/cmd/fs/helpers.go | 2 +- integration/cmd/fs/ls_test.go | 2 +- integration/cmd/fs/main_test.go | 2 +- integration/cmd/fs/mkdir_test.go | 2 +- integration/cmd/fs/rm_test.go | 2 +- integration/cmd/jobs/jobs_test.go | 2 +- integration/cmd/jobs/main_test.go | 2 +- integration/cmd/main_test.go | 2 +- integration/cmd/repos/main_test.go | 2 +- integration/cmd/repos/repos_test.go | 2 +- integration/cmd/secrets/main_test.go | 2 +- integration/cmd/secrets/secrets_test.go | 2 +- integration/cmd/storage_credentials/main_test.go | 2 +- .../cmd/storage_credentials/storage_credentials_test.go | 2 +- integration/cmd/sync/main_test.go | 2 +- integration/cmd/sync/sync_test.go | 2 +- integration/cmd/unknown_command_test.go | 2 +- integration/cmd/version/main_test.go | 2 +- integration/cmd/version/version_test.go | 2 +- integration/cmd/workspace/main_test.go | 2 +- integration/cmd/workspace/workspace_test.go | 2 +- integration/enforce_convention_test.go | 4 ++-- integration/libs/filer/filer_test.go | 2 +- integration/libs/filer/helpers.go | 2 +- integration/libs/filer/main_test.go | 2 +- integration/libs/git/git_clone_test.go | 2 +- integration/libs/git/git_fetch_test.go | 2 +- integration/libs/git/main_test.go | 2 +- integration/libs/locker/locker_test.go | 2 +- integration/libs/locker/main_test.go | 2 +- integration/libs/tags/main_test.go | 2 +- integration/libs/tags/tags_test.go | 2 +- integration/python/main_test.go | 2 +- integration/python/python_tasks_test.go | 2 +- 70 files changed, 71 insertions(+), 71 deletions(-) diff --git a/integration/README.md b/integration/README.md index a7409d365d..1c1d7c6f65 100644 --- a/integration/README.md +++ b/integration/README.md @@ -5,7 +5,7 @@ This directory contains integration tests for the project. The tree structure generally mirrors the source code tree structure. Requirements for new files in this directory: -* Every package **must** be named after its directory with `_integration` appended +* Every package **must** be named after its directory with `_test` appended * Requiring a different package name for integration tests avoids aliasing with the main package. * Every integration test package **must** include a `main_test.go` file. diff --git a/integration/assumptions/dashboard_assumptions_test.go b/integration/assumptions/dashboard_assumptions_test.go index fb384463a2..9696aa9a4e 100644 --- a/integration/assumptions/dashboard_assumptions_test.go +++ b/integration/assumptions/dashboard_assumptions_test.go @@ -1,4 +1,4 @@ -package assumptions_integration +package assumptions_test import ( "encoding/base64" diff --git a/integration/assumptions/main_test.go b/integration/assumptions/main_test.go index b048e9795f..be27613858 100644 --- a/integration/assumptions/main_test.go +++ b/integration/assumptions/main_test.go @@ -1,4 +1,4 @@ -package assumptions_integration +package assumptions_test import ( "testing" diff --git a/integration/bundle/artifacts_test.go b/integration/bundle/artifacts_test.go index 9b4dfefd01..942c4c975c 100644 --- a/integration/bundle/artifacts_test.go +++ b/integration/bundle/artifacts_test.go @@ -1,4 +1,4 @@ -package bundle_integration +package bundle_test import ( "fmt" diff --git a/integration/bundle/basic_test.go b/integration/bundle/basic_test.go index 2c170a3514..77befb5d0c 100644 --- a/integration/bundle/basic_test.go +++ b/integration/bundle/basic_test.go @@ -1,4 +1,4 @@ -package bundle_integration +package bundle_test import ( "os" diff --git a/integration/bundle/bind_resource_test.go b/integration/bundle/bind_resource_test.go index 9bdb3d6350..374c6f346e 100644 --- a/integration/bundle/bind_resource_test.go +++ b/integration/bundle/bind_resource_test.go @@ -1,4 +1,4 @@ -package bundle_integration +package bundle_test import ( "fmt" diff --git a/integration/bundle/clusters_test.go b/integration/bundle/clusters_test.go index 42f09e4a04..d4b16c49b1 100644 --- a/integration/bundle/clusters_test.go +++ b/integration/bundle/clusters_test.go @@ -1,4 +1,4 @@ -package bundle_integration +package bundle_test import ( "fmt" diff --git a/integration/bundle/dashboards_test.go b/integration/bundle/dashboards_test.go index 995704d65a..cbca560fb2 100644 --- a/integration/bundle/dashboards_test.go +++ b/integration/bundle/dashboards_test.go @@ -1,4 +1,4 @@ -package bundle_integration +package bundle_test import ( "fmt" diff --git a/integration/bundle/deploy_test.go b/integration/bundle/deploy_test.go index 5738e6b0e5..c97149b9bb 100644 --- a/integration/bundle/deploy_test.go +++ b/integration/bundle/deploy_test.go @@ -1,4 +1,4 @@ -package bundle_integration +package bundle_test import ( "context" diff --git a/integration/bundle/deploy_then_remove_resources_test.go b/integration/bundle/deploy_then_remove_resources_test.go index 324c471174..5e0b029ccb 100644 --- a/integration/bundle/deploy_then_remove_resources_test.go +++ b/integration/bundle/deploy_then_remove_resources_test.go @@ -1,4 +1,4 @@ -package bundle_integration +package bundle_test import ( "os" diff --git a/integration/bundle/deploy_to_shared_test.go b/integration/bundle/deploy_to_shared_test.go index 9eaa768d8f..d4f1ca9875 100644 --- a/integration/bundle/deploy_to_shared_test.go +++ b/integration/bundle/deploy_to_shared_test.go @@ -1,4 +1,4 @@ -package bundle_integration +package bundle_test import ( "fmt" diff --git a/integration/bundle/deployment_state_test.go b/integration/bundle/deployment_state_test.go index 83e812a452..98b4ef530c 100644 --- a/integration/bundle/deployment_state_test.go +++ b/integration/bundle/deployment_state_test.go @@ -1,4 +1,4 @@ -package bundle_integration +package bundle_test import ( "os" diff --git a/integration/bundle/destroy_test.go b/integration/bundle/destroy_test.go index 1b5669c66d..bb9beb5083 100644 --- a/integration/bundle/destroy_test.go +++ b/integration/bundle/destroy_test.go @@ -1,4 +1,4 @@ -package bundle_integration +package bundle_test import ( "errors" diff --git a/integration/bundle/empty_bundle_test.go b/integration/bundle/empty_bundle_test.go index 07c39815b8..40dd95355c 100644 --- a/integration/bundle/empty_bundle_test.go +++ b/integration/bundle/empty_bundle_test.go @@ -1,4 +1,4 @@ -package bundle_integration +package bundle_test import ( "fmt" diff --git a/integration/bundle/environments_test.go b/integration/bundle/environments_test.go index 4729d860ac..bbdc52cb24 100644 --- a/integration/bundle/environments_test.go +++ b/integration/bundle/environments_test.go @@ -1,4 +1,4 @@ -package bundle_integration +package bundle_test import ( "testing" diff --git a/integration/bundle/generate_job_test.go b/integration/bundle/generate_job_test.go index 96ee5598c3..c466348393 100644 --- a/integration/bundle/generate_job_test.go +++ b/integration/bundle/generate_job_test.go @@ -1,4 +1,4 @@ -package bundle_integration +package bundle_test import ( "context" diff --git a/integration/bundle/generate_pipeline_test.go b/integration/bundle/generate_pipeline_test.go index 394189017a..4b05cc2e41 100644 --- a/integration/bundle/generate_pipeline_test.go +++ b/integration/bundle/generate_pipeline_test.go @@ -1,4 +1,4 @@ -package bundle_integration +package bundle_test import ( "context" diff --git a/integration/bundle/helpers.go b/integration/bundle/helpers.go index f1fba3d688..f1c87c0ef9 100644 --- a/integration/bundle/helpers.go +++ b/integration/bundle/helpers.go @@ -1,4 +1,4 @@ -package bundle_integration +package bundle_test import ( "bytes" diff --git a/integration/bundle/init_test.go b/integration/bundle/init_test.go index 06a2931f43..b1d314b531 100644 --- a/integration/bundle/init_test.go +++ b/integration/bundle/init_test.go @@ -1,4 +1,4 @@ -package bundle_integration +package bundle_test import ( "context" diff --git a/integration/bundle/job_metadata_test.go b/integration/bundle/job_metadata_test.go index ff88a1d222..a8d7a927c2 100644 --- a/integration/bundle/job_metadata_test.go +++ b/integration/bundle/job_metadata_test.go @@ -1,4 +1,4 @@ -package bundle_integration +package bundle_test import ( "context" diff --git a/integration/bundle/local_state_staleness_test.go b/integration/bundle/local_state_staleness_test.go index c38c482ee0..29283c0022 100644 --- a/integration/bundle/local_state_staleness_test.go +++ b/integration/bundle/local_state_staleness_test.go @@ -1,4 +1,4 @@ -package bundle_integration +package bundle_test import ( "context" diff --git a/integration/bundle/main_test.go b/integration/bundle/main_test.go index 04300ed6a9..1c44d0aaf6 100644 --- a/integration/bundle/main_test.go +++ b/integration/bundle/main_test.go @@ -1,4 +1,4 @@ -package bundle_integration +package bundle_test import ( "testing" diff --git a/integration/bundle/python_wheel_test.go b/integration/bundle/python_wheel_test.go index ea9c0bf5ba..3f53dc95f7 100644 --- a/integration/bundle/python_wheel_test.go +++ b/integration/bundle/python_wheel_test.go @@ -1,4 +1,4 @@ -package bundle_integration +package bundle_test import ( "testing" diff --git a/integration/bundle/spark_jar_test.go b/integration/bundle/spark_jar_test.go index c25397fa4b..2dc5cbaa82 100644 --- a/integration/bundle/spark_jar_test.go +++ b/integration/bundle/spark_jar_test.go @@ -1,4 +1,4 @@ -package bundle_integration +package bundle_test import ( "context" diff --git a/integration/bundle/validate_test.go b/integration/bundle/validate_test.go index 1547ba51d0..ebf525a72d 100644 --- a/integration/bundle/validate_test.go +++ b/integration/bundle/validate_test.go @@ -1,4 +1,4 @@ -package bundle_integration +package bundle_test import ( "context" diff --git a/integration/cmd/alerts/alerts_test.go b/integration/cmd/alerts/alerts_test.go index ba362b8369..9113f882c3 100644 --- a/integration/cmd/alerts/alerts_test.go +++ b/integration/cmd/alerts/alerts_test.go @@ -1,4 +1,4 @@ -package alerts_integration +package alerts_test import ( "testing" diff --git a/integration/cmd/alerts/main_test.go b/integration/cmd/alerts/main_test.go index e92588957f..6987ade02b 100644 --- a/integration/cmd/alerts/main_test.go +++ b/integration/cmd/alerts/main_test.go @@ -1,4 +1,4 @@ -package alerts_integration +package alerts_test import ( "testing" diff --git a/integration/cmd/api/api_test.go b/integration/cmd/api/api_test.go index 8a2c592865..7242a0bfc6 100644 --- a/integration/cmd/api/api_test.go +++ b/integration/cmd/api/api_test.go @@ -1,4 +1,4 @@ -package api_integration +package api_test import ( "encoding/json" diff --git a/integration/cmd/api/main_test.go b/integration/cmd/api/main_test.go index 440746ba7b..70d021790d 100644 --- a/integration/cmd/api/main_test.go +++ b/integration/cmd/api/main_test.go @@ -1,4 +1,4 @@ -package api_integration +package api_test import ( "testing" diff --git a/integration/cmd/auth/describe_test.go b/integration/cmd/auth/describe_test.go index 8d56de2aa3..240c7103ae 100644 --- a/integration/cmd/auth/describe_test.go +++ b/integration/cmd/auth/describe_test.go @@ -1,4 +1,4 @@ -package auth_integration +package auth_test import ( "context" diff --git a/integration/cmd/auth/main_test.go b/integration/cmd/auth/main_test.go index 20d43c5b11..97b1d740b4 100644 --- a/integration/cmd/auth/main_test.go +++ b/integration/cmd/auth/main_test.go @@ -1,4 +1,4 @@ -package auth_integration +package auth_test import ( "testing" diff --git a/integration/cmd/clusters/clusters_test.go b/integration/cmd/clusters/clusters_test.go index dc2a367ae3..132b554f12 100644 --- a/integration/cmd/clusters/clusters_test.go +++ b/integration/cmd/clusters/clusters_test.go @@ -1,4 +1,4 @@ -package clusters_integration +package clusters_test import ( "fmt" diff --git a/integration/cmd/clusters/main_test.go b/integration/cmd/clusters/main_test.go index 72d7028be9..ccd5660e70 100644 --- a/integration/cmd/clusters/main_test.go +++ b/integration/cmd/clusters/main_test.go @@ -1,4 +1,4 @@ -package clusters_integration +package clusters_test import ( "testing" diff --git a/integration/cmd/fs/cat_test.go b/integration/cmd/fs/cat_test.go index a6ccb37d3c..67e21310b1 100644 --- a/integration/cmd/fs/cat_test.go +++ b/integration/cmd/fs/cat_test.go @@ -1,4 +1,4 @@ -package fs_integration +package fs_test import ( "context" diff --git a/integration/cmd/fs/completion_test.go b/integration/cmd/fs/completion_test.go index 8b68ed559c..b90c20f789 100644 --- a/integration/cmd/fs/completion_test.go +++ b/integration/cmd/fs/completion_test.go @@ -1,4 +1,4 @@ -package fs_integration +package fs_test import ( "context" diff --git a/integration/cmd/fs/cp_test.go b/integration/cmd/fs/cp_test.go index ee3de547dd..fa507830eb 100644 --- a/integration/cmd/fs/cp_test.go +++ b/integration/cmd/fs/cp_test.go @@ -1,4 +1,4 @@ -package fs_integration +package fs_test import ( "context" diff --git a/integration/cmd/fs/helpers.go b/integration/cmd/fs/helpers.go index 37a2b5de70..cf46f48acd 100644 --- a/integration/cmd/fs/helpers.go +++ b/integration/cmd/fs/helpers.go @@ -1,4 +1,4 @@ -package fs_integration +package fs_test import ( "os" diff --git a/integration/cmd/fs/ls_test.go b/integration/cmd/fs/ls_test.go index 235827d3bb..41d9fc053b 100644 --- a/integration/cmd/fs/ls_test.go +++ b/integration/cmd/fs/ls_test.go @@ -1,4 +1,4 @@ -package fs_integration +package fs_test import ( "context" diff --git a/integration/cmd/fs/main_test.go b/integration/cmd/fs/main_test.go index a48cca594f..b9402f0b29 100644 --- a/integration/cmd/fs/main_test.go +++ b/integration/cmd/fs/main_test.go @@ -1,4 +1,4 @@ -package fs_integration +package fs_test import ( "testing" diff --git a/integration/cmd/fs/mkdir_test.go b/integration/cmd/fs/mkdir_test.go index b1b96f4ac8..93845a3dd4 100644 --- a/integration/cmd/fs/mkdir_test.go +++ b/integration/cmd/fs/mkdir_test.go @@ -1,4 +1,4 @@ -package fs_integration +package fs_test import ( "context" diff --git a/integration/cmd/fs/rm_test.go b/integration/cmd/fs/rm_test.go index 521f097fb9..c3a5349070 100644 --- a/integration/cmd/fs/rm_test.go +++ b/integration/cmd/fs/rm_test.go @@ -1,4 +1,4 @@ -package fs_integration +package fs_test import ( "context" diff --git a/integration/cmd/jobs/jobs_test.go b/integration/cmd/jobs/jobs_test.go index bee4cad9e5..b9dc2976c7 100644 --- a/integration/cmd/jobs/jobs_test.go +++ b/integration/cmd/jobs/jobs_test.go @@ -1,4 +1,4 @@ -package jobs_integration +package jobs_test import ( "encoding/json" diff --git a/integration/cmd/jobs/main_test.go b/integration/cmd/jobs/main_test.go index b35d6e38be..46369a5264 100644 --- a/integration/cmd/jobs/main_test.go +++ b/integration/cmd/jobs/main_test.go @@ -1,4 +1,4 @@ -package jobs_integration +package jobs_test import ( "testing" diff --git a/integration/cmd/main_test.go b/integration/cmd/main_test.go index d60a5f1109..a1a5586b64 100644 --- a/integration/cmd/main_test.go +++ b/integration/cmd/main_test.go @@ -1,4 +1,4 @@ -package cmd_integration +package cmd_test import ( "testing" diff --git a/integration/cmd/repos/main_test.go b/integration/cmd/repos/main_test.go index ff54fd6861..7eaa174bce 100644 --- a/integration/cmd/repos/main_test.go +++ b/integration/cmd/repos/main_test.go @@ -1,4 +1,4 @@ -package repos_integration +package repos_test import ( "testing" diff --git a/integration/cmd/repos/repos_test.go b/integration/cmd/repos/repos_test.go index 8c1b812c76..69f7e31148 100644 --- a/integration/cmd/repos/repos_test.go +++ b/integration/cmd/repos/repos_test.go @@ -1,4 +1,4 @@ -package repos_integration +package repos_test import ( "context" diff --git a/integration/cmd/secrets/main_test.go b/integration/cmd/secrets/main_test.go index 5f7f35e85b..a44d306711 100644 --- a/integration/cmd/secrets/main_test.go +++ b/integration/cmd/secrets/main_test.go @@ -1,4 +1,4 @@ -package secrets_integration +package secrets_test import ( "testing" diff --git a/integration/cmd/secrets/secrets_test.go b/integration/cmd/secrets/secrets_test.go index 6dc4db7c82..8f06699d76 100644 --- a/integration/cmd/secrets/secrets_test.go +++ b/integration/cmd/secrets/secrets_test.go @@ -1,4 +1,4 @@ -package secrets_integration +package secrets_test import ( "context" diff --git a/integration/cmd/storage_credentials/main_test.go b/integration/cmd/storage_credentials/main_test.go index 67529a907c..14d00d9660 100644 --- a/integration/cmd/storage_credentials/main_test.go +++ b/integration/cmd/storage_credentials/main_test.go @@ -1,4 +1,4 @@ -package storage_credentials_integration +package storage_credentials_test import ( "testing" diff --git a/integration/cmd/storage_credentials/storage_credentials_test.go b/integration/cmd/storage_credentials/storage_credentials_test.go index ca9e4234e6..41f21f224d 100644 --- a/integration/cmd/storage_credentials/storage_credentials_test.go +++ b/integration/cmd/storage_credentials/storage_credentials_test.go @@ -1,4 +1,4 @@ -package storage_credentials_integration +package storage_credentials_test import ( "testing" diff --git a/integration/cmd/sync/main_test.go b/integration/cmd/sync/main_test.go index 865790a65f..8d9f3ca252 100644 --- a/integration/cmd/sync/main_test.go +++ b/integration/cmd/sync/main_test.go @@ -1,4 +1,4 @@ -package sync_integration +package sync_test import ( "testing" diff --git a/integration/cmd/sync/sync_test.go b/integration/cmd/sync/sync_test.go index 4e6f989ddb..82124cc953 100644 --- a/integration/cmd/sync/sync_test.go +++ b/integration/cmd/sync/sync_test.go @@ -1,4 +1,4 @@ -package sync_integration +package sync_test import ( "context" diff --git a/integration/cmd/unknown_command_test.go b/integration/cmd/unknown_command_test.go index 4b10ef2db1..e18493940c 100644 --- a/integration/cmd/unknown_command_test.go +++ b/integration/cmd/unknown_command_test.go @@ -1,4 +1,4 @@ -package cmd_integration +package cmd_test import ( "testing" diff --git a/integration/cmd/version/main_test.go b/integration/cmd/version/main_test.go index fd65408596..4aa5e046ac 100644 --- a/integration/cmd/version/main_test.go +++ b/integration/cmd/version/main_test.go @@ -1,4 +1,4 @@ -package version_integration +package version_test import ( "testing" diff --git a/integration/cmd/version/version_test.go b/integration/cmd/version/version_test.go index e567c98137..ab00e7242f 100644 --- a/integration/cmd/version/version_test.go +++ b/integration/cmd/version/version_test.go @@ -1,4 +1,4 @@ -package version_integration +package version_test import ( "encoding/json" diff --git a/integration/cmd/workspace/main_test.go b/integration/cmd/workspace/main_test.go index 427b4d0059..40d140eac9 100644 --- a/integration/cmd/workspace/main_test.go +++ b/integration/cmd/workspace/main_test.go @@ -1,4 +1,4 @@ -package workspace_integration +package workspace_test import ( "testing" diff --git a/integration/cmd/workspace/workspace_test.go b/integration/cmd/workspace/workspace_test.go index d650d5458a..28405a09b1 100644 --- a/integration/cmd/workspace/workspace_test.go +++ b/integration/cmd/workspace/workspace_test.go @@ -1,4 +1,4 @@ -package workspace_integration +package workspace_test import ( "context" diff --git a/integration/enforce_convention_test.go b/integration/enforce_convention_test.go index 50a1be595c..cc822a6a37 100644 --- a/integration/enforce_convention_test.go +++ b/integration/enforce_convention_test.go @@ -59,12 +59,12 @@ func enumeratePackages(t *testing.T) map[string]packageInfo { return pkgmap } -// TestEnforcePackageNames checks that all integration test package names use the "_integration" suffix. +// TestEnforcePackageNames checks that all integration test package names use the "_test" suffix. // We enforce this package name to avoid package name aliasing. func TestEnforcePackageNames(t *testing.T) { pkgmap := enumeratePackages(t) for _, pkg := range pkgmap { - assert.True(t, strings.HasSuffix(pkg.Name, "_integration"), "Package name %s does not end with _integration", pkg.Name) + assert.True(t, strings.HasSuffix(pkg.Name, "_test"), "Package name %s does not end with _test", pkg.Name) } } diff --git a/integration/libs/filer/filer_test.go b/integration/libs/filer/filer_test.go index 0936748a2a..a4cfa9db3f 100644 --- a/integration/libs/filer/filer_test.go +++ b/integration/libs/filer/filer_test.go @@ -1,4 +1,4 @@ -package filer_integration +package filer_test import ( "bytes" diff --git a/integration/libs/filer/helpers.go b/integration/libs/filer/helpers.go index d6011e9391..49031b3922 100644 --- a/integration/libs/filer/helpers.go +++ b/integration/libs/filer/helpers.go @@ -1,4 +1,4 @@ -package filer_integration +package filer_test import ( "errors" diff --git a/integration/libs/filer/main_test.go b/integration/libs/filer/main_test.go index 1e419574dd..ca866d9526 100644 --- a/integration/libs/filer/main_test.go +++ b/integration/libs/filer/main_test.go @@ -1,4 +1,4 @@ -package filer_integration +package filer_test import ( "testing" diff --git a/integration/libs/git/git_clone_test.go b/integration/libs/git/git_clone_test.go index 91707fff05..53cfe6fb98 100644 --- a/integration/libs/git/git_clone_test.go +++ b/integration/libs/git/git_clone_test.go @@ -1,4 +1,4 @@ -package git_integration +package git_test import ( "context" diff --git a/integration/libs/git/git_fetch_test.go b/integration/libs/git/git_fetch_test.go index fce987a2b1..849770c3b8 100644 --- a/integration/libs/git/git_fetch_test.go +++ b/integration/libs/git/git_fetch_test.go @@ -1,4 +1,4 @@ -package git_integration +package git_test import ( "os" diff --git a/integration/libs/git/main_test.go b/integration/libs/git/main_test.go index 1a7aa1fbba..5d68e08512 100644 --- a/integration/libs/git/main_test.go +++ b/integration/libs/git/main_test.go @@ -1,4 +1,4 @@ -package git_integration +package git_test import ( "testing" diff --git a/integration/libs/locker/locker_test.go b/integration/libs/locker/locker_test.go index 020374ffa6..fcc4b346a9 100644 --- a/integration/libs/locker/locker_test.go +++ b/integration/libs/locker/locker_test.go @@ -1,4 +1,4 @@ -package locker_integration +package locker_test import ( "context" diff --git a/integration/libs/locker/main_test.go b/integration/libs/locker/main_test.go index f4036e96f7..33a883768d 100644 --- a/integration/libs/locker/main_test.go +++ b/integration/libs/locker/main_test.go @@ -1,4 +1,4 @@ -package locker_integration +package locker_test import ( "testing" diff --git a/integration/libs/tags/main_test.go b/integration/libs/tags/main_test.go index e692176215..4eaf54a20f 100644 --- a/integration/libs/tags/main_test.go +++ b/integration/libs/tags/main_test.go @@ -1,4 +1,4 @@ -package tags_integration +package tags_test import ( "testing" diff --git a/integration/libs/tags/tags_test.go b/integration/libs/tags/tags_test.go index 3f146c3e4e..2abec29a52 100644 --- a/integration/libs/tags/tags_test.go +++ b/integration/libs/tags/tags_test.go @@ -1,4 +1,4 @@ -package tags_integration +package tags_test import ( "strings" diff --git a/integration/python/main_test.go b/integration/python/main_test.go index e0bdef3cdd..b35da21e1d 100644 --- a/integration/python/main_test.go +++ b/integration/python/main_test.go @@ -1,4 +1,4 @@ -package python_integration +package python_test import ( "testing" diff --git a/integration/python/python_tasks_test.go b/integration/python/python_tasks_test.go index d819b068a1..18191291ce 100644 --- a/integration/python/python_tasks_test.go +++ b/integration/python/python_tasks_test.go @@ -1,4 +1,4 @@ -package python_integration +package python_test import ( "bytes" From faccf3c6ed3d0be1d2913a8a093dfe178f91ac5d Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Fri, 13 Dec 2024 14:07:22 +0100 Subject: [PATCH 23/24] Rename helper files --- integration/bundle/{helpers.go => helpers_test.go} | 0 integration/cmd/fs/{helpers.go => helpers_test.go} | 0 integration/libs/filer/{helpers.go => helpers_test.go} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename integration/bundle/{helpers.go => helpers_test.go} (100%) rename integration/cmd/fs/{helpers.go => helpers_test.go} (100%) rename integration/libs/filer/{helpers.go => helpers_test.go} (100%) diff --git a/integration/bundle/helpers.go b/integration/bundle/helpers_test.go similarity index 100% rename from integration/bundle/helpers.go rename to integration/bundle/helpers_test.go diff --git a/integration/cmd/fs/helpers.go b/integration/cmd/fs/helpers_test.go similarity index 100% rename from integration/cmd/fs/helpers.go rename to integration/cmd/fs/helpers_test.go diff --git a/integration/libs/filer/helpers.go b/integration/libs/filer/helpers_test.go similarity index 100% rename from integration/libs/filer/helpers.go rename to integration/libs/filer/helpers_test.go From da2d3fdda4da9960686fed0cb1ba0c2b16153c06 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Fri, 13 Dec 2024 14:51:06 +0100 Subject: [PATCH 24/24] Skip auth describe success test --- integration/cmd/auth/describe_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/integration/cmd/auth/describe_test.go b/integration/cmd/auth/describe_test.go index 240c7103ae..492c678676 100644 --- a/integration/cmd/auth/describe_test.go +++ b/integration/cmd/auth/describe_test.go @@ -14,6 +14,8 @@ import ( func TestAuthDescribeSuccess(t *testing.T) { t.Log(testutil.GetEnvOrSkipTest(t, "CLOUD_ENV")) + t.Skipf("Skipping because of https://github.com/databricks/cli/issues/2010") + stdout, _ := testcli.RequireSuccessfulRun(t, "auth", "describe") outStr := stdout.String()