From c934cd66bd861765dfd0c1eb84e70325769052cb Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Tue, 19 Nov 2024 14:55:14 +0100 Subject: [PATCH 1/2] Added integration test to deploy bundle to /Shared root path --- .../basic/databricks_template_schema.json | 4 ++ .../basic/template/databricks.yml.tmpl | 4 ++ internal/bundle/deploy_to_shared_test.go | 38 +++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 internal/bundle/deploy_to_shared_test.go diff --git a/internal/bundle/bundles/basic/databricks_template_schema.json b/internal/bundle/bundles/basic/databricks_template_schema.json index c1c5cf12..6f1964d8 100644 --- a/internal/bundle/bundles/basic/databricks_template_schema.json +++ b/internal/bundle/bundles/basic/databricks_template_schema.json @@ -11,6 +11,10 @@ "node_type_id": { "type": "string", "description": "Node type id for job cluster" + }, + "root_path": { + "type": "string", + "description": "Root path to deploy bundle to" } } } diff --git a/internal/bundle/bundles/basic/template/databricks.yml.tmpl b/internal/bundle/bundles/basic/template/databricks.yml.tmpl index a88cbd30..0eca4231 100644 --- a/internal/bundle/bundles/basic/template/databricks.yml.tmpl +++ b/internal/bundle/bundles/basic/template/databricks.yml.tmpl @@ -2,7 +2,11 @@ bundle: name: basic workspace: + {{ if .root_path }} + root_path: "{{.root_path}}/.bundle/{{.unique_id}}" + {{ else }} root_path: "~/.bundle/{{.unique_id}}" + {{ end }} resources: jobs: diff --git a/internal/bundle/deploy_to_shared_test.go b/internal/bundle/deploy_to_shared_test.go new file mode 100644 index 00000000..96c2ea3d --- /dev/null +++ b/internal/bundle/deploy_to_shared_test.go @@ -0,0 +1,38 @@ +package bundle + +import ( + "fmt" + "testing" + + "github.com/databricks/cli/internal" + "github.com/databricks/cli/internal/acc" + "github.com/databricks/cli/libs/env" + "github.com/google/uuid" + "github.com/stretchr/testify/require" +) + +func TestAccDeployBasicToSharedWorkspace(t *testing.T) { + ctx, wt := acc.WorkspaceTest(t) + + nodeTypeId := internal.GetNodeTypeId(env.Get(ctx, "CLOUD_ENV")) + uniqueId := uuid.New().String() + + currentUser, err := wt.W.CurrentUser.Me(ctx) + require.NoError(t, err) + + bundleRoot, err := initTestTemplate(t, ctx, "basic", map[string]any{ + "unique_id": uniqueId, + "node_type_id": nodeTypeId, + "spark_version": defaultSparkVersion, + "root_path": fmt.Sprintf("/Shared/%s", currentUser.UserName), + }) + require.NoError(t, err) + + t.Cleanup(func() { + err = destroyBundle(wt.T, ctx, bundleRoot) + require.NoError(wt.T, err) + }) + + err = deployBundle(wt.T, ctx, bundleRoot) + require.NoError(wt.T, err) +} From 8842d17cf1e9e4683056d4850f4a51731654342e Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Tue, 19 Nov 2024 15:36:54 +0100 Subject: [PATCH 2/2] Update internal/bundle/deploy_to_shared_test.go Co-authored-by: shreyas-goenka <88374338+shreyas-goenka@users.noreply.github.com> --- internal/bundle/deploy_to_shared_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/bundle/deploy_to_shared_test.go b/internal/bundle/deploy_to_shared_test.go index 96c2ea3d..568c1fb5 100644 --- a/internal/bundle/deploy_to_shared_test.go +++ b/internal/bundle/deploy_to_shared_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestAccDeployBasicToSharedWorkspace(t *testing.T) { +func TestAccDeployBasicToSharedWorkspacePath(t *testing.T) { ctx, wt := acc.WorkspaceTest(t) nodeTypeId := internal.GetNodeTypeId(env.Get(ctx, "CLOUD_ENV"))