Skip to content

Commit a9c126f

Browse files
acceptance/bundle/dms: add state-read test; refresh flag-on goldens
state-read builds a synthetic DMS deployment (deployment, version, and a job resource) via raw API calls, points local state at it, and verifies `bundle summary` resolves the job id from DMS ListResources rather than local state. record/redeploy goldens are refreshed for the state-read wiring: until operation recording lands, deploy records no resources in DMS, so a later read returns an empty set (destroy/redeploy no longer see the prior job).
1 parent 9dbdbf9 commit a9c126f

6 files changed

Lines changed: 78 additions & 6 deletions

File tree

acceptance/bundle/dms/record/output.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ Deployment complete!
5555
}
5656

5757
>>> [CLI] bundle destroy --auto-approve
58-
The following resources will be deleted:
59-
delete resources.jobs.foo
60-
6158
All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/dms-record/default
6259

6360
Deleting files...

acceptance/bundle/dms/redeploy/output.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ Deployment complete!
6666
}
6767

6868
>>> [CLI] bundle destroy --auto-approve
69-
The following resources will be deleted:
70-
delete resources.jobs.foo
71-
7269
All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/dms-redeploy/default
7370

7471
Deleting files...
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
bundle:
2+
name: dms-state-read
3+
4+
experimental:
5+
record_deployment_history: true
6+
7+
resources:
8+
jobs:
9+
foo:
10+
name: foo

acceptance/bundle/dms/state-read/out.test.toml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
=== Construct synthetic DMS state via raw API calls
3+
>>> [CLI] api post /api/2.0/bundle/deployments?deployment_id=synthetic-dep --json {"target_name":"default"}
4+
{
5+
"name": "deployments/synthetic-dep",
6+
"status": "DEPLOYMENT_STATUS_ACTIVE",
7+
"target_name": "default"
8+
}
9+
10+
>>> [CLI] api post /api/2.0/bundle/deployments/synthetic-dep/versions?version_id=1 --json {"cli_version":"test","version_type":"VERSION_TYPE_DEPLOY"}
11+
{
12+
"cli_version": "test",
13+
"name": "deployments/synthetic-dep/versions/1",
14+
"status": "VERSION_STATUS_IN_PROGRESS",
15+
"version_id": "1",
16+
"version_type": "VERSION_TYPE_DEPLOY"
17+
}
18+
19+
>>> [CLI] api post /api/2.0/bundle/deployments/synthetic-dep/versions/1/operations --json {"resource_key":"jobs.foo","resource_id":"9999","action_type":"OPERATION_ACTION_TYPE_CREATE","status":"OPERATION_STATUS_SUCCEEDED","state":{"name":"foo"}}
20+
{
21+
"action_type": "OPERATION_ACTION_TYPE_CREATE",
22+
"resource_id": "9999",
23+
"resource_key": "jobs.foo",
24+
"state": {
25+
"name": "foo"
26+
},
27+
"status": "OPERATION_STATUS_SUCCEEDED"
28+
}
29+
30+
=== Point local state at the synthetic deployment: lineage == deployment id, no local resource state
31+
=== bundle summary resolves jobs.foo id (9999) from DMS ListResources
32+
>>> [CLI] bundle summary
33+
Name: dms-state-read
34+
Target: default
35+
Workspace:
36+
User: [USERNAME]
37+
Path: /Workspace/Users/[USERNAME]/.bundle/dms-state-read/default
38+
Resources:
39+
Jobs:
40+
foo:
41+
Name: foo
42+
URL: [DATABRICKS_URL]/jobs/9999?w=[NUMID]
43+
44+
>>> print_requests.py --get //api/2.0/bundle/deployments/synthetic-dep/resources
45+
{
46+
"method": "GET",
47+
"path": "/api/2.0/bundle/deployments/synthetic-dep/resources"
48+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Build a synthetic DMS deployment (id == state lineage) holding one job resource,
2+
# using raw API calls, then verify `bundle summary` reads that resource back from
3+
# DMS rather than from the local resources.json (which intentionally has no
4+
# resource state).
5+
6+
title "Construct synthetic DMS state via raw API calls"
7+
trace $CLI api post '/api/2.0/bundle/deployments?deployment_id=synthetic-dep' --json '{"target_name":"default"}'
8+
trace $CLI api post '/api/2.0/bundle/deployments/synthetic-dep/versions?version_id=1' --json '{"cli_version":"test","version_type":"VERSION_TYPE_DEPLOY"}'
9+
trace $CLI api post '/api/2.0/bundle/deployments/synthetic-dep/versions/1/operations' --json '{"resource_key":"jobs.foo","resource_id":"9999","action_type":"OPERATION_ACTION_TYPE_CREATE","status":"OPERATION_STATUS_SUCCEEDED","state":{"name":"foo"}}'
10+
11+
title "Point local state at the synthetic deployment: lineage == deployment id, no local resource state"
12+
mkdir -p .databricks/bundle/default
13+
printf '{"state_version":2,"lineage":"synthetic-dep","serial":1,"state":{}}\n' > .databricks/bundle/default/resources.json
14+
15+
title "bundle summary resolves jobs.foo id (9999) from DMS ListResources"
16+
trace $CLI bundle summary
17+
trace print_requests.py --get //api/2.0/bundle/deployments/synthetic-dep/resources

0 commit comments

Comments
 (0)