From 7103432b92539d5989c2c573df1fc8a70c09c315 Mon Sep 17 00:00:00 2001 From: afazekas Date: Fri, 9 Sep 2022 11:18:13 +0200 Subject: [PATCH] Unit test logging Tempest used to have logging.conf sample which included stress logging, it was removed from tempest adding more up date version here. Also test cases can fail with an assert method which considered failure not error. Having the test case exceptions logged. Stop overriding the working logger name, as no other action does such override. Change-Id: I46898b705b58ae5921a4c2e6b95ab4c841dbc9af --- tempest_stress/actions/unit_test.py | 7 ++-- tempest_stress/etc/logging_stress.conf.sample | 41 +++++++++++++++++++ 2 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 tempest_stress/etc/logging_stress.conf.sample diff --git a/tempest_stress/actions/unit_test.py b/tempest_stress/actions/unit_test.py index 5790717..e183a7e 100644 --- a/tempest_stress/actions/unit_test.py +++ b/tempest_stress/actions/unit_test.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_log import log as logging from oslo_utils import importutils from tempest_stress import config @@ -50,7 +49,6 @@ class UnitTest(stressaction.StressAction): method = kwargs['test_method'].split('.') self.test_method = method.pop() self.klass = importutils.import_class('.'.join(method)) - self.logger = logging.getLogger('.'.join(method)) # valid options are 'process', 'application' , 'action' self.class_setup_per = kwargs.get('class_setup_per', SetUpClassRunTime.process) @@ -69,7 +67,10 @@ class UnitTest(stressaction.StressAction): def run_core(self): res = self.klass(self.test_method).run() if res.errors: - raise RuntimeError(res.errors) + raise RuntimeError(res.errors[0][1]) + + if res.failures: + raise RuntimeError(res.failures[0][1]) def run(self): if self.class_setup_per != SetUpClassRunTime.application: diff --git a/tempest_stress/etc/logging_stress.conf.sample b/tempest_stress/etc/logging_stress.conf.sample new file mode 100644 index 0000000..b22e1dc --- /dev/null +++ b/tempest_stress/etc/logging_stress.conf.sample @@ -0,0 +1,41 @@ +[loggers] +keys=root,tempest_stress + +[handlers] +keys=file,devel,syslog + +# set the level to DEBUG for more verbosity +[logger_tempest_stress] +level=INFO +handlers=file,devel +qualname=tempest_stress + +[formatters] +keys=simple,tests + +[logger_root] +level=DEBUG +handlers=file + +[handler_file] +class=FileHandler +level=DEBUG +args=('tempest.log', 'w+') +formatter=tests + +[handler_syslog] +class=handlers.SysLogHandler +level=ERROR +args = ('/dev/log', handlers.SysLogHandler.LOG_USER) + +[handler_devel] +class=StreamHandler +level=DEBUG +args=(sys.stdout,) +formatter=simple + +[formatter_tests] +class = oslo_log.formatters.ContextFormatter + +[formatter_simple] +format=%(asctime)s.%(msecs)03d %(process)d %(levelname)s: %(message)s