Change in vdsm[master]: Add timeout to JsonRpcTests:JsonRpcServerTests so they don't...

smizrahi at redhat.com smizrahi at redhat.com
Wed Dec 19 21:35:36 UTC 2012


Saggi Mizrahi has uploaded a new change for review.

Change subject: Add timeout to JsonRpcTests:JsonRpcServerTests so they don't linger forever if server fails to respond
......................................................................

Add timeout to JsonRpcTests:JsonRpcServerTests so they don't linger forever if server fails to respond

Change-Id: Iba0d6f39b0a29df5cc08ae0ceff3d91c31a178f9
Signed-off-by: Saggi Mizrahi <smizrahi at redhat.com>
---
M tests/jsonRpcTests.py
1 file changed, 8 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/50/10250/1

diff --git a/tests/jsonRpcTests.py b/tests/jsonRpcTests.py
index 376feea..b495541 100644
--- a/tests/jsonRpcTests.py
+++ b/tests/jsonRpcTests.py
@@ -157,18 +157,18 @@
     def connect(self):
         self._transport.connect()
 
-    def callMethod(self, methodName, params=(), reqId=None):
+    def callMethod(self, methodName, params=(), reqId=None, timeout=None):
         msg = {'jsonrpc': '2.0',
                'method': methodName,
                'params': params,
                'id': reqId}
 
-        self._transport.sendMessage(json.dumps(msg, 'utf-8'))
+        self._transport.sendMessage(json.dumps(msg, 'utf-8'), timeout=timeout)
         # Notifications have no repsonse
         if reqId is None:
             return
 
-        resp = self._transport.recvMessage()
+        resp = self._transport.recvMessage(timeout=timeout)
         resp = json.loads(resp)
         if resp.get('error') is not None:
             raise JsonRpcError(resp['error']['code'],
@@ -298,7 +298,8 @@
             client = clientFactory()
             client.connect()
             with closing(client):
-                self.assertEquals(client.callMethod("echo", (data,), 10), data)
+                self.assertEquals(client.callMethod("echo", (data,), 10, 1),
+                                  data)
 
     @permutations(REACTOR_TYPE_PERMUTATIONS)
     def testMethodCallArgDict(self, reactorType):
@@ -311,7 +312,7 @@
             with closing(client):
                 self.assertEquals(client.callMethod("echo",
                                                     {'text': data},
-                                                    10),
+                                                    10, 1),
                                   data)
 
     @permutations(REACTOR_TYPE_PERMUTATIONS)
@@ -322,7 +323,7 @@
             client.connect()
             with closing(client):
                 with self.assertRaises(JsonRpcError) as cm:
-                    client.callMethod("I.DO.NOT.EXIST :(", [], 10)
+                    client.callMethod("I.DO.NOT.EXIST :(", [], 10, 1)
 
                 self.assertEquals(cm.exception.code,
                                   JsonRpcMethodNotFoundError().code)
@@ -337,7 +338,7 @@
             client.connect()
             with closing(client):
                 with self.assertRaises(JsonRpcError) as cm:
-                    client.callMethod("echo", [], 10)
+                    client.callMethod("echo", [], 10, timeout=1)
 
                 self.assertEquals(cm.exception.code,
                                   JsonRpcInternalError().code)


--
To view, visit http://gerrit.ovirt.org/10250
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iba0d6f39b0a29df5cc08ae0ceff3d91c31a178f9
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <smizrahi at redhat.com>


More information about the vdsm-patches mailing list