Bug 1279259 - Make TURN server port configurable. r=jmaher, a=test-only
authorBob Clary <bclary@bclary.com>
Wed, 25 Jan 2017 01:56:45 -0800
changeset 377961 2cc634c870096a8cc5a8f5f57fd96f9b14992e20
parent 377960 e1949e439f0ea0a1edc865e5f595debdcc9d1d94
child 377962 f5f482af2c7937f6db5a1180c7f09ba1bdc8c590
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher, test-only
bugs1279259
milestone53.0a2
Bug 1279259 - Make TURN server port configurable. r=jmaher, a=test-only
testing/mochitest/mochitest_options.py
testing/mochitest/runtests.py
testing/tools/websocketprocessbridge/websocketprocessbridge.py
--- a/testing/mochitest/mochitest_options.py
+++ b/testing/mochitest/mochitest_options.py
@@ -583,16 +583,21 @@ class MochitestArguments(ArgumentContain
           }],
         [["--cleanup-crashes"],
          {"action": "store_true",
           "dest": "cleanupCrashes",
           "default": False,
           "help": "Delete pending crash reports before running tests.",
           "suppress": True,
           }],
+        [["--websocket-process-bridge-port"],
+         {"default": "8191",
+          "dest": "websocket_process_bridge_port",
+          "help": "Port for websocket/process bridge. Default 8191.",
+          }],
     ]
 
     defaults = {
         # Bug 1065098 - The geckomediaplugin process fails to produce a leak
         # log for some reason.
         'ignoreMissingLeaks': ["geckomediaplugin"],
         'extensionsToExclude': ['specialpowers'],
         # Set server information on the args object
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -1086,17 +1086,19 @@ class MochitestDesktop(object):
 
     def startWebsocketProcessBridge(self, options):
         """Create a websocket server that can launch various processes that
         JS needs (eg; ICE server for webrtc testing)
         """
 
         command = [sys.executable,
                    os.path.join("websocketprocessbridge",
-                                "websocketprocessbridge.py")]
+                                "websocketprocessbridge.py"),
+                   "--port",
+                   options.websocket_process_bridge_port]
         self.websocketProcessBridge = mozprocess.ProcessHandler(command,
                                                                 cwd=SCRIPT_DIR)
         self.websocketProcessBridge.run()
         self.log.info("runtests.py | websocket/process bridge pid: %d"
                       % self.websocketProcessBridge.pid)
 
         # ensure the server is up, wait for at most ten seconds
         for i in range(1, 100):
--- a/testing/tools/websocketprocessbridge/websocketprocessbridge.py
+++ b/testing/tools/websocketprocessbridge/websocketprocessbridge.py
@@ -3,16 +3,17 @@
 # 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/.
 
 from twisted.internet import protocol, reactor
 from twisted.internet.task import LoopingCall
 import txws
 import psutil
 
+import argparse
 import sys
 import os
 
 # maps a command issued via websocket to running an executable with args
 commands = {
     'iceserver' : [sys.executable,
                    "-u",
                    os.path.join("iceserver", "iceserver.py")]
@@ -84,17 +85,22 @@ parent_process = psutil.Process(os.getpi
 
 def check_parent():
     """ Checks if parent process is still alive, and exits if not """
     if not parent_process.is_running():
         print("websocket/process bridge exiting because parent process is gone")
         reactor.stop()
 
 if __name__ == "__main__":
+    parser = argparse.ArgumentParser(description='Starts websocket/process bridge.')
+    parser.add_argument("--port", type=str, dest="port", default="8191",
+                    help="Port for websocket/process bridge. Default 8191.")
+    args = parser.parse_args()
+
     parent_checker = LoopingCall(check_parent)
     parent_checker.start(1)
 
     bridgeFactory = ProcessSocketBridgeFactory()
-    reactor.listenTCP(8191, txws.WebSocketFactory(bridgeFactory))
-    print("websocket/process bridge listening on port 8191")
+    reactor.listenTCP(int(args.port), txws.WebSocketFactory(bridgeFactory))
+    print("websocket/process bridge listening on port %s" % args.port)
     reactor.run()