Bug 1539317 - Add option to ignore mitmproxy shutdown error code. r=rwood
authorEric Rahm <erahm@mozilla.com>
Fri, 29 Mar 2019 17:26:05 +0000
changeset 466798 78a419376c0c38cd462c096f05d2e0fcd5924e16
parent 466797 e27fc0c01a979c6b8a423846e0461bdebe70eef4
child 466799 4039a7cad5d80a18a4e687963e2850c803e3083f
push id35780
push useropoprus@mozilla.com
push dateFri, 29 Mar 2019 21:53:01 +0000
treeherdermozilla-central@414f37afbe07 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrwood
bugs1539317
milestone68.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 1539317 - Add option to ignore mitmproxy shutdown error code. r=rwood mitmproxy appears to return an error code of 1 if we use the `--no-upstream-cert`. The actual playback works fine. This patch adds an option to reduce the log level to `info` in order to prevent tests from being marked orange due to a shutdown error message. Differential Revision: https://phabricator.services.mozilla.com/D25000
testing/mozbase/mozproxy/mozproxy/backends/mitm.py
--- a/testing/mozbase/mozproxy/mozproxy/backends/mitm.py
+++ b/testing/mozbase/mozproxy/mozproxy/backends/mitm.py
@@ -73,16 +73,18 @@ POLICIES_CONTENT_OFF = """{
 
 class Mitmproxy(Playback):
     def __init__(self, config):
         self.config = config
         self.mitmproxy_proc = None
         self.mitmdump_path = None
         self.browser_path = config.get("binary")
         self.policies_dir = None
+        self.ignore_mitmdump_exit_failure = config.get(
+                "ignore_mitmdump_exit_failure", False)
 
         # mozproxy_dir is where we will download all mitmproxy required files
         # when running locally it comes from obj_path via mozharness/mach
         if self.config.get("obj_path") is not None:
             self.mozproxy_dir = self.config.get("obj_path")
         else:
             # 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
@@ -204,17 +206,20 @@ class Mitmproxy(Playback):
         exit_code = self.mitmproxy_proc.kill()
         if exit_code != 0:
             # 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
             if exit_code is None:
                 LOG.error("Failed to kill the mitmproxy playback process")
             else:
-                LOG.error("Mitmproxy exited with error code %d" % exit_code)
+                log_func = LOG.error
+                if self.ignore_mitmdump_exit_failure:
+                    log_func = LOG.info
+                log_func("Mitmproxy exited with error code %d" % exit_code)
         else:
             LOG.info("Successfully killed the mitmproxy playback process")
 
         self.mitmproxy_proc = None
 
     def check_proxy(self, host="localhost", port=8080):
         s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         try: