From b119a1506e2ad76f3e5bcf6425efbb43741ffc63 Mon Sep 17 00:00:00 2001 From: Marco Collovati Date: Fri, 4 Dec 2026 15:13:35 +0000 Subject: [PATCH] test: stop retrying a dev loop start that keeps timing out (#27681) (CP: 25.3) Resolution notes: - VaadinDevCli: 25.3 lacks the run(Map environment, String...) overload added by #26782 (fix(devloop): do not spawn the daemon for status or ping), which is not on 25.3. Put the hung-start check at the start of the existing run(String...) and kept the rest of the change as in the 25.4 pick; dropped the putAll(environment) line from that overload. - Kept the java.util.Map import, now needed only for HUNG_STARTS. - Test code only; compiled with mvn install -DskipTests -pl flow-tests/test-devloop/test-devloop-support -am. Dev loop ITs were not run. Co-Authored-By: Claude Opus 5.5 --- .../flow/devloop/test/it/VaadinDevCli.java | 55 ++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/flow-tests/test-devloop/test-devloop-support/src/test/java/com/vaadin/flow/devloop/test/it/VaadinDevCli.java b/flow-tests/test-devloop/test-devloop-support/src/test/java/com/vaadin/flow/devloop/test/it/VaadinDevCli.java index 56982b9dae4..6db30a9c5b1 100644 --- a/flow-tests/test-devloop/test-devloop-support/src/test/java/com/vaadin/flow/devloop/test/it/VaadinDevCli.java +++ b/flow-tests/test-devloop/test-devloop-support/src/test/java/com/vaadin/flow/devloop/test/it/VaadinDevCli.java @@ -25,7 +25,9 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; +import java.util.Map; import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; /** @@ -173,6 +175,16 @@ static VaadinDevCli of(Path app) { * @return the exit code and the whole output */ Outcome run(String... arguments) { + String verb = "vaadin-dev " + String.join(" ", arguments); + boolean start = arguments.length > 0 && arguments[0].equals("start"); + HungStarts hung = start ? HUNG_STARTS.get(app) : null; + if (hung != null && hung.count() >= MAX_HUNG_STARTS) { + throw new AssertionError(verb + " was not tried: the last " + + hung.count() + " starts of " + app + " did not finish in " + + COMMAND_TIMEOUT.toMinutes() + + " minutes in this test run. The last one said:\n" + + hung.output()); + } List command = launcher.command(app, List.of(arguments)) .orElseThrow(() -> new IllegalStateException( launcher + " cannot run here")); @@ -196,7 +208,6 @@ Outcome run(String... arguments) { + " -Dvaadin.dev.compiler=" + compiler()); // No spinner: the output is read by assertions, not by a person. builder.environment().put("VAADIN_DEV_PROGRESS", "never"); - String verb = "vaadin-dev " + String.join(" ", arguments); try { Process process = builder.start(); // Read on a thread of its own so the timeout below actually holds: @@ -227,6 +238,12 @@ Outcome run(String... arguments) { .forEach(ProcessHandle::destroyForcibly); process.destroyForcibly(); reader.join(OUTPUT_DRAIN_TIMEOUT.toMillis()); + if (start) { + String said = textOf(output); + HUNG_STARTS.merge(app, new HungStarts(1, said), + (before, now) -> new HungStarts( + before.count() + 1, said)); + } throw new AssertionError(verb + " did not finish in " + COMMAND_TIMEOUT.toMinutes() + " minutes; it said:\n" + textOf(output)); @@ -238,6 +255,9 @@ Outcome run(String... arguments) { + " but something it started still holds its" + " output open; it said:\n" + textOf(output)); } + if (start) { + HUNG_STARTS.remove(app); + } return new Outcome(process.exitValue(), textOf(output)); } finally { in.close(); @@ -322,6 +342,39 @@ private void shutdownWhenThisJvmExits() { */ private static final Duration OUTPUT_DRAIN_TIMEOUT = Duration.ofSeconds(30); + /** + * How many {@code start} commands in a row may run into + * {@link #COMMAND_TIMEOUT} before the next one is not tried at all. + *

+ * Every test begins with a start, so without a limit one server that cannot + * boot costs five minutes per test and uses up the CI step's timeout before + * the other fixtures run. One timeout is still retried: a first start can + * be slow once, for example while a server is downloaded and unpacked. + */ + private static final int MAX_HUNG_STARTS = 2; + + /** + * The {@code start} commands in a row that did not finish in + * {@link #COMMAND_TIMEOUT}, per application, and what the last one said. A + * start that finishes in time removes the entry. The tests still fail, with + * that output, so nothing is hidden. The map lives as long as the test JVM, + * which is one failsafe execution of one fixture, so the next execution + * tries again. Only a timeout counts: a start that exits with an error is + * already fast. + */ + private static final Map HUNG_STARTS = new ConcurrentHashMap<>(); + + /** + * Starts of one application that did not finish in time. + * + * @param count + * how many in a row + * @param output + * what the last one said + */ + private record HungStarts(int count, String output) { + } + /** The daemon's handshake, and the only way the CLI can find it. */ private static final String HANDSHAKE = ".vaadin/daemon.properties";