From 2413e4301854b4c951eedad20869d5a47590447a Mon Sep 17 00:00:00 2001 From: Yuval Lifshitz Date: Wed, 8 May 2024 16:15:26 +0000 Subject: [PATCH] test/rgw/notification: avoid BlockingIOError when logging errors for example. job: 7697397 in test: yuvalif-2024-05-08_09:55:02-rgw:notifications-wip-yuval-65337-distro-default-smithi also reduce the side of the error log by sending less objects to the test_ps_s3_persistent_topic_stats test Signed-off-by: Yuval Lifshitz (cherry picked from commit 184b9bebf85082deb8780b1f4f0e39d75439b684) --- src/test/rgw/bucket_notification/test_bn.py | 34 +++++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/test/rgw/bucket_notification/test_bn.py b/src/test/rgw/bucket_notification/test_bn.py index c8aaabe1d53..bb99f89f853 100644 --- a/src/test/rgw/bucket_notification/test_bn.py +++ b/src/test/rgw/bucket_notification/test_bn.py @@ -45,7 +45,35 @@ from nose.tools import assert_not_equal, assert_equal, assert_in, assert_true import boto.s3.tagging # configure logging for the tests module -log = logging.getLogger(__name__) +class LogWrapper: + def __init__(self): + self.log = logging.getLogger(__name__) + self.errors = 0 + + def info(self, msg, *args, **kwargs): + try: + self.log.info(msg, *args, **kwargs) + except BlockingIOError: + self.errors += 1 + + def warning(self, msg, *args, **kwargs): + try: + self.log.warning(msg, *args, **kwargs) + except BlockingIOError: + self.errors += 1 + + def error(self, msg, *args, **kwargs): + try: + self.log.error(msg, *args, **kwargs) + except BlockingIOError: + self.errors += 1 + + def __del__(self): + if self.errors > 0: + self.log.error("%d logs were lost", self.errors) + + +log = LogWrapper() TOPIC_SUFFIX = "_topic" NOTIFICATION_SUFFIX = "_notif" @@ -169,7 +197,7 @@ class HTTPServerWithEvents(ThreadingHTTPServer): self.addr = addr self.lock = threading.Lock() ThreadingHTTPServer.__init__(self, addr, HTTPPostHandler) - log.info('http server created on %s', str(self.addr)) + log.info('http server created on %s', self.addr) self.proc = threading.Thread(target=self.run) self.proc.start() retries = 0 @@ -3113,7 +3141,7 @@ def test_ps_s3_persistent_topic_stats(): assert_equal(result[1], 0) # create objects in the bucket (async) - number_of_objects = 100 + number_of_objects = 20 client_threads = [] start_time = time.time() for i in range(number_of_objects): -- 2.39.5