Skip to content

Commit c28856c

Browse files
author
Vasileios Karakasis
authored
Merge branch 'master' into nodelist
2 parents 21a6db9 + 42edd30 commit c28856c

27 files changed

+480
-450
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
[![Slack](https://reframe-slack.herokuapp.com/badge.svg)](https://reframe-slack.herokuapp.com/)<br/>
1414
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
1515
[![DOI](https://zenodo.org/badge/89384186.svg)](https://zenodo.org/badge/latestdoi/89384186)<br/>
16-
![Twitter Follow](https://img.shields.io/twitter/follow/ReFrameHPC?style=social)
16+
[![Twitter Follow](https://img.shields.io/twitter/follow/ReFrameHPC?style=social)](https://twitter.com/ReFrameHPC)
1717

1818
# ReFrame in a Nutshell
1919

cscs-checks/system/slurm/slurm.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,3 +257,36 @@ def reference_meminfo(self):
257257
'pilatus:mc': 250,
258258
}
259259
return reference_meminfo[self.current_partition.fullname]
260+
261+
262+
@rfm.simple_test
263+
class slurm_response_check(rfm.RunOnlyRegressionTest):
264+
command = parameter(['squeue', 'sacct'])
265+
descr = 'Slurm command test'
266+
valid_systems = ['daint:login', 'dom:login']
267+
valid_prog_environs = ['builtin']
268+
num_tasks = 1
269+
num_tasks_per_node = 1
270+
reference = {
271+
'squeue': {
272+
'real_time': (0.02, None, 0.1, 's')
273+
},
274+
'sacct': {
275+
'real_time': (0.1, None, 0.1, 's')
276+
}
277+
}
278+
executable = 'time -p'
279+
tags = {'diagnostic', 'health'}
280+
maintainers = ['CB', 'VH']
281+
282+
@rfm.run_before('run')
283+
def set_exec_opts(self):
284+
self.executable_opts = [self.command]
285+
286+
@rfm.run_before('sanity')
287+
def set_sanity(self):
288+
self.sanity_patterns = sn.assert_eq(self.job.exitcode, 0)
289+
self.perf_patterns = {
290+
'real_time': sn.extractsingle(r'real (?P<real_time>\S+)',
291+
self.stderr, 'real_time', float)
292+
}

docs/_static/img/favicon.png

-1.01 KB
Loading

reframe/frontend/executors/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def finalize(self):
319319
jsonext.dump(self.check, fp, indent=2)
320320
except OSError as e:
321321
logging.getlogger().warning(
322-
f'could not dump test case {self.case}: {e}'
322+
f'could not dump test case {self.testcase}: {e}'
323323
)
324324

325325
self._current_stage = 'finalize'

test_reframe.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import argparse # noqa: F401, F403
1616
import pytest # noqa: F401, F403
17-
import unittests.fixtures as fixtures # noqa: F401, F403
17+
import unittests.utility as test_util # noqa: F401, F403
1818

1919

2020
if __name__ == '__main__':
@@ -39,9 +39,9 @@
3939
'--rfm-help', action='help', help='Print this help message and exit.'
4040
)
4141
options, rem_args = parser.parse_known_args()
42-
fixtures.USER_CONFIG_FILE = options.rfm_user_config
43-
fixtures.USER_SYSTEM = options.rfm_user_system
44-
fixtures.init_runtime()
42+
test_util.USER_CONFIG_FILE = options.rfm_user_config
43+
test_util.USER_SYSTEM = options.rfm_user_system
44+
test_util.init_runtime()
4545

4646
# If no positional argument is specified, use the `unittests` directory,
4747
# so as to avoid any automatic discovery of random unit tests from the

unittests/conftest.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Copyright 2016-2021 Swiss National Supercomputing Centre (CSCS/ETH Zurich)
2+
# ReFrame Project Developers. See the top-level LICENSE file for details.
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
6+
#
7+
# unittests/conftest.py -- pytest fixtures used in multiple unit tests
8+
#
9+
10+
import contextlib
11+
import pytest
12+
13+
import reframe.core.runtime as rt
14+
15+
from .utility import TEST_CONFIG_FILE
16+
17+
18+
class _ExecutionContext:
19+
def __init__(self, config_file=TEST_CONFIG_FILE,
20+
system=None, options=None):
21+
self.config_file = config_file
22+
self.system = system
23+
self.options = options
24+
self.__ctx = None
25+
26+
def started(self):
27+
return self.__ctx is not None
28+
29+
def start(self):
30+
self.__ctx = self._make_rt()
31+
next(self.__ctx)
32+
33+
def _make_rt(self):
34+
with rt.temp_runtime(self.config_file, self.system, self.options):
35+
yield
36+
37+
def shutdown(self):
38+
with contextlib.suppress(StopIteration):
39+
next(self.__ctx)
40+
41+
42+
@pytest.fixture
43+
def make_exec_ctx(tmp_path):
44+
'''Fixture to create a temporary execution context for the framework.'''
45+
46+
ctx = _ExecutionContext()
47+
48+
def _make_exec_ctx(config_file=TEST_CONFIG_FILE,
49+
system=None, options=None):
50+
ctx.config_file = config_file
51+
ctx.system = system
52+
ctx.options = options or {}
53+
ctx.options.update({'systems/prefix': str(tmp_path)})
54+
ctx.start()
55+
return ctx
56+
57+
yield _make_exec_ctx
58+
59+
# The execution context may have not been started, in case the test is
60+
# skipped; so skip the shutdown
61+
if ctx.started():
62+
ctx.shutdown()
63+
64+
65+
@pytest.fixture
66+
def make_exec_ctx_g(make_exec_ctx):
67+
'''Same as ``make_exec_ctx_g`` except that it is a generator.
68+
69+
You should use this fixture if you want to pass it to ``yield from``
70+
expressions.
71+
'''
72+
def _make_exec_ctx(*args, **kwargs):
73+
ctx = make_exec_ctx(*args, **kwargs)
74+
yield ctx
75+
76+
yield _make_exec_ctx

unittests/resources/checks/bad/notacheck.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
#
44
# SPDX-License-Identifier: BSD-3-Clause
55

6-
import _foo # noqa: F401
6+
import _foo # noqa: F401

unittests/resources/checks/bad/relative_imports.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
#
77
# module to test reframe's loader with relative imports
88
#
9-
from .. import hellocheck # noqa: F401
10-
from ..hellocheck import HelloTest # noqa: F401
9+
from .. import hellocheck # noqa: F401
10+
from ..hellocheck import HelloTest # noqa: F401

unittests/resources/checks/frontend_checks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import os
1111
import signal
12+
import sys
1213
import time
1314

1415
import reframe as rfm

unittests/test_argparser.py

Lines changed: 62 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@
66
import pytest
77

88
import reframe.core.runtime as rt
9-
import unittests.fixtures as fixtures
9+
import unittests.utility as test_util
1010
from reframe.frontend.argparse import ArgumentParser
1111

1212

1313
@pytest.fixture
14-
def argparser():
15-
with rt.temp_runtime(fixtures.TEST_CONFIG_FILE):
16-
return ArgumentParser()
14+
def default_exec_ctx(make_exec_ctx_g):
15+
yield from make_exec_ctx_g(test_util.BUILTIN_CONFIG_FILE)
16+
17+
18+
@pytest.fixture
19+
def argparser(make_exec_ctx):
20+
make_exec_ctx()
21+
return ArgumentParser()
1722

1823

1924
@pytest.fixture
@@ -122,59 +127,56 @@ def extended_parser():
122127
return parser
123128

124129

125-
def test_option_precedence(extended_parser):
126-
with rt.temp_runtime(fixtures.BUILTIN_CONFIG_FILE):
127-
with rt.temp_environment(variables={
128-
'RFM_TIMESTAMP': '%F',
129-
'RFM_NON_DEFAULT_CRAYPE': 'yes',
130-
'RFM_MODULES_PRELOAD': 'a,b,c',
131-
'RFM_CHECK_SEARCH_PATH': 'x:y:z'
132-
133-
}):
134-
options = extended_parser.parse_args(
135-
['--timestamp=%FT%T', '--nocolor']
136-
)
137-
assert options.recursive is None
138-
assert options.timestamp == '%FT%T'
139-
assert options.non_default_craype is True
140-
assert options.config_file is None
141-
assert options.prefix is None
142-
assert options.stagedir == '/foo'
143-
assert options.module == ['a', 'b', 'c']
144-
assert options.check_path == ['x', 'y', 'z']
145-
assert options.colorize is False
146-
147-
148-
def test_option_with_config(extended_parser):
149-
with rt.temp_runtime(fixtures.BUILTIN_CONFIG_FILE):
150-
with rt.temp_environment(variables={
151-
'RFM_TIMESTAMP': '%F',
152-
'RFM_NON_DEFAULT_CRAYPE': 'yes',
153-
'RFM_MODULES_PRELOAD': 'a,b,c',
154-
'RFM_KEEP_STAGE_FILES': 'no'
155-
}):
156-
site_config = rt.runtime().site_config
157-
options = extended_parser.parse_args(
158-
['--timestamp=%FT%T', '--nocolor']
159-
)
160-
options.update_config(site_config)
161-
assert site_config.get('general/0/check_search_recursive') is False
162-
assert site_config.get('general/0/timestamp_dirs') == '%FT%T'
163-
assert site_config.get('general/0/non_default_craype') is True
164-
assert site_config.get('systems/0/prefix') == '.'
165-
assert site_config.get('general/0/colorize') is False
166-
assert site_config.get('general/0/keep_stage_files') is False
167-
168-
# Defaults specified in parser override those in configuration file
169-
assert site_config.get('systems/0/stagedir') == '/foo'
170-
171-
172-
def test_option_envvar_conversion_error(extended_parser):
173-
with rt.temp_runtime(fixtures.BUILTIN_CONFIG_FILE):
174-
with rt.temp_environment(variables={
175-
'RFM_NON_DEFAULT_CRAYPE': 'foo',
176-
}):
177-
site_config = rt.runtime().site_config
178-
options = extended_parser.parse_args(['--nocolor'])
179-
errors = options.update_config(site_config)
180-
assert len(errors) == 1
130+
def test_option_precedence(default_exec_ctx, extended_parser):
131+
with rt.temp_environment(variables={
132+
'RFM_TIMESTAMP': '%F',
133+
'RFM_NON_DEFAULT_CRAYPE': 'yes',
134+
'RFM_MODULES_PRELOAD': 'a,b,c',
135+
'RFM_CHECK_SEARCH_PATH': 'x:y:z'
136+
137+
}):
138+
options = extended_parser.parse_args(
139+
['--timestamp=%FT%T', '--nocolor']
140+
)
141+
assert options.recursive is None
142+
assert options.timestamp == '%FT%T'
143+
assert options.non_default_craype is True
144+
assert options.config_file is None
145+
assert options.prefix is None
146+
assert options.stagedir == '/foo'
147+
assert options.module == ['a', 'b', 'c']
148+
assert options.check_path == ['x', 'y', 'z']
149+
assert options.colorize is False
150+
151+
152+
def test_option_with_config(default_exec_ctx, extended_parser, tmp_path):
153+
with rt.temp_environment(variables={
154+
'RFM_TIMESTAMP': '%F',
155+
'RFM_NON_DEFAULT_CRAYPE': 'yes',
156+
'RFM_MODULES_PRELOAD': 'a,b,c',
157+
'RFM_KEEP_STAGE_FILES': 'no'
158+
}):
159+
site_config = rt.runtime().site_config
160+
options = extended_parser.parse_args(
161+
['--timestamp=%FT%T', '--nocolor']
162+
)
163+
options.update_config(site_config)
164+
assert site_config.get('general/0/check_search_recursive') is False
165+
assert site_config.get('general/0/timestamp_dirs') == '%FT%T'
166+
assert site_config.get('general/0/non_default_craype') is True
167+
assert site_config.get('systems/0/prefix') == str(tmp_path)
168+
assert site_config.get('general/0/colorize') is False
169+
assert site_config.get('general/0/keep_stage_files') is False
170+
171+
# Defaults specified in parser override those in configuration file
172+
assert site_config.get('systems/0/stagedir') == '/foo'
173+
174+
175+
def test_option_envvar_conversion_error(default_exec_ctx, extended_parser):
176+
with rt.temp_environment(variables={
177+
'RFM_NON_DEFAULT_CRAYPE': 'foo',
178+
}):
179+
site_config = rt.runtime().site_config
180+
options = extended_parser.parse_args(['--nocolor'])
181+
errors = options.update_config(site_config)
182+
assert len(errors) == 1

0 commit comments

Comments
 (0)