Debian Codegraph @

tests/unit/job_runner_handlers/test_loadleveler.py

raw
1 # THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE.
2 # Copyright (C) NIWA & British Crown (Met Office) & Contributors.
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17 import pytest
18
19 from cylc.flow.job_runner_handlers.loadleveler import JOB_RUNNER_HANDLER
20 from cylc.flow.job_runner_handlers.loadleveler import LoadlevelerHandler
21
22
23 @pytest.mark.parametrize(
24 'job_conf,lines',
25 [
26 ( # basic
27 {
28 'directives': {},
29 'execution_time_limit': 180,
30 'job_file_path': 'cylc-run/chop/log/job/1/axe/01/job',
31 'workflow_name': 'chop',
32 'task_id': '1/axe',
33 },
34 [
35 '# @ job_name = chop.axe.1',
36 '# @ output = cylc-run/chop/log/job/1/axe/01/job.out',
37 '# @ error = cylc-run/chop/log/job/1/axe/01/job.err',
38 '# @ wall_clock_limit = 240,180',
39 '# @ queue'
40 ],
41 ),
42
43 ( # some useful directives
44 {
45 'directives': {
46 '-q': 'forever',
47 '-V': '',
48 '-l mem': '256gb',
49 },
50 'execution_time_limit': 180,
51 'job_file_path': 'cylc-run/chop/log/job/1/axe/01/job',
52 'workflow_name': 'chop',
53 'task_id': '1/axe',
54 },
55 [
56 '# @ job_name = chop.axe.1',
57 '# @ output = cylc-run/chop/log/job/1/axe/01/job.out',
58 '# @ error = cylc-run/chop/log/job/1/axe/01/job.err',
59 '# @ wall_clock_limit = 240,180',
60 '# @ -q = forever',
61 '# @ -V',
62 '# @ -l mem = 256gb',
63 '# @ queue'
64 ],
65 ),
66 ],
67 )
68 def test_format_directives(job_conf: dict, lines: list):
69 assert JOB_RUNNER_HANDLER.format_directives(job_conf) == lines
70
71
72 def test_filter_poll_many_output():
73
74 configuration = '''
75 Id Owner Submitted ST PRI Class Running On
76 ---------------- ---------- ----------- -- --- -------- ----------
77 mars.498.0 brownap 5/20 11:31 R 100 silver mars
78 mars.499.0 brownap 5/20 11:31 R 50 No_Class mars
79 mars.501.0 brownap 5/20 11:31 I 50 silver
80 '''
81 out = ['Id', '----------------', 'mars.498', 'mars.499', 'mars.501']
82 assert LoadlevelerHandler.filter_poll_many_output(configuration) == out