diff options
author | Benoit Foucher <benoit@zeroc.com> | 2017-09-14 10:56:49 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2017-09-14 10:56:49 +0200 |
commit | 228808bd70a032ee9f20ad5bdd00f2b79578a84b (patch) | |
tree | 58f456e2c2b5625a26cac2d698cc664166ff1a32 | |
parent | Additional fixes to allow building mappings against C++ binary distribution (diff) | |
download | ice-228808bd70a032ee9f20ad5bdd00f2b79578a84b.tar.bz2 ice-228808bd70a032ee9f20ad5bdd00f2b79578a84b.tar.xz ice-228808bd70a032ee9f20ad5bdd00f2b79578a84b.zip |
Allow running JS tests with browser started manually (eventually
from remote host).
Use --browser=Manual with ./allTests.py and connect to the given
URL with the browser. If browser is running on a different host,
you'll need to start ./allTests.py --host=<host> with host set
to the IP address of the machine running ./allTests.py
Fixes ICE-8366
-rw-r--r-- | js/bin/HttpServer.js | 8 | ||||
-rw-r--r-- | js/test/Common/ControllerI.js | 10 | ||||
-rw-r--r-- | js/test/Ice/objects/Client.js | 1 | ||||
-rw-r--r-- | js/test/Ice/objects/Server.js | 1 | ||||
-rw-r--r-- | scripts/Controller.ice | 5 | ||||
-rw-r--r-- | scripts/Util.py | 115 |
6 files changed, 94 insertions, 46 deletions
diff --git a/js/bin/HttpServer.js b/js/bin/HttpServer.js index b08bb4bca33..e432f7a09e7 100644 --- a/js/bin/HttpServer.js +++ b/js/bin/HttpServer.js @@ -232,6 +232,14 @@ function Init() res.end(controller.render(TestData)) console.log("HTTP/200 (Ok) " + req.method + " " + req.url.pathname); } + else if(req.url.pathname === '/start') + { + res.writeHead(302, + { + "Location": "/test/Ice/acm/controller.html&port=15002" + }); + res.end(); + } else { var iceLib = libraries.indexOf(req.url.pathname) !== -1; diff --git a/js/test/Common/ControllerI.js b/js/test/Common/ControllerI.js index 9c32b492b89..49aa36ddcbb 100644 --- a/js/test/Common/ControllerI.js +++ b/js/test/Common/ControllerI.js @@ -97,7 +97,7 @@ class ProcessI extends Test.Common.Process } } -class ProcessControllerI extends Test.Common.ProcessController +class ProcessControllerI extends Test.Common.BrowserProcessController { constructor(clientOutput, serverOutput, useWorker, scripts) { @@ -193,6 +193,12 @@ class ProcessControllerI extends Test.Common.ProcessController { return "127.0.0.1"; } + + redirect(url, current) + { + current.con.close(Ice.ConnectionClose.Gracefully); + window.location.href = url; + } } function runController(clientOutput, serverOutput, scripts) @@ -272,7 +278,7 @@ function runController(clientOutput, serverOutput, scripts) }; let comm = Ice.initialize(initData); - let str = "Util/ProcessControllerRegistry:" + protocol + " -h 127.0.0.1 -p " + port; + let str = "Util/ProcessControllerRegistry:" + protocol + " -h " + document.location.hostname + " -p " + port; let registry = Test.Common.ProcessControllerRegistryPrx.uncheckedCast(comm.stringToProxy(str)); comm.createObjectAdapter("").then( adapter => diff --git a/js/test/Ice/objects/Client.js b/js/test/Ice/objects/Client.js index 1ecf83e6e02..6c463e380cd 100644 --- a/js/test/Ice/objects/Client.js +++ b/js/test/Ice/objects/Client.js @@ -526,6 +526,7 @@ var run = function(out, id) { + id.properties.setProperty("Ice.Warn.Connections", "0"); var c = Ice.initialize(id); return Ice.Promise.try(() => allTests(out, c)).finally(() => c.destroy()); }; diff --git a/js/test/Ice/objects/Server.js b/js/test/Ice/objects/Server.js index 526bdd4a66e..8928e715f67 100644 --- a/js/test/Ice/objects/Server.js +++ b/js/test/Ice/objects/Server.js @@ -24,6 +24,7 @@ var run = function(out, id, ready) { id.properties.setProperty("Ice.Warn.Dispatch", "0"); + id.properties.setProperty("Ice.Warn.Connections", "0"); var communicator = Ice.initialize(id); var adapter; var echo = Test.EchoPrx.uncheckedCast(communicator.stringToProxy("__echo:default -p 12010")); diff --git a/scripts/Controller.ice b/scripts/Controller.ice index 9c3d3d303d4..f6c3050fa2b 100644 --- a/scripts/Controller.ice +++ b/scripts/Controller.ice @@ -94,6 +94,11 @@ interface ProcessController string getHost(string protocol, bool ipv6); } +interface BrowserProcessController extends ProcessController +{ + void redirect(string url); +} + interface ProcessControllerRegistry { void setProcessController(ProcessController* controller); diff --git a/scripts/Util.py b/scripts/Util.py index f338ba277ee..c49f8cf60b8 100644 --- a/scripts/Util.py +++ b/scripts/Util.py @@ -1305,6 +1305,11 @@ class EchoServer(Server): def __init__(self): Server.__init__(self, mapping=Mapping.getByName("cpp"), quiet=True, waitForShutdown=False) + def getProps(self, current): + props = Server.getProps(self, current) + props["Ice.MessageSizeMax"] = 8192 # Don't limit the amount of data to transmit between client/server + return props + def getCommandLine(self, current): current.push(self.mapping.findTestSuite("Ice/echo").findTestCase("server")) try: @@ -2105,8 +2110,7 @@ class AndroidProcessController(RemoteProcessController): def __init__(self, current): run("adb kill-server") - RemoteProcessController.__init__(self, current, - "tcp -h 127.0.0.1 -p 15001" if current.config.androidemulator else None) + RemoteProcessController.__init__(self, current, "tcp -h 127.0.0.1 -p 15001" if current.config.androidemulator else None) self.device = current.config.device self.avd = current.config.avd self.androidemulator = current.config.androidemulator @@ -2410,44 +2414,42 @@ class UWPProcessController(RemoteProcessController): class BrowserProcessController(RemoteProcessController): def __init__(self, current): - RemoteProcessController.__init__(self, current, "ws -h 127.0.0.1 -p 15002:wss -h 127.0.0.1 -p 15003") + self.host = current.driver.host or "127.0.0.1" + RemoteProcessController.__init__(self, current, "ws -h {0} -p 15002:wss -h {0} -p 15003".format(self.host)) self.httpServer = None - self.testcase = None + self.url = None + self.driver = None try: - from selenium import webdriver - if not hasattr(webdriver, current.config.browser): - raise RuntimeError("unknown browser `{0}'".format(current.config.browser)) - - if current.config.browser == "Firefox": - # - # We need to specify a profile for Firefox. This profile only provides the cert8.db which - # contains our Test CA cert. It should be possible to avoid this by setting the webdriver - # acceptInsecureCerts capability but it's only supported by latest Firefox releases. - # - # capabilities = webdriver.DesiredCapabilities.FIREFOX.copy() - # capabilities["marionette"] = True - # capabilities["acceptInsecureCerts"] = True - # capabilities["moz:firefoxOptions"] = {} - # capabilities["moz:firefoxOptions"]["binary"] = "/Applications/FirefoxNightly.app/Contents/MacOS/firefox-bin" - if isinstance(platform, Linux) and os.environ.get("DISPLAY", "") != ":1" and os.environ.get("USER", "") == "ubuntu": - current.writeln("error: DISPLAY is unset, setting it to :1") - os.environ["DISPLAY"] = ":1" - - profile = webdriver.FirefoxProfile(os.path.join(toplevel, "scripts", "selenium", "firefox")) - self.driver = webdriver.Firefox(firefox_profile=profile) - else: - self.driver = getattr(webdriver, current.config.browser)() - cmd = "node -e \"require('./bin/HttpServer')()\""; cwd = current.testcase.getMapping().getPath() self.httpServer = Expect.Expect(cmd, cwd=cwd) self.httpServer.expect("listening on ports") + + if current.config.browser != "Manual": + from selenium import webdriver + if not hasattr(webdriver, current.config.browser): + raise RuntimeError("unknown browser `{0}'".format(current.config.browser)) + + if current.config.browser == "Firefox": + if isinstance(platform, Linux) and os.environ.get("DISPLAY", "") != ":1" and os.environ.get("USER", "") == "ubuntu": + current.writeln("error: DISPLAY is unset, setting it to :1") + os.environ["DISPLAY"] = ":1" + + # + # We need to specify a profile for Firefox. This profile only provides the cert8.db which + # contains our Test CA cert. It should be possible to avoid this by setting the webdriver + # acceptInsecureCerts capability but it's only supported by latest Firefox releases. + # + profile = webdriver.FirefoxProfile(os.path.join(toplevel, "scripts", "selenium", "firefox")) + self.driver = webdriver.Firefox(firefox_profile=profile) + else: + self.driver = getattr(webdriver, current.config.browser)() except: self.destroy(current.driver) raise def __str__(self): - return str(self.driver) + return str(self.driver) if self.driver else "Manual" def getControllerIdentity(self, current): # @@ -2455,22 +2457,47 @@ class BrowserProcessController(RemoteProcessController): # another testcase, the controller page will connect to the process controller registry # to register itself with this script. # - if self.testcase != current.testcase: - self.testcase = current.testcase - testsuite = ("es5/" if current.config.es5 else "") + str(current.testsuite) - if current.config.protocol == "wss": - protocol = "https" - port = "9090" - cport = "15003" + testsuite = ("es5/" if current.config.es5 else "") + str(current.testsuite) + if current.config.protocol == "wss": + protocol = "https" + port = "9090" + cport = "15003" + else: + protocol = "http" + port = "8080" + cport = "15002" + url = "{0}://{5}:{1}/test/{2}/controller.html?port={3}&worker={4}".format(protocol, + port, + testsuite, + cport, + current.config.worker, + self.host) + if url != self.url: + self.url = url + if self.driver: + self.driver.get(url) else: - protocol = "http" - port = "8080" - cport = "15002" - self.driver.get("{0}://127.0.0.1:{1}/test/{2}/controller.html?port={3}&worker={4}".format(protocol, - port, - testsuite, - cport, - current.config.worker)) + # If not process controller is registered, we request the user to load the controller + # page in the browser. Once loaded, the controller will register and we'll redirect to + # the correct testsuite page. + ident = current.driver.getCommunicator().stringToIdentity("Browser/ProcessController") + prx = None + with self.cond: + while True: + if ident in self.processControllerProxies: + prx = self.processControllerProxies[ident] + break + print("Please load http://{0}:8080/start".format(self.host)) + self.cond.wait(5) + + try: + import Test + Test.Common.BrowserProcessControllerPrx.uncheckedCast(prx).redirect(url) + except: + pass + finally: + self.clearProcessController(prx, prx.ice_getCachedConnection()) + return "Browser/ProcessController" def destroy(self, driver): |