Repository navigation
fix(vaadin-cdi-tests): wait for the deployment to answer and explain missing views - #25737
Conversation
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.
| * creates neither a session nor a UI. | ||
| */ | ||
| private void waitForDeployment() throws InterruptedException { | ||
| long deadline = System.currentTimeMillis() |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
|
|
This ticket/PR has been released with Vaadin 25.4.0-alpha1. |



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.
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.click,followandgetTextgo through a new waiting lookup with a 15 second timeout, instead of an immediatefindElement.onlineevent, 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.*/logs/*.log,*/log/*.logandcatalina.outinto the test-report archive. Deployment errors point atserver.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