Skip to content

Commit c74c70a

Browse files
authored
Merge pull request #3295 from vkarak/feat/enable-storage-switch
[feat] Add a configuration option to enable/disable results storage
2 parents e8c8cc9 + 278eca0 commit c74c70a

File tree

5 files changed

+90
-1
lines changed

5 files changed

+90
-1
lines changed

docs/config_reference.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,6 +1648,14 @@ Result storage configuration
16481648
Currently, only Sqlite can be used as a storage backend.
16491649

16501650

1651+
.. py:attribute:: storage.enable
1652+
1653+
:required: No
1654+
:default: ``true``
1655+
1656+
Enable results storage.
1657+
1658+
16511659
.. py:attribute:: storage.sqlite_conn_timeout
16521660
16531661
:required: No
@@ -1674,6 +1682,16 @@ Result storage configuration
16741682
Permissions of an existing DB file have to be changed manually.
16751683

16761684

1685+
.. py:attribute:: storage.target_systems
1686+
1687+
:required: No
1688+
:default: ``["*"]``
1689+
1690+
A list of systems *only* that this storage configuration is valid for.
1691+
1692+
For a detailed description of this property, have a look at the :attr:`~environments.target_systems` definition for environments.
1693+
1694+
16771695
General Configuration
16781696
=====================
16791697

docs/tutorial.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,3 +2108,8 @@ Finally, a stored session can be deleted using the :option:`--delete-stored-sess
21082108
reframe --delete-stored-sessions=1fb8488e-c361-4355-b7df-c0dcf3cdcc1e
21092109
21102110
Deleting a session will also delete all its test cases from the database.
2111+
2112+
2113+
.. tip::
2114+
2115+
You can disable results storage by either setting ``RFM_ENABLE_RESULTS_STORAGE=0`` or by setting the :attr:`storage.enable <config.storage.enable>` configuration parameter to ``False``.

reframe/frontend/cli.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,21 @@ def __exit__(self, exc_type, exc_val, exc_tb):
236236
sys.exit(self.__exitcode)
237237

238238

239+
def validate_storage_options(namespace, cmd_options):
240+
storage_enabled = runtime.runtime().get_option('storage/0/enable')
241+
for arg in cmd_options:
242+
attr = arg[2:].replace('-', '_')
243+
if not storage_enabled and getattr(namespace, attr, None):
244+
logging.getlogger().error(
245+
f'option `{arg}` requires results storage; '
246+
'either set `RFM_ENABLE_RESULTS_STORAGE=1` or set '
247+
'`"storage": [{"enable": True}]` in the configuration file'
248+
)
249+
return False
250+
251+
return True
252+
253+
239254
@logging.time_function_noexit
240255
def main():
241256
# Setup command line options
@@ -770,6 +785,13 @@ def main():
770785
action='store_true',
771786
help='Resolve module conflicts automatically'
772787
)
788+
argparser.add_argument(
789+
dest='enable_results_storage',
790+
envvar='RFM_ENABLE_RESULTS_STORAGE',
791+
configvar='storage/enable',
792+
action='store_true',
793+
help='Enable results storage'
794+
)
773795
argparser.add_argument(
774796
dest='sqlite_conn_timeout',
775797
envvar='RFM_SQLITE_CONN_TIMEOUT',
@@ -951,6 +973,16 @@ def restrict_logging():
951973
printer.info(logfiles_message())
952974
sys.exit(1)
953975

976+
if not validate_storage_options(options,
977+
['--delete-stored-sessions',
978+
'--describe-stored-sessions',
979+
'--describe-stored-testcases',
980+
'--list-stored-sessions',
981+
'--list-stored-testcases',
982+
'--performance-compare',
983+
'--performance-report']):
984+
sys.exit(1)
985+
954986
rt = runtime.runtime()
955987
try:
956988
if site_config.get('general/0/module_map_file'):

reframe/schemas/config.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,9 +546,11 @@
546546
"type": "object",
547547
"properties": {
548548
"backend": {"type": "string"},
549+
"enable": {"type": "boolean"},
549550
"sqlite_conn_timeout": {"type": "number"},
550551
"sqlite_db_file": {"type": "string"},
551-
"sqlite_db_file_mode": {"type": "string"}
552+
"sqlite_db_file_mode": {"type": "string"},
553+
"target_systems": {"$ref": "#/defs/system_ref"}
552554
}
553555
}
554556
}
@@ -631,10 +633,12 @@
631633
"logging/handlers_perflog/httpjson_debug": false,
632634
"modes/options": [],
633635
"modes/target_systems": ["*"],
636+
"storage/enable": true,
634637
"storage/backend": "sqlite",
635638
"storage/sqlite_conn_timeout": 60,
636639
"storage/sqlite_db_file": "${HOME}/.reframe/reports/results.db",
637640
"storage/sqlite_db_file_mode": "644",
641+
"storage/target_systems": ["*"],
638642
"systems/descr": "",
639643
"systems/max_local_jobs": 8,
640644
"systems/modules_system": "nomod",

unittests/test_cli.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,6 +1329,36 @@ def test_storage_options(run_reframe, tmp_path, table_format):
13291329
assert_no_crash(*run_reframe2(action=f'--delete-stored-session={uuid}'))
13301330

13311331

1332+
@pytest.fixture(params=[
1333+
'--delete-stored-sessions=now-1d:now',
1334+
'--describe-stored-sessions=now-1d:now',
1335+
'--describe-stored-testcases=now-1d:now',
1336+
'--list-stored-sessions',
1337+
'--list-stored-testcases=now-1d:now/mean:/',
1338+
'--performance-compare=now-1d:now/now-1d/mean:/',
1339+
'--performance-report=now-1d:now/mean:/'
1340+
])
1341+
def storage_option(request):
1342+
return request.param
1343+
1344+
1345+
def test_disabled_results_storage(run_reframe, storage_option, monkeypatch):
1346+
monkeypatch.setenv('RFM_ENABLE_RESULTS_STORAGE', 'no')
1347+
if storage_option.startswith('--performance-report'):
1348+
more_options = [storage_option]
1349+
action = '-r'
1350+
else:
1351+
more_options = []
1352+
action = storage_option
1353+
1354+
stdout = assert_no_crash(*run_reframe(
1355+
checkpath=['unittests/resources/checks/frontend_checks.py'],
1356+
action=action,
1357+
more_options=more_options
1358+
), exitcode=1)[1]
1359+
assert 'requires results storage' in stdout
1360+
1361+
13321362
def test_session_annotations(run_reframe):
13331363
assert_no_crash(*run_reframe(
13341364
checkpath=['unittests/resources/checks/frontend_checks.py'],

0 commit comments

Comments
 (0)