comana 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,214 +0,0 @@
1
- #! /usr/bin/env ruby
2
- # coding: utf-8
3
-
4
- require "helper"
5
- class Comana::QueueSubmitter # < ComputationManager
6
- public :dump_prologue
7
- public :dump_script
8
- public :dump_epilogue
9
- end
10
-
11
- class TC_QueueSubmitter < Test::Unit::TestCase
12
- def setup
13
- opts = {
14
- :target => Comana::ComputationManager.new("test/not_started"),
15
- :command => "command_line",
16
- :cluster => "Nodes",
17
- :num_nodes => 4,
18
- }
19
- @qs_notstarted = Comana::QueueSubmitter.new(opts)
20
-
21
- opts = {
22
- :target => Comana::ComputationManager.new("test/queuesubmitter/locked"),
23
- :command => "command_line",
24
- :cluster => "Nodes",
25
- :num_nodes => 4,
26
- }
27
- @qs_locked = Comana::QueueSubmitter.new(opts)
28
-
29
- opts = {
30
- :target => Comana::ComputationManager.new("test/queuesubmitter/unlocked"),
31
- :command => "command_line",
32
- :cluster => "Nodes",
33
- :num_nodes => 4,
34
- }
35
- @qs_unlocked = Comana::QueueSubmitter.new(opts)
36
- end
37
-
38
- def test_initialize
39
- opts = {
40
- #:target => "dir_name",
41
- :command => "command_line",
42
- :cluster => "Nodes",
43
- :num_nodes => 4,
44
- }
45
- assert_raise(Comana::QueueSubmitter::InitializeError){
46
- Comana::QueueSubmitter.new(opts)
47
- }
48
-
49
- opts = {
50
- :target => Comana::ComputationManager.new("dir_name"),
51
- #:command => "command_line",
52
- :cluster => "Nodes",
53
- :num_nodes => 4,
54
- }
55
- assert_raise(Comana::QueueSubmitter::InitializeError){
56
- Comana::QueueSubmitter.new(opts)
57
- }
58
-
59
- opts = {
60
- :target => Comana::ComputationManager.new("dir_name"),
61
- :command => "command_line",
62
- #:cluster => "Nodes",
63
- :num_nodes => 4,
64
- }
65
- assert_nothing_raised{ Comana::QueueSubmitter.new(opts) }
66
-
67
- opts = {
68
- :target => Comana::ComputationManager.new("dir_name"),
69
- :command => "command_line",
70
- :cluster => "Nodes",
71
- #:num_nodes => 4,
72
- }
73
- assert_nothing_raised{ Comana::QueueSubmitter.new(opts) }
74
- end
75
-
76
- def test_dump_prologue
77
- #context "speed mode" do
78
- correct = [
79
- '#! /bin/sh',
80
- 'LOGFILE="${PBS_O_WORKDIR}/prologue_script.log"',
81
- 'echo "hostname : `hostname`" >> $LOGFILE',
82
- 'echo "job id : $1" >> $LOGFILE',
83
- 'echo "job execution user name : $2" >> $LOGFILE',
84
- 'echo "job execution group name : $3" >> $LOGFILE',
85
- 'echo "job name : $4" >> $LOGFILE',
86
- 'echo "list of requested resource limits: $5" >> $LOGFILE',
87
- 'echo "job execution queue : $6" >> $LOGFILE',
88
- 'echo "job account : $7" >> $LOGFILE',
89
- 'echo "PBS_O_WORKDIR : ${PBS_O_WORKDIR}" >> $LOGFILE',
90
- 'echo "nodes in pbs_nodefile : " >> $LOGFILE',
91
- 'cat ${PBS_NODEFILE} >> $LOGFILE',
92
- 'exit 0',
93
- ].join("\n")
94
- assert_equal(correct, @qs_notstarted.dump_prologue)
95
- end
96
-
97
- def test_dump_script
98
- correct = [
99
- "#! /bin/sh",
100
- "#PBS -N test/not_started",
101
- "#PBS -l nodes=4:ppn=1:Nodes,walltime=7:00:00:00",
102
- "#PBS -j oe",
103
- "",
104
- "cd ${PBS_O_WORKDIR} && \\",
105
- "command_line",
106
- ].join("\n")
107
- assert_equal(correct, @qs_notstarted.dump_script)
108
-
109
-
110
- opts = {
111
- :target => Comana::ComputationManager.new("test/not_started"),
112
- :command => "command_line",
113
- #:cluster => "Nodes",
114
- :num_nodes => 4,
115
- }
116
- qs = Comana::QueueSubmitter.new(opts)
117
- correct = [
118
- "#! /bin/sh",
119
- "#PBS -N test/not_started",
120
- "#PBS -l nodes=4:ppn=1,walltime=7:00:00:00",
121
- "#PBS -j oe",
122
- "",
123
- "cd ${PBS_O_WORKDIR} && \\",
124
- "command_line",
125
- ].join("\n")
126
- assert_equal(correct, qs.dump_script)
127
-
128
-
129
- opts = {
130
- :target => Comana::ComputationManager.new("test/not_started"),
131
- :command => "command_line",
132
- :cluster => "Nodes",
133
- #:num_nodes => 4,
134
- }
135
- qs = Comana::QueueSubmitter.new(opts)
136
- correct = [
137
- "#! /bin/sh",
138
- "#PBS -N test/not_started",
139
- "#PBS -l nodes=1:ppn=1:Nodes,walltime=7:00:00:00",
140
- "#PBS -j oe",
141
- "",
142
- "cd ${PBS_O_WORKDIR} && \\",
143
- "command_line",
144
- ].join("\n")
145
- assert_equal(correct, qs.dump_script)
146
-
147
- opts = {
148
- :target => Comana::ComputationManager.new("test/not_started"),
149
- :command => "command_line",
150
- #:cluster => "Nodes",
151
- #:num_nodes => 4,
152
- }
153
- qs = Comana::QueueSubmitter.new(opts)
154
- correct = [
155
- "#! /bin/sh",
156
- "#PBS -N test/not_started",
157
- "#PBS -l walltime=7:00:00:00",
158
- "#PBS -j oe",
159
- "",
160
- "cd ${PBS_O_WORKDIR} && \\",
161
- "command_line",
162
- ].join("\n")
163
- assert_equal(correct, qs.dump_script)
164
-
165
- opts = {
166
- :target => Comana::ComputationManager.new("test/not_started"),
167
- :command => "command_line",
168
- #:cluster => "Nodes",
169
- #:num_nodes => 4,
170
- :priority => -10,
171
- }
172
- qs = Comana::QueueSubmitter.new(opts)
173
- correct = [
174
- "#! /bin/sh",
175
- "#PBS -N test/not_started",
176
- "#PBS -l walltime=7:00:00:00",
177
- "#PBS -p -10",
178
- "#PBS -j oe",
179
- "",
180
- "cd ${PBS_O_WORKDIR} && \\",
181
- "command_line",
182
- ].join("\n")
183
- assert_equal(correct, qs.dump_script)
184
-
185
- end
186
-
187
- def test_dump_epilogue
188
- correct = [
189
- '#! /bin/sh',
190
- 'LOGFILE="${PBS_O_WORKDIR}/epilogue_script.log"',
191
- 'echo "job id : $1" >> $LOGFILE',
192
- 'echo "job execution user name : $2" >> $LOGFILE',
193
- 'echo "job execution group name : $3" >> $LOGFILE',
194
- 'echo "job name : $4" >> $LOGFILE',
195
- 'echo "session id : $5" >> $LOGFILE',
196
- 'echo "list of requested resource limits: $6" >> $LOGFILE',
197
- 'echo "list of resources used by job : $7" >> $LOGFILE',
198
- 'echo "job execution queue : $8" >> $LOGFILE',
199
- 'echo "job account : $9" >> $LOGFILE',
200
- 'echo "job exit code : $10" >> $LOGFILE',
201
- 'exit 0',
202
- ].join("\n")
203
-
204
- assert_equal(correct, @qs_notstarted.dump_epilogue)
205
- end
206
-
207
- def test_finished?
208
- #context "locked" do
209
- assert_equal(true, @qs_locked.finished?)
210
-
211
- #context "unlocked" do
212
- assert_equal(false, @qs_unlocked.finished?)
213
- end
214
- end