-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add acceptance tests for builtin templates (#2135)
## Changes To accommodate: * Add the server URL to the set of output replacements * Include a call to the permissions API to the dummy server * Run the main script in a subshell to isolate working directory changes
- Loading branch information
Showing
14 changed files
with
161 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"project_name": "my_dbt_sql", | ||
"http_path": "/sql/2.0/warehouses/f00dcafe", | ||
"default_catalog": "main", | ||
"personal_schemas": "yes, use a schema based on the current user name during development" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
>>> $CLI bundle init dbt-sql --config-file ./input.json | ||
|
||
Welcome to the dbt template for Databricks Asset Bundles! | ||
|
||
A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html. | ||
workspace_host: http://$DATABRICKS_HOST | ||
|
||
📊 Your new project has been created in the 'my_dbt_sql' directory! | ||
If you already have dbt installed, just type 'cd my_dbt_sql; dbt init' to get started. | ||
Refer to the README.md file for full "getting started" guide and production setup instructions. | ||
|
||
|
||
>>> $CLI bundle validate -t dev | ||
Name: my_dbt_sql | ||
Target: dev | ||
Workspace: | ||
Host: http://$DATABRICKS_HOST | ||
User: $USERNAME | ||
Path: /Workspace/Users/$USERNAME/.bundle/my_dbt_sql/dev | ||
|
||
Validation OK! | ||
|
||
>>> $CLI bundle validate -t prod | ||
Name: my_dbt_sql | ||
Target: prod | ||
Workspace: | ||
Host: http://$DATABRICKS_HOST | ||
User: $USERNAME | ||
Path: /Workspace/Users/$USERNAME/.bundle/my_dbt_sql/prod | ||
|
||
Validation OK! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
trace $CLI bundle init dbt-sql --config-file ./input.json | ||
|
||
cd my_dbt_sql | ||
trace $CLI bundle validate -t dev | ||
trace $CLI bundle validate -t prod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rm -fr my_dbt_sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"project_name": "my_default_python", | ||
"include_notebook": "yes", | ||
"include_dlt": "yes", | ||
"include_python": "yes" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
>>> $CLI bundle init default-python --config-file ./input.json | ||
|
||
Welcome to the default Python template for Databricks Asset Bundles! | ||
Workspace to use (auto-detected, edit in 'my_default_python/databricks.yml'): http://$DATABRICKS_HOST | ||
|
||
✨ Your new project has been created in the 'my_default_python' directory! | ||
|
||
Please refer to the README.md file for "getting started" instructions. | ||
See also the documentation at https://docs.databricks.com/dev-tools/bundles/index.html. | ||
|
||
>>> $CLI bundle validate -t dev | ||
Name: my_default_python | ||
Target: dev | ||
Workspace: | ||
Host: http://$DATABRICKS_HOST | ||
User: $USERNAME | ||
Path: /Workspace/Users/$USERNAME/.bundle/my_default_python/dev | ||
|
||
Validation OK! | ||
|
||
>>> $CLI bundle validate -t prod | ||
Name: my_default_python | ||
Target: prod | ||
Workspace: | ||
Host: http://$DATABRICKS_HOST | ||
User: $USERNAME | ||
Path: /Workspace/Users/$USERNAME/.bundle/my_default_python/prod | ||
|
||
Validation OK! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
trace $CLI bundle init default-python --config-file ./input.json | ||
|
||
cd my_default_python | ||
trace $CLI bundle validate -t dev | ||
trace $CLI bundle validate -t prod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rm -fr my_default_python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"project_name": "my_default_sql", | ||
"http_path": "/sql/2.0/warehouses/f00dcafe", | ||
"default_catalog": "main", | ||
"personal_schemas": "yes, automatically use a schema based on the current user name during development" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
>>> $CLI bundle init default-sql --config-file ./input.json | ||
|
||
Welcome to the default SQL template for Databricks Asset Bundles! | ||
|
||
A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html. | ||
workspace_host: http://$DATABRICKS_HOST | ||
|
||
✨ Your new project has been created in the 'my_default_sql' directory! | ||
|
||
Please refer to the README.md file for "getting started" instructions. | ||
See also the documentation at https://docs.databricks.com/dev-tools/bundles/index.html. | ||
|
||
>>> $CLI bundle validate -t dev | ||
Name: my_default_sql | ||
Target: dev | ||
Workspace: | ||
Host: http://$DATABRICKS_HOST | ||
User: $USERNAME | ||
Path: /Workspace/Users/$USERNAME/.bundle/my_default_sql/dev | ||
|
||
Validation OK! | ||
|
||
>>> $CLI bundle validate -t prod | ||
Name: my_default_sql | ||
Target: prod | ||
Workspace: | ||
Host: http://$DATABRICKS_HOST | ||
User: $USERNAME | ||
Path: /Workspace/Users/$USERNAME/.bundle/my_default_sql/prod | ||
|
||
Validation OK! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
trace $CLI bundle init default-sql --config-file ./input.json | ||
|
||
cd my_default_sql | ||
trace $CLI bundle validate -t dev | ||
trace $CLI bundle validate -t prod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rm -fr my_default_sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,33 +2,30 @@ package acceptance_test | |
|
||
import ( | ||
"encoding/json" | ||
"net" | ||
"net/http" | ||
"net/http/httptest" | ||
"testing" | ||
|
||
"github.com/databricks/databricks-sdk-go/service/catalog" | ||
"github.com/databricks/databricks-sdk-go/service/compute" | ||
"github.com/databricks/databricks-sdk-go/service/iam" | ||
"github.com/databricks/databricks-sdk-go/service/workspace" | ||
) | ||
|
||
type TestServer struct { | ||
*httptest.Server | ||
Mux *http.ServeMux | ||
Port int | ||
Mux *http.ServeMux | ||
} | ||
|
||
type HandlerFunc func(r *http.Request) (any, error) | ||
|
||
func NewTestServer() *TestServer { | ||
mux := http.NewServeMux() | ||
server := httptest.NewServer(mux) | ||
port := server.Listener.Addr().(*net.TCPAddr).Port | ||
|
||
return &TestServer{ | ||
Server: server, | ||
Mux: mux, | ||
Port: port, | ||
} | ||
} | ||
|
||
|
@@ -126,4 +123,27 @@ func AddHandlers(server *TestServer) { | |
ResourceId: "1001", | ||
}, nil | ||
}) | ||
|
||
server.Handle("/api/2.1/unity-catalog/current-metastore-assignment", func(r *http.Request) (any, error) { | ||
return catalog.MetastoreAssignment{ | ||
DefaultCatalogName: "main", | ||
}, nil | ||
}) | ||
|
||
server.Handle("/api/2.0/permissions/directories/1001", func(r *http.Request) (any, error) { | ||
return workspace.WorkspaceObjectPermissions{ | ||
ObjectId: "1001", | ||
ObjectType: "DIRECTORY", | ||
AccessControlList: []workspace.WorkspaceObjectAccessControlResponse{ | ||
{ | ||
UserName: "[email protected]", | ||
AllPermissions: []workspace.WorkspaceObjectPermission{ | ||
{ | ||
PermissionLevel: "CAN_MANAGE", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, nil | ||
}) | ||
} |