diff --git a/libs/utils/executor.py b/libs/utils/executor.py index 1f7a4c11ee07688c787f59631b1c32be981452c6..103c459cc331e6a967dbfff8786217ba98acc27e 100644 --- a/libs/utils/executor.py +++ b/libs/utils/executor.py @@ -545,6 +545,8 @@ class Executor(): logging.info(r'%14s - %s', 'Executor', stats_file.replace(self.te.res_dir, '')) + self._print_footer('Executor') + ################################################################################ # Utility Functions ################################################################################ @@ -564,6 +566,11 @@ class Executor(): logging.info(FMT_TITLE) logging.info(r'%14s - %s', tag, message) + def _print_footer(self, tag, message=None): + if message: + logging.info(r'%14s - %s', tag, message) + logging.info(FMT_FOOTER) + ################################################################################ # Globals @@ -582,5 +589,6 @@ TGT_RUN_DIR = 'run_dir' FMT_SECTION = r'{:#<80}'.format('') FMT_HEADER = r'{:=<80}'.format('') FMT_TITLE = r'{:~<80}'.format('') +FMT_FOOTER = r'{:-<80}'.format('') # vim :set tabstop=4 shiftwidth=4 expandtab diff --git a/libs/utils/test.py b/libs/utils/test.py index f616d2ada87e24cc6219e6b50cd106c3ee19e29b..a0c101f5360e4ddafade53bae55431abd5c64f75 100644 --- a/libs/utils/test.py +++ b/libs/utils/test.py @@ -25,75 +25,77 @@ from executor import Executor class LisaTest(unittest.TestCase): """A base class for LISA defined tests""" - def __init__(self, conf_file, *args, **kwargs): + @classmethod + def _init(cls, conf_file, *args, **kwargs): """ Base class to run LISA test experiments """ - self.logger = logging.getLogger('test') - self.logger.setLevel(logging.INFO) + cls.logger = logging.getLogger('test') + cls.logger.setLevel(logging.INFO) if 'loglevel' in kwargs: - self.logger.setLevel(kwargs['loglevel']) + cls.logger.setLevel(kwargs['loglevel']) kwargs.pop('loglevel') - - self.conf_file = conf_file - self.logger.info("%14s - Using configuration:", + cls.conf_file = conf_file + cls.logger.info("%14s - Using configuration:", "LisaTest") - self.logger.info("%14s - %s", - "LisaTest", self.conf_file) - - self.logger.debug("%14s - Load test specific configuration...", "LisaTest") - json_conf = JsonConf(self.conf_file) - self.conf = json_conf.load() + cls.logger.info("%14s - %s", + "LisaTest", cls.conf_file) - self.logger.debug("%14s - Checking tests configuration...", "LisaTest") - self._checkConf() + cls.logger.debug("%14s - Load test specific configuration...", "LisaTest") + json_conf = JsonConf(cls.conf_file) + cls.conf = json_conf.load() - super(LisaTest, self).__init__(*args, **kwargs) + cls.logger.debug("%14s - Checking tests configuration...", "LisaTest") + cls._checkConf() - self._runExperiments() + cls._runExperiments() - def _runExperiments(self): + @classmethod + def _runExperiments(cls): """ Default experiments execution engine """ - self.logger.info("%14s - Setup tests execution engine...", "LisaTest") - self.executor = Executor(tests_conf = self.conf_file) + cls.logger.info("%14s - Setup tests execution engine...", "LisaTest") + cls.executor = Executor(tests_conf = cls.conf_file); # Alias executor objects to make less verbose tests code - self.te = self.executor.te - self.target = self.executor.target + cls.te = cls.executor.te + cls.target = cls.executor.target # Execute pre-experiments code defined by the test - self._experimentsInit() + cls._experimentsInit() - self.logger.info("%14s - Experiments execution...", "LisaTest") - self.executor.run() + cls.logger.info("%14s - Experiments execution...", "LisaTest") + cls.executor.run() # Execute post-experiments code defined by the test - self._experimentsFinalize() + cls._experimentsFinalize() - def _checkConf(self): + @classmethod + def _checkConf(cls): """ Check for mandatory configuration options """ - assert 'confs' in self.conf, \ + assert 'confs' in cls.conf, \ "Configuration file missing target configurations ('confs' attribute)" - assert self.conf['confs'], \ + assert cls.conf['confs'], \ "Configuration file with empty set of target configurations ('confs' attribute)" - assert 'wloads' in self.conf, \ + assert 'wloads' in cls.conf, \ "Configuration file missing workload configurations ('wloads' attribute)" - assert self.conf['wloads'], \ + assert cls.conf['wloads'], \ "Configuration file with empty set of workloads ('wloads' attribute)" - def _experimentsInit(self): + @classmethod + def _experimentsInit(cls): """ Code executed before running the experiments """ - def _experimentsFinalize(self): + @classmethod + def _experimentsFinalize(cls): """ Code executed after running the experiments """ diff --git a/tests/eas/rfc.py b/tests/eas/rfc.py index 9a8ceab0ad1c9df6867420945658a39198b9dc72..84d99a0f72ef0c5236e6391ca79d2787c43aaabb 100644 --- a/tests/eas/rfc.py +++ b/tests/eas/rfc.py @@ -26,8 +26,9 @@ TESTS_CONF = os.path.join(TESTS_DIRECTORY, "rfc.config") class RFC(LisaTest): """Tests for the Energy-Aware Scheduler""" - def __init__(self, *args, **kwargs): - super(RFC, self).__init__(TESTS_CONF, *args, **kwargs) + @classmethod + def setUpClass(cls, *args, **kwargs): + super(RFC, cls)._init(TESTS_CONF, args, kwargs) def test_energy_regression(self): """Check that there is not regression on energy""" diff --git a/tests/sfreq/smoke_test.py b/tests/sfreq/smoke_test.py index 02531df6ef75a1788a6e7eee2fcba3326a7db80c..a6cc83cce691c7e203c0fe1c40decf872908452b 100644 --- a/tests/sfreq/smoke_test.py +++ b/tests/sfreq/smoke_test.py @@ -26,8 +26,9 @@ TESTS_CONF = os.path.join(TESTS_DIRECTORY, "smoke_test.config") class SFreq(LisaTest): """Tests for SchedFreq framework""" - def __init__(self, *args, **kwargs): - super(SFreq, self).__init__(TESTS_CONF, *args, **kwargs) + @classmethod + def setUpClass(cls, *args, **kwargs): + super(SFreq, cls)._init(TESTS_CONF, *args, **kwargs) def test_regression(self): """Check that there is not regression on energy""" diff --git a/tests/stune/smoke_test_ramp.py b/tests/stune/smoke_test_ramp.py index e7a9d9eb3a32346fc43014b5c1f8e80a72329f16..62385612dab169aca1949a79a4a0293c1641d7e8 100644 --- a/tests/stune/smoke_test_ramp.py +++ b/tests/stune/smoke_test_ramp.py @@ -29,8 +29,9 @@ TESTS_CONF = os.path.join(TESTS_DIRECTORY, "smoke_test_ramp.config") class STune(LisaTest): """Tests for SchedTune framework""" - def __init__(self, *args, **kwargs): - super(STune, self).__init__(TESTS_CONF, *args, **kwargs) + @classmethod + def setUpClass(cls, *args, **kwargs): + super(STune, cls)._init(TESTS_CONF, *args, **kwargs) def test_boosted_utilization_signal(self): """The boosted utilization signal is appropriately boosted