summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Henkel <tobias.henkel@bmw.de>2019-02-03 19:59:30 +0100
committerTobias Henkel <tobias.henkel@bmw.de>2019-02-03 19:59:30 +0100
commitb3b4ab678be82583d67d187424ea68a70fbfaa56 (patch)
tree42cb1a11dd9d2aac1f9900745ca883e0dbc8ce94
parentb44b6c532ce9a999b135d909ae9f9caf0671784d (diff)
Properly log requests in SimpleHTTPRequestHandler
We use the SimpleHTTPRequestHandler as proxy in web urls test and as fake gerrit server. By default it pollutes stderr with every request it receives. This produces much visual noise when running tox. By overriding the log_message method this can be logged properly. Change-Id: Ifc5f1558dc374fa884fd5625221ba4089d533572
Notes
Notes (review): Code-Review+2: Monty Taylor <mordred@inaugust.com> Code-Review+2: Clint 'SpamapS' Byrum <clint@fewbar.com> Workflow+1: Clint 'SpamapS' Byrum <clint@fewbar.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Mon, 04 Feb 2019 20:45:22 +0000 Reviewed-on: https://review.openstack.org/634614 Project: openstack-infra/zuul Branch: refs/heads/master
-rw-r--r--tests/base.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/base.py b/tests/base.py
index a8803c7..59175f0 100644
--- a/tests/base.py
+++ b/tests/base.py
@@ -561,6 +561,9 @@ class GerritWebServer(object):
561 self.send_response(200) 561 self.send_response(200)
562 self.end_headers() 562 self.end_headers()
563 563
564 def log_message(self, fmt, *args):
565 self.log.debug(fmt, *args)
566
564 self.httpd = socketserver.ThreadingTCPServer(('', 0), Server) 567 self.httpd = socketserver.ThreadingTCPServer(('', 0), Server)
565 self.port = self.httpd.socket.getsockname()[1] 568 self.port = self.httpd.socket.getsockname()[1]
566 self.thread = threading.Thread(name='GerritWebServer', 569 self.thread = threading.Thread(name='GerritWebServer',
@@ -2064,6 +2067,8 @@ class WebProxyFixture(fixtures.Fixture):
2064 rules = self.rules 2067 rules = self.rules
2065 2068
2066 class Proxy(http.server.SimpleHTTPRequestHandler): 2069 class Proxy(http.server.SimpleHTTPRequestHandler):
2070 log = logging.getLogger('zuul.WebProxyFixture.Proxy')
2071
2067 def do_GET(self): 2072 def do_GET(self):
2068 path = self.path 2073 path = self.path
2069 for (pattern, replace) in rules: 2074 for (pattern, replace) in rules:
@@ -2078,6 +2083,9 @@ class WebProxyFixture(fixtures.Fixture):
2078 self.end_headers() 2083 self.end_headers()
2079 self.wfile.write(resp.content) 2084 self.wfile.write(resp.content)
2080 2085
2086 def log_message(self, fmt, *args):
2087 self.log.debug(fmt, *args)
2088
2081 self.httpd = socketserver.ThreadingTCPServer(('', 0), Proxy) 2089 self.httpd = socketserver.ThreadingTCPServer(('', 0), Proxy)
2082 self.port = self.httpd.socket.getsockname()[1] 2090 self.port = self.httpd.socket.getsockname()[1]
2083 self.thread = threading.Thread(target=self.httpd.serve_forever) 2091 self.thread = threading.Thread(target=self.httpd.serve_forever)