Skip to content

Commit a86e7dc

Browse files
janniklasrosedenik
authored andcommitted
acceptance: use templates for bundle_default_profile scenarios (#5270)
## Summary Follow-up to #5214 (per [pietern's review comment](#5214 (comment))). Replace the inline heredocs in `acceptance/auth/bundle_default_profile/script` with three committed templates: - `databricks.yml.no-host.tmpl` — bundle with neither `workspace.host` nor `workspace.profile`. Used for the "default_profile is honored" and "`--profile` overrides" phases. - `databricks.yml.with-host.tmpl` — pins `workspace.host: $DATABRICKS_HOST`. `envsubst` fills in the test server URL before each invocation. - `databricks.yml.with-profile.tmpl` — pins `workspace.profile: other`. Before each phase the script overwrites the active `databricks.yml` from the relevant template. The per-scenario subdirectories (`./bundle-with-host`, `./bundle-with-profile`) and the `cd` calls are gone — the active bundle is always at the test root. Stacked on #5266 (sethome-absolute fix). The base will auto-retarget to `main` once #5266 merges. `output.txt` is unchanged across the refactor: both engine variants (`terraform` and `direct`) produce byte-identical output to the pre-refactor run. ## Test plan - [x] `go test ./acceptance -run TestAccept/auth/bundle_default_profile -v` passes for both `DATABRICKS_BUNDLE_ENGINE=terraform` and `=direct`. - [x] `./task fmt-q` and `./task lint-q` clean. This pull request and its description were written by Isaac.
1 parent 68d1b9f commit a86e7dc

5 files changed

Lines changed: 17 additions & 22 deletions

File tree

acceptance/auth/bundle_default_profile/databricks.yml renamed to acceptance/auth/bundle_default_profile/databricks.yml.no-host.tmpl

File renamed without changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
bundle:
2+
name: bundle-with-host
3+
4+
workspace:
5+
host: $DATABRICKS_HOST
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
bundle:
2+
name: bundle-with-profile
3+
4+
workspace:
5+
profile: other

acceptance/auth/bundle_default_profile/script

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,39 +20,25 @@ unset DATABRICKS_HOST
2020
unset DATABRICKS_TOKEN
2121
unset DATABRICKS_CONFIG_PROFILE
2222

23+
cp databricks.yml.no-host.tmpl databricks.yml
2324
title "Bundle without workspace.host: default_profile is honored\n"
2425
trace $CLI bundle validate -o json | jq '{host: .workspace.host, profile: .workspace.profile}'
2526

27+
cp databricks.yml.no-host.tmpl databricks.yml
2628
title "--profile overrides default_profile (negative case)\n"
2729
trace errcode $CLI bundle validate -p other -o json | jq '{host: .workspace.host, profile: .workspace.profile}'
2830

2931
# Switch to a bundle that pins workspace.host. The default_profile guard in
3032
# configureProfile must NOT apply default_profile here, because that would
3133
# silently route the user to a profile pointing at a different host than the
3234
# bundle declares.
33-
mkdir -p ./bundle-with-host
34-
cat > ./bundle-with-host/databricks.yml <<EOF
35-
bundle:
36-
name: bundle-with-host
37-
38-
workspace:
39-
host: $host_value
40-
EOF
41-
35+
DATABRICKS_HOST="$host_value" envsubst < databricks.yml.with-host.tmpl > databricks.yml
4236
title "Bundle with workspace.host: default_profile is NOT applied\n"
43-
(cd ./bundle-with-host && trace errcode $CLI bundle validate -o json | jq '{host: .workspace.host, profile: .workspace.profile}')
37+
trace errcode $CLI bundle validate -o json | jq '{host: .workspace.host, profile: .workspace.profile}'
4438

4539
# Switch to a bundle that pins workspace.profile but no host. The pinned
4640
# profile must win over default_profile — configureProfile's guard skips
4741
# default_profile when workspace.profile is already set.
48-
mkdir -p ./bundle-with-profile
49-
cat > ./bundle-with-profile/databricks.yml <<EOF
50-
bundle:
51-
name: bundle-with-profile
52-
53-
workspace:
54-
profile: other
55-
EOF
56-
42+
cp databricks.yml.with-profile.tmpl databricks.yml
5743
title "Bundle with workspace.profile: pinned profile wins over default_profile\n"
58-
(cd ./bundle-with-profile && trace errcode $CLI bundle validate -o json | jq '{host: .workspace.host, profile: .workspace.profile}')
44+
trace errcode $CLI bundle validate -o json | jq '{host: .workspace.host, profile: .workspace.profile}'

acceptance/auth/bundle_default_profile/test.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
Ignore = [
22
"home",
33
".databricks",
4-
"bundle-with-host",
5-
"bundle-with-profile",
4+
"databricks.yml",
65
]
76

87
# Negative case: -p other tries to reach a non-existing host. Redact the

0 commit comments

Comments
 (0)