Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion acceptance/acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/databricks/cli/internal/testutil"
"github.com/databricks/cli/libs/auth"
"github.com/databricks/cli/libs/testdiff"
"github.com/databricks/cli/libs/testserver"
"github.com/databricks/cli/libs/utils"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -152,6 +153,7 @@ func TestInprocessMode(t *testing.T) {
func setReplsForTestEnvVars(t *testing.T, repls *testdiff.ReplacementsContext) {
envVars := []string{
"TEST_DEFAULT_WAREHOUSE_ID",
"TEST_DEFAULT_CLUSTER_ID",
"TEST_INSTANCE_POOL_ID",
}
for _, envVar := range envVars {
Expand Down Expand Up @@ -244,7 +246,10 @@ func testAccept(t *testing.T, inprocessMode bool, singleTest string) int {
if cloudEnv == "" {
internal.StartDefaultServer(t, LogRequests)
if os.Getenv("TEST_DEFAULT_WAREHOUSE_ID") == "" {
t.Setenv("TEST_DEFAULT_WAREHOUSE_ID", "8ec9edc1-db0c-40df-af8d-7580020fe61e")
t.Setenv("TEST_DEFAULT_WAREHOUSE_ID", testserver.TestDefaultWarehouseId)
}
if os.Getenv("TEST_DEFAULT_CLUSTER_ID") == "" {
t.Setenv("TEST_DEFAULT_CLUSTER_ID", testserver.TestDefaultClusterId)
}
}

Expand Down
6 changes: 3 additions & 3 deletions acceptance/bundle/deployment/bind/cluster/output.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

>>> [CLI] clusters get [CLUSTER-ID]
>>> [CLI] clusters get [TEST_DEFAULT_CLUSTER_ID]
{
"cluster_name": "DEFAULT Test Cluster"
}

>>> [CLI] bundle deployment bind cluster1 [CLUSTER-ID] --auto-approve
>>> [CLI] bundle deployment bind cluster1 [TEST_DEFAULT_CLUSTER_ID] --auto-approve
Updating deployment state...
Successfully bound cluster with an id '[CLUSTER-ID]'
Successfully bound cluster with an id '[TEST_DEFAULT_CLUSTER_ID]'
Run 'bundle deploy' to deploy changes to your workspace

>>> [CLI] bundle deployment unbind cluster1
Expand Down
16 changes: 0 additions & 16 deletions acceptance/bundle/deployment/bind/cluster/test.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
Local = true
Cloud = true
RequiresCluster = true

Ignore = [
"databricks.yml",
]

[[Repls]]
Old = "[0-9]{4}-[0-9]{6}-[0-9a-z]{8}"
New = "[CLUSTER-ID]"

[[Server]]
Pattern = "GET /api/2.1/clusters/get"
Response.Body = '''
{
"cluster_name": "DEFAULT Test Cluster"
}
'''
12 changes: 6 additions & 6 deletions acceptance/bundle/deployment/bind/dashboard/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ Deployment complete!

>>> [CLI] lakeview get [DASHBOARD_ID]
{
"display_name": "test dashboard [UUID]",
"display_name": "test dashboard [UNIQUE_NAME]",
"lifecycle_state": "ACTIVE",
"path": "/Users/[USERNAME]/test dashboard [UUID].lvdash.json",
"parent_path": "/Users/[USERNAME]",
"path": "/Users/[USERNAME]/test dashboard [UNIQUE_NAME].lvdash.json",
"serialized_dashboard": {
"pages": [
{
"name": "02724bf2",
"displayName": "Page One",
"name": "02724bf2",
"pageType": "PAGE_TYPE_CANVAS"
}
]
Expand All @@ -38,15 +38,15 @@ Destroy complete!

>>> [CLI] lakeview get [DASHBOARD_ID]
{
"display_name": "test dashboard [UUID]",
"display_name": "test dashboard [UNIQUE_NAME]",
"lifecycle_state": "ACTIVE",
"path": "/Users/[USERNAME]/test dashboard [UUID].lvdash.json",
"parent_path": "/Users/[USERNAME]",
"path": "/Users/[USERNAME]/test dashboard [UNIQUE_NAME].lvdash.json",
"serialized_dashboard": {
"pages": [
{
"name": "02724bf2",
"displayName": "Page One",
"name": "02724bf2",
"pageType": "PAGE_TYPE_CANVAS"
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ Deployment complete!

>>> [CLI] lakeview get [DASHBOARD_ID]
{
"display_name": "test dashboard [UUID]",
"display_name": "test dashboard [UNIQUE_NAME]",
"lifecycle_state": "ACTIVE"
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
DASHBOARD_DISPLAY_NAME="test dashboard $(uuid)"
if [ -z "$CLOUD_ENV" ]; then
DASHBOARD_DISPLAY_NAME="test dashboard 6260d50f-e8ff-4905-8f28-812345678903" # use hard-coded uuid when running locally
export TEST_DEFAULT_WAREHOUSE_ID="warehouse-1234"
fi
DASHBOARD_DISPLAY_NAME="test dashboard $UNIQUE_NAME"

export DASHBOARD_DISPLAY_NAME
envsubst < databricks.yml.tmpl > databricks.yml
Expand Down
10 changes: 3 additions & 7 deletions acceptance/bundle/deployment/bind/dashboard/script
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
DASHBOARD_DISPLAY_NAME="test dashboard $(uuid)"
if [ -z "$CLOUD_ENV" ]; then
DASHBOARD_DISPLAY_NAME="test dashboard 6260d50f-e8ff-4905-8f28-812345678903" # use hard-coded uuid when running locally
export TEST_DEFAULT_WAREHOUSE_ID="warehouse-1234"
fi
DASHBOARD_DISPLAY_NAME="test dashboard $UNIQUE_NAME"

export DASHBOARD_DISPLAY_NAME
envsubst < databricks.yml.tmpl > databricks.yml
Expand All @@ -19,11 +15,11 @@ trace $CLI bundle deployment bind dashboard1 "${DASHBOARD_ID}" --auto-approve

trace $CLI bundle deploy

trace $CLI lakeview get "${DASHBOARD_ID}" | jq '{display_name, lifecycle_state, path, parent_path, serialized_dashboard} | .serialized_dashboard |= fromjson'
trace $CLI lakeview get "${DASHBOARD_ID}" | jq --sort-keys '{display_name, lifecycle_state, path, parent_path, serialized_dashboard} | .serialized_dashboard |= fromjson'

trace $CLI bundle deployment unbind dashboard1

trace $CLI bundle destroy --auto-approve

# Read the pre-defined dashboard again (expecting it still exists and is not deleted):
trace $CLI lakeview get "${DASHBOARD_ID}" | jq '{display_name, lifecycle_state, path, parent_path, serialized_dashboard} | .serialized_dashboard |= fromjson'
trace $CLI lakeview get "${DASHBOARD_ID}" | jq --sort-keys '{display_name, lifecycle_state, path, parent_path, serialized_dashboard} | .serialized_dashboard |= fromjson'
34 changes: 0 additions & 34 deletions acceptance/bundle/deployment/bind/dashboard/test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,6 @@ Local = true
Cloud = true
RequiresWarehouse = true

Ignore = [
"databricks.yml",
]

[[Repls]]
Old = "[0-9a-f]{32}"
New = "[DASHBOARD_ID]"

[[Server]]
Pattern = "POST /api/2.0/lakeview/dashboards"
Response.Body = '''
{
"dashboard_id":"1234567890abcdef1234567890abcdef"
}
'''

[[Server]]
Pattern = "POST /api/2.0/lakeview/dashboards/{dashboard_id}/published"

[[Server]]
Pattern = "PATCH /api/2.0/lakeview/dashboards/{dashboard_id}"

[[Server]]
Pattern = "GET /api/2.0/lakeview/dashboards/{dashboard_id}"
Response.Body = '''
{
"dashboard_id":"1234567890abcdef1234567890abcdef",
"display_name": "test dashboard 6260d50f-e8ff-4905-8f28-812345678903",
"lifecycle_state": "ACTIVE",
"path": "/Users/[USERNAME]/test dashboard [UUID].lvdash.json",
"parent_path": "/Users/tester@databricks.com",
"serialized_dashboard": "{\"pages\":[{\"name\":\"02724bf2\",\"displayName\":\"Page One\",\"pageType\":\"PAGE_TYPE_CANVAS\"}]}"
}
'''

[[Server]]
Pattern = "DELETE /api/2.0/lakeview/dashboards/{dashboard_id}"
4 changes: 2 additions & 2 deletions acceptance/bundle/deployment/bind/experiment/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Updating deployment state...
Deployment complete!

=== Read the pre-defined experiment: {
"name": "/Users/[USERNAME]/test-experiment[UUID]",
"name": "/Users/[USERNAME]/test-experiment[UNIQUE_NAME]",
"lifecycle_stage": "active"
}

Expand All @@ -24,7 +24,7 @@ Deleting files...
Destroy complete!

=== Read the pre-defined experiment again (expecting it still exists and is not deleted): {
"name": "/Users/[USERNAME]/test-experiment[UUID]",
"name": "/Users/[USERNAME]/test-experiment[UNIQUE_NAME]",
"lifecycle_stage": "active"
}

Expand Down
5 changes: 1 addition & 4 deletions acceptance/bundle/deployment/bind/experiment/script
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ title "Bind experiment test:"
title "Substitute variables in the template"

# double slash at the start prevents Windows to apply replacements to the path
EXPERIMENT_NAME="//Workspace/Users/${CURRENT_USER_NAME}/test-experiment$(uuid)"
if [ -z "$CLOUD_ENV" ]; then
EXPERIMENT_NAME="//Workspace/Users/${CURRENT_USER_NAME}/test-experiment6260d50f-e8ff-4905-8f28-812345678903" # use hard-coded uuid when running locally
fi
EXPERIMENT_NAME="//Workspace/Users/${CURRENT_USER_NAME}/test-experiment$UNIQUE_NAME"
export EXPERIMENT_NAME
envsubst < databricks.yml.tmpl > databricks.yml

Expand Down
26 changes: 0 additions & 26 deletions acceptance/bundle/deployment/bind/experiment/test.toml
Original file line number Diff line number Diff line change
@@ -1,28 +1,2 @@
Local = true
Cloud = true

[[Server]]
Pattern = "POST /api/2.0/mlflow/experiments/create"
Response.Body = '''
{
"experiment_id":"1234567890"
}
'''

[[Server]]
Pattern = "GET /api/2.0/mlflow/experiments/get"
Response.Body = '''
{
"experiment_id": "1234567890",
"experiment": {
"name": "/Users/[USERNAME]/test-experiment6260d50f-e8ff-4905-8f28-812345678903",
"lifecycle_stage": "active"
}
}
'''

[[Server]]
Pattern = "POST /api/2.0/mlflow/experiments/update"

[[Server]]
Pattern = "POST /api/2.0/mlflow/experiments/delete"
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ bundle:
resources:
model_serving_endpoints:
endpoint1:
name: test-endpoint-[UUID]
name: test-endpoint-[UNIQUE_NAME]

>>> [CLI] serving-endpoints create test-endpoint-[UUID]
>>> [CLI] serving-endpoints create test-endpoint-[UNIQUE_NAME]
{
"name": "test-endpoint-[UUID]",
"name": "test-endpoint-[UNIQUE_NAME]",
"permission_level": "CAN_MANAGE",
"route_optimized": false,
"state": {
Expand All @@ -17,9 +17,9 @@ resources:
}
}

>>> [CLI] serving-endpoints get test-endpoint-[UUID]
>>> [CLI] serving-endpoints get test-endpoint-[UNIQUE_NAME]
{
"name": "test-endpoint-[UUID]",
"name": "test-endpoint-[UNIQUE_NAME]",
"permission_level": "CAN_MANAGE",
"route_optimized": false,
"state": {
Expand All @@ -28,9 +28,9 @@ resources:
}
}

>>> [CLI] bundle deployment bind endpoint1 test-endpoint-[UUID]
>>> [CLI] bundle deployment bind endpoint1 test-endpoint-[UNIQUE_NAME]
Updating deployment state...
Successfully bound model_serving_endpoint with an id 'test-endpoint-[UUID]'
Successfully bound model_serving_endpoint with an id 'test-endpoint-[UNIQUE_NAME]'
Run 'bundle deploy' to deploy changes to your workspace

>>> [CLI] bundle deploy
Expand All @@ -39,9 +39,9 @@ Deploying resources...
Updating deployment state...
Deployment complete!

>>> [CLI] serving-endpoints get test-endpoint-[UUID]
>>> [CLI] serving-endpoints get test-endpoint-[UNIQUE_NAME]
{
"name": "test-endpoint-[UUID]",
"name": "test-endpoint-[UNIQUE_NAME]",
"permission_level": "CAN_MANAGE",
"route_optimized": false,
"state": {
Expand All @@ -59,9 +59,9 @@ All files and directories at the following location will be deleted: /Workspace/
Deleting files...
Destroy complete!

>>> [CLI] serving-endpoints get test-endpoint-[UUID]
>>> [CLI] serving-endpoints get test-endpoint-[UNIQUE_NAME]
{
"name": "test-endpoint-[UUID]",
"name": "test-endpoint-[UNIQUE_NAME]",
"permission_level": "CAN_MANAGE",
"route_optimized": false,
"state": {
Expand All @@ -70,4 +70,4 @@ Destroy complete!
}
}

>>> [CLI] serving-endpoints delete test-endpoint-[UUID]
>>> [CLI] serving-endpoints delete test-endpoint-[UNIQUE_NAME]
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
ENDPOINT_NAME="test-endpoint-$(uuid)"
if [ -z "$CLOUD_ENV" ]; then
ENDPOINT_NAME="test-endpoint-6260d50f-e8ff-4905-8f28-812345678903"
fi
ENDPOINT_NAME="test-endpoint-$UNIQUE_NAME"
export ENDPOINT_NAME
envsubst < databricks.yml.tmpl > databricks.yml
cat databricks.yml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,2 @@
Local = true
Cloud = true

Ignore = [
"databricks.yml",
]

[[Server]]
Pattern = "POST /api/2.0/serving-endpoints"
Response.Body = '''
{
"name": "test-endpoint-6260d50f-e8ff-4905-8f28-812345678903"
}
'''

[[Server]]
Pattern = "GET /api/2.0/serving-endpoints/"

[[Server]]
Pattern = "GET /api/2.0/serving-endpoints/{endpoint_name}"
Response.Body = '''
{
"name": "test-endpoint-6260d50f-e8ff-4905-8f28-812345678903",
"permission_level": "CAN_MANAGE",
"route_optimized": false,
"state": {
"config_update": "NOT_UPDATING",
"ready": "NOT_READY"
}
}
'''

[[Server]]
Pattern = "DELETE /api/2.0/serving-endpoints/{endpoint_name}"
Loading