-
Notifications
You must be signed in to change notification settings - Fork 600
/
LsfExecutorTest.groovy
725 lines (619 loc) · 24 KB
/
LsfExecutorTest.groovy
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
/*
* Copyright 2013-2024, Seqera Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nextflow.executor
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import nextflow.Session
import nextflow.processor.TaskConfig
import nextflow.processor.TaskProcessor
import nextflow.processor.TaskRun
import spock.lang.Specification
import spock.lang.Unroll
/**
*
* @author Paolo Di Tommaso <paolo.ditommaso@gmail.com>
*/
class LsfExecutorTest extends Specification {
def testCommandLine() {
when:
def executor = Spy(LsfExecutor)
then:
executor.getSubmitCommandLine(Mock(TaskRun), null) == ['bsub']
}
def testMemDirectiveMemUnit() {
given:
def WORK_DIR = Paths.get('/work/dir')
def executor = Spy(LsfExecutor)
def task = Mock(TaskRun)
task.workDir >> WORK_DIR
when:
def result = executor.getDirectives(task, [])
then:
1 * executor.getJobNameFor(task) >> 'foo'
_ * task.config >> new TaskConfig(memory: '10MB')
then:
result == ['-o', '/work/dir/.command.log',
'-M', '10240',
'-R', 'select[mem>=10240] rusage[mem=10]',
'-J', 'foo']
}
def testMemDirectiveMemUnit2() {
given:
def WORK_DIR = Paths.get('/work/dir')
def executor = Spy(new LsfExecutor(memUnit:'GB', usageUnit:'GB'))
def task = Mock(TaskRun)
task.workDir >> WORK_DIR
when:
executor.@memUnit = 'GB'
executor.@usageUnit = 'GB'
def result = executor.getDirectives(task, [])
then:
1 * executor.getJobNameFor(task) >> 'foo'
_ * task.config >> new TaskConfig(memory: '100GB')
then:
result == ['-o', '/work/dir/.command.log',
'-M', '100',
'-R', 'select[mem>=100] rusage[mem=100]',
'-J', 'foo']
}
def testReserveMemPerTask() {
given:
def WORK_DIR = Paths.get('/work/dir')
def executor = Spy(new LsfExecutor(usageUnit:'KB', perJobMemLimit:true))
def task = Mock(TaskRun)
task.workDir >> WORK_DIR
when:
executor.@usageUnit = 'KB'
executor.@perJobMemLimit = true
def result = executor.getDirectives(task, [])
then:
1 * executor.getJobNameFor(task) >> 'foo'
_ * task.config >> new TaskConfig(memory: '10MB', cpus: 2)
then:
result == ['-o', '/work/dir/.command.log',
'-n', '2',
'-R', 'span[hosts=1]',
'-M', '10240',
'-R', 'select[mem>=10240] rusage[mem=10240]',
'-J', 'foo']
}
def testReserveMemPerTask2() {
given:
def WORK_DIR = Paths.get('/work/dir')
def executor = Spy(new LsfExecutor(perTaskReserve:true, perJobMemLimit: true, usageUnit:'KB'))
def task = Mock(TaskRun)
task.workDir >> WORK_DIR
when:
executor.@perJobMemLimit = true
executor.@perTaskReserve = true
def result = executor.getDirectives(task, [])
then:
1 * executor.getJobNameFor(task) >> 'foo'
_ * task.config >> new TaskConfig(memory: '10MB', cpus: 2)
then:
result == ['-o', '/work/dir/.command.log',
'-n', '2',
'-R', 'span[hosts=1]',
'-M', '10240',
'-R', 'select[mem>=10240] rusage[mem=5120]',
'-J', 'foo']
}
def testHeaders() {
setup:
// LSF executor
def executor = Spy(LsfExecutor)
executor.@memUnit = 'MB'
executor.@usageUnit = 'MB'
executor.session = new Session()
// mock process
def proc = Mock(TaskProcessor)
// process name
proc.getName() >> 'task'
// task object
def task = new TaskRun()
task.processor = proc
task.workDir = Paths.get('/scratch')
task.name = 'mapping hola'
when:
task.config = new TaskConfig()
// config
task.config.queue = 'bsc_ls'
task.config.clusterOptions = "-x 1 -R \"span[ptile=2]\""
task.config.cpus = '2'
task.config.time = '1h 30min'
task.config.memory = '8GB'
then:
executor.getHeaders(task) == '''
#BSUB -o /scratch/.command.log
#BSUB -q bsc_ls
#BSUB -n 2
#BSUB -R "span[hosts=1]"
#BSUB -W 01:30
#BSUB -M 4096
#BSUB -R "select[mem>=8192] rusage[mem=8192]"
#BSUB -J nf-mapping_hola
#BSUB -x 1
#BSUB -R "span[ptile=2]"
'''
.stripIndent().leftTrim()
when:
task.config = new TaskConfig()
task.config.queue = 'alpha'
task.config.cpus = 1
then:
executor.getHeaders(task) == '''
#BSUB -o /scratch/.command.log
#BSUB -q alpha
#BSUB -J nf-mapping_hola
'''
.stripIndent().leftTrim()
when:
task.config = new TaskConfig()
task.config.queue = 'alpha'
task.config.cpus = 1
task.config.time = '1min'
task.config.memory = '10MB'
then:
executor.getHeaders(task) == '''
#BSUB -o /scratch/.command.log
#BSUB -q alpha
#BSUB -W 00:01
#BSUB -M 10
#BSUB -R "select[mem>=10] rusage[mem=10]"
#BSUB -J nf-mapping_hola
'''
.stripIndent().leftTrim()
when:
task.config = new TaskConfig()
task.config.queue = 'gamma'
task.config.cpus = 1
task.config.time = '4h'
task.config.memory = '200MB'
then:
executor.getHeaders(task) == '''
#BSUB -o /scratch/.command.log
#BSUB -q gamma
#BSUB -W 04:00
#BSUB -M 200
#BSUB -R "select[mem>=200] rusage[mem=200]"
#BSUB -J nf-mapping_hola
'''
.stripIndent().leftTrim()
when:
task.config = new TaskConfig()
task.config.queue = 'gamma'
task.config.cpus = 4
task.config.memory = '2GB'
then:
executor.getHeaders(task) == '''
#BSUB -o /scratch/.command.log
#BSUB -q gamma
#BSUB -n 4
#BSUB -R "span[hosts=1]"
#BSUB -M 512
#BSUB -R "select[mem>=2048] rusage[mem=2048]"
#BSUB -J nf-mapping_hola
'''
.stripIndent().leftTrim()
when:
task.config = new TaskConfig()
task.config.queue = 'gamma'
task.config.cpus = 4
task.config.memory = '2GB'
task.config.time = '1d'
then:
executor.getHeaders(task) == '''
#BSUB -o /scratch/.command.log
#BSUB -q gamma
#BSUB -n 4
#BSUB -R "span[hosts=1]"
#BSUB -W 24:00
#BSUB -M 512
#BSUB -R "select[mem>=2048] rusage[mem=2048]"
#BSUB -J nf-mapping_hola
'''
.stripIndent().leftTrim()
when:
task.config = new TaskConfig()
task.config.queue = 'gamma'
task.config.cpus = 8
task.config.memory = '2GB'
task.config.time = '2d'
then:
executor.getHeaders(task) == '''
#BSUB -o /scratch/.command.log
#BSUB -q gamma
#BSUB -n 8
#BSUB -R "span[hosts=1]"
#BSUB -W 48:00
#BSUB -M 256
#BSUB -R "select[mem>=2048] rusage[mem=2048]"
#BSUB -J nf-mapping_hola
'''
.stripIndent().leftTrim()
when:
task.config = new TaskConfig()
task.config.queue = 'delta'
task.config.memory = '2GB'
task.config.time = '2d 12h 5m'
then:
executor.getHeaders(task) == '''
#BSUB -o /scratch/.command.log
#BSUB -q delta
#BSUB -W 60:05
#BSUB -M 2048
#BSUB -R "select[mem>=2048] rusage[mem=2048]"
#BSUB -J nf-mapping_hola
'''
.stripIndent().leftTrim()
}
def testDiskResources() {
given:
def config = new TaskConfig(clusterOptions: [], disk: '10GB')
def WORKDIR = Paths.get('/my/work')
def lsf = Spy(LsfExecutor)
lsf.@memUnit = 'MB'
def task = Mock(TaskRun)
when:
def result = lsf.getDirectives(task)
then:
task.workDir >> WORKDIR
task.config >> config
task.name >> 'foo'
and:
result.join(' ') == "-o $WORKDIR/.command.log -R select[tmp>=10240] rusage[tmp=10240] -J nf-foo"
}
def testPerJobMemLimit() {
setup:
// mock process
def proc = Mock(TaskProcessor)
// process name
proc.getName() >> 'task'
// task object
def task = new TaskRun()
task.processor = proc
task.workDir = Paths.get('/scratch')
task.name = 'mapping hola'
// config
task.config = new TaskConfig()
task.config.queue = 'bsc_ls'
task.config.cpus = 4
task.config.memory = '8GB'
when:
// LSF executor
def executor = Spy(LsfExecutor)
executor.session = new Session()
executor.@memUnit = 'MB'
then:
executor.getHeaders(task) == '''
#BSUB -o /scratch/.command.log
#BSUB -q bsc_ls
#BSUB -n 4
#BSUB -R "span[hosts=1]"
#BSUB -M 2048
#BSUB -R "select[mem>=8192] rusage[mem=8192]"
#BSUB -J nf-mapping_hola
'''
.stripIndent().leftTrim()
}
def 'should use per job mem limit' () {
given:
// mock process
def proc = Mock(TaskProcessor)
// process name
proc.getName() >> 'task'
// task object
def task = new TaskRun()
task.processor = proc
task.workDir = Paths.get('/scratch')
task.name = 'mapping hola'
// config
task.config = new TaskConfig()
task.config.queue = 'bsc_ls'
task.config.cpus = 4
task.config.memory = '8GB'
when:
// LSF executor
def executor = Spy(LsfExecutor)
executor.@memUnit = 'MB'
executor.session = new Session([executor: [perJobMemLimit: true]])
executor.register()
then:
executor.getHeaders(task) == '''
#BSUB -o /scratch/.command.log
#BSUB -q bsc_ls
#BSUB -n 4
#BSUB -R "span[hosts=1]"
#BSUB -M 8192
#BSUB -R "select[mem>=8192] rusage[mem=8192]"
#BSUB -J nf-mapping_hola
'''
.stripIndent().leftTrim()
}
def testWorkDirWithBlanks() {
given:
// LSF executor
def executor = Spy(new LsfExecutor(memUnit: 'MB', usageUnit: 'MB'))
executor.session = new Session()
executor.@memUnit = 'MB'
executor.@usageUnit = 'MB'
and:
// mock process
def proc = Mock(TaskProcessor)
// process name
proc.getName() >> 'task'
// task object
def task = new TaskRun()
task.processor = proc
task.workDir = Paths.get('/scratch/some data/path')
task.name = 'mapping hola'
when:
task.config = new TaskConfig()
// config
task.config.queue = 'bsc_ls'
task.config.clusterOptions = "-x 1 -R \"span[ptile=2]\""
task.config.cpus = '2'
task.config.time = '1h 30min'
task.config.memory = '8GB'
then:
executor.getHeaders(task) == '''
#BSUB -o "/scratch/some data/path/.command.log"
#BSUB -q bsc_ls
#BSUB -n 2
#BSUB -R "span[hosts=1]"
#BSUB -W 01:30
#BSUB -M 4096
#BSUB -R "select[mem>=8192] rusage[mem=8192]"
#BSUB -J nf-mapping_hola
#BSUB -x 1
#BSUB -R "span[ptile=2]"
'''
.stripIndent().leftTrim()
}
def testParseJobId() {
when:
// executor stub object
def executor = Spy(LsfExecutor)
then:
executor.parseJobId( 'Job <2329803> is submitted to default queue <research-rh6>.' ) == '2329803'
}
def testKillCommand() {
when:
// executor stub object
def executor = Spy(LsfExecutor)
then:
executor.killTaskCommand('12345').join(' ') == 'bkill 12345'
}
def testQstatCommand() {
setup:
def executor = Spy(LsfExecutor)
def text =
"""\
JOBID USER STAT QUEUE FROM_HOST EXEC_HOST JOB_NAME SUBMIT_TIME
5085109 pluskal RUN normal it-c01b13 it-c01b11 /lab/solexa_weng/xtal_data/Data_processing/Tomas_Pluskal/20181031_KLR1_autobuild/AutoBuild_run_1_/TEMP0/RUN_FILE_4 Oct 31 13:00
5085585 pluskal RUN normal tak it-c05b12 phenix.autobuild autobuild_config.eff Oct 31 14:05
5085604 pluskal PEND normal it-c05b12 it-c05b12 /lab/solexa_weng/xtal_data/Data_processing/Tomas_Pluskal/20181031_KLR1_autobuild_not_in_place/AutoBuild_run_1_/TEMP0/RUN_FILE_1 Oct 31 14:44
5085611 pluskal PSUSP normal it-c05b12 it-c05b12 /lab/solexa_weng/xtal_data/Data_processing/Tomas_Pluskal/20181031_KLR1_autobuild_not_in_place/AutoBuild_run_1_/TEMP0/RUN_FILE_8 Oct 31 14:44
5085107 pluskal EXIT normal it-c01b13 it-c01b07 /lab/solexa_weng/xtal_data/Data_processing/Tomas_Pluskal/20181031_KLR1_autobuild/AutoBuild_run_1_/TEMP0/RUN_FILE_2 Oct 31 13:00
5085607 pluskal UNKWN normal it-c05b12 it-c01b07 /lab/solexa_weng/xtal_data/Data_processing/Tomas_Pluskal/20181031_KLR1_autobuild_not_in_place/AutoBuild_run_1_/TEMP0/RUN_FILE_4 Oct 31 14:44
5085608 pluskal ZOMBI normal it-c05b12 it-c01b05 /lab/solexa_weng/xtal_data/Data_processing/Tomas_Pluskal/20181031_KLR1_autobuild_not_in_place/AutoBuild_run_1_/TEMP0/RUN_FILE_5 Oct 31 14:44
5085609 pluskal RUN normal it-c05b12 it-c01b14 /lab/solexa_weng/xtal_data/Data_processing/Tomas_Pluskal/20181031_KLR1_autobuild_not_in_place/AutoBuild_run_1_/TEMP0/RUN_FILE_6 Oct 31 14:44
5085702 pluskal RUN normal tak it-c01b14 ./assemble.nf Oct 31 15:08
5085606 pluskal DONE normal it-c05b12 it-c01b12 /lab/solexa_weng/xtal_data/Data_processing/Tomas_Pluskal/20181031_KLR1_autobuild_not_in_place/AutoBuild_run_1_/TEMP0/RUN_FILE_3 Oct 31 14:44
5085034 pluskal RUN normal tak it-c01b13 phenix.autobuild autobuild_config.eff Oct 31 12:56
5085612 pluskal RUN normal it-c05b12 it-c01b13 /lab/solexa_weng/xtal_data/Data_processing/Tomas_Pluskal/20181031_KLR1_autobuild_not_in_place/AutoBuild_run_1_/TEMP0/RUN_FILE_9 Oct 31 14:44
5085703 pluskal RUN normal it-c01b14 it-r16u31:it-r16u31:it-r16u31:it-r16u31:it-r16u31:it-r16u31:it-r16u31:it-r16u31:it-r16u31:it-r16u31 nf-trinityInchwormChrysalis Oct 31 15:08
5085704 longusername RUN normal it-c01b15 it-r16u31:it-r16u31:it-r16u31:it-r16u31:it-r16u31:it-r16u31:it-r16u31:it-r16u31:it-r16u31:it-r16u31 nf-trinityInchwormChrysalis Oct 31 16:08
""".stripIndent().trim()
when:
def result = executor.parseQueueStatus(text)
then:
result['5085109'] == AbstractGridExecutor.QueueStatus.RUNNING
result['5085585'] == AbstractGridExecutor.QueueStatus.RUNNING
result['5085604'] == AbstractGridExecutor.QueueStatus.PENDING
result['5085611'] == AbstractGridExecutor.QueueStatus.HOLD
result['5085107'] == AbstractGridExecutor.QueueStatus.ERROR
result['5085607'] == AbstractGridExecutor.QueueStatus.ERROR
result['5085608'] == AbstractGridExecutor.QueueStatus.ERROR
result['5085609'] == AbstractGridExecutor.QueueStatus.RUNNING
result['5085702'] == AbstractGridExecutor.QueueStatus.RUNNING
result['5085606'] == AbstractGridExecutor.QueueStatus.DONE
result['5085034'] == AbstractGridExecutor.QueueStatus.RUNNING
result['5085612'] == AbstractGridExecutor.QueueStatus.RUNNING
result['5085703'] == AbstractGridExecutor.QueueStatus.RUNNING
result['5085704'] == AbstractGridExecutor.QueueStatus.RUNNING
result.size()==14
}
def 'should parse bjobs stats with extra headers' () {
setup:
def executor = Spy(LsfExecutor)
def TEXT = '''
LSF is processing your request. Please wait ...
LSF is processing your request. Please wait ...
JOBID USER STAT QUEUE FROM_HOST EXEC_HOST JOB_NAME SUBMIT_TIME
5157393 pluskal RUN normal it-c05b07 it-c05b10 *l_cmd_bd) Nov 14 13:00
5157493 pluskal RUN normal it-c05b07 it-c05b10 *l_cmd_cn) Nov 14 13:00
5157552 pluskal RUN normal it-c05b07 it-c05b10 *l_cmd_dl) Nov 14 13:00
5157610 pluskal RUN normal it-c05b07 it-c05b10 *l_cmd_fe) Nov 14 13:00
5157674 pluskal RUN normal it-c05b07 it-c05b10 *l_cmd_gf) Nov 14 13:00
5157710 pluskal RUN normal it-c05b07 it-c05b10 *l_cmd_fv) Nov 14 13:00
'''.stripIndent().trim()
when:
def result = executor.parseQueueStatus(TEXT)
then:
result['5157393'] == AbstractGridExecutor.QueueStatus.RUNNING
result['5157493'] == AbstractGridExecutor.QueueStatus.RUNNING
result['5157552'] == AbstractGridExecutor.QueueStatus.RUNNING
result['5157610'] == AbstractGridExecutor.QueueStatus.RUNNING
result['5157674'] == AbstractGridExecutor.QueueStatus.RUNNING
result['5157710'] == AbstractGridExecutor.QueueStatus.RUNNING
result.size() == 6
}
def testQueueStatusCommand() {
setup:
def executor = Spy(LsfExecutor)
expect:
executor.queueStatusCommand(null) == ['bjobs', '-w']
executor.queueStatusCommand('long') == ['bjobs', '-w', '-q', 'long']
}
def testWrapString() {
given:
def executor = Spy(LsfExecutor)
expect:
executor.wrapHeader('') == ''
executor.wrapHeader('hello') == 'hello'
executor.wrapHeader('span[ptile=number]') == '"span[ptile=number]"'
executor.wrapHeader('hello world') == '"hello world"'
executor.pipeLauncherScript() == true
executor.getSubmitCommandLine(Mock(TaskRun), Mock(Path)) == ['bsub']
}
def 'should apply lsf mem unit' () {
given:
def executor = Spy(LsfExecutor)
executor.session = Mock(Session)
when:
executor.register()
then:
1 * executor.parseLsfConfig() >> [:]
executor.memUnit == 'KB'
executor.usageUnit == 'MB'
when:
executor.register()
then:
1 * executor.parseLsfConfig() >> ['LSF_UNIT_FOR_LIMITS': 'GB']
executor.memUnit == 'GB'
executor.usageUnit == 'GB'
}
def 'should apply per task reserve' () {
given:
def session = Mock(Session)
def executor = Spy(LsfExecutor)
executor.session = session
when:
executor.register()
then:
1 * executor.parseLsfConfig() >> [:]
1 * session.getExecConfigProp(_,'perTaskReserve',_) >> false
!executor.perTaskReserve
when:
executor.register()
then:
1 * executor.parseLsfConfig() >> [RESOURCE_RESERVE_PER_TASK:'y']
1 * session.getExecConfigProp(_,'perTaskReserve',_) >> false
!executor.perTaskReserve
when:
executor.register()
then:
1 * executor.parseLsfConfig() >> [:]
1 * session.getExecConfigProp(_,'perTaskReserve',_) >> true
executor.perTaskReserve
when:
executor.register()
then:
1 * executor.parseLsfConfig() >> [RESOURCE_RESERVE_PER_TASK:'y']
1 * session.getExecConfigProp(_,'perTaskReserve',_) >> { execName,name,defValue -> defValue }
executor.perTaskReserve
}
def 'should apply lsf per job limit' () {
given:
def session = Mock(Session)
def executor = Spy(LsfExecutor)
executor.session = session
when:
executor.register()
then:
1 * executor.parseLsfConfig() >> [:]
1 * session.getExecConfigProp(_,'perJobMemLimit',_) >> false
!executor.perJobMemLimit
when:
executor.register()
then:
1 * executor.parseLsfConfig() >> [LSB_JOB_MEMLIMIT:'y']
1 * session.getExecConfigProp(_,'perJobMemLimit',_) >> false
!executor.perJobMemLimit
when:
executor.register()
then:
1 * executor.parseLsfConfig() >> [:]
1 * session.getExecConfigProp(_,'perJobMemLimit',_) >> true
executor.perJobMemLimit
when:
executor.register()
then:
1 * executor.parseLsfConfig() >> [LSB_JOB_MEMLIMIT:'y']
1 * session.getExecConfigProp(_,'perJobMemLimit',_) >> { execName,name,defValue -> defValue }
executor.perJobMemLimit
}
def 'should parse lsf.config' () {
given:
def executor = Spy(LsfExecutor)
def folder = Files.createTempDirectory('test')
def file = folder.resolve('lsf.conf')
file.text = '''
LSF_FOO=abc
LSF_BAR="x y z"
'''.stripIndent()
when:
def conf = executor.parseLsfConfig()
then:
1 * executor.getEnv0('LSF_ENVDIR') >> null
conf == [:]
when:
conf = executor.parseLsfConfig()
then:
1 * executor.getEnv0('LSF_ENVDIR') >> folder.toString()
conf == [LSF_FOO:'abc', LSF_BAR:'x y z']
cleanup:
folder?.deleteDir()
}
def 'should parse complex config file' () {
given:
def executor = Spy(LsfExecutor)
def file = new File('src/test/resources/nextflow/executor/lsf.conf')
assert file.exists(), 'Cannot find LSF config test file'
when:
def config = executor.parseLsfConfig()
then:
1 * executor.getEnv0('LSF_ENVDIR') >> file.absoluteFile.parent
then:
config.LSF_LOGDIR == '/common/foo/bar/log'
config.LSF_LOG_MASK=='LOG_WARNING'
config.LSF_LIM_PORT == '7869'
config.LSF_UNIT_FOR_LIMITS == 'GB'
config.LSF_STRIP_DOMAIN == '.cbio.private:.cbio.delta.org:.delta.org'
config.LSF_MASTER_LIST == "omega-sched01 omega-sched02"
config.LSF_API_CONNTIMEOUT == '10'
config.RESOURCE_RESERVE_PER_TASK == 'Y'
}
// Adapted from PbsExecutorTest.groovy
@Unroll
def 'should return valid job name given #name'() {
given:
def executor = [:] as LsfExecutor
def task = Mock(TaskRun)
task.getName() >> name
expect:
executor.getJobNameFor(task) == expected
executor.getJobNameFor(task).size() <= 4094
where:
name | expected
'hello' | 'nf-hello'
'12 45' | 'nf-12_45'
'hello[123]-[xyz]' | 'nf-hello123-xyz'
'a'.repeat(509) | 'nf-'.concat("a".repeat(508))
}
}