Skip to content

Commit 7c7fd13

Browse files
authored
Add an acceptance test for deploying a dashboard from a nested folder structure (#3007)
## Changes Added a new test that has a nested folder structure which reflects how some users are arranging their files in the bundle
1 parent 3e07e24 commit 7c7fd13

File tree

6 files changed

+100
-0
lines changed

6 files changed

+100
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"pages":[{"name":"02724bf2","displayName":"Dashboard test bundle-deploy-dashboard"}]}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
bundle:
2+
name: deploy-dashboard-nested-folders-$UNIQUE_NAME
3+
4+
include:
5+
- "resources/*.yml"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
>>> [CLI] bundle deploy
3+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/deploy-dashboard-nested-folders-[UNIQUE_NAME]/default/files...
4+
Deploying resources...
5+
Updating deployment state...
6+
Deployment complete!
7+
8+
>>> [CLI] lakeview get [DASHBOARD_ID]
9+
{
10+
"lifecycle_state": "ACTIVE",
11+
"parent_path": "/Users/[USERNAME]",
12+
"path": "/Users/[USERNAME]/test bundle-deploy-dashboard [UUID].lvdash.json",
13+
"serialized_dashboard": "{\"pages\":[{\"name\":\"02724bf2\",\"displayName\":\"Dashboard test bundle-deploy-dashboard\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}"
14+
}
15+
16+
>>> [CLI] bundle destroy --auto-approve
17+
The following resources will be deleted:
18+
delete dashboard dashboard1
19+
20+
All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/deploy-dashboard-nested-folders-[UNIQUE_NAME]/default
21+
22+
Deleting files...
23+
Destroy complete!
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
resources:
2+
dashboards:
3+
dashboard1:
4+
display_name: $DASHBOARD_DISPLAY_NAME
5+
warehouse_id: $TEST_DEFAULT_WAREHOUSE_ID
6+
embed_credentials: true
7+
file_path: ../dashboards/sample-dashboard.lvdash.json
8+
parent_path: /Users/$CURRENT_USER_NAME
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
DASHBOARD_DISPLAY_NAME="test bundle-deploy-dashboard $(uuid)"
2+
if [ -z "$CLOUD_ENV" ]; then
3+
DASHBOARD_DISPLAY_NAME="test bundle/deploy/ 6260d50f-e8ff-4905-8f28-812345678903" # use hard-coded uuid when running locally
4+
export TEST_DEFAULT_WAREHOUSE_ID="warehouse-1234"
5+
fi
6+
7+
export DASHBOARD_DISPLAY_NAME
8+
envsubst < databricks.yml.tmpl > databricks.yml
9+
envsubst < resources/dashboards.yml.tmpl > resources/dashboards.yml
10+
11+
cleanup() {
12+
trace $CLI bundle destroy --auto-approve
13+
}
14+
trap cleanup EXIT
15+
16+
trace $CLI bundle deploy
17+
DASHBOARD_ID=$($CLI bundle summary --output json | jq -r '.resources.dashboards.dashboard1.id')
18+
trace $CLI lakeview get $DASHBOARD_ID | jq '{lifecycle_state, parent_path, path, serialized_dashboard}'
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
Badness = "Cannot read dashboard, expecting deployment to succeed"
2+
Local = true
3+
Cloud = true
4+
RequiresWarehouse = true
5+
6+
Ignore = [
7+
"databricks.yml",
8+
"resources/dashboards.yml",
9+
]
10+
11+
[[Repls]]
12+
Old = "[0-9a-f]{32}"
13+
New = "[DASHBOARD_ID]"
14+
15+
[[Repls]]
16+
# Windows:
17+
Old = 'The system cannot find the file specified.'
18+
New = 'no such file or directory'
19+
20+
[[Server]]
21+
Pattern = "POST /api/2.0/lakeview/dashboards"
22+
Response.Body = '''
23+
{
24+
"dashboard_id":"1234567890abcdef1234567890abcdef"
25+
}
26+
'''
27+
28+
[[Server]]
29+
Pattern = "POST /api/2.0/lakeview/dashboards/{dashboard_id}/published"
30+
31+
[[Server]]
32+
Pattern = "GET /api/2.0/lakeview/dashboards/{dashboard_id}"
33+
Response.Body = '''
34+
{
35+
"dashboard_id":"1234567890abcdef1234567890abcdef",
36+
"display_name": "test dashboard 6260d50f-e8ff-4905-8f28-812345678903",
37+
"lifecycle_state": "ACTIVE",
38+
"path": "/Users/[USERNAME]/test bundle-deploy-dashboard 6260d50f-e8ff-4905-8f28-812345678903.lvdash.json",
39+
"parent_path": "/Users/tester@databricks.com",
40+
"serialized_dashboard": "{\"pages\":[{\"name\":\"02724bf2\",\"displayName\":\"Dashboard test bundle-deploy-dashboard\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}"
41+
}
42+
'''
43+
44+
[[Server]]
45+
Pattern = "DELETE /api/2.0/lakeview/dashboards/{dashboard_id}"

0 commit comments

Comments
 (0)