[ARVADOS] updated: 7c607284a048225b86b210c8c5397ff8a983d820

Git user git at public.curoverse.com
Fri Apr 8 11:24:34 EDT 2016


Summary of changes:
 sdk/python/tests/test_websockets.py | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

       via  7c607284a048225b86b210c8c5397ff8a983d820 (commit)
      from  0c848aa00c9af71ea2c7a575d8ee04b420a5eae7 (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 7c607284a048225b86b210c8c5397ff8a983d820
Author: radhika <radhika at curoverse.com>
Date:   Fri Apr 8 11:23:53 2016 -0400

    7658: improve the log verification in case of unexpected close.

diff --git a/sdk/python/tests/test_websockets.py b/sdk/python/tests/test_websockets.py
index 9c8def8..f3f82fe 100644
--- a/sdk/python/tests/test_websockets.py
+++ b/sdk/python/tests/test_websockets.py
@@ -2,8 +2,8 @@ import arvados
 import arvados.events
 from datetime import datetime, timedelta, tzinfo
 import logging
+import logging.handlers
 import mock
-import os
 import Queue
 import run_test_server
 import tempfile
@@ -132,6 +132,11 @@ 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)
+        rootLogger = logging.getLogger()
+        fileHandler = logging.FileHandler(log_file.name)
+        rootLogger.addHandler(fileHandler)
+
         filters = [['object_uuid', 'is_a', 'arvados#human']]
         filters.append(['created_at', '>=', self.localiso(self.TIME_PAST)])
         self.ws = arvados.events.subscribe(
@@ -174,6 +179,16 @@ class WebsocketTest(run_test_server.TestCaseWithServers):
             with self.assertRaises(Queue.Empty):
                 self.assertEqual(events.get(True, 2), None)
 
+        # verify log message to ensure that an (un)expected close
+        log_messages = log_file.read()
+        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)
+
     def test_websocket_reconnect_on_unexpected_close(self):
         self._test_websocket_reconnect(True)
 
@@ -186,7 +201,9 @@ class WebsocketTest(run_test_server.TestCaseWithServers):
         event_client_connect.side_effect = [None, Exception('EventClient.connect error'), None]
 
         log_file = tempfile.NamedTemporaryFile(suffix='log.out', delete=True)
-        logging.basicConfig(filename=log_file.name, level=logging.DEBUG,)
+        rootLogger = logging.getLogger()
+        fileHandler = logging.FileHandler(log_file.name)
+        rootLogger.addHandler(fileHandler)
 
         run_test_server.authorize_with('active')
         events = Queue.Queue(100)
@@ -206,4 +223,4 @@ class WebsocketTest(run_test_server.TestCaseWithServers):
         log_messages = log_file.read()
         found = log_messages.find("Error during websocket reconnect. Will retry")
         self.assertNotEqual(found, -1)
-        os.unlink(log_file.name)
+        rootLogger.removeHandler(fileHandler)

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list