Skip to content

Commit

Permalink
test/rgw/notifications: make sure that http handler is running
Browse files Browse the repository at this point in the history
fail test if not. to indicate this is a test issue
and not a product bug

Signed-off-by: Yuval Lifshitz <ylifshit@ibm.com>
  • Loading branch information
yuvalif committed May 12, 2024
1 parent 1f509da commit 9d56bbe
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/test/rgw/bucket_notification/test_bn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -187,6 +192,7 @@ def do_POST(self):
time.sleep(self.server.delay)
self.end_headers()

import requests

class HTTPServerWithEvents(ThreadingHTTPServer):
"""multithreaded HTTP server used by the handler to store events"""
Expand All @@ -210,6 +216,11 @@ def __init__(self, addr, delay=0, cloudevents=False):
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):
Expand Down

0 comments on commit 9d56bbe

Please sign in to comment.