Skip to content

Commit e8aa56f

Browse files
authored
acc: simulate dashboard eventual consistency and harden dashboard tests (databricks#5724)
Follow-up to databricks#5694. We've seen the dashboard API be eventually consistent: a GET right after a create can 404 before the write propagates. The dashboard acceptance tests run on cloud (`Cloud = true`) and read a dashboard immediately after deploy, so they are exposed to this. - Add a testserver EC mode for dashboards: under the eventual-consistency token (opt-in via `TESTS_STALE_ONCE=1`, direct engine only) the first GET of a dashboard after it is created returns 404. This reproduces the cloud window deterministically. - Enable it for the dashboards directory and wrap the first `lakeview get` after each create with `retry.py`, so reads right after deploy are retried rather than assumed to succeed. Test-only: no engine changes. Making the direct engine itself resilient to the same 404 (plan/refresh reads) is a separate follow-up. This pull request and its description were written by Isaac.
1 parent cf2525d commit e8aa56f

36 files changed

Lines changed: 253 additions & 95 deletions

File tree

acceptance/acceptance_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ func runTest(t *testing.T,
767767
args := []string{"bash", "-euo", "pipefail", EntryPointScript}
768768
cmd := exec.CommandContext(ctx, args[0], args[1:]...)
769769

770-
cfg, user := internal.PrepareServerAndClient(t, config, LogRequests, tmpDir)
770+
cfg, user := internal.PrepareServerAndClient(t, config, LogRequests, tmpDir, testEnv)
771771
testdiff.PrepareReplacementsUser(t, &repls, user)
772772
testdiff.PrepareReplacementsWorkspaceConfig(t, &repls, cfg)
773773

acceptance/bundle/resources/dashboards/change-embed-credentials/output.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/change-embed-crede
99
Deploying resources...
1010
Updating deployment state...
1111
Deployment complete!
12-
13-
>>> [CLI] lakeview get [DASHBOARD_ID]
1412
{
1513
"display_name": "test dashboard",
1614
"lifecycle_state": "ACTIVE",
@@ -36,8 +34,6 @@ Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/change-embed-crede
3634
Deploying resources...
3735
Updating deployment state...
3836
Deployment complete!
39-
40-
>>> [CLI] lakeview get [DASHBOARD_ID]
4137
{
4238
"display_name": "test dashboard",
4339
"lifecycle_state": "ACTIVE",

acceptance/bundle/resources/dashboards/change-embed-credentials/script

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,16 @@ deploy_dashboard() {
1515
trace $CLI bundle deploy
1616
dashboard_id=$($CLI bundle summary --output json | jq -r '.resources.dashboards.my_dashboard.id')
1717

18-
trace $CLI lakeview get $dashboard_id | jq "{display_name, lifecycle_state, parent_path, path, serialized_dashboard, warehouse_id}"
18+
DASHBOARD=$(retry $CLI lakeview get $dashboard_id)
19+
echo "$dashboard_id:DASHBOARD_ID" >> ACC_REPLS
20+
echo "$(echo "$DASHBOARD" | jq -r '.etag'):ETAG" >> ACC_REPLS
21+
echo "$DASHBOARD" | jq "{display_name, lifecycle_state, parent_path, path, serialized_dashboard, warehouse_id}"
1922
trace $CLI lakeview get-published $dashboard_id | jq "{warehouse_id, embed_credentials}"
2023
}
2124

2225
# Create the dashboard with embed_credentials=false
2326
deploy_dashboard
2427

25-
# Capture the dashboard ID as a replacement.
26-
dashboard_id=$($CLI bundle summary --output json | jq -r '.resources.dashboards.my_dashboard.id')
27-
echo "$dashboard_id:DASHBOARD_ID" >> ACC_REPLS
28-
echo "$($CLI lakeview get $dashboard_id | jq -r '.etag'):ETAG" >> ACC_REPLS
29-
3028
# Change embed_credentials to true - this should trigger an update
3129
export EMBED_CREDENTIALS="true"
3230
deploy_dashboard

acceptance/bundle/resources/dashboards/change-name/output.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/change-name-[UNIQU
99
Deploying resources...
1010
Updating deployment state...
1111
Deployment complete!
12-
13-
>>> [CLI] lakeview get [DASHBOARD_ID]
1412
{
1513
"display_name": "dashboard1",
1614
"lifecycle_state": "ACTIVE",
@@ -30,8 +28,6 @@ Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/change-name-[UNIQU
3028
Deploying resources...
3129
Updating deployment state...
3230
Deployment complete!
33-
34-
>>> [CLI] lakeview get [DASHBOARD_ID]
3531
{
3632
"display_name": "dashboard2",
3733
"lifecycle_state": "ACTIVE",

acceptance/bundle/resources/dashboards/change-name/script

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ deploy_dashboard() {
1212
trace $CLI bundle plan
1313
trace $CLI bundle deploy
1414
dashboard_id=$($CLI bundle summary --output json | jq -r '.resources.dashboards.my_dashboard.id')
15-
trace $CLI lakeview get $dashboard_id | jq '{display_name, lifecycle_state, parent_path, path, serialized_dashboard, warehouse_id}'
15+
# Wait out eventual consistency: retry until the current name is visible (the read
16+
# 404s on create and returns the stale name right after a rename).
17+
DASHBOARD=$(retry --until "$NAME" $CLI lakeview get $dashboard_id)
18+
echo "$DASHBOARD" | jq '{display_name, lifecycle_state, parent_path, path, serialized_dashboard, warehouse_id}'
1619
}
1720

1821
# Create the dashboard
@@ -21,7 +24,7 @@ deploy_dashboard
2124
# Capture the dashboard ID as a replacement.
2225
dashboard_id=$($CLI bundle summary --output json | jq -r '.resources.dashboards.my_dashboard.id')
2326
echo "$dashboard_id:DASHBOARD_ID" >> ACC_REPLS
24-
echo "$($CLI lakeview get $dashboard_id | jq -r '.etag'):ETAG" >> ACC_REPLS
27+
echo "$(echo "$DASHBOARD" | jq -r '.etag'):ETAG" >> ACC_REPLS
2528

2629
# Change the name
2730
export NAME="dashboard2"

acceptance/bundle/resources/dashboards/change-parent-path/output.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Deploying resources...
1010
Updating deployment state...
1111
Deployment complete!
1212

13-
>>> [CLI] lakeview get [ORIGINAL_DASHBOARD_ID]
13+
>>> retry [CLI] lakeview get [ORIGINAL_DASHBOARD_ID]
1414
{
1515
"display_name": "test dashboard",
1616
"lifecycle_state": "ACTIVE",
@@ -35,7 +35,7 @@ Deploying resources...
3535
Updating deployment state...
3636
Deployment complete!
3737

38-
>>> [CLI] lakeview get [NEW_DASHBOARD_ID]
38+
>>> retry [CLI] lakeview get [NEW_DASHBOARD_ID]
3939
{
4040
"display_name": "test dashboard",
4141
"lifecycle_state": "ACTIVE",

acceptance/bundle/resources/dashboards/change-parent-path/script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ deploy_dashboard() {
1414
trace $CLI bundle plan
1515
trace $CLI bundle deploy --auto-approve
1616
dashboard_id=$($CLI bundle summary --output json | jq -r '.resources.dashboards.my_dashboard.id')
17-
trace $CLI lakeview get $dashboard_id | jq '{display_name, lifecycle_state, parent_path, path, serialized_dashboard, warehouse_id}'
17+
trace retry $CLI lakeview get $dashboard_id | jq '{display_name, lifecycle_state, parent_path, path, serialized_dashboard, warehouse_id}'
1818
}
1919

2020
# Create the dashboard with initial parent_path

acceptance/bundle/resources/dashboards/change-serialized-dashboard/output.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,13 @@ Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/change-serialized-
99
Deploying resources...
1010
Updating deployment state...
1111
Deployment complete!
12-
13-
>>> [CLI] lakeview get [DASHBOARD_ID]
1412
{
1513
"display_name": "test dashboard",
1614
"lifecycle_state": "ACTIVE",
1715
"parent_path": "/Users/[USERNAME]/.bundle/change-serialized-dashboard-[UNIQUE_NAME]/default/resources",
1816
"path": "/Users/[USERNAME]/.bundle/change-serialized-dashboard-[UNIQUE_NAME]/default/resources/test dashboard.lvdash.json",
1917
"warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]"
2018
}
21-
22-
>>> [CLI] lakeview get [DASHBOARD_ID]
2319
{
2420
"displayName": "name1",
2521
"name": "name1",
@@ -36,17 +32,13 @@ Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/change-serialized-
3632
Deploying resources...
3733
Updating deployment state...
3834
Deployment complete!
39-
40-
>>> [CLI] lakeview get [DASHBOARD_ID]
4135
{
4236
"display_name": "test dashboard",
4337
"lifecycle_state": "ACTIVE",
4438
"parent_path": "/Users/[USERNAME]/.bundle/change-serialized-dashboard-[UNIQUE_NAME]/default/resources",
4539
"path": "/Users/[USERNAME]/.bundle/change-serialized-dashboard-[UNIQUE_NAME]/default/resources/test dashboard.lvdash.json",
4640
"warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]"
4741
}
48-
49-
>>> [CLI] lakeview get [DASHBOARD_ID]
5042
{
5143
"displayName": "name2",
5244
"name": "name2",

acceptance/bundle/resources/dashboards/change-serialized-dashboard/script

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ deploy_dashboard() {
1212
trace $CLI bundle deploy
1313
dashboard_id=$($CLI bundle summary --output json | jq -r '.resources.dashboards.my_dashboard.id')
1414

15-
trace $CLI lakeview get $dashboard_id | jq '{display_name, lifecycle_state, parent_path, path, warehouse_id}'
16-
trace $CLI lakeview get $dashboard_id | jq '.serialized_dashboard | fromjson' | jq -S '.pages[0]'
15+
# Wait out eventual consistency: retry until the current page is visible (the read
16+
# 404s on create and returns the stale page right after the serialized update).
17+
DASHBOARD=$(retry --until "$PAGE_NAME" $CLI lakeview get $dashboard_id)
18+
echo "$DASHBOARD" | jq '{display_name, lifecycle_state, parent_path, path, warehouse_id}'
19+
echo "$DASHBOARD" | jq '.serialized_dashboard | fromjson' | jq -S '.pages[0]'
1720
}
1821

1922
# Create the dashboard with initial serialized_dashboard

acceptance/bundle/resources/dashboards/dataset-catalog-schema/output.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@ Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/deploy-dashboard-d
44
Deploying resources...
55
Updating deployment state...
66
Deployment complete!
7-
8-
>>> [CLI] lakeview get [DASHBOARD_ID]
97
{
108
"lifecycle_state": "ACTIVE",
119
"parent_path": "/Users/[USERNAME]",
1210
"path": "/Users/[USERNAME]/test bundle-deploy-dashboard-dataset [UUID].lvdash.json"
1311
}
14-
15-
>>> [CLI] lakeview get [DASHBOARD_ID]
1612
{
1713
"catalog": "main",
1814
"schema": "default"

0 commit comments

Comments
 (0)