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
2 changes: 1 addition & 1 deletion bundle/phases/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func Deploy() bundle.Mutator {
bundle.Seq(
terraform.StatePull(),
deploy.StatePull(),
deploy.CheckRunningResource(),
mutator.ValidateGitDetails(),
libraries.MatchWithArtifacts(),
artifacts.CleanUp(),
Expand All @@ -36,6 +35,7 @@ func Deploy() bundle.Mutator {
permissions.ApplyWorkspaceRootPermissions(),
terraform.Interpolate(),
terraform.Write(),
deploy.CheckRunningResource(),
bundle.Defer(
terraform.Apply(),
bundle.Seq(
Expand Down
43 changes: 43 additions & 0 deletions internal/bundle/basic_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package bundle

import (
"os"
"path/filepath"
"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 TestAccBasicBundleDeployWithFailOnActiveRuns(t *testing.T) {
ctx, _ := acc.WorkspaceTest(t)

nodeTypeId := internal.GetNodeTypeId(env.Get(ctx, "CLOUD_ENV"))
uniqueId := uuid.New().String()
root, err := initTestTemplate(t, ctx, "basic", map[string]any{
"unique_id": uniqueId,
"node_type_id": nodeTypeId,
"spark_version": "13.2.x-snapshot-scala2.12",
})
require.NoError(t, err)

t.Cleanup(func() {
err = destroyBundle(t, ctx, root)
require.NoError(t, err)
})

// deploy empty bundle
err = deployBundleWithFlags(t, ctx, root, []string{"--fail-on-active-runs"})
require.NoError(t, err)

// Remove .databricks directory to simulate a fresh deployment
err = os.RemoveAll(filepath.Join(root, ".databricks"))
require.NoError(t, err)

// deploy empty bundle again
err = deployBundleWithFlags(t, ctx, root, []string{"--fail-on-active-runs"})
require.NoError(t, err)
}
9 changes: 9 additions & 0 deletions internal/bundle/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ func deployBundle(t *testing.T, ctx context.Context, path string) error {
return err
}

func deployBundleWithFlags(t *testing.T, ctx context.Context, path string, flags []string) error {
t.Setenv("BUNDLE_ROOT", path)
args := []string{"bundle", "deploy", "--force-lock"}
args = append(args, flags...)
c := internal.NewCobraTestRunnerWithContext(t, ctx, args...)
_, _, err := c.Run()
return err
}

func runResource(t *testing.T, ctx context.Context, path string, key string) (string, error) {
ctx = cmdio.NewContext(ctx, cmdio.Default())

Expand Down