Skip to content

Commit 4d2ae5d

Browse files
author
Vasileios Karakasis
authored
Merge pull request #1104 from ekouts/test/slurm-constraint-error
[test] Add check for Slurm error message when no constraint is given
2 parents 3cc72fc + 0da4266 commit 4d2ae5d

File tree

1 file changed

+41
-40
lines changed

1 file changed

+41
-40
lines changed

cscs-checks/system/slurm/slurm.py

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,70 +2,61 @@
22
import reframe.utility.sanity as sn
33

44

5-
# Base class for Slurm simple binary tests
65
class SlurmSimpleBaseCheck(rfm.RunOnlyRegressionTest):
6+
'''Base class for Slurm simple binary tests'''
7+
78
def __init__(self):
8-
super().__init__()
99
self.valid_systems = ['daint:gpu', 'daint:mc',
1010
'dom:gpu', 'dom:mc',
1111
'kesch:cn', 'kesch:pn']
1212
self.valid_prog_environs = ['PrgEnv-cray']
13-
self.tags = {'slurm', 'maintenance', 'ops', 'production'}
13+
self.tags = {'slurm', 'maintenance', 'ops',
14+
'production', 'single-node'}
1415
self.num_tasks_per_node = 1
1516
if self.current_system.name == 'kesch':
1617
self.exclusive_access = True
1718

1819
self.maintainers = ['RS', 'VK']
1920

20-
def setup(self, *args, **kwargs):
21-
if self.num_tasks == 1:
22-
self.tags.add('single-node')
23-
24-
super().setup(*args, **kwargs)
25-
26-
# Base class for Slurm tests that require compiling some code
27-
2821

2922
class SlurmCompiledBaseCheck(rfm.RegressionTest):
23+
'''Base class for Slurm tests that require compiling some code'''
24+
3025
def __init__(self):
31-
super().__init__()
3226
self.valid_systems = ['daint:gpu', 'daint:mc',
3327
'dom:gpu', 'dom:mc',
3428
'kesch:cn', 'kesch:pn']
3529
self.valid_prog_environs = ['PrgEnv-cray']
36-
self.tags = {'slurm', 'maintenance', 'ops', 'production'}
30+
self.tags = {'slurm', 'maintenance', 'ops',
31+
'production', 'single-node'}
3732
self.num_tasks_per_node = 1
3833
if self.current_system.name == 'kesch':
3934
self.exclusive_access = True
4035

4136
self.maintainers = ['RS', 'VK']
4237

43-
def setup(self, *args, **kwargs):
44-
if self.num_tasks == 1:
45-
self.tags.add('single-node')
46-
47-
super().setup(*args, **kwargs)
48-
4938

5039
@rfm.simple_test
5140
class HostnameCheck(SlurmSimpleBaseCheck):
5241
def __init__(self):
5342
super().__init__()
5443
self.executable = '/bin/hostname'
55-
self.hostname_string = {
56-
'kesch:cn': r'keschcn-\d{4}\b',
57-
'kesch:pn': r'keschpn-\d{4}\b',
58-
'daint:gpu': r'nid\d{5}\b',
59-
'daint:mc': r'nid\d{5}\b',
60-
'dom:gpu': r'nid\d{5}\b',
61-
'dom:mc': r'nid\d{5}\b',
44+
self.hostname_patt = {
45+
'kesch:cn': r'^keschcn-\d{4}$',
46+
'kesch:pn': r'^keschpn-\d{4}$',
47+
'daint:gpu': r'^nid\d{5}$',
48+
'daint:mc': r'^nid\d{5}$',
49+
'dom:gpu': r'^nid\d{5}$',
50+
'dom:mc': r'^nid\d{5}$',
6251
}
6352

64-
def setup(self, partition, environ, **job_opts):
65-
num_matches = sn.count(sn.findall(
66-
self.hostname_string[partition.fullname], self.stdout))
53+
@rfm.run_before('sanity')
54+
def set_sanity_patterns(self):
55+
partname = self.current_partition.fullname
56+
num_matches = sn.count(
57+
sn.findall(self.hostname_patt[partname], self.stdout)
58+
)
6759
self.sanity_patterns = sn.assert_eq(self.num_tasks, num_matches)
68-
super().setup(partition, environ, **job_opts)
6960

7061

7162
@rfm.simple_test
@@ -79,10 +70,24 @@ def __init__(self):
7970
self.executable = '/bin/echo'
8071
self.executable_opts = ['$MY_VAR']
8172
self.variables = {'MY_VAR': 'TEST123456!'}
73+
self.tags.remove('single-node')
8274
num_matches = sn.count(sn.findall(r'TEST123456!', self.stdout))
8375
self.sanity_patterns = sn.assert_eq(self.num_tasks, num_matches)
8476

8577

78+
@rfm.simple_test
79+
class RequiredConstraintCheck(SlurmSimpleBaseCheck):
80+
def __init__(self):
81+
super().__init__()
82+
self.valid_systems = ['daint:login', 'dom:login']
83+
self.executable = 'srun'
84+
self.executable_opts = ['hostname']
85+
self.sanity_patterns = sn.assert_found(
86+
r'error: You have to specify, at least, what sort of node you '
87+
r'need: -C gpu for GPU enabled nodes, or -C mc for multicore '
88+
r'nodes.', self.stderr)
89+
90+
8691
@rfm.simple_test
8792
class RequestLargeMemoryNodeCheck(SlurmSimpleBaseCheck):
8893
def __init__(self):
@@ -94,10 +99,8 @@ def __init__(self):
9499
self.stdout, 'mem', float)
95100
self.sanity_patterns = sn.assert_bounded(mem_obtained, 122.0, 128.0)
96101

97-
# we override setup function to pass additional
98-
# options to Slurm
99-
def setup(self, partition, environ, **job_opts):
100-
super().setup(partition, environ, **job_opts)
102+
@rfm.run_before('run')
103+
def set_memory_limit(self):
101104
self.job.options += ['--mem=120000']
102105

103106

@@ -141,10 +144,8 @@ def __init__(self):
141144
self.executable = 'cat /proc/cray_xt/cname'
142145
self.sanity_patterns = sn.assert_found(r'c0-0.*', self.stdout)
143146

144-
# we override setup function to pass additional
145-
# options to Slurm
146-
def setup(self, partition, environ, **job_opts):
147-
super().setup(partition, environ, **job_opts)
147+
@rfm.run_before('run')
148+
def set_slurm_constraint(self):
148149
self.job.options = ['--constraint=c0-0']
149150

150151

@@ -160,6 +161,6 @@ def __init__(self):
160161
r'(exceeded memory limit)|(Out Of Memory)', self.stderr
161162
)
162163

163-
def setup(self, partition, environ, **job_opts):
164-
super().setup(partition, environ, **job_opts)
164+
@rfm.run_before('run')
165+
def set_memory_limit(self):
165166
self.job.options += ['--mem=2000']

0 commit comments

Comments
 (0)