]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
test/rgw/notification: avoid BlockingIOError when logging errors
authorYuval Lifshitz <ylifshit@ibm.com>
Wed, 8 May 2024 16:15:26 +0000 (16:15 +0000)
committerYuval Lifshitz <ylifshit@ibm.com>
Wed, 15 May 2024 04:36:19 +0000 (04:36 +0000)
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 <ylifshit@ibm.com>
(cherry picked from commit 184b9bebf85082deb8780b1f4f0e39d75439b684)

src/test/rgw/bucket_notification/test_bn.py

index c8aaabe1d530f634514b38840648648ddb2425a6..bb99f89f8535c3da33c2d44393260e759ca622b6 100644 (file)
@@ -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):