mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Back out a37e6c57ae0f (bug 959520) for making marionette-webapi infinitely retry
This commit is contained in:
parent
dda1182e42
commit
44a41bb21e
@ -2,7 +2,6 @@
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import errno
|
||||
import json
|
||||
import socket
|
||||
|
||||
@ -53,8 +52,9 @@ class MarionetteClient(object):
|
||||
response += self._recv_n_bytes(int(length) + 1 + len(length) - 10)
|
||||
return json.loads(response)
|
||||
else:
|
||||
raise InvalidResponseException("Could not communicate with Marionette server. "
|
||||
"Is the Gecko process still running?",
|
||||
raise InvalidResponseException("Could not successfully complete "
|
||||
"transport of message to Gecko, "
|
||||
"socket closed?",
|
||||
status=ErrorCodes.INVALID_RESPONSE)
|
||||
|
||||
def connect(self, timeout=360.0):
|
||||
@ -90,13 +90,7 @@ class MarionetteClient(object):
|
||||
|
||||
for packet in [data[i:i + self.max_packet_length] for i in
|
||||
range(0, len(data), self.max_packet_length)]:
|
||||
try:
|
||||
self.sock.send(packet)
|
||||
except IOError as e:
|
||||
if e.errno == errno.EPIPE:
|
||||
raise IOError("%s: Connection to Marionette server is lost. Check gecko.log (desktop firefox) or logcat (b2g) for errors." % str(e))
|
||||
else:
|
||||
raise e
|
||||
self.sock.send(packet)
|
||||
|
||||
response = self.receive()
|
||||
return response
|
||||
|
@ -20,7 +20,6 @@ from manifestparser import TestManifest
|
||||
from mozhttpd import MozHttpd
|
||||
from marionette import Marionette
|
||||
from moztest.results import TestResultCollection, TestResult, relevant_line
|
||||
from mixins.b2g import B2GTestResultMixin, get_b2g_pid, get_dm
|
||||
|
||||
|
||||
class MarionetteTest(TestResult):
|
||||
@ -114,7 +113,7 @@ class MarionetteTestResult(unittest._TextTestResult, TestResultCollection):
|
||||
context=context, **kwargs)
|
||||
# call any registered result modifiers
|
||||
for modifier in self.result_modifiers:
|
||||
result_expected, result_actual, output, context = modifier(t, result_expected, result_actual, output, context)
|
||||
modifier(t, result_expected, result_actual, output, context)
|
||||
t.finish(result_actual,
|
||||
time_end=time.time() if test.start_time else 0,
|
||||
reason=relevant_line(output),
|
||||
@ -239,7 +238,6 @@ class MarionetteTextTestRunner(unittest.TextTestRunner):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.marionette = kwargs['marionette']
|
||||
self.capabilities = kwargs.pop('capabilities')
|
||||
del kwargs['marionette']
|
||||
unittest.TextTestRunner.__init__(self, **kwargs)
|
||||
|
||||
@ -311,40 +309,6 @@ class MarionetteTextTestRunner(unittest.TextTestRunner):
|
||||
return result
|
||||
|
||||
|
||||
class B2GMarionetteTestResult(MarionetteTestResult, B2GTestResultMixin):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
# stupid hack because _TextTestRunner doesn't accept **kwargs
|
||||
b2g_pid = kwargs.pop('b2g_pid')
|
||||
MarionetteTestResult.__init__(self, *args, **kwargs)
|
||||
kwargs['b2g_pid'] = b2g_pid
|
||||
B2GTestResultMixin.__init__(self, *args, **kwargs)
|
||||
|
||||
|
||||
class B2GMarionetteTextTestRunner(MarionetteTextTestRunner):
|
||||
|
||||
resultclass = B2GMarionetteTestResult
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
MarionetteTextTestRunner.__init__(self, **kwargs)
|
||||
if self.capabilities['device'] != 'desktop':
|
||||
self.resultclass = B2GMarionetteTestResult
|
||||
self.b2g_pid = None
|
||||
|
||||
def _makeResult(self):
|
||||
return self.resultclass(self.stream,
|
||||
self.descriptions,
|
||||
self.verbosity,
|
||||
marionette=self.marionette,
|
||||
b2g_pid=self.b2g_pid)
|
||||
|
||||
def run(self, test):
|
||||
dm_type = os.environ.get('DM_TRANS', 'adb')
|
||||
if dm_type == 'adb':
|
||||
self.b2g_pid = get_b2g_pid(get_dm())
|
||||
return super(B2GMarionetteTextTestRunner, self).run(test)
|
||||
|
||||
|
||||
class BaseMarionetteOptions(OptionParser):
|
||||
def __init__(self, **kwargs):
|
||||
OptionParser.__init__(self, **kwargs)
|
||||
@ -803,12 +767,6 @@ class BaseMarionetteTestRunner(object):
|
||||
self.start_marionette()
|
||||
if self.emulator:
|
||||
self.marionette.emulator.wait_for_homescreen(self.marionette)
|
||||
# Retrieve capabilities for later use
|
||||
if not self._capabilities:
|
||||
self.capabilities
|
||||
|
||||
if self.capabilities['device'] != 'desktop':
|
||||
self.textrunnerclass = B2GMarionetteTextTestRunner
|
||||
|
||||
testargs = {}
|
||||
if self.type is not None:
|
||||
@ -891,8 +849,7 @@ class BaseMarionetteTestRunner(object):
|
||||
|
||||
if suite.countTestCases():
|
||||
runner = self.textrunnerclass(verbosity=3,
|
||||
marionette=self.marionette,
|
||||
capabilities=self.capabilities)
|
||||
marionette=self.marionette)
|
||||
results = runner.run(suite)
|
||||
self.results.append(results)
|
||||
|
||||
|
@ -4,28 +4,6 @@
|
||||
|
||||
import mozdevice
|
||||
import os
|
||||
import re
|
||||
|
||||
|
||||
def get_dm(**kwargs):
|
||||
dm_type = os.environ.get('DM_TRANS', 'adb')
|
||||
if dm_type == 'adb':
|
||||
return mozdevice.DeviceManagerADB(**kwargs)
|
||||
elif dm_type == 'sut':
|
||||
host = os.environ.get('TEST_DEVICE')
|
||||
if not host:
|
||||
raise Exception('Must specify host with SUT!')
|
||||
return mozdevice.DeviceManagerSUT(host=host)
|
||||
else:
|
||||
raise Exception('Unknown device manager type: %s' % dm_type)
|
||||
|
||||
|
||||
def get_b2g_pid(dm):
|
||||
b2g_output = dm.shellCheckOutput(['b2g-ps'])
|
||||
pid_re = re.compile(r"""[\s\S]*b2g[\s]*root[\s]*([\d]+)[\s\S]*""")
|
||||
if 'b2g' in b2g_output:
|
||||
pid = pid_re.match(b2g_output)
|
||||
return pid.group(1)
|
||||
|
||||
|
||||
class B2GTestCaseMixin(object):
|
||||
@ -36,61 +14,18 @@ class B2GTestCaseMixin(object):
|
||||
|
||||
def get_device_manager(self, *args, **kwargs):
|
||||
if not self._device_manager:
|
||||
self._device_manager = get_dm(**kwargs)
|
||||
dm_type = os.environ.get('DM_TRANS', 'adb')
|
||||
if dm_type == 'adb':
|
||||
self._device_manager = mozdevice.DeviceManagerADB(**kwargs)
|
||||
elif dm_type == 'sut':
|
||||
host = os.environ.get('TEST_DEVICE')
|
||||
if not host:
|
||||
raise Exception('Must specify host with SUT!')
|
||||
self._device_manager = mozdevice.DeviceManagerSUT(host=host)
|
||||
else:
|
||||
raise Exception('Unknown device manager type: %s' % dm_type)
|
||||
return self._device_manager
|
||||
|
||||
@property
|
||||
def device_manager(self):
|
||||
return self.get_device_manager()
|
||||
|
||||
class B2GTestResultMixin(object):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.result_modifiers.append(self.b2g_output_modifier)
|
||||
self.b2g_pid = kwargs.pop('b2g_pid')
|
||||
|
||||
def b2g_output_modifier(self, test, result_expected, result_actual, output, context):
|
||||
# This function will check if b2g is running and report any recent errors. This is
|
||||
# used in automation since a plaian 'socket.timeout' error doesn't tell you
|
||||
# much information about what actually is going on
|
||||
def diagnose_socket(output):
|
||||
dm_type = os.environ.get('DM_TRANS', 'adb')
|
||||
if dm_type == 'adb':
|
||||
device_manager = get_dm()
|
||||
pid = get_b2g_pid(device_manager)
|
||||
if pid:
|
||||
# find recent errors
|
||||
message = ""
|
||||
error_re = re.compile(r"""[\s\S]*(exception|error)[\s\S]*""", flags=re.IGNORECASE)
|
||||
logcat = device_manager.getLogcat()
|
||||
latest = []
|
||||
iters = len(logcat) - 1
|
||||
# reading from the latest line
|
||||
while len(latest) < 5 and iters >= 0:
|
||||
line = logcat[iters]
|
||||
error_log_line = error_re.match(line)
|
||||
if error_log_line is not None:
|
||||
latest.append(line)
|
||||
iters -= 1
|
||||
message += "\nMost recent errors/exceptions are:\n"
|
||||
for line in reversed(latest):
|
||||
message += "%s" % line
|
||||
b2g_status = ""
|
||||
if pid != self.b2g_pid:
|
||||
b2g_status = "The B2G process has restarted after crashing during the tests so "
|
||||
else:
|
||||
b2g_status = "B2G is still running but "
|
||||
output += "%s\n%sMarionette can't respond due to either a Gecko, Gaia or Marionette error. " \
|
||||
"Above, the 5 most recent errors are " \
|
||||
"listed. Check logcat for all errors if these errors are not the cause " \
|
||||
"of the failure." % (message, b2g_status)
|
||||
else:
|
||||
output += "B2G process has died"
|
||||
return output
|
||||
# For some reason, errno is not available for this exception
|
||||
if "Broken pipe" in output:
|
||||
output = diagnose_socket(output)
|
||||
elif "socket.timeout" in output:
|
||||
output = diagnose_socket(output)
|
||||
return result_expected, result_actual, output, context
|
||||
|
||||
|
@ -174,7 +174,6 @@ class HTMLReportingTestResultMixin(object):
|
||||
test.debug = None
|
||||
if result_actual is not 'PASS':
|
||||
test.debug = self.gather_debug()
|
||||
return result_expected, result_actual, output, context
|
||||
|
||||
def gather_debug(self):
|
||||
debug = {}
|
||||
|
Loading…
Reference in New Issue
Block a user