зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1316622 - Add timeout reset API to Marionette Python client; r=automatedtester,whimboo
This removes the `default_timeouts` internal state associated with the Marionette client connection and introduces a new API to reset all timeouts to their documented defaults in `marionette_driver.timeouts.Timeout`. MozReview-Commit-ID: 3xFWsYLngMp --HG-- extra : rebase_source : a712985559c0c1d9cab3d08197a3351610fcb996
This commit is contained in:
Родитель
49ca3755bc
Коммит
ebbefec1e2
|
@ -544,7 +544,7 @@ class Marionette(object):
|
|||
DEFAULT_SHUTDOWN_TIMEOUT = 65 # Firefox will kill hanging threads after 60s
|
||||
|
||||
def __init__(self, host="localhost", port=2828, app=None, bin=None,
|
||||
baseurl=None, timeout=None, socket_timeout=DEFAULT_SOCKET_TIMEOUT,
|
||||
baseurl=None, socket_timeout=DEFAULT_SOCKET_TIMEOUT,
|
||||
startup_timeout=None, **instance_args):
|
||||
"""Construct a holder for the Marionette connection.
|
||||
|
||||
|
@ -557,9 +557,6 @@ class Marionette(object):
|
|||
Defaults to port 2828.
|
||||
:param baseurl: Where to look for files served from Marionette's
|
||||
www directory.
|
||||
:param timeout: Dictionary of default page load, script, and
|
||||
implicit wait timeouts. Timeouts in the session are reset
|
||||
to these values whenever ``reset_timeouts`` is called.
|
||||
:param socket_timeout: Timeout for Marionette socket operations.
|
||||
:param startup_timeout: Seconds to wait for a connection with
|
||||
binary.
|
||||
|
@ -574,7 +571,6 @@ class Marionette(object):
|
|||
self.host = host
|
||||
self.port = self.local_port = int(port)
|
||||
self.bin = bin
|
||||
self.default_timeouts = timeout
|
||||
self.instance = None
|
||||
self.session = None
|
||||
self.session_id = None
|
||||
|
@ -764,22 +760,6 @@ class Marionette(object):
|
|||
|
||||
raise errors.lookup(error)(message, stacktrace=stacktrace)
|
||||
|
||||
def reset_timeouts(self):
|
||||
"""Resets timeouts to their defaults to the
|
||||
`self.default_timeouts` attribute. If unset, only the page load
|
||||
timeout is reset to 30 seconds.
|
||||
|
||||
"""
|
||||
setters = {"search": "implicit",
|
||||
"script": "script",
|
||||
"page load": "page_load"}
|
||||
|
||||
if self.default_timeouts is not None:
|
||||
for typ, ms in self.default_timeouts:
|
||||
setattr(self.timeout, setters[typ], ms)
|
||||
else:
|
||||
self.timeout.page_load = 30
|
||||
|
||||
def check_for_crash(self):
|
||||
"""Check if the process crashed.
|
||||
|
||||
|
@ -1128,7 +1108,7 @@ class Marionette(object):
|
|||
self.instance.restart(prefs)
|
||||
self.raise_for_port()
|
||||
self.start_session()
|
||||
self.reset_timeouts()
|
||||
self.timeout.reset()
|
||||
|
||||
# Restore the context as used before the restart
|
||||
self.set_context(context)
|
||||
|
@ -1177,7 +1157,7 @@ class Marionette(object):
|
|||
raise errors.MarionetteException("quit() can only be called "
|
||||
"on Gecko instances launched by Marionette")
|
||||
|
||||
self.reset_timeouts()
|
||||
self.timeout.reset()
|
||||
|
||||
if in_app:
|
||||
if callable(callback):
|
||||
|
@ -1244,7 +1224,7 @@ class Marionette(object):
|
|||
self.raise_for_port()
|
||||
|
||||
self.start_session(session_id=session_id)
|
||||
self.reset_timeouts()
|
||||
self.timeout.reset()
|
||||
|
||||
# Restore the context as used before the restart
|
||||
self.set_context(context)
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
import errors
|
||||
|
||||
|
||||
DEFAULT_SCRIPT_TIMEOUT = 30
|
||||
DEFAULT_PAGE_LOAD_TIMEOUT = 300
|
||||
DEFAULT_IMPLICIT_WAIT_TIMEOUT = 0
|
||||
|
||||
|
||||
class Timeouts(object):
|
||||
"""Manage timeout settings in the Marionette session.
|
||||
|
||||
|
@ -85,3 +90,9 @@ class Timeouts(object):
|
|||
|
||||
"""
|
||||
self._set("implicit", sec)
|
||||
|
||||
def reset(self):
|
||||
"""Resets timeouts to their default values."""
|
||||
self.script = DEFAULT_SCRIPT_TIMEOUT
|
||||
self.page_load = DEFAULT_PAGE_LOAD_TIMEOUT
|
||||
self.implicit = DEFAULT_IMPLICIT_WAIT_TIMEOUT
|
||||
|
|
|
@ -255,7 +255,7 @@ class CommonTestCase(unittest.TestCase):
|
|||
self.httpd = self._httpd_weakref()
|
||||
if self.marionette.session is None:
|
||||
self.marionette.start_session()
|
||||
self.marionette.reset_timeouts()
|
||||
self.marionette.timeout.reset()
|
||||
|
||||
super(CommonTestCase, self).setUp()
|
||||
|
||||
|
|
|
@ -308,12 +308,6 @@ class BaseMarionetteArguments(ArgumentParser):
|
|||
self.add_argument('--symbols-path',
|
||||
help='absolute path to directory containing breakpad symbols, or the '
|
||||
'url of a zip file containing symbols')
|
||||
self.add_argument('--timeout',
|
||||
type=int,
|
||||
help='if a --timeout value is given, it will set the default page load '
|
||||
'timeout, search timeout and script timeout to the given value. '
|
||||
'If not passed in, it will use the default values of 30000ms for '
|
||||
'page load, 0ms for search timeout and 10000ms for script timeout')
|
||||
self.add_argument('--startup-timeout',
|
||||
type=int,
|
||||
default=60,
|
||||
|
@ -508,7 +502,7 @@ class BaseMarionetteTestRunner(object):
|
|||
app=None, app_args=None, binary=None, profile=None,
|
||||
logger=None, logdir=None,
|
||||
repeat=0, testvars=None,
|
||||
symbols_path=None, timeout=None,
|
||||
symbols_path=None,
|
||||
shuffle=False, shuffle_seed=random.randint(0, sys.maxint), this_chunk=1,
|
||||
total_chunks=1,
|
||||
server_root=None, gecko_log=None, result_callbacks=None,
|
||||
|
@ -538,7 +532,6 @@ class BaseMarionetteTestRunner(object):
|
|||
self.logdir = logdir
|
||||
self.repeat = repeat
|
||||
self.symbols_path = symbols_path
|
||||
self.timeout = timeout
|
||||
self.socket_timeout = socket_timeout
|
||||
self.shuffle = shuffle
|
||||
self.shuffle_seed = shuffle_seed
|
||||
|
@ -723,7 +716,6 @@ class BaseMarionetteTestRunner(object):
|
|||
os.mkdir(self.logdir)
|
||||
|
||||
kwargs = {
|
||||
'timeout': self.timeout,
|
||||
'socket_timeout': self.socket_timeout,
|
||||
'prefs': self.prefs,
|
||||
'startup_timeout': self.startup_timeout,
|
||||
|
|
|
@ -122,7 +122,7 @@ def test_build_kwargs_basic_args(build_kwargs_using):
|
|||
always be included, irrespective of the runner's settings)
|
||||
get passed to the call to runner.driverclass'''
|
||||
|
||||
basic_args = ['timeout', 'socket_timeout', 'prefs',
|
||||
basic_args = ['socket_timeout', 'prefs',
|
||||
'startup_timeout', 'verbose', 'symbols_path']
|
||||
built_kwargs = build_kwargs_using([(a, getattr(sentinel, a)) for a in basic_args])
|
||||
for arg in basic_args:
|
||||
|
|
|
@ -13,7 +13,7 @@ from marionette_driver.by import By
|
|||
|
||||
class TestTimeouts(MarionetteTestCase):
|
||||
def tearDown(self):
|
||||
self.marionette.reset_timeouts()
|
||||
self.marionette.timeout.reset()
|
||||
MarionetteTestCase.tearDown(self)
|
||||
|
||||
def test_page_timeout_notdefinetimeout_pass(self):
|
||||
|
|
Загрузка…
Ссылка в новой задаче