Skip to content

Commit 49f8b13

Browse files
authored
Add an acceptance test for binding database instances (#3424)
## Why <!-- Why are these changes needed? Provide the context that the reviewer might be missing. For example, were there any decisions behind the change that are not reflected in the code itself? --> The new test validates that `bind` works for the `database_instances` resources. ## Tests <!-- How have you tested the changes? --> <!-- If your PR needs to be included in the release notes for next release, add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
1 parent 07e3362 commit 49f8b13

File tree

5 files changed

+75
-0
lines changed

5 files changed

+75
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
resources:
2+
database_instances:
3+
database_instance1:
4+
name: "test-instance-02"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Local = true
2+
Cloud = false
3+
4+
[EnvMatrix]
5+
DATABRICKS_CLI_DEPLOYMENT = ["terraform"]
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
>>> [CLI] bundle deployment bind database_instance1 [UUID] --auto-approve
3+
Updating deployment state...
4+
Successfully bound database_instance with an id '[UUID]'. Run 'bundle deploy' to deploy changes to your workspace
5+
6+
>>> [CLI] bundle summary
7+
Name: test-bundle-$UNIQUE_NAME
8+
Target: default
9+
Workspace:
10+
User: [USERNAME]
11+
Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle-$UNIQUE_NAME/default
12+
Resources:
13+
Database instances:
14+
database_instance1:
15+
Name: test-instance-02
16+
URL: [DATABRICKS_URL]/compute/database-instances/test-instance-02?o=[NUMID]
17+
18+
>>> [CLI] bundle deployment unbind database_instance1
19+
Updating deployment state...
20+
21+
>>> [CLI] bundle summary
22+
Name: test-bundle-$UNIQUE_NAME
23+
Target: default
24+
Workspace:
25+
User: [USERNAME]
26+
Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle-$UNIQUE_NAME/default
27+
Resources:
28+
Database instances:
29+
database_instance1:
30+
Name: test-instance-02
31+
URL: (not deployed)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
DATABASE_INSTANCE_ID="12345678-1234-5678-9abc-123456789def"
2+
trace $CLI bundle deployment bind database_instance1 "${DATABASE_INSTANCE_ID}" --auto-approve
3+
trace $CLI bundle summary
4+
5+
trace $CLI bundle deployment unbind database_instance1
6+
trace $CLI bundle summary
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Local = true
2+
Cloud = false
3+
BundleConfigTarget = "databricks.yml"
4+
5+
Ignore = [
6+
".databricks"
7+
]
8+
9+
[[Server]]
10+
Pattern = "GET /api/2.0/database/instances/"
11+
Response.Body = '''
12+
{
13+
"database_instances": [
14+
{
15+
"id": "12345678-1234-5678-9abc-123456789def",
16+
"name": "test-instance-01"
17+
}
18+
]
19+
}
20+
'''
21+
22+
[[Server]]
23+
Pattern = "GET /api/2.0/database/instances/{name}"
24+
Response.Body = '''
25+
{
26+
"id": "12345678-1234-5678-9abc-123456789def",
27+
"name": "test-instance-01"
28+
}
29+
'''

0 commit comments

Comments
 (0)