Skip to content

Commit d1eb5d7

Browse files
denikIsaac
andcommitted
acceptance: fix engine-var references left after CI-matrix removal
Dropping DATABRICKS_BUNDLE_ENGINE from the matrix left several scripts still referencing the now-unset variable. Under set -u those errored, and a prior -update baked the "unbound variable" output into their goldens (permissions, recreate-keys, grants, resource_deps), so the tests were green against broken goldens. - Strip the engine suffix from the remaining out.*.$DATABRICKS_BUNDLE_ENGINE.json writes (permissions/_script, recreate-keys/_script, run_as/pipelines/_script). - Drop the direct-only `if [ "$DATABRICKS_BUNDLE_ENGINE" = "direct" ]` guards now that direct is the only engine (volumes/uppercase-name, grants remove-principal), and the dead terraform-only blocks in resource_deps. - Default read_state.py to the direct engine when the variable is unset (terraform only when set explicitly); direct is the CLI default now. - Point the templates/default-python/classic and readplan/lineage-mismatch plan reads at the renamed plain plan files. - Pin generate/auto-bind to the plain DMS variant (bind is unsupported with deployment history), matching its previous single engine run. - Fix user_agent/verify.py to expect engine/direct now that recorded requests are no longer engine-suffixed, and regenerate all affected goldens. Co-authored-by: Isaac <no-reply@databricks.com>
1 parent ea7393e commit d1eb5d7

8 files changed

Lines changed: 49 additions & 24 deletions

File tree

‎acceptance/bin/read_state.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def print_resource_recorded(group, name, *attrs):
7979

8080
if os.environ.get("DATABRICKS_BUNDLE_DEPLOYMENT_HISTORY") == "true":
8181
print_resource_recorded(*sys.argv[1:])
82-
elif os.environ.get("DATABRICKS_BUNDLE_ENGINE", "").startswith("direct"):
83-
print_resource_direct(*sys.argv[1:])
84-
else:
82+
elif os.environ.get("DATABRICKS_BUNDLE_ENGINE") == "terraform":
8583
print_resource_terraform(*sys.argv[1:])
84+
else:
85+
print_resource_direct(*sys.argv[1:])
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
cp: plan.direct.json: No such file or directory
21

3-
Exit code: 1
2+
>>> musterr [CLI] bundle deploy --plan plan.json
3+
Warn: Plan was created with CLI version 0.0.0-test but current version is [CLI_VERSION]
4+
Error: plan lineage "different-lineage" does not match state lineage ""; the state may have been modified by another process
5+
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# The plan is committed rather than generated, so it must match the shape of the target it is fed
22
# to: a recorded target's state carries the deployment_history feature, and validatePlan rejects a
33
# plan whose features differ before it looks at lineage.
4-
plan=plan.direct.json
4+
#
5+
# The deployment-history variant needs the recorded-shape plan; copy it over plan.json so the
6+
# traced command line ("--plan plan.json") is the same in both variants.
57
if [ "$DATABRICKS_BUNDLE_DEPLOYMENT_HISTORY" = "true" ]; then
6-
plan=plan.dms.json
8+
cp plan.dms.json plan.json
79
fi
810

9-
# Copy to one name so the traced command line is the same in both variants.
10-
cp $plan plan.json
11-
1211
# Try to deploy with mismatched lineage (should fail)
1312
trace musterr $CLI bundle deploy --plan plan.json
1413
rm plan.json

‎acceptance/bundle/generate/auto-bind/output.txt‎

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,37 @@ Created job with ID: [NUMID]
1010
>>> [CLI] bundle generate job --key test_job --existing-job-id [NUMID] --config-dir resources --source-dir src --bind
1111
File successfully saved to src/test.py
1212
Job configuration successfully saved to resources/test_job.job.yml
13-
Error: bind is not supported for a bundle target that records deployment history
13+
Successfully bound job with an id '[NUMID]'
1414

15+
>>> ls src/
16+
test.py
17+
18+
>>> cat resources/test_job.job.yml
19+
name: auto-bind-job-[UNIQUE_NAME]
20+
21+
=== Deploy the bound job:
22+
>>> [CLI] bundle deploy
23+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/auto-bind-test-[UNIQUE_NAME]/files...
24+
Updated jobs.test_job
25+
Files: 5 uploaded, 0 deleted
26+
Resources: 0 created, 1 changed, 0 deleted, 0 unchanged
27+
28+
=== Destroy the bundle:
29+
>>> [CLI] bundle destroy --auto-approve
30+
The following resources will be deleted:
31+
delete resources.jobs.test_job
32+
33+
All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/auto-bind-test-[UNIQUE_NAME]
34+
35+
Destroy: 1 deleted
36+
37+
=== Check that job is bound and does not exist after bundle is destroyed:
38+
>>> errcode [CLI] jobs get [NUMID] --output json
39+
Error: Job [NUMID] does not exist.
40+
41+
Exit code: 1
1542

1643
=== Delete the tmp folder:
1744
>>> [CLI] workspace delete /Workspace/Users/[USERNAME]/python-[UNIQUE_NAME]/test
1845

1946
>>> [CLI] workspace delete /Workspace/Users/[USERNAME]/python-[UNIQUE_NAME]
20-
21-
Exit code: 1

‎acceptance/bundle/resources/schemas/update/output.txt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Resources: 1 created, 0 changed, 0 deleted, 0 unchanged
1515
"name": "myschema"
1616
}
1717
}
18-
State not found for schemas.schema1 in .databricks/bundle/default/terraform/terraform.tfstate
18+
schemas schema1 id='main.myschema' name='myschema' catalog_name='main' comment='COMMENT1'
1919

2020
=== Update comment and re-deploy
2121
>>> update_file.py databricks.yml COMMENT1 COMMENT2
@@ -30,7 +30,7 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged
3030
json.method = "PATCH";
3131
json.path = "/api/2.1/unity-catalog/schemas/main.myschema";
3232
json.body.comment = "COMMENT2";
33-
State not found for schemas.schema1 in .databricks/bundle/default/terraform/terraform.tfstate
33+
schemas schema1 id='main.myschema' name='myschema' catalog_name='main' comment='COMMENT2'
3434

3535
=== Restore comment to original value and re-deploy
3636
>>> update_file.py databricks.yml COMMENT2 COMMENT1
@@ -45,4 +45,4 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged
4545
json.method = "PATCH";
4646
json.path = "/api/2.1/unity-catalog/schemas/main.myschema";
4747
json.body.comment = "COMMENT1";
48-
State not found for schemas.schema1 in .databricks/bundle/default/terraform/terraform.tfstate
48+
schemas schema1 id='main.myschema' name='myschema' catalog_name='main' comment='COMMENT1'

‎acceptance/bundle/resources/sql_warehouses/output.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Resources:
3737
>>> [CLI] bundle deploy
3838
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test_sql_warehouse/default/files...
3939
Created sql_warehouses.test_sql_warehouse
40-
Files: 13 uploaded, 0 deleted
40+
Files: 10 uploaded, 0 deleted
4141
Resources: 1 created, 0 changed, 0 deleted, 0 unchanged
4242

4343
=== Verify the create request

‎acceptance/bundle/templates/default-python/classic/script‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ $CLI bundle plan -o json -t prod | nostamp > ../../out.plan_prod.json
1212

1313
rm "$OUT_REQUESTS"
1414
# With --plan variant we don't build artifacts, so we can filter out relevant log lines
15-
$CLI bundle deploy -t dev $(readplanarg ../../out.plan_dev.direct.json) 2>&1 | grep -vE '^Building python_artifact|^Uploading .databricks'
15+
$CLI bundle deploy -t dev $(readplanarg ../../out.plan_dev.json) 2>&1 | grep -vE '^Building python_artifact|^Uploading .databricks'
1616
print_requests.py --sort '^//import-file/' '^//telemetry-ext' > ../../out.requests.dev.txt
1717
trace $CLI bundle plan -t dev # check if if there is drift
1818
trace $CLI bundle plan -t dev -o json | nostamp > ../../out.plan_after_deploy_dev.json
1919

20-
$CLI bundle deploy -t prod $(readplanarg ../../out.plan_prod.direct.json) 2>&1 | grep -vE '^Building python_artifact|^Uploading dist'
20+
$CLI bundle deploy -t prod $(readplanarg ../../out.plan_prod.json) 2>&1 | grep -vE '^Building python_artifact|^Uploading dist'
2121
print_requests.py --sort '^//import-file/' '^//telemetry-ext' > ../../out.requests.prod.txt
2222
trace $CLI bundle plan -t prod # check if there is drift
2323
trace $CLI bundle plan -t prod -o json | nostamp > ../../out.plan_after_deploy_prod.json

‎acceptance/bundle/user_agent/verify.py‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ def extract_engine(s):
2121

2222

2323
def check_user_agent(fname):
24-
if ".terraform." in fname:
25-
expected = "engine/terraform"
26-
elif ".direct" in fname:
27-
expected = "engine/direct"
28-
else:
24+
# The CI matrix no longer varies the engine, so the recorded-request files are no longer
25+
# engine-suffixed; every deploy runs on the direct engine now.
26+
if "out.requests." not in fname:
2927
return
28+
expected = "engine/direct"
3029

3130
printer = TESTROOT / "bin" / "print_requests.py"
3231

0 commit comments

Comments
 (0)