-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathjobarray_hlp_test.go
112 lines (91 loc) · 2.8 KB
/
jobarray_hlp_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package drmaa2os
import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/dgruber/drmaa2interface"
"github.com/dgruber/drmaa2os/fakes"
)
var _ = Describe("JobarrayHlp", func() {
Context("Perform actions without issues", func() {
var jobs []drmaa2interface.Job
BeforeEach(func() {
jobs = []drmaa2interface.Job{
&fakes.Job{
ID: "1",
Session: "session",
},
&fakes.Job{
ID: "2",
Session: "session",
}}
})
It("should suspend all jobs", func() {
err := jobAction(suspend, jobs)
Ω(err).Should(BeNil())
Ω(jobs[0].GetState()).Should(Equal(drmaa2interface.Suspended))
Ω(jobs[1].GetState()).Should(Equal(drmaa2interface.Suspended))
})
It("should resume all jobs", func() {
err := jobAction(resume, jobs)
Ω(err).Should(BeNil())
Ω(jobs[0].GetState()).Should(Equal(drmaa2interface.Running))
Ω(jobs[1].GetState()).Should(Equal(drmaa2interface.Running))
})
It("should hold all jobs", func() {
err := jobAction(hold, jobs)
Ω(err).Should(BeNil())
Ω(jobs[0].GetState()).Should(Equal(drmaa2interface.QueuedHeld))
Ω(jobs[1].GetState()).Should(Equal(drmaa2interface.QueuedHeld))
})
It("should release all jobs", func() {
err := jobAction(release, jobs)
Ω(err).Should(BeNil())
Ω(jobs[0].GetState()).Should(Equal(drmaa2interface.Running))
Ω(jobs[1].GetState()).Should(Equal(drmaa2interface.Running))
})
It("should terminate all jobs", func() {
err := jobAction(terminate, jobs)
Ω(err).Should(BeNil())
Ω(jobs[0].GetState()).Should(Equal(drmaa2interface.Failed))
Ω(jobs[1].GetState()).Should(Equal(drmaa2interface.Failed))
})
})
Context("Perform action with errors", func() {
var jobs []drmaa2interface.Job
BeforeEach(func() {
jobs = append(jobs, &fakes.Job{
ID: "1",
Session: "session",
ErrorWhenSuspend: true,
})
jobs = append(jobs, &fakes.Job{
ID: "2",
Session: "session",
})
})
It("should report an error when first job fails to get suspended", func() {
err := jobAction(suspend, jobs)
Ω(err).ShouldNot(BeNil())
Ω(err.Error()).Should(Equal("Job 1 error: Some error happened"))
Ω(jobs[1].GetState()).Should(Equal(drmaa2interface.Suspended))
})
It("should report an error when second job fails to get suspended", func() {
jobs = []drmaa2interface.Job{
&fakes.Job{
ID: "1",
Session: "session",
ErrorWhenSuspend: false,
},
&fakes.Job{
ID: "2",
Session: "session",
ErrorWhenSuspend: true,
},
}
err := jobAction(suspend, jobs)
Ω(err).ShouldNot(BeNil())
Ω(err.Error()).Should(Equal("Job 2 error: Some error happened"))
Ω(jobs[0].GetState()).Should(Equal(drmaa2interface.Suspended))
})
})
})