Bug 1544089 - [mochitest] - Configure ssltunnel to listen on loopback address for Desktop and any public address for Remote tests, r=gbrown.
authorBob Clary <bclary@bclary.com>
Tue, 23 Apr 2019 00:36:52 +0000
changeset 470458 7699de41e02b63c11701a27f162ba539734e484e
parent 470457 ba2e784fcc836dfe7375d863de473f3e3c4a16fb
child 470459 fc739beb6782fc83f23b15fc383f7ca5887393bd
push id35906
push useraciure@mozilla.com
push dateTue, 23 Apr 2019 22:14:56 +0000
treeherdermozilla-central@0ce3633f8b80 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgbrown
bugs1544089
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 1544089 - [mochitest] - Configure ssltunnel to listen on loopback address for Desktop and any public address for Remote tests, r=gbrown. Depends on D27722 Differential Revision: https://phabricator.services.mozilla.com/D27723
testing/mochitest/runjunit.py
testing/mochitest/runrobocop.py
testing/mochitest/runtests.py
testing/mochitest/runtestsremote.py
--- a/testing/mochitest/runjunit.py
+++ b/testing/mochitest/runjunit.py
@@ -62,17 +62,18 @@ class JUnitTestRunner(MochitestDesktop):
 
         self.server_init()
 
         self.cleanup()
         self.device.clear_logcat()
         self.build_profile()
         self.startServers(
             self.options,
-            debuggerInfo=None)
+            debuggerInfo=None,
+            public=True)
         self.log.debug("Servers started")
 
     def server_init(self):
         """
            Additional initialization required to satisfy MochitestDesktop.startServers
         """
         self._locations = None
         self.server = None
--- a/testing/mochitest/runrobocop.py
+++ b/testing/mochitest/runrobocop.py
@@ -118,17 +118,18 @@ class RobocopTestRunner(MochitestDesktop
                            self.options.robocopApk)
         # Display remote diagnostics; if running in mach, keep output terse.
         if self.options.log_mach is None:
             self.printDeviceInfo()
         self.setupLocalPaths()
         self.buildProfile()
         self.startServers(
             self.options,
-            debuggerInfo=None)
+            debuggerInfo=None,
+            public=True)
         self.log.debug("Servers started")
 
     def cleanup(self):
         """
            Cleanup at end of job run.
         """
         self.log.debug("Cleaning up...")
         self.stopServers()
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -624,28 +624,38 @@ class SSLTunnel:
                     'tls1',
                     'ssl3',
                     'rc4',
                     'failHandshake'):
                 config.write(
                     "%s:%s:%s:%s\n" %
                     (option, loc.host, loc.port, self.sslPort))
 
-    def buildConfig(self, locations):
+    def buildConfig(self, locations, public=None):
         """Create the ssltunnel configuration file"""
         configFd, self.configFile = tempfile.mkstemp(
             prefix="ssltunnel", suffix=".cfg")
         with os.fdopen(configFd, "w") as config:
             config.write("httpproxy:1\n")
             config.write("certdbdir:%s\n" % self.certPath)
             config.write("forward:127.0.0.1:%s\n" % self.httpPort)
             config.write(
                 "websocketserver:%s:%s\n" %
                 (self.webServer, self.webSocketPort))
-            config.write("listen:*:%s:pgoserver\n" % self.sslPort)
+            # Use "*" to tell ssltunnel to listen on the public ip
+            # address instead of the loopback address 127.0.0.1. This
+            # may have the side-effect of causing firewall warnings on
+            # macOS and Windows. Use "127.0.0.1" to listen on the
+            # loopback address.  Remote tests using physical or
+            # emulated Android devices must use the public ip address
+            # in order for the sslproxy to work but Desktop tests
+            # which run on the same host as ssltunnel may use the
+            # loopback address.
+            listen_address = "*" if public else "127.0.0.1"
+            config.write("listen:%s:%s:pgoserver\n" % (listen_address, self.sslPort))
 
             for loc in locations:
                 if loc.scheme == "https" and "nocert" not in loc.options:
                     self.writeLocation(config, loc)
 
     def start(self):
         """ Starts the SSL Tunnel """
 
@@ -1158,17 +1168,17 @@ class MochitestDesktop(object):
                 sock.close()
                 break
             except Exception:
                 time.sleep(0.1)
         else:
             self.log.error("runtests.py | Timed out while waiting for "
                            "websocket/process bridge startup.")
 
-    def startServers(self, options, debuggerInfo):
+    def startServers(self, options, debuggerInfo, public=None):
         # start servers and set ports
         # TODO: pass these values, don't set on `self`
         self.webServer = options.webServer
         self.httpPort = options.httpPort
         self.sslPort = options.sslPort
         self.webSocketPort = options.webSocketPort
 
         # httpd-path is specified by standard makefile targets and may be specified
@@ -1183,17 +1193,17 @@ class MochitestDesktop(object):
 
         if options.subsuite in ["media"]:
             self.startWebsocketProcessBridge(options)
 
         # start SSL pipe
         self.sslTunnel = SSLTunnel(
             options,
             logger=self.log)
-        self.sslTunnel.buildConfig(self.locations)
+        self.sslTunnel.buildConfig(self.locations, public=public)
         self.sslTunnel.start()
 
         # If we're lucky, the server has fully started by now, and all paths are
         # ready, etc.  However, xpcshell cold start times suck, at least for debug
         # builds.  We'll try to connect to the server for awhile, and if we fail,
         # we'll try to kill the server and exit with an error.
         if self.server is not None:
             self.server.ensureReady(self.SERVER_STARTUP_TIMEOUT)
--- a/testing/mochitest/runtestsremote.py
+++ b/testing/mochitest/runtestsremote.py
@@ -206,23 +206,24 @@ class MochiRemote(MochitestDesktop):
 
         def fixup():
             options.xrePath = remoteXrePath
             options.utilityPath = remoteUtilityPath
             options.profilePath = remoteProfilePath
 
         return fixup
 
-    def startServers(self, options, debuggerInfo):
+    def startServers(self, options, debuggerInfo, public=None):
         """ Create the servers on the host and start them up """
         restoreRemotePaths = self.switchToLocalPaths(options)
         MochitestDesktop.startServers(
             self,
             options,
-            debuggerInfo)
+            debuggerInfo,
+            public=True)
         restoreRemotePaths()
 
     def buildProfile(self, options):
         restoreRemotePaths = self.switchToLocalPaths(options)
         if options.testingModulesDir:
             try:
                 self.device.push(options.testingModulesDir, self.remoteModulesDir)
                 self.device.chmod(self.remoteModulesDir, recursive=True, root=True)