From 9d56bbe689bab2292a00ff527388006a28f208b4 Mon Sep 17 00:00:00 2001 From: Yuval Lifshitz Date: Thu, 9 May 2024 15:33:41 +0000 Subject: [PATCH] test/rgw/notifications: make sure that http handler is running fail test if not. to indicate this is a test issue and not a product bug Signed-off-by: Yuval Lifshitz --- src/test/rgw/bucket_notification/test_bn.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/rgw/bucket_notification/test_bn.py b/src/test/rgw/bucket_notification/test_bn.py index fc06a14dc3499..f46f993055030 100644 --- a/src/test/rgw/bucket_notification/test_bn.py +++ b/src/test/rgw/bucket_notification/test_bn.py @@ -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): -- 2.39.5