Skip to content

Commit 1f0fd3f

Browse files
committed
destroy for jobs + test
1 parent b88e1c7 commit 1f0fd3f

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

acceptance/bundle/resources/jobs/output.txt

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,63 @@ Deployment complete!
8888
"path": "/api/2.2/jobs/reset"
8989
}
9090
jobs foo id='[TEST_JOB_ID+0]' name='foo'
91+
92+
=== Fetch job ID and verify remote state
93+
>>> [CLI] jobs get [TEST_JOB_ID+0]
94+
{
95+
"job_id":[TEST_JOB_ID+0],
96+
"settings": {
97+
"deployment": {
98+
"kind":"BUNDLE",
99+
"metadata_file_path":"/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/metadata.json"
100+
},
101+
"edit_mode":"UI_LOCKED",
102+
"format":"MULTI_TASK",
103+
"job_clusters": [
104+
{
105+
"job_cluster_key":"key",
106+
"new_cluster": {
107+
"num_workers":0,
108+
"spark_version":"13.3.x-scala2.12"
109+
}
110+
}
111+
],
112+
"max_concurrent_runs":1,
113+
"name":"foo",
114+
"queue": {
115+
"enabled":true
116+
},
117+
"trigger": {
118+
"pause_status":"UNPAUSED",
119+
"periodic": {
120+
"interval":1,
121+
"unit":"HOURS"
122+
}
123+
}
124+
}
125+
}
126+
127+
=== Destroy the job and verify that it's removed from the state and from remote
128+
>>> [CLI] bundle destroy --auto-approve
129+
The following resources will be deleted:
130+
delete job foo
131+
132+
All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default
133+
134+
Deleting files...
135+
Destroy complete!
136+
137+
>>> print_requests
138+
{
139+
"body": {
140+
"job_id": [TEST_JOB_ID+0]
141+
},
142+
"method": "POST",
143+
"path": "/api/2.2/jobs/delete"
144+
}
145+
State not found for jobs.foo
146+
147+
>>> musterr [CLI] jobs get [TEST_JOB_ID+0]
148+
Error: Not Found
149+
150+
Exit code (musterr): 1

acceptance/bundle/resources/jobs/script

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,17 @@ title "Update trigger.periodic.unit and re-deploy"
1313
trace update_file.py databricks.yml DAYS HOURS
1414
trace $CLI bundle deploy
1515
trace print_requests
16+
17+
title "Fetch job ID and verify remote state"
18+
19+
ppid=`read_id.py jobs foo`
20+
21+
trace $CLI jobs get $ppid
22+
rm out.requests.txt
23+
24+
title "Destroy the job and verify that it's removed from the state and from remote"
25+
trace $CLI bundle destroy --auto-approve
26+
trace print_requests
27+
28+
trace musterr $CLI jobs get $ppid
29+
rm out.requests.txt

bundle/terranova/terranova_resources/job.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ func (r *ResourceJob) DoUpdate(ctx context.Context, id string) (string, error) {
5353
}
5454

5555
func (r *ResourceJob) DoDelete(ctx context.Context, id string) error {
56+
idInt, err := strconv.ParseInt(id, 10, 64)
57+
if err != nil {
58+
return err
59+
}
60+
r.client.Jobs.DeleteByJobId(ctx, idInt)
61+
if err != nil {
62+
return SDKError{Method: "Jobs.DeleteByJobId", Err: err}
63+
}
5664
return nil
5765
}
5866

0 commit comments

Comments
 (0)