Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions integration/bundle/bind_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ import (
)

func TestBindJobToExistingJob(t *testing.T) {
env := testutil.GetEnvOrSkipTest(t, "CLOUD_ENV")
t.Log(env)

ctx, wt := acc.WorkspaceTest(t)
gt := &generateJobTest{T: wt, w: wt.W}

Expand Down Expand Up @@ -82,9 +79,6 @@ func TestBindJobToExistingJob(t *testing.T) {
}

func TestAbortBind(t *testing.T) {
env := testutil.GetEnvOrSkipTest(t, "CLOUD_ENV")
t.Log(env)

ctx, wt := acc.WorkspaceTest(t)
gt := &generateJobTest{T: wt, w: wt.W}

Expand Down Expand Up @@ -131,9 +125,6 @@ func TestAbortBind(t *testing.T) {
}

func TestGenerateAndBind(t *testing.T) {
env := testutil.GetEnvOrSkipTest(t, "CLOUD_ENV")
t.Log(env)

ctx, wt := acc.WorkspaceTest(t)
gt := &generateJobTest{T: wt, w: wt.W}

Expand Down
3 changes: 0 additions & 3 deletions integration/bundle/deployment_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ import (
)

func TestFilesAreSyncedCorrectlyWhenNoSnapshot(t *testing.T) {
env := testutil.GetEnvOrSkipTest(t, "CLOUD_ENV")
t.Log(env)

ctx, wt := acc.WorkspaceTest(t)
w := wt.W

Expand Down
30 changes: 13 additions & 17 deletions integration/bundle/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@ import (
"testing"

"github.com/databricks/cli/bundle/config"
"github.com/databricks/cli/internal/acc"
"github.com/databricks/cli/internal/testcli"
"github.com/databricks/cli/internal/testutil"
"github.com/databricks/cli/libs/iamutil"
"github.com/databricks/databricks-sdk-go"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestBundleInitErrorOnUnknownFields(t *testing.T) {
t.Log(testutil.GetEnvOrSkipTest(t, "CLOUD_ENV"))

tmpDir := t.TempDir()
_, _, err := testcli.RequireErrorRun(t, "bundle", "init", "./testdata/init/field-does-not-exist", "--output-dir", tmpDir)
assert.EqualError(t, err, "failed to compute file content for bar.tmpl. variable \"does_not_exist\" not defined")
Expand All @@ -40,15 +38,14 @@ func TestBundleInitErrorOnUnknownFields(t *testing.T) {
// make changes that can break the MLOps Stacks DAB. In which case we should
// skip this test until the MLOps Stacks DAB is updated to work again.
func TestBundleInitOnMlopsStacks(t *testing.T) {
env := testutil.GetCloud(t).String()
_, wt := acc.WorkspaceTest(t)
w := wt.W

tmpDir1 := t.TempDir()
tmpDir2 := t.TempDir()

w, err := databricks.NewWorkspaceClient(&databricks.Config{})
require.NoError(t, err)

projectName := testutil.RandomName("project_name_")
env := testutil.GetCloud(t).String()

// Create a config file with the project name and root dir
initConfig := map[string]string{
Expand Down Expand Up @@ -102,23 +99,22 @@ func TestBundleInitOnMlopsStacks(t *testing.T) {
}

func TestBundleInitHelpers(t *testing.T) {
env := testutil.GetEnvOrSkipTest(t, "CLOUD_ENV")
t.Log(env)
ctx, wt := acc.WorkspaceTest(t)
w := wt.W

w, err := databricks.NewWorkspaceClient(&databricks.Config{})
require.NoError(t, err)

me, err := w.CurrentUser.Me(context.Background())
me, err := w.CurrentUser.Me(ctx)
require.NoError(t, err)

var smallestNode string
switch env {
case "azure":
switch testutil.GetCloud(t) {
case testutil.Azure:
smallestNode = "Standard_D3_v2"
case "gcp":
case testutil.GCP:
smallestNode = "n1-standard-4"
default:
case testutil.AWS:
smallestNode = "i3.xlarge"
default:
t.Fatal("Unknown cloud environment")
}

tests := []struct {
Expand Down
2 changes: 0 additions & 2 deletions integration/bundle/spark_jar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ func runSparkJarTestFromWorkspace(t *testing.T, sparkVersion string) {
}

func TestSparkJarTaskDeployAndRunOnVolumes(t *testing.T) {
testutil.GetEnvOrSkipTest(t, "CLOUD_ENV")
testutil.RequireJDK(t, context.Background(), "1.8.0")

// Failure on earlier DBR versions:
Expand All @@ -76,7 +75,6 @@ func TestSparkJarTaskDeployAndRunOnVolumes(t *testing.T) {
}

func TestSparkJarTaskDeployAndRunOnWorkspace(t *testing.T) {
testutil.GetEnvOrSkipTest(t, "CLOUD_ENV")
testutil.RequireJDK(t, context.Background(), "1.8.0")

// Failure on earlier DBR versions:
Expand Down
2 changes: 0 additions & 2 deletions integration/bundle/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import (
)

func TestBundleValidate(t *testing.T) {
testutil.GetEnvOrSkipTest(t, "CLOUD_ENV")

tmpDir := t.TempDir()
testutil.WriteFile(t, filepath.Join(tmpDir, "databricks.yml"),
`
Expand Down
3 changes: 0 additions & 3 deletions integration/cmd/alerts/alerts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ import (
"testing"

"github.com/databricks/cli/internal/testcli"
"github.com/databricks/cli/internal/testutil"
"github.com/stretchr/testify/assert"
)

func TestAlertsCreateErrWhenNoArguments(t *testing.T) {
t.Log(testutil.GetEnvOrSkipTest(t, "CLOUD_ENV"))

_, _, err := testcli.RequireErrorRun(t, "alerts-legacy", "create")
assert.Equal(t, "please provide command input in JSON format by specifying the --json flag", err.Error())
}
6 changes: 1 addition & 5 deletions integration/cmd/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import (
)

func TestApiGet(t *testing.T) {
t.Log(testutil.GetEnvOrSkipTest(t, "CLOUD_ENV"))

stdout, _ := testcli.RequireSuccessfulRun(t, "api", "get", "/api/2.0/preview/scim/v2/Me")

// Deserialize SCIM API response.
Expand All @@ -31,9 +29,7 @@ func TestApiGet(t *testing.T) {
}

func TestApiPost(t *testing.T) {
env := testutil.GetEnvOrSkipTest(t, "CLOUD_ENV")
t.Log(env)
if env == "gcp" {
if testutil.GetCloud(t) == testutil.GCP {
t.Skip("DBFS REST API is disabled on gcp")
}

Expand Down
5 changes: 0 additions & 5 deletions integration/cmd/auth/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@ import (
"testing"

"github.com/databricks/cli/internal/testcli"
"github.com/databricks/cli/internal/testutil"
"github.com/databricks/databricks-sdk-go"
"github.com/stretchr/testify/require"
)

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")
Expand All @@ -35,8 +32,6 @@ 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")
Expand Down
5 changes: 0 additions & 5 deletions integration/cmd/clusters/clusters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@ import (

"github.com/databricks/cli/internal/acc"
"github.com/databricks/cli/internal/testcli"
"github.com/databricks/cli/internal/testutil"
"github.com/databricks/databricks-sdk-go/listing"
"github.com/databricks/databricks-sdk-go/service/compute"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestClustersList(t *testing.T) {
t.Log(testutil.GetEnvOrSkipTest(t, "CLOUD_ENV"))

stdout, stderr := testcli.RequireSuccessfulRun(t, "clusters", "list")
outStr := stdout.String()
assert.Contains(t, outStr, "ID")
Expand All @@ -30,8 +27,6 @@ func TestClustersList(t *testing.T) {
}

func TestClustersGet(t *testing.T) {
t.Log(testutil.GetEnvOrSkipTest(t, "CLOUD_ENV"))

clusterId := findValidClusterID(t)
stdout, stderr := testcli.RequireSuccessfulRun(t, "clusters", "get", clusterId)
outStr := stdout.String()
Expand Down
3 changes: 0 additions & 3 deletions integration/cmd/fs/cat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/databricks/cli/internal/acc"
"github.com/databricks/cli/internal/testcli"
"github.com/databricks/cli/internal/testutil"
"github.com/databricks/cli/libs/filer"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -72,8 +71,6 @@ func TestFsCatOnNonExistentFile(t *testing.T) {
}

func TestFsCatForDbfsInvalidScheme(t *testing.T) {
t.Log(testutil.GetEnvOrSkipTest(t, "CLOUD_ENV"))

_, _, err := testcli.RequireErrorRun(t, "fs", "cat", "dab:/non-existent-file")
assert.ErrorContains(t, err, "invalid scheme: dab")
}
Expand Down
2 changes: 0 additions & 2 deletions integration/cmd/fs/cp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,6 @@ func TestFsCpErrorsWhenSourceIsDirWithoutRecursiveFlag(t *testing.T) {
}

func TestFsCpErrorsOnInvalidScheme(t *testing.T) {
t.Log(testutil.GetEnvOrSkipTest(t, "CLOUD_ENV"))

_, _, err := testcli.RequireErrorRun(t, "fs", "cp", "dbfs:/a", "https:/b")
assert.Equal(t, "invalid scheme: https", err.Error())
}
Expand Down
2 changes: 0 additions & 2 deletions integration/cmd/fs/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import (
)

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)
Expand Down
2 changes: 0 additions & 2 deletions integration/cmd/fs/ls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@ func TestFsLsForNonexistingDir(t *testing.T) {
func TestFsLsWithoutScheme(t *testing.T) {
t.Parallel()

t.Log(testutil.GetEnvOrSkipTest(t, "CLOUD_ENV"))

_, _, err := testcli.RequireErrorRun(t, "fs", "ls", "/path-without-a-dbfs-scheme", "--output=json")
assert.ErrorIs(t, err, fs.ErrNotExist)
}
7 changes: 1 addition & 6 deletions integration/cmd/jobs/jobs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,14 @@ import (
"fmt"
"testing"

"github.com/databricks/cli/internal/acc"
"github.com/databricks/cli/internal/testcli"
"github.com/databricks/cli/internal/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestCreateJob(t *testing.T) {
acc.WorkspaceTest(t)
env := testutil.GetEnvOrSkipTest(t, "CLOUD_ENV")
if env != "azure" {
t.Skipf("Not running test on cloud %s", env)
}
testutil.Require(t, testutil.Azure)
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
Expand Down
49 changes: 16 additions & 33 deletions integration/cmd/repos/repos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strconv"
"testing"

"github.com/databricks/cli/internal/acc"
"github.com/databricks/cli/internal/testcli"
"github.com/databricks/cli/internal/testutil"
"github.com/databricks/databricks-sdk-go"
Expand Down Expand Up @@ -48,11 +49,8 @@ func createTemporaryRepo(t *testing.T, w *databricks.WorkspaceClient, ctx contex
}

func TestReposCreateWithProvider(t *testing.T) {
t.Log(testutil.GetEnvOrSkipTest(t, "CLOUD_ENV"))

ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
require.NoError(t, err)
ctx, wt := acc.WorkspaceTest(t)
w := wt.W
repoPath := synthesizeTemporaryRepoPath(t, w, ctx)

_, stderr := testcli.RequireSuccessfulRun(t, "repos", "create", repoUrl, "gitHub", "--path", repoPath)
Expand All @@ -65,11 +63,8 @@ func TestReposCreateWithProvider(t *testing.T) {
}

func TestReposCreateWithoutProvider(t *testing.T) {
t.Log(testutil.GetEnvOrSkipTest(t, "CLOUD_ENV"))

ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
require.NoError(t, err)
ctx, wt := acc.WorkspaceTest(t)
w := wt.W
repoPath := synthesizeTemporaryRepoPath(t, w, ctx)

_, stderr := testcli.RequireSuccessfulRun(t, "repos", "create", repoUrl, "--path", repoPath)
Expand All @@ -82,11 +77,8 @@ func TestReposCreateWithoutProvider(t *testing.T) {
}

func TestReposGet(t *testing.T) {
t.Log(testutil.GetEnvOrSkipTest(t, "CLOUD_ENV"))

ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
require.NoError(t, err)
ctx, wt := acc.WorkspaceTest(t)
w := wt.W

repoId, repoPath := createTemporaryRepo(t, w, ctx)

Expand All @@ -102,7 +94,7 @@ func TestReposGet(t *testing.T) {
assert.Equal(t, byIdOutput.String(), byPathOutput.String())

// Get by path fails
_, stderr, err = testcli.RequireErrorRun(t, "repos", "get", repoPath+"-doesntexist", "--output=json")
_, stderr, err := testcli.RequireErrorRun(t, "repos", "get", repoPath+"-doesntexist", "--output=json")
assert.ErrorContains(t, err, "failed to look up repo")

// Get by path resolves to something other than a repo
Expand All @@ -111,11 +103,8 @@ func TestReposGet(t *testing.T) {
}

func TestReposUpdate(t *testing.T) {
t.Log(testutil.GetEnvOrSkipTest(t, "CLOUD_ENV"))

ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
require.NoError(t, err)
ctx, wt := acc.WorkspaceTest(t)
w := wt.W

repoId, repoPath := createTemporaryRepo(t, w, ctx)

Expand All @@ -132,11 +121,8 @@ func TestReposUpdate(t *testing.T) {
}

func TestReposDeleteByID(t *testing.T) {
t.Log(testutil.GetEnvOrSkipTest(t, "CLOUD_ENV"))

ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
require.NoError(t, err)
ctx, wt := acc.WorkspaceTest(t)
w := wt.W

repoId, _ := createTemporaryRepo(t, w, ctx)

Expand All @@ -146,16 +132,13 @@ func TestReposDeleteByID(t *testing.T) {
assert.Equal(t, "", stderr.String())

// Check it was actually deleted
_, err = w.Repos.GetByRepoId(ctx, repoId)
_, err := w.Repos.GetByRepoId(ctx, repoId)
assert.True(t, apierr.IsMissing(err), err)
}

func TestReposDeleteByPath(t *testing.T) {
t.Log(testutil.GetEnvOrSkipTest(t, "CLOUD_ENV"))

ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
require.NoError(t, err)
ctx, wt := acc.WorkspaceTest(t)
w := wt.W

repoId, repoPath := createTemporaryRepo(t, w, ctx)

Expand All @@ -165,6 +148,6 @@ func TestReposDeleteByPath(t *testing.T) {
assert.Equal(t, "", stderr.String())

// Check it was actually deleted
_, err = w.Repos.GetByRepoId(ctx, repoId)
_, err := w.Repos.GetByRepoId(ctx, repoId)
assert.True(t, apierr.IsMissing(err), err)
}
Loading
Loading