summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty Brandenberg <monty@lindenlab.com>2013-05-13 18:32:03 -0400
committerMonty Brandenberg <monty@lindenlab.com>2013-05-13 18:32:03 -0400
commit81ffd3fccac709a5903dd0d7572db50c50850347 (patch)
tree969034fe9c973fd9ff283ac983ade5d3530c51be
parent2a59fef6beff7144085ea98ede4a3b4300248d7f (diff)
Whinge reduction effort on the unit tests. Python 2.7 SocketServer
library has new exception-throwing behavior when a client disconnects unannounced. Generally ignore exceptions as a result as we don't care about the server side. On HTTP trace-mode tests, spin a little faster and longer to give libcurl time to emit all the junk it wants to send us. Should reduce 'reasonable time' failures on tests <12> and <13>.
-rw-r--r--indra/llcorehttp/tests/test_httprequest.hpp12
-rw-r--r--indra/llcorehttp/tests/test_llcorehttp_peer.py35
2 files changed, 35 insertions, 12 deletions
diff --git a/indra/llcorehttp/tests/test_httprequest.hpp b/indra/llcorehttp/tests/test_httprequest.hpp
index ff84b04070..e2021bac12 100644
--- a/indra/llcorehttp/tests/test_httprequest.hpp
+++ b/indra/llcorehttp/tests/test_httprequest.hpp
@@ -1226,11 +1226,11 @@ void HttpRequestTestObjectType::test<12>()
// Run the notification pump.
int count(0);
- int limit(10);
+ int limit(200);
while (count++ < limit && mHandlerCalls < 1)
{
req->update(1000000);
- usleep(100000);
+ usleep(10000);
}
ensure("Request executed in reasonable time", count < limit);
ensure("One handler invocation for request", mHandlerCalls == 1);
@@ -1339,8 +1339,8 @@ void HttpRequestTestObjectType::test<13>()
HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID,
0U,
url_base,
- 0,
- 0,
+ 0,
+ 0,
opts,
NULL,
&handler);
@@ -1352,11 +1352,11 @@ void HttpRequestTestObjectType::test<13>()
// Run the notification pump.
int count(0);
- int limit(10);
+ int limit(200);
while (count++ < limit && mHandlerCalls < 1)
{
req->update(1000000);
- usleep(100000);
+ usleep(10000);
}
ensure("Request executed in reasonable time", count < limit);
ensure("One handler invocation for request", mHandlerCalls == 1);
diff --git a/indra/llcorehttp/tests/test_llcorehttp_peer.py b/indra/llcorehttp/tests/test_llcorehttp_peer.py
index 8796ae57c7..3c3af8dc75 100644
--- a/indra/llcorehttp/tests/test_llcorehttp_peer.py
+++ b/indra/llcorehttp/tests/test_llcorehttp_peer.py
@@ -73,6 +73,8 @@ class TestHTTPRequestHandler(BaseHTTPRequestHandler):
Some combinations make no sense, there's no effort to protect
you from that.
"""
+ ignore_exceptions = (Exception,)
+
def read(self):
# The following logic is adapted from the library module
# SimpleXMLRPCServer.py.
@@ -112,20 +114,29 @@ class TestHTTPRequestHandler(BaseHTTPRequestHandler):
def do_GET(self, withdata=True):
# Of course, don't attempt to read data.
- self.answer(dict(reply="success", status=200,
- reason="Your GET operation worked"))
+ try:
+ self.answer(dict(reply="success", status=200,
+ reason="Your GET operation worked"))
+ except self.ignore_exceptions, e:
+ print >> sys.stderr, "Exception during GET (ignoring): %s" % str(e)
def do_POST(self):
# Read the provided POST data.
# self.answer(self.read())
- self.answer(dict(reply="success", status=200,
- reason=self.read()))
+ try:
+ self.answer(dict(reply="success", status=200,
+ reason=self.read()))
+ except self.ignore_exceptions, e:
+ print >> sys.stderr, "Exception during POST (ignoring): %s" % str(e)
def do_PUT(self):
# Read the provided PUT data.
# self.answer(self.read())
- self.answer(dict(reply="success", status=200,
- reason=self.read()))
+ try:
+ self.answer(dict(reply="success", status=200,
+ reason=self.read()))
+ except self.ignore_exceptions, e:
+ print >> sys.stderr, "Exception during PUT (ignoring): %s" % str(e)
def answer(self, data, withdata=True):
debug("%s.answer(%s): self.path = %r", self.__class__.__name__, data, self.path)
@@ -223,6 +234,17 @@ class Server(ThreadingMixIn, HTTPServer):
# operation of freeport() absolutely depends on it being off.
allow_reuse_address = False
+ # Override of BaseServer.handle_error(). Not too interested
+ # in errors and the default handler emits a scary traceback
+ # to stderr which annoys some. Disable this override to get
+ # default behavior which *shouldn't* cause the program to return
+ # a failure status.
+ def handle_error(self, request, client_address):
+ print '-'*40
+ print 'Ignoring exception during processing of request from',
+ print client_address
+ print '-'*40
+
if __name__ == "__main__":
do_valgrind = False
path_search = False
@@ -249,3 +271,4 @@ if __name__ == "__main__":
args = ["valgrind", "--log-file=./valgrind.log"] + args
path_search = True
sys.exit(run(server=Thread(name="httpd", target=httpd.serve_forever), use_path=path_search, *args))
+