]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/rgw/notifications: make sure that http handler is running 56979/head
authorYuval Lifshitz <ylifshit@ibm.com>
Thu, 9 May 2024 15:33:41 +0000 (15:33 +0000)
committerYuval Lifshitz <ylifshit@ibm.com>
Sun, 12 May 2024 10:39:15 +0000 (10:39 +0000)
fail test if not. to indicate this is a test issue
and not a product bug

Signed-off-by: Yuval Lifshitz <ylifshit@ibm.com>
src/test/rgw/bucket_notification/test_bn.py

index fc06a14dc3499b2bac252d7624e21475211a5f4b..f46f9930550302fff2877dd9a2891f4425c18de7 100644 (file)
@@ -166,6 +166,11 @@ class HTTPPostHandler(BaseHTTPRequestHandler):
     def do_POST(self):
         """implementation of POST handler"""
         content_length = int(self.headers['Content-Length'])
+        if content_length == 0:
+            log.info('HTTP Server received iempty event')
+            self.send_response(200)
+            self.end_headers()
+            return
         body = self.rfile.read(content_length)
         if self.server.cloudevents:
             event = from_http(self.headers, body) 
@@ -187,6 +192,7 @@ class HTTPPostHandler(BaseHTTPRequestHandler):
             time.sleep(self.server.delay)
         self.end_headers()
 
+import requests
 
 class HTTPServerWithEvents(ThreadingHTTPServer):
     """multithreaded HTTP server used by the handler to store events"""
@@ -210,6 +216,11 @@ class HTTPServerWithEvents(ThreadingHTTPServer):
             log.error('http server on %s failed to start. closing...', str(self.addr))
             self.close()
             assert False
+        # make sure that http handler is able to consume requests
+        url = 'http://{}:{}'.format(self.addr[0], self.addr[1])
+        response = requests.post(url, {})
+        print(response)
+        assert response.status_code == 200
 
 
     def run(self):