Skip to content

Commit cb1ecd3

Browse files
committed
Use EngineType; enforce env var engine matching state
1 parent a6fe375 commit cb1ecd3

33 files changed

+248
-323
lines changed

acceptance/bundle/deployment/migrate/basic/out.plan_after_migrate.json

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

acceptance/bundle/deployment/migrate/basic/out.test.toml

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

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

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

acceptance/bundle/deployment/migrate/basic/output.txt renamed to acceptance/bundle/migrate/basic/output.txt

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,31 @@ terraform
2323
>>> jq .state."resources.pipelines.test_pipeline".state.tags.volume_storage_location out.new_state.json
2424
"s3://deco-uc-prod-isolated-aws-us-east-1/metastore/[UUID]/volumes/[UUID]"
2525

26-
>>> [CLI] bundle plan
26+
>>> DATABRICKS_BUNDLE_ENGINE=terraform musterr [CLI] bundle plan
27+
Error: Required engine "terraform" does not match present state files. Set required engine via "DATABRICKS_BUNDLE_ENGINE" env var.
28+
29+
Available state files:
30+
- terraform.tfstate: remote terraform state serial=4 lineage="[UUID]"
31+
- [TEST_TMP_DIR]/.databricks/bundle/default/resources.json: local direct state serial=5 lineage="[UUID]"
32+
33+
34+
>>> DATABRICKS_BUNDLE_ENGINE=terraform musterr [CLI] bundle deploy
35+
Error: Required engine "terraform" does not match present state files. Set required engine via "DATABRICKS_BUNDLE_ENGINE" env var.
36+
37+
Available state files:
38+
- terraform.tfstate: remote terraform state serial=4 lineage="[UUID]"
39+
- [TEST_TMP_DIR]/.databricks/bundle/default/resources.json: local direct state serial=5 lineage="[UUID]"
40+
41+
42+
>>> DATABRICKS_BUNDLE_ENGINE=direct [CLI] bundle plan
2743
update pipelines.test_pipeline
2844

2945
Plan: 0 to add, 1 to change, 0 to delete, 2 unchanged
3046

31-
>>> [CLI] bundle debug plan
47+
>>> DATABRICKS_BUNDLE_ENGINE= [CLI] bundle plan
48+
update pipelines.test_pipeline
49+
50+
Plan: 0 to add, 1 to change, 0 to delete, 2 unchanged
3251

3352
>>> print_requests.py --get //jobs/get
3453
{
@@ -46,7 +65,7 @@ Plan: 0 to add, 1 to change, 0 to delete, 2 unchanged
4665
{
4766
"headers": {
4867
"User-Agent": [
49-
"cli/[DEV_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/bundle_debug_plan cmd-exec-id/[UUID] engine/direct auth/pat"
68+
"cli/[DEV_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/bundle_plan cmd-exec-id/[UUID] engine/direct auth/pat"
5069
]
5170
},
5271
"method": "GET",
@@ -56,7 +75,7 @@ Plan: 0 to add, 1 to change, 0 to delete, 2 unchanged
5675
}
5776
}
5877

59-
>>> [CLI] bundle deploy
78+
>>> DATABRICKS_BUNDLE_ENGINE= [CLI] bundle deploy
6079
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/migrate-basic-test/default/files...
6180
Deploying resources...
6281
Updating deployment state...
@@ -70,3 +89,11 @@ Deployment complete!
7089
>>> musterr [CLI] bundle deployment migrate
7190
Error: already using direct engine
7291
Details: [TEST_TMP_DIR]/.databricks/bundle/default/resources.json: local direct state serial=5 lineage="[UUID]"
92+
93+
>>> DATABRICKS_BUNDLE_ENGINE= [CLI] bundle debug states
94+
[TEST_TMP_DIR]/.databricks/bundle/default/resources.json: local direct state serial=5 lineage="[UUID]"
95+
96+
>>> DATABRICKS_BUNDLE_ENGINE= [CLI] bundle debug states --force-pull
97+
terraform.tfstate: remote terraform state serial=4 lineage="[UUID]"
98+
resources.json: remote direct state serial=5 lineage="[UUID]"
99+
[TEST_TMP_DIR]/.databricks/bundle/default/resources.json: local direct state serial=5 lineage="[UUID]"

acceptance/bundle/deployment/migrate/basic/script renamed to acceptance/bundle/migrate/basic/script

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,28 @@ trace musterr $CLI bundle deployment migrate
44
trace DATABRICKS_BUNDLE_ENGINE=terraform $CLI bundle deploy
55
print_state.py > out.original_state.json
66

7-
trace $CLI bundle deployment migrate
7+
trace $CLI bundle deployment migrate 2>&1 | contains.py 'Migrated 3 resources'
88
print_state.py > out.new_state.json
99
trace ls -1 .databricks/bundle/default/ | contains.py "resources.json"
1010
# check that this is stored as resolved value, not as reference:
1111
trace jq '.state."resources.pipelines.test_pipeline".state.tags.volume_storage_location' out.new_state.json | contains.py 's3://'
1212

13+
# this is expected to fail because state does not match env var
14+
trace DATABRICKS_BUNDLE_ENGINE=terraform musterr $CLI bundle plan
15+
trace DATABRICKS_BUNDLE_ENGINE=terraform musterr $CLI bundle deploy
16+
1317
rm out.requests.txt
14-
trace $CLI bundle plan | contains.py "2 unchanged" # should be "3 unchanged" when permanent drift is fixed
15-
trace $CLI bundle debug plan > out.plan_after_migrate.json
18+
# Both DATABRICKS_BUNDLE_ENGINE=direct and DATABRICKS_BUNDLE_ENGINE= work
19+
trace DATABRICKS_BUNDLE_ENGINE=direct $CLI bundle plan | contains.py "2 unchanged" # should be "3 unchanged" once permanent drift is fixed
20+
trace DATABRICKS_BUNDLE_ENGINE= $CLI bundle plan | contains.py "2 unchanged"
1621
trace print_requests.py --get //jobs/get | contains.py 'engine/direct'
1722

18-
trace $CLI bundle deploy
23+
trace DATABRICKS_BUNDLE_ENGINE="" $CLI bundle deploy
1924
trace print_requests.py --get //jobs/get | jq '.headers["User-Agent"][0]' | contains.py 'engine/direct'
2025

2126
title "Should show that it's already migrated"
2227
trace musterr $CLI bundle deployment migrate
28+
trace DATABRICKS_BUNDLE_ENGINE= $CLI bundle debug states
29+
trace DATABRICKS_BUNDLE_ENGINE= $CLI bundle debug states --force-pull
30+
2331
rm out.requests.txt

0 commit comments

Comments
 (0)