Bug 1387265 - Expand talos tp6 to macosx; r=jmaher

MozReview-Commit-ID: 78LGHEJNGz4

--HG--
extra : rebase_source : ad7189968b15ea7cd830d18a0e7033df65d8489f
This commit is contained in:
Rob Wood 2017-08-15 15:30:23 -04:00
Родитель c15c300513
Коммит 1721a468a7
5 изменённых файлов: 45 добавлений и 13 удалений

Просмотреть файл

@ -140,6 +140,9 @@ GPATH
^testing/talos/talos/tests/devtools/damp.manifest.develop
^talos-venv
^py3venv
^testing/talos/talos/mitmproxy/mitmdump
^testing/talos/talos/mitmproxy/mitmproxy
^testing/talos/talos/mitmproxy/mitmweb
# Ignore files created when running a reftest.
^lextab.py$

Просмотреть файл

@ -229,6 +229,7 @@ macosx64-tests-talos:
- talos-tp5o
- talos-perf-reftest
- talos-perf-reftest-singletons
- talos-tp6
linux32-tests:
- cppunit

Просмотреть файл

@ -1854,6 +1854,7 @@ talos-tp6:
run-on-projects:
by-test-platform:
windows.*: ['mozilla-beta', 'mozilla-central', 'mozilla-inbound', 'autoland', 'try', 'date']
macosx.*: ['mozilla-beta', 'mozilla-central', 'mozilla-inbound', 'autoland', 'try', 'date']
default: []
max-run-time: 3600
mozharness:

Просмотреть файл

@ -405,8 +405,16 @@ class Talos(TestingMixin, MercurialScript, BlobUploadMixin, TooltoolMixin,
self.info("Skipping: mitmproxy is not required")
return
# setup python 3.x virtualenv
self.setup_py3_virtualenv()
# tp6 is supported in production only on win and macosx
os_name = self.platform_name()
if 'win' not in os_name and os_name != 'macosx':
self.fatal("Aborting: this test is not supported on this platform.")
# on windows we need to install a pytyon 3 virtual env; on macosx we
# use a mitmdump pre-built binary that doesn't need an external python 3
if 'win' in os_name:
# setup python 3.x virtualenv
self.setup_py3_virtualenv()
# install mitmproxy
self.install_mitmproxy()
@ -432,9 +440,18 @@ class Talos(TestingMixin, MercurialScript, BlobUploadMixin, TooltoolMixin,
def install_mitmproxy(self):
"""Install the mitmproxy tool into the Python 3.x env"""
self.info("Installing mitmproxy")
self.py3_install_modules(modules=['mitmproxy'])
self.mitmdump = os.path.join(self.py3_path_to_executables(), 'mitmdump')
if 'win' in self.platform_name():
self.info("Installing mitmproxy")
self.py3_install_modules(modules=['mitmproxy'])
self.mitmdump = os.path.join(self.py3_path_to_executables(), 'mitmdump')
else:
# on macosx we use a prebuilt mitmproxy release binary
mitmproxy_bin_url = 'https://github.com/mitmproxy/mitmproxy/releases/download/v2.0.2/mitmproxy-2.0.2-osx.tar.gz'
mitmproxy_path = os.path.join(self.talos_path, 'talos', 'mitmproxy')
self.mitmdump = os.path.join(mitmproxy_path, 'mitmdump')
if not os.path.exists(self.mitmdump):
self.download_unpack(mitmproxy_bin_url, mitmproxy_path)
self.info('The mitmdump macosx binary is found at: %s' % self.mitmdump)
self.run_command([self.mitmdump, '--version'], env=self.query_env())
def query_mitmproxy_recording_set(self):

Просмотреть файл

@ -3,6 +3,7 @@
# 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 os
import psutil
import sys
import subprocess
import time
@ -81,6 +82,10 @@ def install_mitmproxy_cert(mitmproxy_proc, browser_path, scripts_path):
LOG.info("Installing mitmxproxy CA certficate into Firefox")
# browser_path is exe, we want install dir
browser_install = os.path.dirname(browser_path)
# on macosx we need to remove the last folders 'Content/MacOS'
if mozinfo.os == 'mac':
browser_install = browser_install[:-14]
LOG.info('Calling configure_mitmproxy with browser folder: %s' % browser_install)
configure_mitmproxy(browser_install, scripts_path)
# cannot continue if failed to add CA cert to Firefox, need to check
@ -104,18 +109,21 @@ def start_mitmproxy_playback(mitmdump_path,
# <path>/mitmdump -s "<path>mitmdump-alternate-server-replay/alternate-server-replay.py
# <path>recording-1.mp <path>recording-2.mp..."
param = os.path.join(here, 'alternate-server-replay.py')
env = os.environ.copy()
# this part is platform-specific
if mozinfo.os == 'win':
param2 = '""' + param.replace('\\', '\\\\\\') + ' ' + \
' '.join(mitmproxy_recordings).replace('\\', '\\\\\\') + '""'
env = os.environ.copy()
sys.path.insert(1, mitmdump_path)
# mitmproxy needs some DLL's that are a part of Firefox itself, so add to path
env["PATH"] = os.path.dirname(browser_path) + ";" + env["PATH"]
elif mozinfo.os == 'mac':
param2 = param + ' ' + ' '.join(mitmproxy_recordings)
env["PATH"] = os.path.dirname(browser_path)
else:
# TODO: support other platforms, Bug 1366355
LOG.error('Aborting: talos mitmproxy is currently only supported on Windows')
LOG.error('Aborting: talos mitmproxy is currently only supported on Windows and Mac')
sys.exit()
command = [mitmdump_path, '-k', '-s', param2]
@ -125,7 +133,7 @@ def start_mitmproxy_playback(mitmdump_path,
# to turn off mitmproxy log output, use these params for Popen:
# Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
mitmproxy_proc = subprocess.Popen(command, env=env)
time.sleep(5)
time.sleep(10)
data = mitmproxy_proc.poll()
if data is None:
LOG.info("Mitmproxy playback successfully started as pid %d" % mitmproxy_proc.pid)
@ -138,13 +146,15 @@ def start_mitmproxy_playback(mitmdump_path,
def stop_mitmproxy_playback(mitmproxy_proc):
"""Stop the mitproxy server playback"""
LOG.info("Stopping mitmproxy playback, klling process %d" % mitmproxy_proc.pid)
mitmproxy_proc.kill()
time.sleep(5)
exit_code = mitmproxy_proc.poll()
if exit_code:
LOG.info("Successfully killed the mitmproxy playback process")
if mozinfo.os == 'mac':
mitmproxy_proc.terminate()
else:
mitmproxy_proc.kill()
time.sleep(10)
if mitmproxy_proc.pid in psutil.pids():
# I *think* we can still continue, as process will be automatically
# killed anyway when mozharness is done (?) if not, we won't be able
# to startup mitmxproy next time if it is already running
LOG.error("Failed to kill the mitmproxy playback process")
else:
LOG.info("Successfully killed the mitmproxy playback process")