-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathjobarray_test.go
88 lines (68 loc) · 2.21 KB
/
jobarray_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
package drmaa2os
import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/dgruber/drmaa2interface"
"github.com/dgruber/drmaa2os/fakes"
)
var _ = Describe("Jobarray", func() {
Context("Basic JobArray Operations", func() {
id := "ID"
session := "sessionname"
template := drmaa2interface.JobTemplate{
RemoteCommand: "Command",
JobName: "name",
}
It("should return all set content", func() {
aj := newArrayJob(id, session, template, nil)
Ω(aj).ShouldNot(BeNil())
Ω(aj.GetID()).Should(Equal(id))
Ω(aj.GetSessionName()).Should(Equal(session))
Ω(aj.GetJobTemplate()).ShouldNot(BeNil())
Ω(aj.GetJobs()).Should(BeNil())
})
It("should perform operation on all jobs", func() {
js := []drmaa2interface.Job{
&fakes.Job{
ID: "1",
Session: "session",
},
&fakes.Job{
ID: "2",
Session: "session",
}}
aj := newArrayJob(id, session, template, js)
Ω(aj).ShouldNot(BeNil())
aj.Suspend()
jobs := aj.GetJobs()
Ω(jobs).ShouldNot(BeNil())
Ω(len(jobs)).Should(BeNumerically("==", 2))
Ω(jobs[0].GetState()).Should(Equal(drmaa2interface.Suspended))
Ω(jobs[1].GetState()).Should(Equal(drmaa2interface.Suspended))
aj.Resume()
jobs = aj.GetJobs()
Ω(jobs).ShouldNot(BeNil())
Ω(len(jobs)).Should(BeNumerically("==", 2))
Ω(jobs[0].GetState()).Should(Equal(drmaa2interface.Running))
Ω(jobs[1].GetState()).Should(Equal(drmaa2interface.Running))
aj.Hold()
jobs = aj.GetJobs()
Ω(jobs).ShouldNot(BeNil())
Ω(len(jobs)).Should(BeNumerically("==", 2))
Ω(jobs[0].GetState()).Should(Equal(drmaa2interface.QueuedHeld))
Ω(jobs[1].GetState()).Should(Equal(drmaa2interface.QueuedHeld))
aj.Release()
jobs = aj.GetJobs()
Ω(jobs).ShouldNot(BeNil())
Ω(len(jobs)).Should(BeNumerically("==", 2))
Ω(jobs[0].GetState()).Should(Equal(drmaa2interface.Running))
Ω(jobs[1].GetState()).Should(Equal(drmaa2interface.Running))
aj.Terminate()
jobs = aj.GetJobs()
Ω(jobs).ShouldNot(BeNil())
Ω(len(jobs)).Should(BeNumerically("==", 2))
Ω(jobs[0].GetState()).Should(Equal(drmaa2interface.Failed))
Ω(jobs[1].GetState()).Should(Equal(drmaa2interface.Failed))
})
})
})