Bug 1518447 Capture full Mitmproxy logs and have them available as treeherder artifact r=rwood,davehunt,tarek
authorFlorin Strugariu <fstrugariu@mozilla.com>
Tue, 12 Mar 2019 14:57:43 +0000
changeset 524549 74df776abe146e5f8563e9a040c9c01ee7796e1d
parent 524548 5c4d90e31d8c92a7df69e63d7f0624df52fed79f
child 524550 2f7c1341cc1e39358cf79de3dc476c0104ae8279
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrwood, davehunt, tarek
bugs1518447
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1518447 Capture full Mitmproxy logs and have them available as treeherder artifact r=rwood,davehunt,tarek Differential Revision: https://phabricator.services.mozilla.com/D21923
testing/mozbase/mozproxy/mozproxy/backends/mitm.py
--- a/testing/mozbase/mozproxy/mozproxy/backends/mitm.py
+++ b/testing/mozbase/mozproxy/mozproxy/backends/mitm.py
@@ -87,16 +87,18 @@ class Mitmproxy(Playback):
             # in production it is ../tasks/task_N/build/, in production that dir
             # is not available as an envvar, however MOZ_UPLOAD_DIR is set as
             # ../tasks/task_N/build/blobber_upload_dir so take that and go up 1 level
             self.mozproxy_dir = os.path.dirname(
                 os.path.dirname(os.environ["MOZ_UPLOAD_DIR"])
             )
 
         self.mozproxy_dir = os.path.join(self.mozproxy_dir, "testing", "mozproxy")
+        self.upload_dir = os.environ.get("MOZ_UPLOAD_DIR", self.mozproxy_dir)
+
         self.recordings_path = self.mozproxy_dir
         LOG.info(
             "mozproxy_dir used for mitmproxy downloads and exe files: %s"
             % self.mozproxy_dir
         )
         # setting up the MOZPROXY_DIR env variable so custom scripts know
         # where to get the data
         os.environ["MOZPROXY_DIR"] = self.mozproxy_dir
@@ -186,17 +188,17 @@ class Mitmproxy(Playback):
 
             mitmproxy_recordings.append(
                 os.path.join(mitmproxy_recording_path, recording)
             )
 
         # mitmproxy needs some DLL's that are a part of Firefox itself, so add to path
         env = os.environ.copy()
         env["PATH"] = os.path.dirname(browser_path) + ";" + env["PATH"]
-        command = [mitmdump_path, "-k", "-q"]
+        command = [mitmdump_path, "-k"]
 
         if "custom_script" in self.config:
             # cmd line to start mitmproxy playback using custom playback script is as follows:
             # <path>/mitmdump -s "<path>/alternate-server-replay.py
             #  <path>recording-1.mp <path>recording-2.mp..."
             custom_script = self.config["custom_script"] + " " + " ".join(mitmproxy_recordings)
 
             # this part is platform-specific
@@ -205,17 +207,20 @@ class Mitmproxy(Playback):
                 sys.path.insert(1, mitmdump_path)
 
             command.extend(["-s", custom_script])
 
         LOG.info("Starting mitmproxy playback using env path: %s" % env["PATH"])
         LOG.info("Starting mitmproxy playback using command: %s" % " ".join(command))
         # to turn off mitmproxy log output, use these params for Popen:
         # Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
-        mitmproxy_proc = ProcessHandler(command, env=env)
+        mitmproxy_proc = ProcessHandler(command,
+                                        logfile=os.path.join(self.upload_dir,
+                                                             "mitmproxy.log"),
+                                        env=env)
         mitmproxy_proc.run()
 
         # XXX replace the code below with a loop with a connection attempt
         # Bug 1532557
         time.sleep(MITMDUMP_SLEEP)
         data = mitmproxy_proc.poll()
         if data is None:  # None value indicates process hasn't terminated
             LOG.info(