[ARVADOS] updated: 791bfa0fabd9b37ff8b52fb934f16b47461731da
Git user
git at public.curoverse.com
Mon Apr 11 10:01:15 EDT 2016
Summary of changes:
sdk/python/tests/test_websockets.py | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
via 791bfa0fabd9b37ff8b52fb934f16b47461731da (commit)
from 7ddbf6b763f15bb84d7d897d373e37e85a8c3d6b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 791bfa0fabd9b37ff8b52fb934f16b47461731da
Author: radhika <radhika at curoverse.com>
Date: Mon Apr 11 10:00:36 2016 -0400
7658: update connect error test to use stream handler to read the log file, instead of using a temp file.
diff --git a/sdk/python/tests/test_websockets.py b/sdk/python/tests/test_websockets.py
index 1ed138c..907dd93 100644
--- a/sdk/python/tests/test_websockets.py
+++ b/sdk/python/tests/test_websockets.py
@@ -6,6 +6,7 @@ import logging.handlers
import mock
import Queue
import run_test_server
+import StringIO
import tempfile
import threading
import time
@@ -132,10 +133,10 @@ class WebsocketTest(run_test_server.TestCaseWithServers):
run_test_server.authorize_with('active')
events = Queue.Queue(100)
- log_file = tempfile.NamedTemporaryFile(suffix='log.out', delete=True)
+ logstream = StringIO.StringIO()
rootLogger = logging.getLogger()
- fileHandler = logging.FileHandler(log_file.name)
- rootLogger.addHandler(fileHandler)
+ streamHandler = logging.StreamHandler(logstream)
+ rootLogger.addHandler(streamHandler)
filters = [['object_uuid', 'is_a', 'arvados#human']]
filters.append(['created_at', '>=', self.localiso(self.TIME_PAST)])
@@ -180,14 +181,14 @@ class WebsocketTest(run_test_server.TestCaseWithServers):
self.assertEqual(events.get(True, 2), None)
# verify log message to ensure that an (un)expected close
- log_messages = log_file.read()
+ log_messages = logstream.getvalue()
closeLogFound = log_messages.find("Unexpected close. Reconnecting.")
retryLogFound = log_messages.find("Error during websocket reconnect. Will retry")
if close_unexpected:
self.assertNotEqual(closeLogFound, -1)
else:
self.assertEqual(closeLogFound, -1)
- rootLogger.removeHandler(fileHandler)
+ rootLogger.removeHandler(streamHandler)
def test_websocket_reconnect_on_unexpected_close(self):
self._test_websocket_reconnect(True)
@@ -200,10 +201,10 @@ class WebsocketTest(run_test_server.TestCaseWithServers):
def test_websocket_reconnect_retry(self, event_client_connect):
event_client_connect.side_effect = [None, Exception('EventClient.connect error'), None]
- log_file = tempfile.NamedTemporaryFile(suffix='log.out', delete=True)
+ logstream = StringIO.StringIO()
rootLogger = logging.getLogger()
- fileHandler = logging.FileHandler(log_file.name)
- rootLogger.addHandler(fileHandler)
+ streamHandler = logging.StreamHandler(logstream)
+ rootLogger.addHandler(streamHandler)
run_test_server.authorize_with('active')
events = Queue.Queue(100)
@@ -220,7 +221,7 @@ class WebsocketTest(run_test_server.TestCaseWithServers):
self.ws.on_closed()
# verify log messages to ensure retry happened
- log_messages = log_file.read()
+ log_messages = logstream.getvalue()
found = log_messages.find("Error 'EventClient.connect error' during websocket reconnect. Will retry")
self.assertNotEqual(found, -1)
- rootLogger.removeHandler(fileHandler)
+ rootLogger.removeHandler(streamHandler)
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list