Skip to content

Commit 269ccc4

Browse files
authored
testserver: add permissions, add ids to more resources (#3730)
## Changes - Add permissions CRUD for arbitrary types, no longer need custom handlers in test.toml - Add a helper to get unique IDs, use it everywhere instead of per-type counters. - Add ids to objects that were previously missing them: directories, files, dashboards, repos. ## Tests Existing tests that defined custom Server block test.toml switched to built-in implementation.
1 parent 73b65eb commit 269ccc4

File tree

21 files changed

+598
-154
lines changed

21 files changed

+598
-154
lines changed
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
Local = true
22
Cloud = false
33
RecordRequests = true
4-
5-
[[Server]]
6-
Pattern = "PUT /api/2.0/permissions/directories/{objectId}"

acceptance/bundle/deployment/unbind/permissions/output.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Deployment complete!
1111
{
1212
"all_permissions": [
1313
{
14-
"inherited": false,
1514
"permission_level": "CAN_MANAGE"
1615
}
1716
],
@@ -32,7 +31,6 @@ Deployment complete!
3231
{
3332
"all_permissions": [
3433
{
35-
"inherited": false,
3634
"permission_level": "CAN_MANAGE"
3735
}
3836
],
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
{
2+
"method": "POST",
3+
"path": "/api/2.0/pipelines",
4+
"body": {
5+
"channel": "CURRENT",
6+
"configuration": {
7+
"bundle.sourcePath": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/files/src"
8+
},
9+
"deployment": {
10+
"kind": "BUNDLE",
11+
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/state/metadata.json"
12+
},
13+
"edition": "ADVANCED",
14+
"libraries": [
15+
{
16+
"notebook": {
17+
"path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/files/src/pipeline"
18+
}
19+
}
20+
],
21+
"name": "my_default_python_pipeline",
22+
"schema": "my_default_python_prod"
23+
}
24+
}
25+
{
26+
"method": "POST",
27+
"path": "/api/2.0/workspace/delete",
28+
"body": {
29+
"path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/artifacts/.internal",
30+
"recursive": true
31+
}
32+
}
33+
{
34+
"method": "POST",
35+
"path": "/api/2.0/workspace/delete",
36+
"body": {
37+
"path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/state/deploy.lock"
38+
}
39+
}
40+
{
41+
"method": "POST",
42+
"path": "/api/2.0/workspace/mkdirs",
43+
"body": {
44+
"path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/artifacts/.internal"
45+
}
46+
}
47+
{
48+
"method": "POST",
49+
"path": "/api/2.0/workspace/mkdirs",
50+
"body": {
51+
"path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/files/.vscode"
52+
}
53+
}
54+
{
55+
"method": "POST",
56+
"path": "/api/2.0/workspace/mkdirs",
57+
"body": {
58+
"path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/files/fixtures"
59+
}
60+
}
61+
{
62+
"method": "POST",
63+
"path": "/api/2.0/workspace/mkdirs",
64+
"body": {
65+
"path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/files/resources"
66+
}
67+
}
68+
{
69+
"method": "POST",
70+
"path": "/api/2.0/workspace/mkdirs",
71+
"body": {
72+
"path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/files/src/my_default_python"
73+
}
74+
}
75+
{
76+
"method": "POST",
77+
"path": "/api/2.0/workspace/mkdirs",
78+
"body": {
79+
"path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/files/tests"
80+
}
81+
}
82+
{
83+
"method": "POST",
84+
"path": "/api/2.2/jobs/create",
85+
"body": {
86+
"deployment": {
87+
"kind": "BUNDLE",
88+
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/state/metadata.json"
89+
},
90+
"edit_mode": "UI_LOCKED",
91+
"format": "MULTI_TASK",
92+
"job_clusters": [
93+
{
94+
"job_cluster_key": "job_cluster",
95+
"new_cluster": {
96+
"autoscale": {
97+
"max_workers": 4,
98+
"min_workers": 1
99+
},
100+
"data_security_mode": "SINGLE_USER",
101+
"node_type_id": "[NODE_TYPE_ID]",
102+
"num_workers": 0,
103+
"spark_version": "15.4.x-scala2.12"
104+
}
105+
}
106+
],
107+
"max_concurrent_runs": 1,
108+
"name": "my_default_python_job",
109+
"queue": {
110+
"enabled": true
111+
},
112+
"tasks": [
113+
{
114+
"depends_on": [
115+
{
116+
"task_key": "refresh_pipeline"
117+
}
118+
],
119+
"job_cluster_key": "job_cluster",
120+
"libraries": [
121+
{
122+
"whl": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/artifacts/.internal/my_default_python-0.0.1-py3-none-any.whl"
123+
}
124+
],
125+
"python_wheel_task": {
126+
"entry_point": "main",
127+
"package_name": "my_default_python"
128+
},
129+
"task_key": "main_task"
130+
},
131+
{
132+
"job_cluster_key": "job_cluster",
133+
"notebook_task": {
134+
"notebook_path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/files/src/notebook"
135+
},
136+
"task_key": "notebook_task"
137+
},
138+
{
139+
"depends_on": [
140+
{
141+
"task_key": "notebook_task"
142+
}
143+
],
144+
"pipeline_task": {
145+
"pipeline_id": "[UUID]"
146+
},
147+
"task_key": "refresh_pipeline"
148+
}
149+
],
150+
"trigger": {
151+
"pause_status": "UNPAUSED",
152+
"periodic": {
153+
"interval": 1,
154+
"unit": "DAYS"
155+
}
156+
}
157+
}
158+
}
159+
{
160+
"method": "PUT",
161+
"path": "/api/2.0/permissions/directories/[NUMID]",
162+
"body": {
163+
"access_control_list": [
164+
{
165+
"permission_level": "CAN_MANAGE",
166+
"user_name": "[USERNAME]"
167+
}
168+
]
169+
}
170+
}
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
{
2+
"method": "POST",
3+
"path": "/api/2.0/pipelines",
4+
"body": {
5+
"channel": "CURRENT",
6+
"configuration": {
7+
"bundle.sourcePath": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/files/src"
8+
},
9+
"deployment": {
10+
"kind": "BUNDLE",
11+
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/state/metadata.json"
12+
},
13+
"edition": "ADVANCED",
14+
"libraries": [
15+
{
16+
"notebook": {
17+
"path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/files/src/pipeline"
18+
}
19+
}
20+
],
21+
"name": "my_default_python_pipeline",
22+
"schema": "my_default_python_prod"
23+
}
24+
}
25+
{
26+
"method": "POST",
27+
"path": "/api/2.0/workspace/delete",
28+
"body": {
29+
"path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/artifacts/.internal",
30+
"recursive": true
31+
}
32+
}
33+
{
34+
"method": "POST",
35+
"path": "/api/2.0/workspace/delete",
36+
"body": {
37+
"path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/state/deploy.lock"
38+
}
39+
}
40+
{
41+
"method": "POST",
42+
"path": "/api/2.0/workspace/mkdirs",
43+
"body": {
44+
"path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/artifacts/.internal"
45+
}
46+
}
47+
{
48+
"method": "POST",
49+
"path": "/api/2.0/workspace/mkdirs",
50+
"body": {
51+
"path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/files/.vscode"
52+
}
53+
}
54+
{
55+
"method": "POST",
56+
"path": "/api/2.0/workspace/mkdirs",
57+
"body": {
58+
"path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/files/fixtures"
59+
}
60+
}
61+
{
62+
"method": "POST",
63+
"path": "/api/2.0/workspace/mkdirs",
64+
"body": {
65+
"path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/files/resources"
66+
}
67+
}
68+
{
69+
"method": "POST",
70+
"path": "/api/2.0/workspace/mkdirs",
71+
"body": {
72+
"path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/files/src/my_default_python"
73+
}
74+
}
75+
{
76+
"method": "POST",
77+
"path": "/api/2.0/workspace/mkdirs",
78+
"body": {
79+
"path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/files/tests"
80+
}
81+
}
82+
{
83+
"method": "POST",
84+
"path": "/api/2.2/jobs/create",
85+
"body": {
86+
"deployment": {
87+
"kind": "BUNDLE",
88+
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/state/metadata.json"
89+
},
90+
"edit_mode": "UI_LOCKED",
91+
"format": "MULTI_TASK",
92+
"job_clusters": [
93+
{
94+
"job_cluster_key": "job_cluster",
95+
"new_cluster": {
96+
"autoscale": {
97+
"max_workers": 4,
98+
"min_workers": 1
99+
},
100+
"data_security_mode": "SINGLE_USER",
101+
"node_type_id": "[NODE_TYPE_ID]",
102+
"spark_version": "15.4.x-scala2.12"
103+
}
104+
}
105+
],
106+
"max_concurrent_runs": 1,
107+
"name": "my_default_python_job",
108+
"queue": {
109+
"enabled": true
110+
},
111+
"tasks": [
112+
{
113+
"depends_on": [
114+
{
115+
"task_key": "refresh_pipeline"
116+
}
117+
],
118+
"job_cluster_key": "job_cluster",
119+
"libraries": [
120+
{
121+
"whl": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/artifacts/.internal/my_default_python-0.0.1-py3-none-any.whl"
122+
}
123+
],
124+
"python_wheel_task": {
125+
"entry_point": "main",
126+
"package_name": "my_default_python"
127+
},
128+
"task_key": "main_task"
129+
},
130+
{
131+
"job_cluster_key": "job_cluster",
132+
"notebook_task": {
133+
"notebook_path": "/Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/files/src/notebook",
134+
"source": "WORKSPACE"
135+
},
136+
"task_key": "notebook_task"
137+
},
138+
{
139+
"depends_on": [
140+
{
141+
"task_key": "notebook_task"
142+
}
143+
],
144+
"pipeline_task": {
145+
"pipeline_id": "[UUID]"
146+
},
147+
"task_key": "refresh_pipeline"
148+
}
149+
],
150+
"trigger": {
151+
"pause_status": "UNPAUSED",
152+
"periodic": {
153+
"interval": 1,
154+
"unit": "DAYS"
155+
}
156+
}
157+
}
158+
}
159+
{
160+
"method": "PUT",
161+
"path": "/api/2.0/permissions/directories/[NUMID]",
162+
"body": {
163+
"access_control_list": [
164+
{
165+
"permission_level": "CAN_MANAGE",
166+
"user_name": "[USERNAME]"
167+
}
168+
]
169+
}
170+
}

acceptance/bundle/templates/default-python/classic/output.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,11 @@ Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/my_default_python/
5252
Deploying resources...
5353
Updating deployment state...
5454
Deployment complete!
55+
56+
>>> [CLI] bundle deploy -t prod
57+
Building python_artifact...
58+
Uploading dist/my_default_python-0.0.1-py3-none-any.whl...
59+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/my_default_python/prod/files...
60+
Deploying resources...
61+
Updating deployment state...
62+
Deployment complete!

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ trace $CLI bundle deploy -t dev
1515
jq -c < ../../out.requests.txt | sort | jq 'select(.method != "GET" and (.path | contains("/import-file/") | not) and (.path | contains("/telemetry-ext") | not))' > ../../out.requests.dev.$DATABRICKS_BUNDLE_ENGINE.txt
1616

1717
rm ../../out.requests.txt
18-
# TODO: fails on testserver with 501 Not Implemented on PUT [DATABRICKS_URL]/api/2.0/permissions/directories/0
19-
#trace errcode $CLI bundle deploy -t prod
20-
#jq -c < ../../out.requests.txt | sort | jq 'select(.method != "GET" and (.path | contains("/import-file/") | not) and (.path | contains("/telemetry-ext") | not))' > ../../out.requests.prod.$DATABRICKS_BUNDLE_ENGINE.txt
21-
#rm ../../out.requests.txt
18+
trace $CLI bundle deploy -t prod
19+
jq -c < ../../out.requests.txt | sort | jq 'select(.method != "GET" and (.path | contains("/import-file/") | not) and (.path | contains("/telemetry-ext") | not))' > ../../out.requests.prod.$DATABRICKS_BUNDLE_ENGINE.txt
20+
rm ../../out.requests.txt
2221

2322
# Do not affect this repository's git behaviour #2318
2423
mv .gitignore out.gitignore

0 commit comments

Comments
 (0)