From a1d8331804fc561ed2d99ec740d23160779d79a7 Mon Sep 17 00:00:00 2001 From: Eirini Koutsaniti Date: Thu, 22 Dec 2022 10:25:34 +0100 Subject: [PATCH 1/4] Add unittest for failing perf test --- unittests/test_policies.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/unittests/test_policies.py b/unittests/test_policies.py index 84fbe62b04..a290690819 100644 --- a/unittests/test_policies.py +++ b/unittests/test_policies.py @@ -989,6 +989,24 @@ def perf1(self): return _MyTest() +@pytest.fixture +def failing_perf_test(): + class _MyFailingTest(rfm.RunOnlyRegressionTest): + valid_systems = ['*'] + valid_prog_environs = ['*'] + executable = 'echo perf0=100' + + @sanity_function + def validate(self): + return False + + @performance_function('unit0') + def perf0(self): + return sn.extractsingle(r'perf0=(\S+)', self.stdout, 1, float) + + return _MyFailingTest() + + @pytest.fixture def simple_test(): class _MySimpleTest(rfm.RunOnlyRegressionTest): @@ -1192,7 +1210,8 @@ def test_perf_logging_no_perfvars(make_runner, make_exec_ctx, perf_test, def test_perf_logging_multiline(make_runner, make_exec_ctx, perf_test, - simple_test, config_perflog, tmp_path): + simple_test, failing_perf_test, config_perflog, + tmp_path): make_exec_ctx( config_perflog( fmt=( @@ -1207,7 +1226,7 @@ def test_perf_logging_multiline(make_runner, make_exec_ctx, perf_test, ) logging.configure_logging(rt.runtime().site_config) runner = make_runner() - testcases = executors.generate_testcases([perf_test, simple_test]) + testcases = executors.generate_testcases([perf_test, simple_test, failing_perf_test]) runner.runall(testcases) logfile = tmp_path / 'perflogs' / 'generic' / 'default' / '_MyTest.log' From 9f6c837253a45633ae192b4b9cbd97703924af76 Mon Sep 17 00:00:00 2001 From: Eirini Koutsaniti Date: Thu, 22 Dec 2022 10:34:20 +0100 Subject: [PATCH 2/4] Skip log_performance when the check is None --- reframe/core/logging.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/reframe/core/logging.py b/reframe/core/logging.py index ed05763ccf..a749945076 100644 --- a/reframe/core/logging.py +++ b/reframe/core/logging.py @@ -726,6 +726,9 @@ def _update_check_extras(self): ) def log_performance(self, level, task, msg=None, multiline=False): + if self.extra['__rfm_check__'] is None: + return + self.extra['check_partition'] = task.testcase.partition.name self.extra['check_environ'] = task.testcase.environ.name self.extra['check_result'] = 'pass' if task.succeeded else 'fail' From 71ec37e0cd8f6865aafa31d1ad6d323f70fb4a99 Mon Sep 17 00:00:00 2001 From: Eirini Koutsaniti Date: Thu, 22 Dec 2022 10:42:07 +0100 Subject: [PATCH 3/4] Fix formatting --- unittests/test_policies.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/unittests/test_policies.py b/unittests/test_policies.py index a290690819..bab919ce94 100644 --- a/unittests/test_policies.py +++ b/unittests/test_policies.py @@ -1210,8 +1210,8 @@ def test_perf_logging_no_perfvars(make_runner, make_exec_ctx, perf_test, def test_perf_logging_multiline(make_runner, make_exec_ctx, perf_test, - simple_test, failing_perf_test, config_perflog, - tmp_path): + simple_test, failing_perf_test, + config_perflog, tmp_path): make_exec_ctx( config_perflog( fmt=( @@ -1226,7 +1226,9 @@ def test_perf_logging_multiline(make_runner, make_exec_ctx, perf_test, ) logging.configure_logging(rt.runtime().site_config) runner = make_runner() - testcases = executors.generate_testcases([perf_test, simple_test, failing_perf_test]) + testcases = executors.generate_testcases( + [perf_test, simple_test, failing_perf_test] + ) runner.runall(testcases) logfile = tmp_path / 'perflogs' / 'generic' / 'default' / '_MyTest.log' From 1ea8518841e186dcbd54b43e90be6b406f83d237 Mon Sep 17 00:00:00 2001 From: Eirini Koutsaniti Date: Thu, 22 Dec 2022 10:54:55 +0100 Subject: [PATCH 4/4] Remove unnecessary check from executors --- reframe/frontend/executors/__init__.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/reframe/frontend/executors/__init__.py b/reframe/frontend/executors/__init__.py index 957ea58689..19631c2a58 100644 --- a/reframe/frontend/executors/__init__.py +++ b/reframe/frontend/executors/__init__.py @@ -386,9 +386,8 @@ def finalize(self): self._current_stage = 'finalize' self._notify_listeners('on_task_success') - if self.check.is_performance_check(): - self._perflogger.log_performance(logging.INFO, self, - multiline=self._perflog_compat) + self._perflogger.log_performance(logging.INFO, self, + multiline=self._perflog_compat) @logging.time_function def cleanup(self, *args, **kwargs): @@ -398,9 +397,8 @@ def fail(self, exc_info=None): self._failed_stage = self._current_stage self._exc_info = exc_info or sys.exc_info() self._notify_listeners('on_task_failure') - if self.check.is_performance_check(): - self._perflogger.log_performance(logging.INFO, self, - multiline=self._perflog_compat) + self._perflogger.log_performance(logging.INFO, self, + multiline=self._perflog_compat) def skip(self, exc_info=None): self._skipped = True