Skip to content

fix(vaadin-cdi-tests): wait for the deployment to answer and explain missing views - #25737

Merged
Artur- merged 8 commits into
mainfrom
fix/client-stuck-on-offline-stub-after-failed-init
Sep 18, 2026
Merged

Artur- merged 8 commits into
mainfrom
fix/client-stuck-on-offline-stub-after-failed-init

Conversation

@totally-not-ai

@totally-not-ai totally-not-ai Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The CDI integration tests sometimes failed with a bare "no such element" because they navigated before the deployed application could answer. The tests now wait for the deployment to respond before navigating, retry when the Flow client shows its offline stub, and print useful details when an element really is missing.

What changed

This change is test-only. It touches the shared CDI test base class and the CI job that collects test reports, so no production code or public API is affected.

  • Readiness wait before navigation. setup() now polls the counter filter (?getCount=...) until the deployment answers with a parsable count. Arquillian returns from a deploy as soon as the container reports the archive deployed, which on a busy runner can be before the application serves anything. The probe answers from the filter chain, so it needs the archive deployed and CDI running but creates no session and no UI. If nothing answers within 120 seconds, the failure names the URL and the last error.
  • Element lookups wait instead of failing at once. click, follow and getText go through a new waiting lookup with a 15 second timeout, instead of an immediate findElement.
  • Recovery from the offline stub. When the wait times out and the page is showing the Flow client's offline stub, the page is loaded again, up to 5 times. A reload is the only thing that retries the UI initialization: the client's connection-lost state is cleared by a browser online event, which never fires when the browser was online all along and only the server failed to answer. Nothing is lost by reloading, because the stub means the view never rendered.
  • Better failure messages. A missing element now reports the real elapsed time and how many reloads were spent, says when the browser is showing the offline stub, and includes the current URL and the browser console. Reading the console is guarded so it can never hide the original failure.
  • CI collects container logs. The CDI job now also packs */logs/*.log, */log/*.log and catalina.out into the test-report archive. Deployment errors point at server.log, which used to be lost when the runner was recycled.

Note on timing: tests that used to fail fast on a missing element can now take up to about 90 extra seconds before failing (the element timeout plus the reloads). That is a deliberate trade for a much lower flake rate.

Test summary

  • The CDI integration suite itself is the check: each test now blocks until the deployed application answers a real request before it navigates.
  • Element interactions (click, link navigation, text reads) succeed when the view renders slightly later, rather than failing on the first miss.
  • A view stuck behind the Flow client's offline stub recovers through page reloads within the retry budget.
  • When an element genuinely never appears, the run still fails — with the elapsed time, reload count, offline-stub state, current URL and browser console in the message, plus the container log in the CI artifact.

A failed UI initialization request leaves the client in CONNECTION_LOST,
and that state is only cleared by a browser 'online' event. When the
browser was online all along and only the server was briefly unable to
answer, the event never comes, so every later navigation returns the
offline stub without contacting the server again.

The case asserts the behaviour we want and fails today. It was found
while investigating why the CDI push tests land on the offline stub on
Payara; no fix is included yet.
…led init"

This reverts commit e068359. The case asserted behaviour the client
does not have yet, and the client is not what is being changed here: the
CDI tests get a readiness wait and better diagnostics instead. The
client never retrying a failed initialization is real and stays worth
fixing, but on its own branch and with its own discussion.
…is missing

Arquillian returns from a deploy as soon as the container reports the
archive deployed, which on a loaded runner can be before the
application answers anything. The first test to navigate then got a
failed UI initialization request, and because the Flow client replaces
the view with its offline stub in that case, the test failed on a bare
"no such element" for a view that was never rendered.

Tests now wait for the deployment to answer before they navigate, and
element lookups wait instead of failing at once. While the client is
showing the offline stub the page is loaded again, since that is the
only thing that retries the initialization: the connection-lost state
the client sets is cleared by a browser 'online' event, which never
fires when the browser was online the whole time.

When an element really does not appear, the failure now names the
offline stub and carries the current url and the browser console, and
the CDI job collects the container's own log. Neither was available
before, so a failure left nothing to explain itself with.
A container that is up but has not installed the application yet answers
the probe with an error page instead of refusing the connection, so the
count is parsed rather than only read. Link navigation goes through the
same waiting lookup as the other element helpers.
…cost

waitUntil already returns the element it waited for, so looking it up a
second time only added a lookup that the surrounding catch does not
cover: an element detached in between threw past the diagnostics instead
of through them.

The failure now reports how long the wait really took and how many times
the page was loaded again, rather than the timeout of a single attempt,
which read as 15 seconds even when the recovery had spent minutes. The
number of reloads is capped instead of bounded by a deadline, so the
budget is one constant rather than two overlapping ones.
@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

 1 452 files  ±0   1 536 suites  ±0   1h 38m 50s ⏱️ + 6m 46s
11 904 tests ±0  11 836 ✅ ±0  68 💤 ±0  0 ❌ ±0 
12 222 runs  ±0  12 154 ✅ ±0  68 💤 ±0  0 ❌ ±0 

Results for commit ce59758. ± Comparison against base commit 5708e37.

♻️ This comment has been updated with latest results.

* creates neither a session nor a UI.
*/
private void waitForDeployment() throws InterruptedException {
long deadline = System.currentTimeMillis()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do this and the below, and maybe existing code, have enough in common to extract something like waitUntil(check) where check is run until it passes or timeout passes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call — and it turned out the helper already exists, so nothing new had to be extracted.

waitForCount further down this class was already polling an HTTP answer through TestBench's waitUntil(condition, timeoutInSeconds), which is exactly "run the check until it passes or the timeout passes". The readiness check now follows that precedent instead of hand-rolling a deadline, a Thread.sleep and a loop: the condition returns whether the deployment answered, and it records the last reason it did not so the timeout can still name the URL and the final failure. That also dropped the InterruptedException from the signature.

I left awaitElement on its own loop, because it is a different shape rather than the same one: it needs a recovery step — loading the page again — between whole wait attempts, not a predicate evaluated on every poll. Folding it into a single condition would reload every few hundred milliseconds while the offline stub is up, which would keep interrupting the very wait it is trying to satisfy. Its inner wait is the same waitUntil though, so after this change there is no hand-rolled polling left in the class.

I also considered giving waitForCount the same tolerance for a failed read, but kept it as it was: by the time a test calls it, setup has already waited for the deployment to answer, so an IOException there is a real error worth surfacing immediately rather than one to swallow for ten seconds.

waitForCount already polls an http answer through waitUntil, so the
readiness check does the same instead of hand-rolling a deadline, a
sleep and a loop. The condition reports whether the deployment answered
and keeps the last reason it did not, so the timeout still names the url
and what the final attempt failed with.
@Artur-
Artur- enabled auto-merge September 18, 2026 09:22
@sonarqubecloud

Copy link
Copy Markdown

@Artur-
Artur- added this pull request to the merge queue Sep 18, 2026
Merged via the queue into main with commit a2e81f4 Sep 18, 2026
73 of 75 checks passed
@Artur-
Artur- deleted the fix/client-stuck-on-offline-stub-after-failed-init branch September 18, 2026 10:09
@vaadin-bot

Copy link
Copy Markdown
Collaborator

This ticket/PR has been released with Vaadin 25.4.0-alpha1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants