From 86985d3de44ed5d0d01cdca4618c8d15ce922cd2 Mon Sep 17 00:00:00 2001 From: Guillaume Raffy Date: Wed, 13 Nov 2024 14:56:45 +0100 Subject: [PATCH] the user can now output the benchmark results to a remote sql database accessed via ssh note: as the production benchmarks are currently stored at IPR on a database server accessed via ssh, this allows iprbench to store its results to IPR benchmark database. work rleated to [https://bugzilla.ipr.univ-rennes.fr/show_bug.cgi?id=3958] --- iprbench/resultsdb/sqlresultsdb.py | 22 +++++++++++++++++++--- test/test_iprbench.py | 21 ++++++++++++++++++++- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/iprbench/resultsdb/sqlresultsdb.py b/iprbench/resultsdb/sqlresultsdb.py index 7bdd447..c2cd594 100644 --- a/iprbench/resultsdb/sqlresultsdb.py +++ b/iprbench/resultsdb/sqlresultsdb.py @@ -1,7 +1,7 @@ from typing import List import logging from pathlib import Path -from cocluto.SimpaDbUtil import ISqlDatabaseBackend, SqliteDb, SqlTableField +from cocluto.SimpaDbUtil import ISqlDatabaseBackend, SqliteDb, SqlTableField, SshAccessedMysqlDb from ..core import IResultsDb, IResultsTable, BenchmarkParamValues, IBenchmark, IResultsDbCreator, ResultsDbParams, BenchParam @@ -63,11 +63,27 @@ class SqlResultsDb(IResultsDb): return table -class SqlResultsDbCreator(IResultsDbCreator): +class SqliteResultsDbCreator(IResultsDbCreator): def __init__(self): - super().__init__('sql-database') + super().__init__('sqlite-database') def create_resultsdb(self, resultsdb_config: ResultsDbParams) -> IResultsDb: sql_backend = SqliteDb(Path(resultsdb_config['sqlite_file_path'])) return SqlResultsDb(sql_backend) + + +class SqlServerResultsDbCreator(IResultsDbCreator): + """creates a SqlResultsDb instance configured using a RemoteMysqlDb backend + """ + def __init__(self): + super().__init__('sqlserver-viassh-database') + + def create_resultsdb(self, resultsdb_config: ResultsDbParams) -> IResultsDb: + db_server_fqdn = resultsdb_config['db_server_fqdn'] + db_user = resultsdb_config['db_user'] + db_name = resultsdb_config['db_name'] + ssh_user = resultsdb_config['ssh_user'] + sql_backend = SshAccessedMysqlDb(db_server_fqdn, db_user, db_name, ssh_user) + # sql_backend = RemoteMysqlDb(db_server_fqdn, db_user, db_name) + return SqlResultsDb(sql_backend) diff --git a/test/test_iprbench.py b/test/test_iprbench.py index 67b904f..5567bdb 100644 --- a/test/test_iprbench.py +++ b/test/test_iprbench.py @@ -45,12 +45,31 @@ class IprBenchTestCase(unittest.TestCase): 'num_cores': 2 } resultsdb_params = { - 'type': 'sql-database', + 'type': 'sqlite-database', 'sqlite_file_path': '/tmp/iprbench_results.sql' } command = f'iprbench-run --benchmark-id \'mamul1\' --config \'{json.dumps(config)}\' --results-dir {results_dir} --resultsdb-params \'{json.dumps(resultsdb_params)}\'' subprocess.run(command, shell=True, check=True, executable='/bin/bash') + def test_sqlserver(self): + logging.info('test_sqlserver') + results_dir = Path('/tmp/mamul1_out') + config = { + 'compiler_id': 'gfortran', + 'matrix_size': 1024, + 'num_loops': 10, + 'num_cores': 2 + } + resultsdb_params = { + 'type': 'sqlserver-viassh-database', + 'db_server_fqdn': 'iprbenchsdb.ipr.univ-rennes1.fr', + 'db_user': 'test_iprbenchw', + 'db_name': 'test_iprbenchs', + 'ssh_user': 'test_iprbenchw' + } + command = f'iprbench-run --benchmark-id \'mamul1\' --config \'{json.dumps(config)}\' --results-dir {results_dir} --resultsdb-params \'{json.dumps(resultsdb_params)}\'' + subprocess.run(command, shell=True, check=True, executable='/bin/bash') + def test_iprbench_hibench(self): logging.info('test_iprbench_hibench') results_dir = Path('/tmp/hibench_out')