From 1c463dc3246e873e3cd9b46c8fd12b1308def14e Mon Sep 17 00:00:00 2001 From: Mikhail Shabarov <61410877+mshabarov@users.noreply.github.com> Date: Fri, 4 Dec 2026 14:15:17 +0000 Subject: [PATCH] test: run JUnit 6 browser ITs on the Selenium hub when test.use.hub is set (#27590) (CP: 25.4) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to #27547 **build failure** · flow-tests · the nightly dev loop build on bender.vaadin.com The first nightly dev loop builds on bender failed in every browser IT: the tests started the Chrome installed on the agent, Chrome 115, which Vaadin no longer supports, so each test timed out on the "your browser is not supported" page. With this change the JUnit 6 browser ITs use the Selenium hub on bender, the same as the JUnit 4 tests already do. **Risks:** - 🔒 The dev loop test applications accept dev tools connections from any host, not only localhost. Test fixtures in dev mode only; nothing outside `flow-tests/test-devloop` changes. - ✅ Without `-Dtest.use.hub=true` the tests still start a local Chrome on `localhost`, so GitHub Actions runs are unchanged. **Context.** The JUnit 4 base class goes to the hub when `test.use.hub` is set and opens the application by the agent's IP address; the JUnit 6 base class always started a local Chrome. Flow only lets dev tools connect from localhost, and the dev loop browser ITs need dev tools to bring an applied change into the open page, so a browser on the hub needs `devmode.hostsAllowed`. - `AbstractBrowserIT` in `flow-test-util-junit6` creates a `RemoteWebDriver` on the hub named by `com.vaadin.testbench.Parameters.hubHostname` when `test.use.hub` is set, and builds the root URL from the new `getDeploymentHostname()`: the site local address on the hub, `localhost` otherwise - `DevLoopBrowserIT`, `DevLoopSpringStatisticsIT` and `AbstractCspStrictIT` open the application by that host name instead of a fixed `localhost` - Every dev loop fixture passes `vaadin.devmode.hostsAllowed=*` to its server, the same way it already passes `vaadin.contentSecurityPolicy`; the Spring Boot fixture sets it in `application.properties` - The value is a pom property and not a `-D` on the build, because the `vaadin-dev` daemon starts the server through a Maven run of its own --------- Co-authored-by: Claude Opus 5.5 --- .../test/cspstrict/AbstractCspStrictIT.java | 2 +- flow-tests/test-devloop/README.md | 7 ++ flow-tests/test-devloop/pom.xml | 6 ++ .../test-devloop-cargo/devloop-app/pom.xml | 1 + .../test-devloop-jbosseap/devloop-app/pom.xml | 4 ++ .../test-devloop-jetty/devloop-app/pom.xml | 1 + .../test-devloop-liberty/devloop-app/pom.xml | 1 + .../devloop-app/pom.xml | 3 + .../test-devloop-payara/devloop-app/pom.xml | 3 + .../src/main/resources/application.properties | 5 ++ .../test/it/DevLoopSpringStatisticsIT.java | 2 +- .../devloop/test/it/AbstractDevLoopIT.java | 16 ++++- .../devloop/test/it/DevLoopBrowserIT.java | 2 +- .../test-devloop-tomee/devloop-app/pom.xml | 1 + .../testutil/junit6/AbstractBrowserIT.java | 64 +++++++++++++++++-- 15 files changed, 109 insertions(+), 9 deletions(-) diff --git a/flow-tests/test-csp-strict/src/test/java/com/vaadin/flow/test/cspstrict/AbstractCspStrictIT.java b/flow-tests/test-csp-strict/src/test/java/com/vaadin/flow/test/cspstrict/AbstractCspStrictIT.java index ef0601ec9e9..798621d105a 100644 --- a/flow-tests/test-csp-strict/src/test/java/com/vaadin/flow/test/cspstrict/AbstractCspStrictIT.java +++ b/flow-tests/test-csp-strict/src/test/java/com/vaadin/flow/test/cspstrict/AbstractCspStrictIT.java @@ -67,7 +67,7 @@ protected void open() { @Override protected String getRootURL() { - return "http://localhost:" + PORT; + return "http://" + getDeploymentHostname() + ":" + PORT; } /** diff --git a/flow-tests/test-devloop/README.md b/flow-tests/test-devloop/README.md index 282f24d4a55..b9704fb7d71 100644 --- a/flow-tests/test-devloop/README.md +++ b/flow-tests/test-devloop/README.md @@ -107,6 +107,13 @@ mvn -o -pl flow-tests/test-devloop/test-devloop-jetty/devloop-app -Pdevloop-mave `-Dit.test=` narrows both executions, so the named ITs run once with each compiler. +The browser ITs use a local headless Chrome. To run them on a Selenium hub, +as the other Flow ITs do in CI, add `-Dtest.use.hub=true` and +`-Dcom.vaadin.testbench.Parameters.hubHostname=`. The browser then opens +the application at this machine's site-local address rather than at +`localhost`, so every fixture listens on all interfaces and passes +`vaadin.devmode.hostsAllowed` to let that browser use the dev tools connection. + Each fixture's README has the rest: what it pins and why, how to drive the loop by hand, and the patch-and-revert rule the ITs follow so that a failed run never leaves the working tree dirty. diff --git a/flow-tests/test-devloop/pom.xml b/flow-tests/test-devloop/pom.xml index 2056ada5a1a..6b8ec0819ac 100644 --- a/flow-tests/test-devloop/pom.xml +++ b/flow-tests/test-devloop/pom.xml @@ -45,6 +45,12 @@ true + + * diff --git a/flow-tests/test-devloop/test-devloop-cargo/devloop-app/pom.xml b/flow-tests/test-devloop/test-devloop-cargo/devloop-app/pom.xml index f58e9e2de4b..15233c0edde 100644 --- a/flow-tests/test-devloop/test-devloop-cargo/devloop-app/pom.xml +++ b/flow-tests/test-devloop/test-devloop-cargo/devloop-app/pom.xml @@ -190,6 +190,7 @@ live, so nothing else may push to the browser on its own. --> false ${vaadin.contentSecurityPolicy} + ${vaadin.devmode.hostsAllowed} diff --git a/flow-tests/test-devloop/test-devloop-jbosseap/devloop-app/pom.xml b/flow-tests/test-devloop/test-devloop-jbosseap/devloop-app/pom.xml index 8659c021e94..a0cfad656fa 100644 --- a/flow-tests/test-devloop/test-devloop-jbosseap/devloop-app/pom.xml +++ b/flow-tests/test-devloop/test-devloop-jbosseap/devloop-app/pom.xml @@ -224,6 +224,10 @@ live, so nothing else may push to the browser on its own. --> -Dvaadin.frontend.hotdeploy=false -Dvaadin.contentSecurityPolicy=${vaadin.contentSecurityPolicy} + -Dvaadin.devmode.hostsAllowed=${vaadin.devmode.hostsAllowed} + + -Djboss.bind.address=0.0.0.0 diff --git a/flow-tests/test-devloop/test-devloop-jetty/devloop-app/pom.xml b/flow-tests/test-devloop/test-devloop-jetty/devloop-app/pom.xml index 6ce8264da25..83b6667bc6a 100644 --- a/flow-tests/test-devloop/test-devloop-jetty/devloop-app/pom.xml +++ b/flow-tests/test-devloop/test-devloop-jetty/devloop-app/pom.xml @@ -174,6 +174,7 @@ live, so nothing else may push to the browser on its own. --> false ${vaadin.contentSecurityPolicy} + ${vaadin.devmode.hostsAllowed} diff --git a/flow-tests/test-devloop/test-devloop-liberty/devloop-app/pom.xml b/flow-tests/test-devloop/test-devloop-liberty/devloop-app/pom.xml index fd0cee03067..8403c641d6e 100644 --- a/flow-tests/test-devloop/test-devloop-liberty/devloop-app/pom.xml +++ b/flow-tests/test-devloop/test-devloop-liberty/devloop-app/pom.xml @@ -197,6 +197,7 @@ -Dvaadin.frontend.hotdeploy=false -Dvaadin.contentSecurityPolicy=${vaadin.contentSecurityPolicy} + -Dvaadin.devmode.hostsAllowed=${vaadin.devmode.hostsAllowed} diff --git a/flow-tests/test-devloop/test-devloop-payara-micro/devloop-app/pom.xml b/flow-tests/test-devloop/test-devloop-payara-micro/devloop-app/pom.xml index 3b89ff157cf..8b9bda3d36a 100644 --- a/flow-tests/test-devloop/test-devloop-payara-micro/devloop-app/pom.xml +++ b/flow-tests/test-devloop/test-devloop-payara-micro/devloop-app/pom.xml @@ -189,6 +189,9 @@ + / diff --git a/flow-tests/test-devloop/test-devloop-payara/devloop-app/pom.xml b/flow-tests/test-devloop/test-devloop-payara/devloop-app/pom.xml index b90b768c2aa..43fa67ecc5a 100644 --- a/flow-tests/test-devloop/test-devloop-payara/devloop-app/pom.xml +++ b/flow-tests/test-devloop/test-devloop-payara/devloop-app/pom.xml @@ -216,6 +216,9 @@ + diff --git a/flow-tests/test-devloop/test-devloop-spring/devloop-app/src/main/resources/application.properties b/flow-tests/test-devloop/test-devloop-spring/devloop-app/src/main/resources/application.properties index 761ff3f8dd3..0c93443bc40 100644 --- a/flow-tests/test-devloop/test-devloop-spring/devloop-app/src/main/resources/application.properties +++ b/flow-tests/test-devloop/test-devloop-spring/devloop-app/src/main/resources/application.properties @@ -11,6 +11,11 @@ vaadin.frontend.hotdeploy=false # not filtered (see pom.xml), so this does not follow -Dvaadin.contentSecurityPolicy. vaadin.contentSecurityPolicy=strict +# Dev tools from any host, as the other fixtures get from +# vaadin.devmode.hostsAllowed in flow-tests/test-devloop/pom.xml: the browser ITs +# on bender.vaadin.com run on the Selenium hub, another machine. +vaadin.devmode.hostsAllowed=* + # Tomcat caches what it serves from META-INF/resources for 5 seconds and # revalidates on that TTL alone, never on the file's timestamp - so a fetch # right after an apply can be served the pre-edit bytes even though the daemon diff --git a/flow-tests/test-devloop/test-devloop-spring/devloop-app/src/test/java/com/vaadin/flow/devloop/test/it/DevLoopSpringStatisticsIT.java b/flow-tests/test-devloop/test-devloop-spring/devloop-app/src/test/java/com/vaadin/flow/devloop/test/it/DevLoopSpringStatisticsIT.java index 7abe6d2b55a..f1ec5ec7416 100644 --- a/flow-tests/test-devloop/test-devloop-spring/devloop-app/src/test/java/com/vaadin/flow/devloop/test/it/DevLoopSpringStatisticsIT.java +++ b/flow-tests/test-devloop/test-devloop-spring/devloop-app/src/test/java/com/vaadin/flow/devloop/test/it/DevLoopSpringStatisticsIT.java @@ -51,7 +51,7 @@ class DevLoopSpringStatisticsIT extends AbstractBrowserIT { @Override protected String getRootURL() { - return AbstractDevLoopIT.ROOT_URL; + return AbstractDevLoopIT.rootUrl(getDeploymentHostname()); } @BeforeEach diff --git a/flow-tests/test-devloop/test-devloop-support/src/test/java/com/vaadin/flow/devloop/test/it/AbstractDevLoopIT.java b/flow-tests/test-devloop/test-devloop-support/src/test/java/com/vaadin/flow/devloop/test/it/AbstractDevLoopIT.java index f486be5a6c1..0ccf4e26653 100644 --- a/flow-tests/test-devloop/test-devloop-support/src/test/java/com/vaadin/flow/devloop/test/it/AbstractDevLoopIT.java +++ b/flow-tests/test-devloop/test-devloop-support/src/test/java/com/vaadin/flow/devloop/test/it/AbstractDevLoopIT.java @@ -92,8 +92,7 @@ abstract class AbstractDevLoopIT { * Where the application is served, with no trailing slash: the port, and * the context root for a fixture that cannot serve from {@code /}. */ - static final String ROOT_URL = "http://localhost:" + SERVER_PORT - + contextPath(); + static final String ROOT_URL = rootUrl("localhost"); protected VaadinDevCli cli; @@ -199,6 +198,19 @@ private static String contextPath() { return readPomProperty("devloop.context.path").orElse(""); } + /** + * Where the application is served for a client on the given host name, with + * no trailing slash. A browser on the Selenium hub needs this machine's + * address, as {@code localhost} there is the hub itself. + * + * @param hostname + * the host name the client reaches this machine by + * @return the root URL of the application + */ + static String rootUrl(String hostname) { + return "http://" + hostname + ":" + SERVER_PORT + contextPath(); + } + private static Optional readPomProperty(String name) { Path pom = APP.resolve("pom.xml"); String tag = Pattern.quote(name); diff --git a/flow-tests/test-devloop/test-devloop-support/src/test/java/com/vaadin/flow/devloop/test/it/DevLoopBrowserIT.java b/flow-tests/test-devloop/test-devloop-support/src/test/java/com/vaadin/flow/devloop/test/it/DevLoopBrowserIT.java index 282933fc026..a31dce05baa 100644 --- a/flow-tests/test-devloop/test-devloop-support/src/test/java/com/vaadin/flow/devloop/test/it/DevLoopBrowserIT.java +++ b/flow-tests/test-devloop/test-devloop-support/src/test/java/com/vaadin/flow/devloop/test/it/DevLoopBrowserIT.java @@ -56,7 +56,7 @@ class DevLoopBrowserIT extends AbstractBrowserIT { @Override protected String getRootURL() { - return AbstractDevLoopIT.ROOT_URL; + return AbstractDevLoopIT.rootUrl(getDeploymentHostname()); } @BeforeEach diff --git a/flow-tests/test-devloop/test-devloop-tomee/devloop-app/pom.xml b/flow-tests/test-devloop/test-devloop-tomee/devloop-app/pom.xml index 03429851ab8..6c1017a855c 100644 --- a/flow-tests/test-devloop/test-devloop-tomee/devloop-app/pom.xml +++ b/flow-tests/test-devloop/test-devloop-tomee/devloop-app/pom.xml @@ -182,6 +182,7 @@ tomee-plugin.args is the channel it takes for its agents. --> false ${vaadin.contentSecurityPolicy} + ${vaadin.devmode.hostsAllowed}