Skip to content

Commit d718aa4

Browse files
committed
bundle: run select/basic on cloud; test full deploy after partial deploy
Rename select/ok to select/basic and extend it: - Enable on cloud (Local+Cloud) with a $UNIQUE_NAME-templated bundle and a destroy cleanup trap, pinned to the direct engine (the only engine where --select works). The serialized plan is written to an ignored plan.json so cloud runs don't diverge on remote state. - After the partial deploy (--select jobs.foo deploys foo+bar), run a full plan/deploy with no selection: the plan shows only baz to add with foo and bar unchanged, deploy creates baz, and a final plan reports no changes. Add select/rejected (terraform, local) covering the --select rejection that select/basic no longer exercises now that it is direct-only. Co-authored-by: Isaac
1 parent c2b30d5 commit d718aa4

17 files changed

Lines changed: 138 additions & 139 deletions
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
bundle:
2-
name: select
2+
name: select-$UNIQUE_NAME
33

44
resources:
55
jobs:
66
bar:
7-
name: job-bar
7+
name: bar-$UNIQUE_NAME
88

99
foo:
10-
name: job-foo
10+
name: foo-$UNIQUE_NAME
1111
tasks:
1212
- task_key: run_bar
1313
run_job_task:
1414
job_id: ${resources.jobs.bar.id}
1515

1616
baz:
17-
name: job-baz
17+
name: baz-$UNIQUE_NAME

acceptance/bundle/select/basic/out.test.toml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

acceptance/bundle/select/ok/out.direct.txt renamed to acceptance/bundle/select/basic/output.txt

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ create jobs.foo
2222

2323
Plan: 2 to add, 0 to change, 0 to delete, 0 unchanged
2424

25-
>>> [CLI] bundle plan --select jobs.foo -o json
26-
2725
=== bundle deploy --select jobs.foo
28-
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/select/default/files...
26+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/select-[UNIQUE_NAME]/default/files...
2927
Deploying resources...
3028
Updating deployment state...
3129
Deployment complete!
@@ -37,12 +35,12 @@ Deployment complete!
3735
"body": {
3836
"deployment": {
3937
"kind": "BUNDLE",
40-
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/select/default/state/metadata.json"
38+
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/select-[UNIQUE_NAME]/default/state/metadata.json"
4139
},
4240
"edit_mode": "UI_LOCKED",
4341
"format": "MULTI_TASK",
4442
"max_concurrent_runs": 1,
45-
"name": "job-bar",
43+
"name": "bar-[UNIQUE_NAME]",
4644
"queue": {
4745
"enabled": true
4846
}
@@ -54,12 +52,12 @@ Deployment complete!
5452
"body": {
5553
"deployment": {
5654
"kind": "BUNDLE",
57-
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/select/default/state/metadata.json"
55+
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/select-[UNIQUE_NAME]/default/state/metadata.json"
5856
},
5957
"edit_mode": "UI_LOCKED",
6058
"format": "MULTI_TASK",
6159
"max_concurrent_runs": 1,
62-
"name": "job-foo",
60+
"name": "foo-[UNIQUE_NAME]",
6361
"queue": {
6462
"enabled": true
6563
},
@@ -73,3 +71,51 @@ Deployment complete!
7371
]
7472
}
7573
}
74+
75+
=== Full plan after partial deploy
76+
>>> [CLI] bundle plan
77+
create jobs.baz
78+
79+
Plan: 1 to add, 0 to change, 0 to delete, 2 unchanged
80+
81+
=== Full deploy
82+
>>> [CLI] bundle deploy
83+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/select-[UNIQUE_NAME]/default/files...
84+
Deploying resources...
85+
Updating deployment state...
86+
Deployment complete!
87+
88+
>>> print_requests.py --sort //jobs
89+
{
90+
"method": "POST",
91+
"path": "/api/2.2/jobs/create",
92+
"body": {
93+
"deployment": {
94+
"kind": "BUNDLE",
95+
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/select-[UNIQUE_NAME]/default/state/metadata.json"
96+
},
97+
"edit_mode": "UI_LOCKED",
98+
"format": "MULTI_TASK",
99+
"max_concurrent_runs": 1,
100+
"name": "baz-[UNIQUE_NAME]",
101+
"queue": {
102+
"enabled": true
103+
}
104+
}
105+
}
106+
107+
=== Full plan again
108+
>>> [CLI] bundle plan
109+
Plan: 0 to add, 0 to change, 0 to delete, 3 unchanged
110+
111+
=== Destroy
112+
>>> [CLI] bundle destroy --auto-approve
113+
The following resources will be deleted:
114+
delete resources.jobs.bar
115+
delete resources.jobs.baz
116+
delete resources.jobs.foo
117+
118+
All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/select-[UNIQUE_NAME]/default
119+
120+
Deleting files...
121+
Destroy complete!
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
envsubst '$UNIQUE_NAME' < databricks.yml.tmpl > databricks.yml
2+
3+
cleanup() {
4+
title "Destroy"
5+
trace $CLI bundle destroy --auto-approve
6+
rm -f out.requests.txt
7+
}
8+
trap cleanup EXIT
9+
10+
# --- selector resolution ---
11+
# Unqualified name, unique across resource types.
12+
trace $CLI bundle plan --select bar
13+
# Repeated --select.
14+
trace $CLI bundle plan --select jobs.bar --select jobs.baz
15+
# Comma-separated --select (equivalent to repeating the flag).
16+
trace $CLI bundle plan --select jobs.bar,jobs.baz
17+
# Qualified name; foo pulls in its dependency bar but not the independent baz.
18+
trace $CLI bundle plan --select jobs.foo
19+
20+
# --- partial deploy ---
21+
# Serialize the filtered plan, then deploy it: inline, or via --plan (READPLAN=1).
22+
# The deploy is not traced because readplanarg varies the command line between
23+
# READPLAN variants, which must produce identical output.
24+
$CLI bundle plan --select jobs.foo -o json > plan.json
25+
title "bundle deploy --select jobs.foo\n"
26+
$CLI bundle deploy --select jobs.foo $(readplanarg plan.json)
27+
# Only bar and foo were created, never baz.
28+
trace print_requests.py --sort //jobs
29+
30+
# --- full plan/deploy after the partial deploy ---
31+
# foo and bar are already deployed, so only baz remains to create.
32+
title "Full plan after partial deploy"
33+
trace $CLI bundle plan
34+
title "Full deploy"
35+
trace $CLI bundle deploy
36+
# Only baz is created this time.
37+
trace print_requests.py --sort //jobs
38+
# Everything is deployed now: no changes.
39+
title "Full plan again"
40+
trace $CLI bundle plan
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Local = true
2+
Cloud = true
3+
RecordRequests = true
4+
# --select is only supported by the direct engine, so this happy-path test runs on
5+
# direct only (the rejection on terraform is covered by bundle/select/rejected).
6+
EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"]
7+
# Also run a variant that deploys a serialized (already filtered) plan via --plan.
8+
EnvMatrix.READPLAN = ["", "1"]
9+
# databricks.yml and plan.json are generated at runtime.
10+
Ignore = [".databricks", ".gitignore", "databricks.yml", "plan.json"]

acceptance/bundle/select/ok/out.plan.direct.json

Lines changed: 0 additions & 59 deletions
This file was deleted.

acceptance/bundle/select/ok/out.plan.terraform.json

Whitespace-only changes.

acceptance/bundle/select/ok/out.terraform.txt

Lines changed: 0 additions & 38 deletions
This file was deleted.

acceptance/bundle/select/ok/out.test.toml

Lines changed: 0 additions & 4 deletions
This file was deleted.

acceptance/bundle/select/ok/output.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)