Skip to content

Commit 819274c

Browse files
authored
acc: add dashboards/unpublish-out-of-band test (#4266)
New test that shows difference between TF and direct when dashboard is unpublished out of band.
1 parent 74dea87 commit 819274c

File tree

12 files changed

+134
-0
lines changed

12 files changed

+134
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"pages":[{"name":"test-page","displayName":"Test Dashboard"}]}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
bundle:
2+
name: unpublish-out-of-band-${UNIQUE_NAME}
3+
4+
resources:
5+
dashboards:
6+
dashboard1:
7+
display_name: ${DASHBOARD_DISPLAY_NAME}
8+
warehouse_id: ${TEST_DEFAULT_WAREHOUSE_ID}
9+
file_path: ./dashboard.lvdash.json
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"plan_version": 2,
3+
"cli_version": "[DEV_VERSION]",
4+
"lineage": "[UUID]",
5+
"serial": 1,
6+
"plan": {
7+
"resources.dashboards.dashboard1": {
8+
"action": "create",
9+
"new_state": {
10+
"value": {
11+
"display_name": "test bundle-deploy-dashboard [UNIQUE_NAME])",
12+
"embed_credentials": false,
13+
"parent_path": "/Workspace/Users/[USERNAME]/.bundle/unpublish-out-of-band-[UNIQUE_NAME]/default/resources",
14+
"serialized_dashboard": "{\"pages\":[{\"name\":\"test-page\",\"displayName\":\"Test Dashboard\"}]}\n",
15+
"warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]"
16+
}
17+
},
18+
"changes": {
19+
"etag": {
20+
"action": "update",
21+
"reason": "remote_already_set",
22+
"old": [ETAG]
23+
}
24+
}
25+
}
26+
}
27+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
create dashboards.dashboard1
2+
3+
Plan: 1 to add, 0 to change, 0 to delete, 0 unchanged
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"plan_version": 2,
3+
"cli_version": "[DEV_VERSION]",
4+
"plan": {
5+
"resources.dashboards.dashboard1": {
6+
"action": "skip"
7+
}
8+
}
9+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged

acceptance/bundle/resources/dashboards/unpublish-out-of-band/out.test.toml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
>>> [CLI] bundle deploy
3+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/unpublish-out-of-band-[UNIQUE_NAME]/default/files...
4+
Deploying resources...
5+
Updating deployment state...
6+
Deployment complete!
7+
8+
>>> [CLI] lakeview get-published [DASHBOARD_ID]
9+
{
10+
"embed_credentials": false
11+
}
12+
13+
>>> [CLI] lakeview unpublish [DASHBOARD_ID]
14+
15+
=== Run bundle plan after unpublishing
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
export DASHBOARD_DISPLAY_NAME="test bundle-deploy-dashboard $UNIQUE_NAME)"
2+
3+
if [ -z "$CLOUD_ENV" ]; then
4+
export TEST_DEFAULT_WAREHOUSE_ID="warehouse-1234"
5+
echo "warehouse-1234:TEST_DEFAULT_WAREHOUSE_ID" >> ACC_REPLS
6+
fi
7+
8+
envsubst < databricks.yml.tmpl > databricks.yml
9+
10+
cleanup() {
11+
$CLI bundle destroy --auto-approve > /dev/null 2>&1
12+
}
13+
trap cleanup EXIT
14+
15+
# Deploy the dashboard
16+
trace $CLI bundle deploy
17+
DASHBOARD_ID=$($CLI bundle summary --output json | jq -r '.resources.dashboards.dashboard1.id')
18+
19+
# Capture the dashboard ID as a replacement.
20+
echo "$DASHBOARD_ID:DASHBOARD_ID" >> ACC_REPLS
21+
22+
# Verify dashboard was deployed and is published
23+
trace $CLI lakeview get-published $DASHBOARD_ID | jq '{embed_credentials}'
24+
25+
# Unpublish the dashboard out of band (simulating external action)
26+
trace $CLI lakeview unpublish $DASHBOARD_ID
27+
28+
title "Run bundle plan after unpublishing"
29+
# Terraform: shows "skip" because it only reads draft state, not published state
30+
# Direct: shows "create" because GetPublished returns 404, causing DoRead to fail
31+
$CLI bundle plan > out.plan.$DATABRICKS_BUNDLE_ENGINE.txt
32+
33+
$CLI bundle plan -o json > out.plan.$DATABRICKS_BUNDLE_ENGINE.json
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Local = true
2+
Cloud = true
3+
RequiresWarehouse = true
4+
RecordRequests = false
5+
6+
Ignore = [
7+
"databricks.yml",
8+
]

0 commit comments

Comments
 (0)