Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
986 changes: 986 additions & 0 deletions acceptance/bundle/refschema/out.fields.txt

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions acceptance/bundle/resources/job_runs/basic/databricks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
bundle:
name: job-runs-basic

resources:
jobs:
my_job:
name: my-job
tasks:
- task_key: main
notebook_task:
notebook_path: /Workspace/test
Comment thread
radakam marked this conversation as resolved.

job_runs:
my_run:
job_id: ${resources.jobs.my_job.id}
3 changes: 3 additions & 0 deletions acceptance/bundle/resources/job_runs/basic/out.test.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

90 changes: 90 additions & 0 deletions acceptance/bundle/resources/job_runs/basic/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@

=== deploy triggers exactly one run
>>> [CLI] bundle validate
Name: job-runs-basic
Target: default
Workspace:
User: [USERNAME]
Path: /Workspace/Users/[USERNAME]/.bundle/job-runs-basic/default

Validation OK!

>>> [CLI] bundle plan
create job_runs.my_run
create jobs.my_job

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

>>> [CLI] bundle summary
Name: job-runs-basic
Target: default
Workspace:
User: [USERNAME]
Path: /Workspace/Users/[USERNAME]/.bundle/job-runs-basic/default
Resources:
Job Runs:
my_run:
Name:
URL: (not deployed)
Jobs:
my_job:
Name: my-job
URL: (not deployed)

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/job-runs-basic/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/job-runs-basic/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!

>>> [CLI] bundle plan
Plan: 0 to add, 0 to change, 0 to delete, 2 unchanged

>>> [CLI] bundle summary
Name: job-runs-basic
Target: default
Workspace:
User: [USERNAME]
Path: /Workspace/Users/[USERNAME]/.bundle/job-runs-basic/default
Resources:
Job Runs:
my_run:
Name:
URL: (not deployed)
Jobs:
my_job:
Name: my-job
URL: [DATABRICKS_URL]/jobs/[MY_JOB_ID]?w=[NUMID]

=== exactly one run-now request was made
>>> print_requests.py //jobs/run-now
{
"method": "POST",
"path": "/api/2.2/jobs/run-now",
"body": {
"job_id": [MY_JOB_ID]
}
}

=== the triggered run id is stored in state
>>> read_id.py my_run
[MY_RUN_ID]

>>> read_id.py my_job
[MY_JOB_ID]

>>> [CLI] bundle destroy --auto-approve
The following resources will be deleted:
delete resources.job_runs.my_run
delete resources.jobs.my_job

All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/job-runs-basic/default

Deleting files...
Destroy complete!
24 changes: 24 additions & 0 deletions acceptance/bundle/resources/job_runs/basic/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
cleanup() {
trace $CLI bundle destroy --auto-approve
rm out.requests.txt
}
trap cleanup EXIT

title "deploy triggers exactly one run"
trace $CLI bundle validate
trace $CLI bundle plan
trace $CLI bundle summary
trace $CLI bundle deploy
Comment thread
radakam marked this conversation as resolved.
Comment thread
radakam marked this conversation as resolved.

# confirm that redeploy does not trigger a second run
trace $CLI bundle deploy

trace $CLI bundle plan
trace $CLI bundle summary

title "exactly one run-now request was made"
trace print_requests.py //jobs/run-now

title "the triggered run id is stored in state"
trace read_id.py my_run
trace read_id.py my_job
4 changes: 4 additions & 0 deletions acceptance/bundle/resources/job_runs/basic/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# job_runs is a direct-engine-only resource; the Terraform provider has no
# equivalent, so restrict the matrix to direct.
EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"]
RecordRequests = true
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
bundle:
name: job-runs-notebook-change

resources:
jobs:
my_job:
name: my-job
tasks:
- task_key: main
notebook_task:
notebook_path: /Workspace/test

job_runs:
my_run:
job_id: ${resources.jobs.my_job.id}
job_parameters:
env: dev
# Snapshot the whole job so any change to it (e.g. notebook_path) re-triggers the run.
job_settings: ${resources.jobs.my_job}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

85 changes: 85 additions & 0 deletions acceptance/bundle/resources/job_runs/notebook_change/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@

=== initial deploy triggers the first run
>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/job-runs-notebook-change/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!

>>> print_requests.py //jobs/run-now
{
"method": "POST",
"path": "/api/2.2/jobs/run-now",
"body": {
"job_id": [NUMID],
"job_parameters": {
"env": "dev"
}
}
}

=== change the job notebook_path and redeploy
>>> update_file.py databricks.yml notebook_path: /Workspace/test notebook_path: /Workspace/other

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/job-runs-notebook-change/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!

>>> [CLI] bundle plan
Plan: 0 to add, 0 to change, 0 to delete, 2 unchanged

=== the job was updated with the new notebook_path
>>> print_requests.py --keep //jobs/reset
{
"method": "POST",
"path": "/api/2.2/jobs/reset",
"body": {
"job_id": [NUMID],
"new_settings": {
"deployment": {
"kind": "BUNDLE",
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/job-runs-notebook-change/default/state/metadata.json"
},
"edit_mode": "UI_LOCKED",
"format": "MULTI_TASK",
"max_concurrent_runs": 1,
"name": "my-job",
"queue": {
"enabled": true
},
"tasks": [
{
"notebook_task": {
"notebook_path": "/Workspace/other"
},
"task_key": "main"
}
]
}
}
}

=== the job change re-triggered the run via the job_settings snapshot
>>> print_requests.py //jobs/run-now
{
"method": "POST",
"path": "/api/2.2/jobs/run-now",
"body": {
"job_id": [NUMID],
"job_parameters": {
"env": "dev"
}
}
}

>>> [CLI] bundle destroy --auto-approve
The following resources will be deleted:
delete resources.job_runs.my_run
delete resources.jobs.my_job

All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/job-runs-notebook-change/default

Deleting files...
Destroy complete!
20 changes: 20 additions & 0 deletions acceptance/bundle/resources/job_runs/notebook_change/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cleanup() {
trace $CLI bundle destroy --auto-approve
rm out.requests.txt
}
trap cleanup EXIT

title "initial deploy triggers the first run"
trace $CLI bundle deploy
trace print_requests.py //jobs/run-now

title "change the job notebook_path and redeploy"
trace update_file.py databricks.yml "notebook_path: /Workspace/test" "notebook_path: /Workspace/other"
trace $CLI bundle deploy
trace $CLI bundle plan

title "the job was updated with the new notebook_path"
trace print_requests.py --keep //jobs/reset

title "the job change re-triggered the run via the job_settings snapshot"
trace print_requests.py //jobs/run-now
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# job_runs is a direct-engine-only resource; the Terraform provider has no
# equivalent, so restrict the matrix to direct.
EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"]
RecordRequests = true
17 changes: 17 additions & 0 deletions acceptance/bundle/resources/job_runs/redeploy/databricks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
bundle:
name: job-runs-redeploy

resources:
jobs:
my_job:
name: my-job
tasks:
- task_key: main
notebook_task:
notebook_path: /Workspace/test

job_runs:
my_run:
job_id: ${resources.jobs.my_job.id}
job_parameters:
env: dev
3 changes: 3 additions & 0 deletions acceptance/bundle/resources/job_runs/redeploy/out.test.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

92 changes: 92 additions & 0 deletions acceptance/bundle/resources/job_runs/redeploy/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@

=== initial deploy triggers the first run
>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/job-runs-redeploy/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!

>>> [CLI] bundle plan
Plan: 0 to add, 0 to change, 0 to delete, 2 unchanged

>>> [CLI] bundle summary
Name: job-runs-redeploy
Target: default
Workspace:
User: [USERNAME]
Path: /Workspace/Users/[USERNAME]/.bundle/job-runs-redeploy/default
Resources:
Job Runs:
my_run:
Name:
URL: (not deployed)
Jobs:
my_job:
Name: my-job
URL: [DATABRICKS_URL]/jobs/[MY_JOB_ID]?w=[NUMID]

>>> read_id.py my_job
[MY_JOB_ID]

>>> print_requests.py //jobs/run-now
{
"method": "POST",
"path": "/api/2.2/jobs/run-now",
"body": {
"job_id": [MY_JOB_ID],
"job_parameters": {
"env": "dev"
}
}
}

=== change the run configuration and redeploy
>>> update_file.py databricks.yml env: dev env: prod

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/job-runs-redeploy/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!

>>> [CLI] bundle plan
Plan: 0 to add, 0 to change, 0 to delete, 2 unchanged

>>> [CLI] bundle summary
Name: job-runs-redeploy
Target: default
Workspace:
User: [USERNAME]
Path: /Workspace/Users/[USERNAME]/.bundle/job-runs-redeploy/default
Resources:
Job Runs:
my_run:
Name:
URL: (not deployed)
Jobs:
my_job:
Name: my-job
URL: [DATABRICKS_URL]/jobs/[MY_JOB_ID]?w=[NUMID]

=== the config change triggered a second, different run
>>> print_requests.py //jobs/run-now
{
"method": "POST",
"path": "/api/2.2/jobs/run-now",
"body": {
"job_id": [MY_JOB_ID],
"job_parameters": {
"env": "prod"
}
}
}

>>> [CLI] bundle destroy --auto-approve
The following resources will be deleted:
delete resources.job_runs.my_run
delete resources.jobs.my_job

All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/job-runs-redeploy/default

Deleting files...
Destroy complete!
Loading
Loading