Skip to content

Commit ae48197

Browse files
committed
add a test
1 parent f699aba commit ae48197

File tree

6 files changed

+108
-0
lines changed

6 files changed

+108
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
bundle:
2+
name: migrate-var-test
3+
4+
variables:
5+
job_name:
6+
default: "Default Job Name"
7+
8+
resources:
9+
jobs:
10+
test_job:
11+
name: "${var.job_name}"
12+
tasks:
13+
- task_key: "main"
14+
notebook_task:
15+
notebook_path: "./notebook.py"
16+
17+
targets:
18+
dev:
19+
default: true
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Databricks notebook source
2+
print("Hello from notebook")

acceptance/bundle/migrate/var_arg/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.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
2+
>>> DATABRICKS_BUNDLE_ENGINE=terraform [CLI] bundle deploy --var=job_name=Custom Job Name
3+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/migrate-var-test/dev/files...
4+
Deploying resources...
5+
Updating deployment state...
6+
Deployment complete!
7+
8+
>>> [CLI] bundle deployment migrate --var=job_name=Custom Job Name
9+
Note: Migration should be done after a full deploy. Running plan now to verify that deployment was done:
10+
Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged
11+
Success! Migrated 1 resources to direct engine state file: [TEST_TMP_DIR]/.databricks/bundle/dev/resources.json
12+
13+
Validate the migration by running "databricks bundle plan --var 'job_name=Custom Job Name'", there should be no actions planned.
14+
15+
The state file is not synchronized to the workspace yet. To do that and finalize the migration, run "bundle deploy --var 'job_name=Custom Job Name'".
16+
17+
To undo the migration, remove [TEST_TMP_DIR]/.databricks/bundle/dev/resources.json and rename [TEST_TMP_DIR]/.databricks/bundle/dev/terraform/terraform.tfstate.backup to [TEST_TMP_DIR]/.databricks/bundle/dev/terraform/terraform.tfstate
18+
19+
20+
>>> print_state.py
21+
"Custom Job Name"
22+
23+
>>> DATABRICKS_BUNDLE_ENGINE=direct [CLI] bundle plan --var=job_name=Custom Job Name
24+
Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged
25+
26+
>>> DATABRICKS_BUNDLE_ENGINE= [CLI] bundle destroy --var=job_name=Custom Job Name --auto-approve
27+
The following resources will be deleted:
28+
delete resources.jobs.test_job
29+
30+
All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/migrate-var-test/dev
31+
32+
Deleting files...
33+
Destroy complete!
34+
35+
>>> DATABRICKS_BUNDLE_ENGINE=terraform [CLI] bundle deploy --var job_name=Custom Job Name
36+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/migrate-var-test/dev/files...
37+
Deploying resources...
38+
Updating deployment state...
39+
Deployment complete!
40+
41+
>>> [CLI] bundle deployment migrate --var job_name=Custom Job Name
42+
Note: Migration should be done after a full deploy. Running plan now to verify that deployment was done:
43+
Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged
44+
Success! Migrated 1 resources to direct engine state file: [TEST_TMP_DIR]/.databricks/bundle/dev/resources.json
45+
46+
Validate the migration by running "databricks bundle plan --var 'job_name=Custom Job Name'", there should be no actions planned.
47+
48+
The state file is not synchronized to the workspace yet. To do that and finalize the migration, run "bundle deploy --var 'job_name=Custom Job Name'".
49+
50+
To undo the migration, remove [TEST_TMP_DIR]/.databricks/bundle/dev/resources.json and rename [TEST_TMP_DIR]/.databricks/bundle/dev/terraform/terraform.tfstate.backup to [TEST_TMP_DIR]/.databricks/bundle/dev/terraform/terraform.tfstate
51+
52+
53+
>>> print_state.py
54+
"Custom Job Name"
55+
56+
>>> DATABRICKS_BUNDLE_ENGINE=direct [CLI] bundle plan --var job_name=Custom Job Name
57+
Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged
58+
59+
>>> DATABRICKS_BUNDLE_ENGINE= [CLI] bundle destroy --var=job_name=Custom Job Name --auto-approve
60+
The following resources will be deleted:
61+
delete resources.jobs.test_job
62+
63+
All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/migrate-var-test/dev
64+
65+
Deleting files...
66+
Destroy complete!
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
trace DATABRICKS_BUNDLE_ENGINE=terraform $CLI bundle deploy --var="job_name=Custom Job Name"
2+
trace $CLI bundle deployment migrate --var="job_name=Custom Job Name" 2>&1 | contains.py 'Migrated 1 resources'
3+
trace print_state.py | jq '.state."resources.jobs.test_job".state.name'
4+
trace DATABRICKS_BUNDLE_ENGINE=direct $CLI bundle plan --var="job_name=Custom Job Name" | contains.py "1 unchanged"
5+
trace DATABRICKS_BUNDLE_ENGINE= $CLI bundle destroy --var="job_name=Custom Job Name" --auto-approve
6+
7+
# Try different syntax, '--var X', instead of '--var=X'
8+
rm -fr .databricks
9+
10+
# Deploy with Terraform using a variable
11+
trace DATABRICKS_BUNDLE_ENGINE=terraform $CLI bundle deploy --var "job_name=Custom Job Name"
12+
trace $CLI bundle deployment migrate --var "job_name=Custom Job Name" 2>&1 | contains.py 'Migrated 1 resources'
13+
trace print_state.py | jq '.state."resources.jobs.test_job".state.name'
14+
trace DATABRICKS_BUNDLE_ENGINE=direct $CLI bundle plan --var "job_name=Custom Job Name" | contains.py "1 unchanged"
15+
trace DATABRICKS_BUNDLE_ENGINE= $CLI bundle destroy --var="job_name=Custom Job Name" --auto-approve
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
RecordRequests = false

0 commit comments

Comments
 (0)