Skip to content

Commit 020f146

Browse files
committed
Move cloud-specific node type helper
1 parent 04ae9b0 commit 020f146

18 files changed

+42
-80
lines changed

internal/bundle/basic_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@ import (
55
"path/filepath"
66
"testing"
77

8-
"github.com/databricks/cli/internal"
98
"github.com/databricks/cli/internal/acc"
10-
"github.com/databricks/cli/libs/env"
9+
"github.com/databricks/cli/internal/testutil"
1110
"github.com/google/uuid"
1211
"github.com/stretchr/testify/require"
1312
)
1413

1514
func TestAccBasicBundleDeployWithFailOnActiveRuns(t *testing.T) {
1615
ctx, _ := acc.WorkspaceTest(t)
1716

18-
nodeTypeId := internal.GetNodeTypeId(env.Get(ctx, "CLOUD_ENV"))
17+
nodeTypeId := testutil.GetCloud(t).NodeTypeID()
1918
uniqueId := uuid.New().String()
2019
root, err := initTestTemplate(t, ctx, "basic", map[string]any{
2120
"unique_id": uniqueId,

internal/bundle/bind_resource_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"path/filepath"
77
"testing"
88

9-
"github.com/databricks/cli/internal"
109
"github.com/databricks/cli/internal/acc"
1110
"github.com/databricks/cli/internal/testcli"
1211
"github.com/databricks/cli/internal/testutil"
@@ -24,7 +23,7 @@ func TestAccBindJobToExistingJob(t *testing.T) {
2423
ctx, wt := acc.WorkspaceTest(t)
2524
gt := &generateJobTest{T: wt, w: wt.W}
2625

27-
nodeTypeId := internal.GetNodeTypeId(env)
26+
nodeTypeId := testutil.GetCloud(t).NodeTypeID()
2827
uniqueId := uuid.New().String()
2928
bundleRoot, err := initTestTemplate(t, ctx, "basic", map[string]any{
3029
"unique_id": uniqueId,
@@ -89,7 +88,7 @@ func TestAccAbortBind(t *testing.T) {
8988
ctx, wt := acc.WorkspaceTest(t)
9089
gt := &generateJobTest{T: wt, w: wt.W}
9190

92-
nodeTypeId := internal.GetNodeTypeId(env)
91+
nodeTypeId := testutil.GetCloud(t).NodeTypeID()
9392
uniqueId := uuid.New().String()
9493
bundleRoot, err := initTestTemplate(t, ctx, "basic", map[string]any{
9594
"unique_id": uniqueId,

internal/bundle/clusters_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ import (
44
"fmt"
55
"testing"
66

7-
"github.com/databricks/cli/internal"
87
"github.com/databricks/cli/internal/acc"
98
"github.com/databricks/cli/internal/testutil"
10-
"github.com/databricks/cli/libs/env"
119
"github.com/databricks/databricks-sdk-go/service/compute"
1210
"github.com/google/uuid"
1311
"github.com/stretchr/testify/require"
@@ -20,7 +18,7 @@ func TestAccDeployBundleWithCluster(t *testing.T) {
2018
t.Skip("Skipping test for AWS cloud because it is not permitted to create clusters")
2119
}
2220

23-
nodeTypeId := internal.GetNodeTypeId(env.Get(ctx, "CLOUD_ENV"))
21+
nodeTypeId := testutil.GetCloud(t).NodeTypeID()
2422
uniqueId := uuid.New().String()
2523
root, err := initTestTemplate(t, ctx, "clusters", map[string]any{
2624
"unique_id": uniqueId,

internal/bundle/deploy_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ import (
1111
"testing"
1212

1313
"github.com/databricks/cli/cmd/root"
14-
"github.com/databricks/cli/internal"
1514
"github.com/databricks/cli/internal/acc"
1615
"github.com/databricks/cli/internal/testcli"
17-
"github.com/databricks/cli/libs/env"
16+
"github.com/databricks/cli/internal/testutil"
1817
"github.com/databricks/databricks-sdk-go"
1918
"github.com/databricks/databricks-sdk-go/apierr"
2019
"github.com/databricks/databricks-sdk-go/service/catalog"
@@ -133,7 +132,7 @@ func TestAccBundlePipelineDeleteWithoutAutoApprove(t *testing.T) {
133132
ctx, wt := acc.WorkspaceTest(t)
134133
w := wt.W
135134

136-
nodeTypeId := internal.GetNodeTypeId(env.Get(ctx, "CLOUD_ENV"))
135+
nodeTypeId := testutil.GetCloud(t).NodeTypeID()
137136
uniqueId := uuid.New().String()
138137
bundleRoot, err := initTestTemplate(t, ctx, "deploy_then_remove_resources", map[string]any{
139138
"unique_id": uniqueId,
@@ -219,7 +218,7 @@ properties such as the 'catalog' or 'storage' are changed:
219218
func TestAccDeployBasicBundleLogs(t *testing.T) {
220219
ctx, wt := acc.WorkspaceTest(t)
221220

222-
nodeTypeId := internal.GetNodeTypeId(env.Get(ctx, "CLOUD_ENV"))
221+
nodeTypeId := testutil.GetCloud(t).NodeTypeID()
223222
uniqueId := uuid.New().String()
224223
root, err := initTestTemplate(t, ctx, "basic", map[string]any{
225224
"unique_id": uniqueId,

internal/bundle/deploy_then_remove_resources_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import (
55
"path/filepath"
66
"testing"
77

8-
"github.com/databricks/cli/internal"
98
"github.com/databricks/cli/internal/acc"
10-
"github.com/databricks/cli/libs/env"
9+
"github.com/databricks/cli/internal/testutil"
1110
"github.com/google/uuid"
1211
"github.com/stretchr/testify/assert"
1312
"github.com/stretchr/testify/require"
@@ -17,7 +16,7 @@ func TestAccBundleDeployThenRemoveResources(t *testing.T) {
1716
ctx, wt := acc.WorkspaceTest(t)
1817
w := wt.W
1918

20-
nodeTypeId := internal.GetNodeTypeId(env.Get(ctx, "CLOUD_ENV"))
19+
nodeTypeId := testutil.GetCloud(t).NodeTypeID()
2120
uniqueId := uuid.New().String()
2221
bundleRoot, err := initTestTemplate(t, ctx, "deploy_then_remove_resources", map[string]any{
2322
"unique_id": uniqueId,

internal/bundle/deploy_to_shared_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@ import (
44
"fmt"
55
"testing"
66

7-
"github.com/databricks/cli/internal"
87
"github.com/databricks/cli/internal/acc"
9-
"github.com/databricks/cli/libs/env"
8+
"github.com/databricks/cli/internal/testutil"
109
"github.com/google/uuid"
1110
"github.com/stretchr/testify/require"
1211
)
1312

1413
func TestAccDeployBasicToSharedWorkspacePath(t *testing.T) {
1514
ctx, wt := acc.WorkspaceTest(t)
1615

17-
nodeTypeId := internal.GetNodeTypeId(env.Get(ctx, "CLOUD_ENV"))
16+
nodeTypeId := testutil.GetCloud(t).NodeTypeID()
1817
uniqueId := uuid.New().String()
1918

2019
currentUser, err := wt.W.CurrentUser.Me(ctx)

internal/bundle/deployment_state_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"testing"
88

99
"github.com/databricks/cli/bundle/deploy"
10-
"github.com/databricks/cli/internal"
1110
"github.com/databricks/cli/internal/acc"
1211
"github.com/databricks/cli/internal/testutil"
1312
"github.com/google/uuid"
@@ -21,7 +20,7 @@ func TestAccFilesAreSyncedCorrectlyWhenNoSnapshot(t *testing.T) {
2120
ctx, wt := acc.WorkspaceTest(t)
2221
w := wt.W
2322

24-
nodeTypeId := internal.GetNodeTypeId(env)
23+
nodeTypeId := testutil.GetCloud(t).NodeTypeID()
2524
uniqueId := uuid.New().String()
2625
bundleRoot, err := initTestTemplate(t, ctx, "basic", map[string]any{
2726
"unique_id": uniqueId,

internal/bundle/destroy_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ import (
66
"path/filepath"
77
"testing"
88

9-
"github.com/databricks/cli/internal"
109
"github.com/databricks/cli/internal/acc"
11-
"github.com/databricks/cli/libs/env"
10+
"github.com/databricks/cli/internal/testutil"
1211
"github.com/databricks/databricks-sdk-go/apierr"
1312
"github.com/google/uuid"
1413
"github.com/stretchr/testify/assert"
@@ -19,7 +18,7 @@ func TestAccBundleDestroy(t *testing.T) {
1918
ctx, wt := acc.WorkspaceTest(t)
2019
w := wt.W
2120

22-
nodeTypeId := internal.GetNodeTypeId(env.Get(ctx, "CLOUD_ENV"))
21+
nodeTypeId := testutil.GetCloud(t).NodeTypeID()
2322
uniqueId := uuid.New().String()
2423
bundleRoot, err := initTestTemplate(t, ctx, "deploy_then_remove_resources", map[string]any{
2524
"unique_id": uniqueId,

internal/bundle/generate_job_test.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,6 @@ func (gt *generateJobTest) createTestJob(ctx context.Context) int64 {
7777
t := gt.T
7878
w := gt.w
7979

80-
var nodeTypeId string
81-
switch testutil.GetCloud(t) {
82-
case testutil.AWS:
83-
nodeTypeId = "i3.xlarge"
84-
case testutil.Azure:
85-
nodeTypeId = "Standard_DS4_v2"
86-
case testutil.GCP:
87-
nodeTypeId = "n1-standard-4"
88-
}
89-
9080
tmpdir := acc.TemporaryWorkspaceDir(t, "generate-job-")
9181
f, err := filer.NewWorkspaceFilesClient(w, tmpdir)
9282
require.NoError(t, err)
@@ -102,7 +92,7 @@ func (gt *generateJobTest) createTestJob(ctx context.Context) int64 {
10292
NewCluster: &compute.ClusterSpec{
10393
SparkVersion: "13.3.x-scala2.12",
10494
NumWorkers: 1,
105-
NodeTypeId: nodeTypeId,
95+
NodeTypeId: testutil.GetCloud(t).NodeTypeID(),
10696
SparkConf: map[string]string{
10797
"spark.databricks.enableWsfs": "true",
10898
"spark.databricks.hive.metastore.glueCatalog.enabled": "true",

internal/bundle/generate_pipeline_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"strings"
1010
"testing"
1111

12-
"github.com/databricks/cli/internal"
1312
"github.com/databricks/cli/internal/acc"
1413
"github.com/databricks/cli/internal/testcli"
1514
"github.com/databricks/cli/internal/testutil"
@@ -96,8 +95,7 @@ func (gt *generatePipelineTest) createTestPipeline(ctx context.Context) (string,
9695
err = f.Write(ctx, "test.py", strings.NewReader("print('Hello!')"))
9796
require.NoError(t, err)
9897

99-
env := testutil.GetEnvOrSkipTest(t, "CLOUD_ENV")
100-
nodeTypeId := internal.GetNodeTypeId(env)
98+
nodeTypeId := testutil.GetCloud(t).NodeTypeID()
10199

102100
name := testutil.RandomName("generated-pipeline-")
103101
resp, err := w.Pipelines.Create(ctx, pipelines.CreatePipeline{

0 commit comments

Comments
 (0)