Skip to content
Open
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
85 changes: 0 additions & 85 deletions acceptance/acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"os"
"os/exec"
"path/filepath"
"reflect"
"regexp"
"runtime"
"slices"
Expand All @@ -26,7 +25,6 @@ import (
"unicode/utf8"

"github.com/google/uuid"
"gopkg.in/yaml.v3"

"github.com/databricks/cli/acceptance/internal"
"github.com/databricks/cli/internal/testutil"
Expand Down Expand Up @@ -548,18 +546,6 @@ func runTest(t *testing.T,
// Add materialized config to outputs for comparison
outputs[internal.MaterializedConfigFile] = true

bundleConfigTarget := "databricks.yml"
if config.BundleConfigTarget != nil {
bundleConfigTarget = *config.BundleConfigTarget
}

if bundleConfigTarget != "" {
configCreated := applyBundleConfig(t, tmpDir, config.BundleConfig, bundleConfigTarget)
if configCreated {
inputs[bundleConfigTarget] = true
}
}

timeout := config.Timeout

if runtime.GOOS == "windows" {
Expand Down Expand Up @@ -1378,77 +1364,6 @@ func prepareWheelBuildDirectory(t *testing.T, dir string) string {
return latestWheel
}

// Applies BundleConfig setting to file named bundleConfigTarget and updates it in place if there were any changes.
// Returns true if new file was created.
func applyBundleConfig(t *testing.T, tmpDir string, bundleConfig map[string]any, bundleConfigTarget string) bool {
validConfig := make(map[string]map[string]any, len(bundleConfig))

for _, configName := range utils.SortedKeys(bundleConfig) {
configValue := bundleConfig[configName]
// Setting BundleConfig.<name> to empty string disables it.
// This is useful when parent directory defines some config that child test wants to cancel.
if configValue == "" {
continue
}
cfg, ok := configValue.(map[string]any)
if !ok {
t.Fatalf("Unexpected type for BundleConfig.%s: %#v", configName, configValue)
}
validConfig[configName] = cfg
}

if len(validConfig) == 0 {
return false
}

configPath := filepath.Join(tmpDir, bundleConfigTarget)
configData, configExists := tryReading(t, configPath)

newConfigData := configData
var applied []string

for _, configName := range utils.SortedKeys(validConfig) {
configValue := validConfig[configName]
updated, err := internal.MergeBundleConfig(newConfigData, configValue)
if err != nil {
t.Fatalf("Failed to merge BundleConfig.%s: %s\nvvalue: %#v\ntext:\n%s", configName, err, configValue, newConfigData)
}
if isSameYAMLContent(newConfigData, updated) {
t.Logf("No effective updates from BundleConfig.%s", configName)
} else {
newConfigData = updated
applied = append(applied, configName)
}
}

if newConfigData != configData {
t.Logf("Writing updated bundle config to %s. BundleConfig sections: %s", bundleConfigTarget, strings.Join(applied, ", "))
testutil.WriteFile(t, configPath, newConfigData)
return !configExists
}

return false
}

// Returns true if both strings are deep-equal after unmarshalling
func isSameYAMLContent(str1, str2 string) bool {
var obj1, obj2 any

if str1 == str2 {
return true
}

if err := yaml.Unmarshal([]byte(str1), &obj1); err != nil {
return false
}

if err := yaml.Unmarshal([]byte(str2), &obj2); err != nil {
return false
}

return reflect.DeepEqual(obj1, obj2)
}

func BuildYamlfmt(t *testing.T) {
// Using make here instead of "go build" directly cause it's faster when it's already built
args := []string{
Expand Down
3 changes: 3 additions & 0 deletions acceptance/bundle/apps/app_yaml/databricks.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

resources:
apps:
myapp:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

workspace:
artifact_path: /Volumes/foo/bar/artifacts

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

workspace:
artifact_path: /foo/bar/artifacts

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

workspace:
artifact_path: /Workspace/foo/bar/artifacts

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

presets:
artifacts_dynamic_version: true

Expand Down
3 changes: 3 additions & 0 deletions acceptance/bundle/artifacts/build_and_files/databricks.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

artifacts:
custom:
build: touch built.txt
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

artifacts:
artifact_with_custom_dist:
type: whl
Expand Down
3 changes: 3 additions & 0 deletions acceptance/bundle/artifacts/glob_exact_whl/databricks.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

artifacts:
my_prebuilt_whl:
type: whl
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
bundle:
name: test-bundle

include:
- resources/artifacts.yml
3 changes: 3 additions & 0 deletions acceptance/bundle/artifacts/issue_3109/databricks.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
bundle:
name: test-bundle

include:
- src/job1/databricks_job/resources/*.yaml
3 changes: 3 additions & 0 deletions acceptance/bundle/artifacts/shell/err-bash/databricks.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

artifacts:
my_artifact:
executable: bash
Expand Down
3 changes: 3 additions & 0 deletions acceptance/bundle/artifacts/shell/err-sh/databricks.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

artifacts:
my_artifact:
executable: sh
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

variables:
cluster:
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

workspace:
artifact_path: /foo/bar/artifacts

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

resources:
jobs:
test_job:
Expand Down
3 changes: 3 additions & 0 deletions acceptance/bundle/artifacts/whl_dbfs/databricks.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

resources:
jobs:
test_job:
Expand Down
3 changes: 3 additions & 0 deletions acceptance/bundle/artifacts/whl_dynamic/databricks.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

artifacts:
my_test_code:
type: whl
Expand Down
3 changes: 3 additions & 0 deletions acceptance/bundle/artifacts/whl_explicit/databricks.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

artifacts:
my_test_code:
type: whl
Expand Down
3 changes: 3 additions & 0 deletions acceptance/bundle/artifacts/whl_implicit/databricks.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

resources:
jobs:
test_job:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

workspace:
artifact_path: /foo/bar

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

resources:
jobs:
test_job:
Expand Down
3 changes: 3 additions & 0 deletions acceptance/bundle/artifacts/whl_multiple/databricks.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

artifacts:
my_test_code:
type: whl
Expand Down
3 changes: 3 additions & 0 deletions acceptance/bundle/artifacts/whl_no_cleanup/databricks.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

experimental:
skip_artifact_cleanup: true

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

resources:
jobs:
test_job:
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
BundleConfig.default_name = ""

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

artifacts:
my_test_code:
type: whl
Expand Down
3 changes: 3 additions & 0 deletions acceptance/bundle/bundle_tag/id/databricks.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

resources:
jobs:
foo:
Expand Down
3 changes: 3 additions & 0 deletions acceptance/bundle/bundle_tag/url/databricks.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

resources:
jobs:
foo:
Expand Down
3 changes: 3 additions & 0 deletions acceptance/bundle/bundle_tag/url_ref/databricks.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

resources:
jobs:
foo:
Expand Down
3 changes: 3 additions & 0 deletions acceptance/bundle/deploy/experimental-python/databricks.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

sync: {paths: []} # dont need to copy files

experimental:
Expand Down
3 changes: 3 additions & 0 deletions acceptance/bundle/deploy/fail-on-active-runs/databricks.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

resources:
jobs:
my_job:
Expand Down
3 changes: 3 additions & 0 deletions acceptance/bundle/deploy/python-notebook/databricks.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

sync: {paths: []} # dont need to copy files

resources:
Expand Down
2 changes: 0 additions & 2 deletions acceptance/bundle/deployment/bind/alert/test.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
Cloud = true
Local = false

BundleConfigTarget = "databricks.yml"

# On aws the host URL includes the workspace ID as well. Thus skipping it to keep the test simple.
CloudEnvs.aws = false

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle-$UNIQUE_NAME

resources:
clusters:
cluster1:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle-$UNIQUE_NAME

resources:
dashboards:
dashboard1:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle-$UNIQUE_NAME

resources:
dashboards:
dashboard1:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
bundle:
name: test-bundle

resources:
database_instances:
database_instance1:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ Successfully bound database_instance with an id '[UUID]'
Run 'bundle deploy' to deploy changes to your workspace

>>> [CLI] bundle summary
Name: test-bundle-$UNIQUE_NAME
Name: test-bundle
Target: default
Workspace:
User: [USERNAME]
Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle-$UNIQUE_NAME/default
Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default
Resources:
Database instances:
database_instance1:
Expand All @@ -20,11 +20,11 @@ Resources:
Updating deployment state...

>>> [CLI] bundle summary
Name: test-bundle-$UNIQUE_NAME
Name: test-bundle
Target: default
Workspace:
User: [USERNAME]
Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle-$UNIQUE_NAME/default
Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default
Resources:
Database instances:
database_instance1:
Expand Down
Loading