diff --git a/acceptance/bundle/resources/dashboards/change-serialized-inline/databricks.yml.tmpl b/acceptance/bundle/resources/dashboards/change-serialized-inline/databricks.yml.tmpl new file mode 100644 index 00000000000..0942aa4f690 --- /dev/null +++ b/acceptance/bundle/resources/dashboards/change-serialized-inline/databricks.yml.tmpl @@ -0,0 +1,12 @@ +bundle: + name: change-serialized-inline-$UNIQUE_NAME + +resources: + dashboards: + inline_dash: + display_name: Inline Dash + warehouse_id: $TEST_DEFAULT_WAREHOUSE_ID + serialized_dashboard: # inline YAML MAP = the non-string case + pages: + - name: page1 + displayName: Page 1 diff --git a/acceptance/bundle/resources/dashboards/change-serialized-inline/out.plan.direct.json b/acceptance/bundle/resources/dashboards/change-serialized-inline/out.plan.direct.json new file mode 100644 index 00000000000..b9244b3ab9d --- /dev/null +++ b/acceptance/bundle/resources/dashboards/change-serialized-inline/out.plan.direct.json @@ -0,0 +1,95 @@ +{ + "plan_version": 2, + "cli_version": "[CLI_VERSION]", + "lineage": "[UUID]", + "serial": 1, + "plan": { + "resources.dashboards.inline_dash": { + "action": "update", + "new_state": { + "value": { + "display_name": "Inline Dash", + "embed_credentials": false, + "parent_path": "/Workspace/Users/[USERNAME]/.bundle/change-serialized-inline-[UNIQUE_NAME]/default/resources", + "published": true, + "serialized_dashboard": { + "pages": [ + { + "displayName": "Page One", + "name": "page1" + } + ] + }, + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" + } + }, + "remote_state": { + "create_time": "[TIMESTAMP]", + "dashboard_id": "[DASHBOARD_ID]", + "display_name": "Inline Dash", + "embed_credentials": false, + "etag": "[NUMID]", + "lifecycle_state": "ACTIVE", + "parent_path": "/Workspace/Users/[USERNAME]/.bundle/change-serialized-inline-[UNIQUE_NAME]/default/resources", + "path": "/Users/[USERNAME]/.bundle/change-serialized-inline-[UNIQUE_NAME]/default/resources/Inline Dash.lvdash.json", + "published": true, + "serialized_dashboard": "{\"pages\":[{\"displayName\":\"Page 1\",\"name\":\"page1\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}\n", + "update_time": "[TIMESTAMP]", + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" + }, + "changes": { + "create_time": { + "action": "skip", + "reason": "spec:output_only", + "remote": "[TIMESTAMP]" + }, + "dashboard_id": { + "action": "skip", + "reason": "spec:output_only", + "remote": "[DASHBOARD_ID]" + }, + "etag": { + "action": "skip", + "reason": "custom", + "old": "[NUMID]", + "remote": "[NUMID]" + }, + "lifecycle_state": { + "action": "skip", + "reason": "spec:output_only", + "remote": "ACTIVE" + }, + "path": { + "action": "skip", + "reason": "spec:output_only", + "remote": "/Users/[USERNAME]/.bundle/change-serialized-inline-[UNIQUE_NAME]/default/resources/Inline Dash.lvdash.json" + }, + "serialized_dashboard": { + "action": "update", + "old": { + "pages": [ + { + "displayName": "Page 1", + "name": "page1" + } + ] + }, + "new": { + "pages": [ + { + "displayName": "Page One", + "name": "page1" + } + ] + }, + "remote": "{\"pages\":[{\"displayName\":\"Page 1\",\"name\":\"page1\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}\n" + }, + "update_time": { + "action": "skip", + "reason": "spec:output_only", + "remote": "[TIMESTAMP]" + } + } + } + } +} diff --git a/acceptance/bundle/resources/dashboards/change-serialized-inline/out.plan.terraform.json b/acceptance/bundle/resources/dashboards/change-serialized-inline/out.plan.terraform.json new file mode 100644 index 00000000000..7795272689a --- /dev/null +++ b/acceptance/bundle/resources/dashboards/change-serialized-inline/out.plan.terraform.json @@ -0,0 +1,8 @@ +{ + "cli_version": "[CLI_VERSION]", + "plan": { + "resources.dashboards.inline_dash": { + "action": "update" + } + } +} diff --git a/acceptance/bundle/resources/dashboards/change-serialized-inline/out.requests.direct.txt b/acceptance/bundle/resources/dashboards/change-serialized-inline/out.requests.direct.txt new file mode 100644 index 00000000000..763f6fc22c7 --- /dev/null +++ b/acceptance/bundle/resources/dashboards/change-serialized-inline/out.requests.direct.txt @@ -0,0 +1,18 @@ +{ + "method": "PATCH", + "path": "/api/2.0/lakeview/dashboards/[DASHBOARD_ID]", + "body": { + "display_name": "Inline Dash", + "parent_path": "/Workspace/Users/[USERNAME]/.bundle/change-serialized-inline-[UNIQUE_NAME]/default/resources", + "serialized_dashboard": "{\"pages\":[{\"displayName\":\"Page One\",\"name\":\"page1\"}]}", + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" + } +} +{ + "method": "POST", + "path": "/api/2.0/lakeview/dashboards/[DASHBOARD_ID]/published", + "body": { + "embed_credentials": false, + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" + } +} diff --git a/acceptance/bundle/resources/dashboards/change-serialized-inline/out.requests.terraform.txt b/acceptance/bundle/resources/dashboards/change-serialized-inline/out.requests.terraform.txt new file mode 100644 index 00000000000..641cd24882e --- /dev/null +++ b/acceptance/bundle/resources/dashboards/change-serialized-inline/out.requests.terraform.txt @@ -0,0 +1,23 @@ +{ + "method": "PATCH", + "path": "/api/2.0/lakeview/dashboards/[DASHBOARD_ID]", + "body": { + "create_time": "[TIMESTAMP]", + "dashboard_id": "[DASHBOARD_ID]", + "display_name": "Inline Dash", + "lifecycle_state": "ACTIVE", + "parent_path": "/Users/[USERNAME]/.bundle/change-serialized-inline-[UNIQUE_NAME]/default/resources", + "path": "/Users/[USERNAME]/.bundle/change-serialized-inline-[UNIQUE_NAME]/default/resources/Inline Dash.lvdash.json", + "serialized_dashboard": "{\"pages\":[{\"displayName\":\"Page One\",\"name\":\"page1\"}]}", + "update_time": "[TIMESTAMP]", + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" + } +} +{ + "method": "POST", + "path": "/api/2.0/lakeview/dashboards/[DASHBOARD_ID]/published", + "body": { + "embed_credentials": false, + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" + } +} diff --git a/acceptance/bundle/resources/dashboards/change-serialized-inline/out.test.toml b/acceptance/bundle/resources/dashboards/change-serialized-inline/out.test.toml new file mode 100644 index 00000000000..bf4f0e7d3c6 --- /dev/null +++ b/acceptance/bundle/resources/dashboards/change-serialized-inline/out.test.toml @@ -0,0 +1,4 @@ +Cloud = false +EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["terraform", "direct"] +EnvMatrix.DMS = ["", "true"] +EnvMatrix.READPLAN = ["", "1"] diff --git a/acceptance/bundle/resources/dashboards/change-serialized-inline/output.txt b/acceptance/bundle/resources/dashboards/change-serialized-inline/output.txt new file mode 100644 index 00000000000..ca5a2744eaf --- /dev/null +++ b/acceptance/bundle/resources/dashboards/change-serialized-inline/output.txt @@ -0,0 +1,27 @@ + +>>> [CLI] bundle deploy +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/change-serialized-inline-[UNIQUE_NAME]/default/files... +Created dashboards.inline_dash +Files: 6 uploaded, 0 deleted +Resources: 1 created, 0 changed, 0 deleted, 0 unchanged + +>>> [CLI] bundle plan +update dashboards.inline_dash + +Plan: 0 to add, 1 to change, 0 to delete, 0 unchanged + +>>> [CLI] bundle plan -o json + +=== deploy the change +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/change-serialized-inline-[UNIQUE_NAME]/default/files... +Updated dashboards.inline_dash +Files: 4 uploaded, 0 deleted +Resources: 0 created, 1 changed, 0 deleted, 0 unchanged + +>>> [CLI] bundle destroy --auto-approve +The following resources will be deleted: + delete resources.dashboards.inline_dash + +All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/change-serialized-inline-[UNIQUE_NAME]/default + +Destroy: 1 deleted diff --git a/acceptance/bundle/resources/dashboards/change-serialized-inline/script b/acceptance/bundle/resources/dashboards/change-serialized-inline/script new file mode 100644 index 00000000000..03b8c2ac46b --- /dev/null +++ b/acceptance/bundle/resources/dashboards/change-serialized-inline/script @@ -0,0 +1,31 @@ +# Inherited MSYS_NO_PATHCONV breaks bare python helpers on Windows; this test doesn't need it. +unset MSYS_NO_PATHCONV + +cleanup() { + trace $CLI bundle destroy --auto-approve + rm -f out.requests.txt +} +trap cleanup EXIT + +# Deploy an inline-YAML-map dashboard. +envsubst < databricks.yml.tmpl > databricks.yml +trace $CLI bundle deploy + +rm out.requests.txt + +dashboard_id=$($CLI bundle summary --output json | jq -r '.resources.dashboards.inline_dash.id') +add_repl "$dashboard_id" DASHBOARD_ID + +# Wait out eventual consistency before changing. +retry --until "Page 1" $CLI lakeview get "$dashboard_id" > /dev/null + +update_file.py databricks.yml "Page 1" "Page One" + +trace $CLI bundle plan | contains.py "update" "!recreate" + +trace $CLI bundle plan -o json > out.plan.$DATABRICKS_BUNDLE_ENGINE.json + +title "deploy the change\n" +$CLI bundle deploy $(readplanarg out.plan.$DATABRICKS_BUNDLE_ENGINE.json) + +print_requests.py //api/2.0/lakeview/dashboards > out.requests.$DATABRICKS_BUNDLE_ENGINE.txt diff --git a/acceptance/bundle/resources/dashboards/change-serialized-inline/test.toml b/acceptance/bundle/resources/dashboards/change-serialized-inline/test.toml new file mode 100644 index 00000000000..5cab5faff69 --- /dev/null +++ b/acceptance/bundle/resources/dashboards/change-serialized-inline/test.toml @@ -0,0 +1,10 @@ +# the real API returns a pretty printed JSON output which causes +# the test to fail, since we are testing CLI only feature, we can set to +# Cloud = true +Cloud = false + +Ignore = [ + "databricks.yml", +] + +EnvMatrix.READPLAN = ["", "1"] diff --git a/acceptance/bundle/resources/dashboards/serialized-inline/databricks.yml.tmpl b/acceptance/bundle/resources/dashboards/serialized-inline/databricks.yml.tmpl new file mode 100644 index 00000000000..ca96f9fcf14 --- /dev/null +++ b/acceptance/bundle/resources/dashboards/serialized-inline/databricks.yml.tmpl @@ -0,0 +1,12 @@ +bundle: + name: dashboard-serialized-inline-$UNIQUE_NAME + +resources: + dashboards: + inline_dash: + display_name: Inline Dash + warehouse_id: $TEST_DEFAULT_WAREHOUSE_ID + serialized_dashboard: # inline YAML MAP = the non-string case + pages: + - name: page1 + displayName: Page 1 diff --git a/acceptance/bundle/resources/dashboards/serialized-inline/out.test.toml b/acceptance/bundle/resources/dashboards/serialized-inline/out.test.toml new file mode 100644 index 00000000000..b1bef937a27 --- /dev/null +++ b/acceptance/bundle/resources/dashboards/serialized-inline/out.test.toml @@ -0,0 +1,4 @@ +Cloud = true +EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["terraform", "direct"] +EnvMatrix.DMS = ["", "true"] +EnvMatrix.READPLAN = ["", "1"] diff --git a/acceptance/bundle/resources/dashboards/serialized-inline/output.txt b/acceptance/bundle/resources/dashboards/serialized-inline/output.txt new file mode 100644 index 00000000000..f469ff494a4 --- /dev/null +++ b/acceptance/bundle/resources/dashboards/serialized-inline/output.txt @@ -0,0 +1,29 @@ + +>>> [CLI] bundle plan +create dashboards.inline_dash + +Plan: 1 to add, 0 to change, 0 to delete, 0 unchanged +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/dashboard-serialized-inline-[UNIQUE_NAME]/default/files... +Created dashboards.inline_dash +Files: 7 uploaded, 0 deleted +Resources: 1 created, 0 changed, 0 deleted, 0 unchanged + +>>> print_requests.py //api/2.0/lakeview/dashboards +{ + "method": "POST", + "path": "/api/2.0/lakeview/dashboards", + "body": { + "display_name": "Inline Dash", + "parent_path": "/Workspace/Users/[USERNAME]/.bundle/dashboard-serialized-inline-[UNIQUE_NAME]/default/resources", + "serialized_dashboard": "{\"pages\":[{\"displayName\":\"Page 1\",\"name\":\"page1\"}]}", + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" + } +} +{ + "method": "POST", + "path": "/api/2.0/lakeview/dashboards/[INLINE_DASH_ID]/published", + "body": { + "embed_credentials": false, + "warehouse_id": "[TEST_DEFAULT_WAREHOUSE_ID]" + } +} diff --git a/acceptance/bundle/resources/dashboards/serialized-inline/script b/acceptance/bundle/resources/dashboards/serialized-inline/script new file mode 100644 index 00000000000..78c6503704b --- /dev/null +++ b/acceptance/bundle/resources/dashboards/serialized-inline/script @@ -0,0 +1,19 @@ +# Inherited MSYS_NO_PATHCONV breaks bare python helpers on Windows; this test doesn't need it. +unset MSYS_NO_PATHCONV + +envsubst < databricks.yml.tmpl > databricks.yml + +cleanup() { + # Cleanup; direct's destroy 404s on the stale GET and diverges, so keep it out of the diff. + $CLI bundle destroy --auto-approve &> LOG.destroy + rm -f out.requests.txt +} +trap cleanup EXIT + +trace $CLI bundle plan +$CLI bundle plan -o json > tmp.plan.json +$CLI bundle deploy $(readplanarg tmp.plan.json) +replace_ids.py + +# Prove the inline YAML map reaches the API as a JSON string. +trace print_requests.py //api/2.0/lakeview/dashboards diff --git a/acceptance/bundle/resources/dashboards/serialized-inline/test.toml b/acceptance/bundle/resources/dashboards/serialized-inline/test.toml new file mode 100644 index 00000000000..6f91063a6ee --- /dev/null +++ b/acceptance/bundle/resources/dashboards/serialized-inline/test.toml @@ -0,0 +1,6 @@ +Ignore = [ + "databricks.yml", + "tmp.plan.json", +] + +EnvMatrix.READPLAN = ["", "1"]