Skip to content

Commit 29d838d

Browse files
authored
Merge pull request #3313 from vkarak/feat/default-disable-results-db
[enhancement] Disable results storage by default
2 parents da525c1 + a294958 commit 29d838d

File tree

5 files changed

+94
-26
lines changed

5 files changed

+94
-26
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
set -xe
4+
5+
export RFM_ENABLE_RESULTS_STORAGE=1
6+
7+
pushd reframe-examples/tutorial
8+
reframe -c stream/stream_runonly.py -r
9+
reframe -c stream/stream_runonly.py -r
10+
reframe -C config/baseline.py -c stream/stream_runonly.py -r
11+
reframe -C config/baseline_environs.py -c stream/stream_build_run.py --exec-policy=serial -r
12+
reframe -C config/baseline_environs.py -c stream/stream_fixtures.py -l
13+
reframe -C config/baseline_environs.py -c stream/stream_fixtures.py -r
14+
reframe -C config/baseline_environs.py -c stream/stream_variables.py -S num_threads=2 -r
15+
reframe -C config/baseline_environs.py -c stream/stream_variables_fixtures.py --exec-policy=serial -S stream_test.stream_binary.array_size=50000000 -r
16+
reframe -C config/baseline_environs.py -c stream/stream_parameters.py --exec-policy=serial -r
17+
reframe -C config/baseline_environs.py -c stream/stream_variables_fixtures.py -P num_threads=1,2,4,8 --exec-policy=serial -r
18+
reframe -c deps/deps_complex.py -r
19+
reframe --restore-session --failed -r
20+
reframe -c deps/deps_complex.py --keep-stage-files -r
21+
reframe --restore-session --keep-stage-files -n T6 -r
22+
reframe -c deps/deps_complex.py -n T6 -r
23+
popd

reframe/frontend/cli.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ def main():
628628
configvar='general/perf_report_spec',
629629
envvar='RFM_PERF_REPORT_SPEC',
630630
help=('Print a report for performance tests '
631-
'(default: "now:now/last:+job_nodelist/+result")')
631+
'(default: "now-1d:now/last:+job_nodelist/+result")')
632632
)
633633
reporting_options.add_argument(
634634
'--session-extras', action='append', metavar='KV_DATA',
@@ -979,8 +979,7 @@ def restrict_logging():
979979
'--describe-stored-testcases',
980980
'--list-stored-sessions',
981981
'--list-stored-testcases',
982-
'--performance-compare',
983-
'--performance-report']):
982+
'--performance-compare']):
984983
sys.exit(1)
985984

986985
rt = runtime.runtime()
@@ -1655,9 +1654,12 @@ def module_unuse(*paths):
16551654
if (options.performance_report and
16561655
not options.dry_run and not report.is_empty()):
16571656
try:
1658-
data = reporting.performance_compare(
1659-
rt.get_option('general/0/perf_report_spec'), report
1660-
)
1657+
if rt.get_option('storage/0/enable'):
1658+
data = reporting.performance_compare(
1659+
rt.get_option('general/0/perf_report_spec'), report
1660+
)
1661+
else:
1662+
data = report.report_data()
16611663
except Exception as err:
16621664
printer.warning(
16631665
f'failed to generate performance report: {err}'
@@ -1699,7 +1701,8 @@ def module_unuse(*paths):
16991701
)
17001702

17011703
# Store the generated report for analytics
1702-
if not report.is_empty() and not options.dry_run:
1704+
if (rt.get_option('storage/0/enable') and
1705+
not report.is_empty() and not options.dry_run):
17031706
try:
17041707
sess_uuid = report.store()
17051708
except Exception as e:

reframe/frontend/reporting/__init__.py

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import uuid
1818
from collections import UserDict
1919
from collections.abc import Hashable
20-
from filelock import FileLock
2120

2221
import reframe as rfm
2322
import reframe.utility.jsonext as jsonext
@@ -419,7 +418,11 @@ def update_run_stats(self, stats):
419418
'num_skipped': self.__report['runs'][-1]['num_skipped']
420419
})
421420

422-
def _save(self, filename, compress, link_to_last):
421+
def is_empty(self):
422+
'''Return :obj:`True` is no test cases where run'''
423+
return self.__report['session_info']['num_cases'] == 0
424+
425+
def save(self, filename, compress=False, link_to_last=True):
423426
filename = _expand_report_filename(filename, newfile=True)
424427
with open(filename, 'w') as fp:
425428
if compress:
@@ -446,20 +449,47 @@ def _save(self, filename, compress, link_to_last):
446449
else:
447450
raise ReframeError('path exists and is not a symlink')
448451

449-
def is_empty(self):
450-
'''Return :obj:`True` is no test cases where run'''
451-
return self.__report['session_info']['num_cases'] == 0
452-
453-
def save(self, filename, compress=False, link_to_last=True):
454-
prefix = os.path.dirname(filename) or '.'
455-
with FileLock(os.path.join(prefix, '.report.lock')):
456-
self._save(filename, compress, link_to_last)
457-
458452
def store(self):
459453
'''Store the report in the results storage.'''
460454

461455
return StorageBackend.default().store(self, self.filename)
462456

457+
def report_data(self):
458+
'''Get tabular data from this report'''
459+
460+
columns = ['name', 'sysenv', 'job_nodelist',
461+
'pvar', 'punit', 'pval', 'result']
462+
data = [columns]
463+
num_runs = len(self.__report['runs'])
464+
for runid, runinfo in enumerate(self.__report['runs']):
465+
for tc in map(_TCProxy, runinfo['testcases']):
466+
if tc['result'] != 'success' and runid != num_runs - 1:
467+
# Skip this testcase until its last retry
468+
continue
469+
470+
for pvar, reftuple in tc['perfvalues'].items():
471+
pvar = pvar.split(':')[-1]
472+
pval, _, _, _, punit = reftuple
473+
if pval is None:
474+
# Ignore `None` performance values
475+
# (performance tests that failed sanity)
476+
continue
477+
478+
line = []
479+
for c in columns:
480+
if c == 'pvar':
481+
line.append(pvar)
482+
elif c == 'pval':
483+
line.append(pval)
484+
elif c == 'punit':
485+
line.append(punit)
486+
else:
487+
line.append(tc[c])
488+
489+
data.append(line)
490+
491+
return data
492+
463493
def generate_xml_report(self):
464494
'''Generate a JUnit report from a standard ReFrame JSON report.'''
465495

reframe/schemas/config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@
589589
"general/module_mappings": [],
590590
"general/non_default_craype": false,
591591
"general/perf_info_level": "info",
592-
"general/perf_report_spec": "now:now/last:/+job_nodelist+result",
592+
"general/perf_report_spec": "now-1d:now/last:/+job_nodelist+result",
593593
"general/pipeline_timeout": 3,
594594
"general/purge_environment": false,
595595
"general/remote_detect": false,
@@ -634,7 +634,7 @@
634634
"logging/handlers_perflog/httpjson_debug": false,
635635
"modes/options": [],
636636
"modes/target_systems": ["*"],
637-
"storage/enable": true,
637+
"storage/enable": false,
638638
"storage/backend": "sqlite",
639639
"storage/sqlite_conn_timeout": 60,
640640
"storage/sqlite_db_file": "${HOME}/.reframe/reports/results.db",

unittests/test_cli.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,14 @@ def test_perflogdir_from_env(run_reframe, tmp_path, monkeypatch):
420420
'default' / 'PerformanceFailureCheck.log')
421421

422422

423-
def test_performance_report(run_reframe, run_action):
423+
@pytest.fixture(params=['storage=yes', 'storage=no'])
424+
def storage_enabled(request, monkeypatch):
425+
value = request.param.split('=')[1]
426+
monkeypatch.setenv('RFM_ENABLE_RESULTS_STORAGE', value)
427+
return value == 'yes'
428+
429+
430+
def test_performance_report(run_reframe, run_action, storage_enabled):
424431
returncode, stdout, stderr = run_reframe(
425432
checkpath=['unittests/resources/checks/frontend_checks.py'],
426433
more_options=['-n', '^PerformanceFailureCheck',
@@ -433,6 +440,9 @@ def test_performance_report(run_reframe, run_action):
433440
else:
434441
assert returncode == 0
435442

443+
if run_action != 'dry_run':
444+
assert 'PERFORMANCE REPORT' in stdout
445+
436446
assert 'Traceback' not in stdout
437447
assert 'Traceback' not in stderr
438448

@@ -1269,7 +1279,8 @@ def assert_no_crash(returncode, stdout, stderr, exitcode=0):
12691279
return returncode, stdout, stderr
12701280

12711281

1272-
def test_storage_options(run_reframe, tmp_path, table_format):
1282+
def test_storage_options(run_reframe, tmp_path, table_format, monkeypatch):
1283+
monkeypatch.setenv('RFM_ENABLE_RESULTS_STORAGE', 'yes')
12731284
run_reframe2 = functools.partial(
12741285
run_reframe,
12751286
checkpath=['unittests/resources/checks/frontend_checks.py'],
@@ -1335,8 +1346,7 @@ def test_storage_options(run_reframe, tmp_path, table_format):
13351346
'--describe-stored-testcases=now-1d:now',
13361347
'--list-stored-sessions',
13371348
'--list-stored-testcases=now-1d:now/mean:/',
1338-
'--performance-compare=now-1d:now/now-1d/mean:/',
1339-
'--performance-report=now-1d:now/mean:/'
1349+
'--performance-compare=now-1d:now/now-1d/mean:/'
13401350
])
13411351
def storage_option(request):
13421352
return request.param
@@ -1359,7 +1369,8 @@ def test_disabled_results_storage(run_reframe, storage_option, monkeypatch):
13591369
assert 'requires results storage' in stdout
13601370

13611371

1362-
def test_session_annotations(run_reframe):
1372+
def test_session_annotations(run_reframe, monkeypatch):
1373+
monkeypatch.setenv('RFM_ENABLE_RESULTS_STORAGE', 'yes')
13631374
assert_no_crash(*run_reframe(
13641375
checkpath=['unittests/resources/checks/frontend_checks.py'],
13651376
action='-r',
@@ -1373,13 +1384,14 @@ def test_session_annotations(run_reframe):
13731384
assert text in stdout
13741385

13751386

1376-
def test_performance_compare(run_reframe, table_format):
1387+
def test_performance_compare(run_reframe, table_format, monkeypatch):
13771388
def assert_no_crash(returncode, stdout, stderr, exitcode=0):
13781389
assert returncode == exitcode
13791390
assert 'Traceback' not in stdout
13801391
assert 'Traceback' not in stderr
13811392
return returncode, stdout, stderr
13821393

1394+
monkeypatch.setenv('RFM_ENABLE_RESULTS_STORAGE', 'yes')
13831395
run_reframe2 = functools.partial(
13841396
run_reframe,
13851397
checkpath=['unittests/resources/checks/frontend_checks.py'],

0 commit comments

Comments
 (0)