Skip to content

Commit dc257ec

Browse files
authored
testserver: Add CRUD for apps and quality monitors (#2629)
## Changes - Add support for create/update/get/delete for apps and quality monitors to testserver. ## Why This replaces manually encoding responses in existing tests. I'm using this in terraform removal branch to run experiments. ## Tests Existing tests that hard-coded responses now use the testserver directly.
1 parent 6fe8acb commit dc257ec

File tree

14 files changed

+280
-72
lines changed

14 files changed

+280
-72
lines changed

acceptance/bundle/apps/test.toml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,3 @@ RecordRequests = true
44
Ignore = [
55
'.databricks',
66
]
7-
8-
[[Server]]
9-
Pattern = "POST /api/2.0/apps"
10-
11-
[[Server]]
12-
Pattern = "GET /api/2.0/apps/myapp"
13-
Response.Body = '''
14-
{
15-
"name": "myapp",
16-
"description": "",
17-
"compute_status": {
18-
"state": "ACTIVE",
19-
"message": "App compute is active."
20-
},
21-
"app_status": {
22-
"state": "RUNNING",
23-
"message": "Application is running."
24-
}
25-
}
26-
'''
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"assets_dir":"/Users/user/databricks_lakehouse_monitoring",
3+
"output_schema_name":"catalog.schema",
4+
"snapshot": {}
5+
}

acceptance/bundle/deployment/bind/quality-monitor/output.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11

2+
>>> [CLI] quality-monitors create catalog.schema.table --json @input.json
3+
{
4+
"assets_dir":"/Users/user/databricks_lakehouse_monitoring",
5+
"drift_metrics_table_name":"",
6+
"monitor_version":"",
7+
"output_schema_name":"catalog.schema",
8+
"profile_metrics_table_name":"",
9+
"snapshot": {},
10+
"status":"MONITOR_STATUS_ACTIVE",
11+
"table_name":"catalog.schema.table"
12+
}
13+
214
>>> [CLI] bundle deployment bind monitor1 catalog.schema.table
315
Updating deployment state...
416
Successfully bound quality_monitor with an id 'catalog.schema.table'. Run 'bundle deploy' to deploy changes to your workspace
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
trace $CLI quality-monitors create catalog.schema.table --json @input.json
12
trace $CLI bundle deployment bind monitor1 "catalog.schema.table"
23
trace $CLI bundle deploy
Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,2 @@
11
Local = true
22
Cloud = false
3-
4-
[[Server]]
5-
Pattern = "GET /api/2.1/unity-catalog/tables/catalog.schema.table/monitor"
6-
Response.Body = '''
7-
{
8-
"assets_dir":"/Users/user/databricks_lakehouse_monitoring",
9-
"dashboard_id":"01f00b1c15de19c7945fa190201813df",
10-
"drift_metrics_table_name":"catalog.schema.table_drift_metrics",
11-
"monitor_version":"0",
12-
"output_schema_name":"catalog.schema",
13-
"profile_metrics_table_name":"catalog.schema.table_profile_metrics",
14-
"snapshot": {},
15-
"status":"MONITOR_STATUS_ACTIVE",
16-
"table_name":"catalog.schema.table"
17-
}
18-
'''
19-
20-
[[Server]]
21-
Pattern = "PUT /api/2.1/unity-catalog/tables/users.user.table/monitor"

acceptance/cmd/workspace/apps/input.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"name": "test-name",
23
"description": "My app description.",
34
"resources": [
45
{

acceptance/cmd/workspace/apps/out.requests.txt

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,32 @@
1+
{
2+
"method": "POST",
3+
"path": "/api/2.0/apps",
4+
"body": {
5+
"description": "My app description.",
6+
"name": "test-name",
7+
"resources": [
8+
{
9+
"description": "API key for external service.",
10+
"name": "api-key",
11+
"secret": {
12+
"key": "my-key",
13+
"permission": "READ",
14+
"scope": "my-scope"
15+
}
16+
}
17+
]
18+
}
19+
}
20+
{
21+
"method": "GET",
22+
"path": "/api/2.0/apps/test-name"
23+
}
124
{
225
"method": "PATCH",
326
"path": "/api/2.0/apps/test-name",
427
"body": {
528
"description": "My app description.",
6-
"name": "",
29+
"name": "test-name",
730
"resources": [
831
{
932
"description": "API key for external service.",

acceptance/cmd/workspace/apps/output.txt

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,45 @@
11

2+
=== Apps create with correct input
3+
>>> [CLI] apps create --json @input.json
4+
{
5+
"app_status": {
6+
"message":"Application is running.",
7+
"state":"RUNNING"
8+
},
9+
"compute_status": {
10+
"message":"App compute is active.",
11+
"state":"ACTIVE"
12+
},
13+
"description":"My app description.",
14+
"id":"1000",
15+
"name":"test-name",
16+
"resources": [
17+
{
18+
"description":"API key for external service.",
19+
"name":"api-key",
20+
"secret": {
21+
"key":"my-key",
22+
"permission":"READ",
23+
"scope":"my-scope"
24+
}
25+
}
26+
],
27+
"url":"test-name-123.cloud.databricksapps.com"
28+
}
29+
230
=== Apps update with correct input
331
>>> [CLI] apps update test-name --json @input.json
432
{
533
"app_status": {
634
"message":"Application is running.",
7-
"state":"DEPLOYING"
35+
"state":"RUNNING"
836
},
937
"compute_status": {
1038
"message":"App compute is active.",
11-
"state":"ERROR"
39+
"state":"ACTIVE"
1240
},
1341
"description":"My app description.",
14-
"id":"12345",
42+
"id":"1001",
1543
"name":"test-name",
1644
"resources": [
1745
{

acceptance/cmd/workspace/apps/script

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
title "Apps create with correct input"
2+
trace $CLI apps create --json @input.json
3+
14
title "Apps update with correct input"
25
trace $CLI apps update test-name --json @input.json
36

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1 @@
11
RecordRequests = true
2-
3-
[[Server]]
4-
Pattern = "PATCH /api/2.0/apps/test-name"
5-
Response.Body = '''
6-
{
7-
"name": "test-name",
8-
"description": "My app description.",
9-
"compute_status": {
10-
"state": "ERROR",
11-
"message": "App compute is active."
12-
},
13-
"app_status": {
14-
"state": "DEPLOYING",
15-
"message": "Application is running."
16-
},
17-
"url": "test-name-123.cloud.databricksapps.com",
18-
"resources": [
19-
{
20-
"name": "api-key",
21-
"description": "API key for external service.",
22-
"secret": {
23-
"scope": "my-scope",
24-
"key": "my-key",
25-
"permission": "READ"
26-
}
27-
}
28-
],
29-
"id": "12345"
30-
}'''

0 commit comments

Comments
 (0)