Skip to content

Commit b8d0130

Browse files
authored
add test code for job task order (#3183)
1 parent fe54a55 commit b8d0130

File tree

1 file changed

+182
-0
lines changed

1 file changed

+182
-0
lines changed

jobs/resource_job_test.go

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,188 @@ func TestResourceJobCreate_MultiTask(t *testing.T) {
293293
assert.Equal(t, "789", d.Id())
294294
}
295295

296+
func TestResourceJobCreate_TaskOrder(t *testing.T) {
297+
d, err := qa.ResourceFixture{
298+
Fixtures: []qa.HTTPFixture{
299+
{
300+
Method: "POST",
301+
Resource: "/api/2.1/jobs/create",
302+
ExpectedRequest: JobSettings{
303+
Name: "Featurizer",
304+
Tasks: []JobTaskSettings{
305+
{
306+
TaskKey: "a",
307+
ExistingClusterID: "abc",
308+
NotebookTask: &NotebookTask{
309+
NotebookPath: "/a",
310+
},
311+
},
312+
{
313+
TaskKey: "b",
314+
DependsOn: []jobs.TaskDependency{
315+
{
316+
TaskKey: "a",
317+
},
318+
},
319+
ExistingClusterID: "abc",
320+
NotebookTask: &NotebookTask{
321+
NotebookPath: "/b",
322+
},
323+
},
324+
{
325+
TaskKey: "c",
326+
DependsOn: []jobs.TaskDependency{
327+
{
328+
TaskKey: "a",
329+
},
330+
{
331+
TaskKey: "b",
332+
},
333+
},
334+
ExistingClusterID: "abc",
335+
NotebookTask: &NotebookTask{
336+
NotebookPath: "/c",
337+
},
338+
},
339+
{
340+
TaskKey: "d",
341+
DependsOn: []jobs.TaskDependency{
342+
{
343+
TaskKey: "a",
344+
},
345+
{
346+
TaskKey: "b",
347+
},
348+
{
349+
TaskKey: "c",
350+
},
351+
},
352+
ExistingClusterID: "abc",
353+
NotebookTask: &NotebookTask{
354+
NotebookPath: "/d",
355+
},
356+
},
357+
},
358+
MaxConcurrentRuns: 1,
359+
Health: &JobHealth{
360+
Rules: []JobHealthRule{
361+
{
362+
Metric: "RUN_DURATION_SECONDS",
363+
Operation: "GREATER_THAN",
364+
Value: 3600,
365+
},
366+
},
367+
},
368+
},
369+
Response: Job{
370+
JobID: 789,
371+
},
372+
},
373+
{
374+
Method: "GET",
375+
Resource: "/api/2.1/jobs/get?job_id=789",
376+
Response: Job{
377+
// good enough for mock
378+
Settings: &JobSettings{
379+
Tasks: []JobTaskSettings{
380+
{
381+
TaskKey: "b",
382+
},
383+
{
384+
TaskKey: "a",
385+
},
386+
{
387+
TaskKey: "d",
388+
},
389+
{
390+
TaskKey: "c",
391+
},
392+
},
393+
},
394+
},
395+
},
396+
},
397+
Create: true,
398+
Resource: ResourceJob(),
399+
HCL: `
400+
name = "Featurizer"
401+
402+
health {
403+
rules {
404+
metric = "RUN_DURATION_SECONDS"
405+
op = "GREATER_THAN"
406+
value = 3600
407+
}
408+
}
409+
410+
task {
411+
task_key = "a"
412+
413+
existing_cluster_id = "abc"
414+
415+
notebook_task {
416+
notebook_path = "/a"
417+
}
418+
}
419+
420+
task {
421+
task_key = "b"
422+
423+
depends_on {
424+
task_key = "a"
425+
}
426+
427+
existing_cluster_id = "abc"
428+
429+
notebook_task {
430+
notebook_path = "/b"
431+
}
432+
}
433+
434+
task {
435+
task_key = "c"
436+
437+
depends_on {
438+
task_key = "a"
439+
}
440+
441+
depends_on {
442+
task_key = "b"
443+
}
444+
445+
existing_cluster_id = "abc"
446+
447+
notebook_task {
448+
notebook_path = "/c"
449+
}
450+
}
451+
452+
task {
453+
task_key = "d"
454+
455+
depends_on {
456+
task_key = "a"
457+
}
458+
459+
depends_on {
460+
task_key = "b"
461+
}
462+
463+
depends_on {
464+
task_key = "c"
465+
}
466+
467+
existing_cluster_id = "abc"
468+
469+
notebook_task {
470+
notebook_path = "/d"
471+
}
472+
}`,
473+
}.Apply(t)
474+
assert.NoError(t, err)
475+
assert.Equal(t, "789", d.Id())
476+
}
477+
296478
func TestResourceJobCreate_ConditionTask(t *testing.T) {
297479
d, err := qa.ResourceFixture{
298480
Fixtures: []qa.HTTPFixture{

0 commit comments

Comments
 (0)