Skip to content

Commit dbd5096

Browse files
authored
acc: Added a test to reproduce run_as not being reset when removed from bundle config (#4942)
## Changes Added a test to reproduce run_as not being reset when removed from bundle config ## Why Reproducing #4873 <!-- If your PR needs to be included in the release notes for next release, add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
1 parent c7771a8 commit dbd5096

6 files changed

Lines changed: 160 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
bundle:
2+
name: "run_as_job_default"
3+
4+
resources:
5+
jobs:
6+
job_with_run_as:
7+
tasks:
8+
- task_key: "task_one"
9+
notebook_task:
10+
notebook_path: "./test.py"
11+
new_cluster:
12+
spark_version: $DEFAULT_SPARK_VERSION
13+
node_type_id: $NODE_TYPE_ID
14+
num_workers: 1
15+
run_as:
16+
user_name: deco-test-user@databricks.com

acceptance/bundle/run_as/job_default/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: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
2+
=== Deploy with run_as
3+
>>> [CLI] bundle deploy
4+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/run_as_job_default/default/files...
5+
Deploying resources...
6+
Updating deployment state...
7+
Deployment complete!
8+
9+
>>> print_requests.py //jobs
10+
{
11+
"method": "POST",
12+
"path": "/api/2.2/jobs/create",
13+
"body": {
14+
"deployment": {
15+
"kind": "BUNDLE",
16+
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/run_as_job_default/default/state/metadata.json"
17+
},
18+
"edit_mode": "UI_LOCKED",
19+
"format": "MULTI_TASK",
20+
"max_concurrent_runs": 1,
21+
"name": "Untitled",
22+
"queue": {
23+
"enabled": true
24+
},
25+
"run_as": {
26+
"user_name": "deco-test-user@databricks.com"
27+
},
28+
"tasks": [
29+
{
30+
"new_cluster": {
31+
"node_type_id": "[NODE_TYPE_ID]",
32+
"num_workers": 1,
33+
"spark_version": "13.3.x-snapshot-scala2.12"
34+
},
35+
"notebook_task": {
36+
"notebook_path": "/Workspace/Users/[USERNAME]/.bundle/run_as_job_default/default/files/test"
37+
},
38+
"task_key": "task_one"
39+
}
40+
]
41+
}
42+
}
43+
44+
>>> [CLI] jobs get [NUMID]
45+
{
46+
"user_name": "deco-test-user@databricks.com"
47+
}
48+
49+
=== Remove run_as and redeploy
50+
>>> [CLI] bundle plan
51+
update jobs.job_with_run_as
52+
53+
Plan: 0 to add, 1 to change, 0 to delete, 0 unchanged
54+
55+
>>> [CLI] bundle deploy
56+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/run_as_job_default/default/files...
57+
Deploying resources...
58+
Updating deployment state...
59+
Deployment complete!
60+
61+
>>> print_requests.py //jobs
62+
{
63+
"method": "POST",
64+
"path": "/api/2.2/jobs/reset",
65+
"body": {
66+
"job_id": [NUMID],
67+
"new_settings": {
68+
"deployment": {
69+
"kind": "BUNDLE",
70+
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/run_as_job_default/default/state/metadata.json"
71+
},
72+
"edit_mode": "UI_LOCKED",
73+
"format": "MULTI_TASK",
74+
"max_concurrent_runs": 1,
75+
"name": "Untitled",
76+
"queue": {
77+
"enabled": true
78+
},
79+
"tasks": [
80+
{
81+
"new_cluster": {
82+
"node_type_id": "[NODE_TYPE_ID]",
83+
"num_workers": 1,
84+
"spark_version": "13.3.x-snapshot-scala2.12"
85+
},
86+
"notebook_task": {
87+
"notebook_path": "/Workspace/Users/[USERNAME]/.bundle/run_as_job_default/default/files/test"
88+
},
89+
"task_key": "task_one"
90+
}
91+
]
92+
}
93+
}
94+
}
95+
96+
>>> [CLI] jobs get [NUMID]
97+
{
98+
"user_name": "deco-test-user@databricks.com"
99+
}
100+
101+
>>> [CLI] bundle destroy --auto-approve
102+
The following resources will be deleted:
103+
delete resources.jobs.job_with_run_as
104+
105+
All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/run_as_job_default/default
106+
107+
Deleting files...
108+
Destroy complete!
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
envsubst < databricks.yml.tmpl > databricks.yml
2+
3+
cleanup() {
4+
trace $CLI bundle destroy --auto-approve
5+
rm -f out.requests.txt
6+
}
7+
trap cleanup EXIT
8+
9+
title "Deploy with run_as"
10+
trace $CLI bundle deploy
11+
trace print_requests.py //jobs | contains.py "!GET" "POST"
12+
JOB_ID=$($CLI bundle summary -o json | jq -r '.resources.jobs.job_with_run_as.id')
13+
trace $CLI jobs get $JOB_ID | jq -r '.settings.run_as'
14+
15+
update_file.py databricks.yml "run_as:
16+
user_name: deco-test-user@databricks.com" ''
17+
18+
title "Remove run_as and redeploy"
19+
trace $CLI bundle plan
20+
trace $CLI bundle deploy
21+
trace print_requests.py //jobs | contains.py "!GET" "POST"
22+
trace $CLI jobs get $JOB_ID | jq -r '.settings.run_as'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Databricks notebook source
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Badness = "run_as is still set even though it's not in bundle and not in reset request"
2+
3+
Local = false
4+
Cloud = true
5+
RecordRequests = true
6+
7+
[EnvMatrix]
8+
DATABRICKS_BUNDLE_ENGINE = ["terraform", "direct"]

0 commit comments

Comments
 (0)