Change in vdsm[master]: tests: Support parallel testing in apiTests
agl at us.ibm.com
agl at us.ibm.com
Mon Nov 19 19:44:01 UTC 2012
Adam Litke has uploaded a new change for review.
Change subject: tests: Support parallel testing in apiTests
......................................................................
tests: Support parallel testing in apiTests
The apiTests module tests the JSON-RPC server by creating a server instance on a
specific port and then connecting clients to that port. Unfortunately, this
means that only one instance of the test can be running on a host at any given
time. Our Jenkins infrastructure would like to run parallel tests. To enable
this, we allow the test to find an open port to use.
Change-Id: Icee7a7cac15ba271374b622d4227d5c15e190341
Signed-off-by: Adam Litke <agl at us.ibm.com>
---
M tests/apiTests.py
1 file changed, 17 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/42/9342/1
diff --git a/tests/apiTests.py b/tests/apiTests.py
index c51c9fc..4b1a56b 100644
--- a/tests/apiTests.py
+++ b/tests/apiTests.py
@@ -22,6 +22,7 @@
import os
import os.path
import socket
+import errno
import json
import struct
@@ -123,6 +124,7 @@
1. Override the API so we can program our own return values
2. Start an embedded server to process our requests
"""
+ global port
log = logging.getLogger('apiTests')
handler = logging.StreamHandler()
fmt_str = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
@@ -137,9 +139,22 @@
# Bridge imports the API module so we must set up the fake API first
import Bridge
bridge = Bridge.DynamicBridge(schema)
- server = BindingJsonRpc.BindingJsonRpc(bridge, ip, port)
- server.start()
+ # Support parallel testing. Try hard to find an open port to use
+ while True:
+ try:
+ server = BindingJsonRpc.BindingJsonRpc(bridge, ip, port)
+ break
+ except socket.error as ex:
+ if ex.errno == errno.EADDRINUSE:
+ port += 1
+ if port > 65535:
+ raise socket.error(
+ errno.EADDRINUSE,
+ "Can not find available port to bind")
+ else:
+ raise
+ server.start()
class APITest(TestCaseBase):
def expectAPI(self, obj, meth, retval):
--
To view, visit http://gerrit.ovirt.org/9342
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icee7a7cac15ba271374b622d4227d5c15e190341
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <agl at us.ibm.com>
More information about the vdsm-patches
mailing list