Skip to content

Commit 48807d2

Browse files
authored
Merge pull request #2718 from ekouts/bugfix/perflog_compat_fail_perf
[bugfix] Fix `perflog_compat` crash when performance test fails in sanity
2 parents 3b1c362 + 1ea8518 commit 48807d2

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

reframe/core/logging.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,9 @@ def _update_check_extras(self):
726726
)
727727

728728
def log_performance(self, level, task, msg=None, multiline=False):
729+
if self.extra['__rfm_check__'] is None:
730+
return
731+
729732
self.extra['check_partition'] = task.testcase.partition.name
730733
self.extra['check_environ'] = task.testcase.environ.name
731734
self.extra['check_result'] = 'pass' if task.succeeded else 'fail'

reframe/frontend/executors/__init__.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,8 @@ def finalize(self):
386386

387387
self._current_stage = 'finalize'
388388
self._notify_listeners('on_task_success')
389-
if self.check.is_performance_check():
390-
self._perflogger.log_performance(logging.INFO, self,
391-
multiline=self._perflog_compat)
389+
self._perflogger.log_performance(logging.INFO, self,
390+
multiline=self._perflog_compat)
392391

393392
@logging.time_function
394393
def cleanup(self, *args, **kwargs):
@@ -398,9 +397,8 @@ def fail(self, exc_info=None):
398397
self._failed_stage = self._current_stage
399398
self._exc_info = exc_info or sys.exc_info()
400399
self._notify_listeners('on_task_failure')
401-
if self.check.is_performance_check():
402-
self._perflogger.log_performance(logging.INFO, self,
403-
multiline=self._perflog_compat)
400+
self._perflogger.log_performance(logging.INFO, self,
401+
multiline=self._perflog_compat)
404402

405403
def skip(self, exc_info=None):
406404
self._skipped = True

unittests/test_policies.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,24 @@ def perf1(self):
989989
return _MyTest()
990990

991991

992+
@pytest.fixture
993+
def failing_perf_test():
994+
class _MyFailingTest(rfm.RunOnlyRegressionTest):
995+
valid_systems = ['*']
996+
valid_prog_environs = ['*']
997+
executable = 'echo perf0=100'
998+
999+
@sanity_function
1000+
def validate(self):
1001+
return False
1002+
1003+
@performance_function('unit0')
1004+
def perf0(self):
1005+
return sn.extractsingle(r'perf0=(\S+)', self.stdout, 1, float)
1006+
1007+
return _MyFailingTest()
1008+
1009+
9921010
@pytest.fixture
9931011
def simple_test():
9941012
class _MySimpleTest(rfm.RunOnlyRegressionTest):
@@ -1192,7 +1210,8 @@ def test_perf_logging_no_perfvars(make_runner, make_exec_ctx, perf_test,
11921210

11931211

11941212
def test_perf_logging_multiline(make_runner, make_exec_ctx, perf_test,
1195-
simple_test, config_perflog, tmp_path):
1213+
simple_test, failing_perf_test,
1214+
config_perflog, tmp_path):
11961215
make_exec_ctx(
11971216
config_perflog(
11981217
fmt=(
@@ -1207,7 +1226,9 @@ def test_perf_logging_multiline(make_runner, make_exec_ctx, perf_test,
12071226
)
12081227
logging.configure_logging(rt.runtime().site_config)
12091228
runner = make_runner()
1210-
testcases = executors.generate_testcases([perf_test, simple_test])
1229+
testcases = executors.generate_testcases(
1230+
[perf_test, simple_test, failing_perf_test]
1231+
)
12111232
runner.runall(testcases)
12121233

12131234
logfile = tmp_path / 'perflogs' / 'generic' / 'default' / '_MyTest.log'

0 commit comments

Comments
 (0)