doc webdav: Have a timeout on YAML tests

During a database upgrade from cmdline, the HTTP server will be inactive,
so it would cause a deadlock at the WebDAV tests. Having the HTTP port
answer requests before the db is ready would be a bad idea, so we'd better
just timeout and skip the tests.

bzr revid: p_christ@hol.gr-20101207133947-bbni3x48wo3yffa2
This commit is contained in:
P. Christeas 2010-12-07 15:39:47 +02:00
parent 5350ab0c19
commit de6720663b
2 changed files with 10 additions and 4 deletions

View File

@ -1,12 +1,17 @@
-
In order to test the document_ftp functionality
In order to test the document_webdav functionality
-
I open the HTTP port and perform an OPTIONS request to the server
-
!python {model: ir.attachment}: |
from document_webdav import test_davclient as te
reload(te) # reload..
dc = te.DAVClient()
dc = te.DAVClient(timeout=2.0)
# have a small timeout, enough for any heavily-loaded test server to
# respond, but small so that this test won't block further loading.
# Don't catch the exception, so that the whole YAML test will abort
# if the WebDAV service is not available (eg. during an upgrade from
# command line).
dc.gd_options()
dc.get_creds(self, cr, uid)
dc.gd_options(path=cr.dbname, expect={'DAV': ['1',]})

View File

@ -324,7 +324,7 @@ class DAVClient(object):
"""An instance of a WebDAV client, connected to the OpenERP server
"""
def __init__(self, user=None, passwd=None, dbg=0, use_ssl=False, useragent=False):
def __init__(self, user=None, passwd=None, dbg=0, use_ssl=False, useragent=False, timeout=None):
if use_ssl:
self.host = config.get_misc('httpsd', 'interface', False)
self.port = config.get_misc('httpsd', 'port', 8071)
@ -346,6 +346,7 @@ class DAVClient(object):
self.user = user
self.passwd = passwd
self.dbg = dbg
self.timeout = timeout or 5.0 # seconds, tests need to respond pretty fast!
self.hdrs = {}
if useragent:
self.set_useragent(useragent)
@ -386,7 +387,7 @@ class DAVClient(object):
dbg = self.dbg
hdrs.update(self.hdrs)
log.debug("Getting %s http://%s:%d/%s", method, self.host, self.port, path)
conn = httplib.HTTPConnection(self.host, port=self.port)
conn = httplib.HTTPConnection(self.host, port=self.port, timeout=self.timeout)
conn.set_debuglevel(dbg)
if not path:
path = "/index.html"