Skip to content

feat: add shareDriver, isReuseDriver hook, SPA navigation and headed mode to AbstractComponentIT#9255

Draft
manolo wants to merge 12 commits into
mainfrom
feat/reuse-driver-class
Draft

feat: add shareDriver, isReuseDriver hook, SPA navigation and headed mode to AbstractComponentIT#9255
manolo wants to merge 12 commits into
mainfrom
feat/reuse-driver-class

Conversation

@manolo
Copy link
Copy Markdown
Member

@manolo manolo commented May 9, 2026

Extends AbstractComponentIT with four independent opt-in features, each enabled by a system property:

-Dtest.reuseDriver=true (existing, unchanged behavior)
One Chrome window per test class. Reuses the driver between methods, creates a new one per class.

-Dtest.shareDriver=true (new)
One Chrome window for the entire JVM fork — reused across all test classes in the same process. Implies test.reuseDriver. Includes a health-check before each class, debug-mode session persistence to disk for reconnect across runs, a JVM shutdown hook for cleanup, and a consecutive-failure abort rule (stops the fork after 5 consecutive failures to avoid burning CI time on a dead driver).

-Dtest.useSpa=true (new)
When combined with reuseDriver or shareDriver, navigates between routes via the Vaadin vaadin-navigate client event instead of a full page load. Falls back to a full load automatically when the browser is not on a Vaadin page or when navigating to the same route (which would leak session state).

-Dtest.headed=true (new)
Runs Chrome in headed (visible) mode. Default is headless. Also implied when a JDWP debug agent is attached.

isReuseDriver() hook (new)
Allows subclasses to opt out of driver reuse on a per-class basis without changing the global system property. Returns true if either test.reuseDriver or test.shareDriver is active.

Benchmark results (GHA, Ubuntu)

All runs use forkCount=4 unless noted. "Longest shard" is the wall-clock time of the slowest IT shard job.

Config Shards Driver SPA Longest shard
main baseline 10 reuseDriver 369s
shareDriver 10 shareDriver 358s
shareDriver + SPA 10 shareDriver 462s
reuseDriver + SPA 10 reuseDriver 468s
shareDriver 8 shareDriver 525s
reuseDriver 8 reuseDriver 441s
reuseDriver + SPA 8 reuseDriver 421s

Key findings:

  • shareDriver vs reuseDriver with 10 shards: ~11s difference — within noise, not significant. With forkCount=4 the Chrome startup cost is already amortized across 4 parallel forks.
  • SPA navigation adds overhead with 10 shards (extra Vaadin client check per test) but helps with 8 shards where tests run more sequentially per fork.
  • 8 shards is slower than 10 shards overall, but reuseDriver + SPA at 421s is the best 8-shard configuration.
  • Local development benefit is significant: headed + reuseDriver reduces a 73s run to 16s for the same 29 tests.

The CI in this PR uses 8 shards + reuseDriver + useSpa as a benchmark configuration.

@manolo manolo force-pushed the feat/reuse-driver-class branch 2 times, most recently from c750284 to e0b6dec Compare May 9, 2026 15:42
@vaadin vaadin deleted a comment from github-actions Bot May 9, 2026
…igation

Three independent opt-in features in AbstractComponentIT:

test.reuseDriver (existing) - one Chrome window per test class.
test.shareDriver (new) - one Chrome window for the entire JVM fork (implies
reuseDriver). Health-check before reuse, debug-mode session persistence and
reconnect, JVM shutdown hook for cleanup.
test.useSpa (new) - SPA navigation via vaadin-navigate instead of full page
load (requires reuseDriver or shareDriver). Falls back to full load on same
route or non-Vaadin pages.
test.headed (new) - headed Chrome instead of headless.
isReuseDriver() hook - subclasses can opt out per class.
Consecutive-failure abort after 5 failures in shareDriver mode.

ci: use shareDriver to benchmark cross-class browser reuse in GHA
@manolo manolo force-pushed the feat/reuse-driver-class branch from 7a788ec to c28f672 Compare May 9, 2026 16:23
@vaadin vaadin deleted a comment from github-actions Bot May 9, 2026
@manolo manolo changed the title feat: add isReuseDriver() hook, cross-class driver reuse, and SPA navigation feat: add shareDriver, isReuseDriver hook, SPA navigation and headed mode to AbstractComponentIT May 10, 2026
@manolo manolo force-pushed the feat/reuse-driver-class branch from bfa7e25 to 32f0a4b Compare May 10, 2026 11:59
manolo added 3 commits May 10, 2026 17:18
Tests that configure initial state via query parameters (e.g.
initialSelection=0) were failing because trySpaNavigation received
only getTestPath() without query params, causing the view to initialize
without the required parameters.

Pass the full relative URL including query string so the Vaadin router
receives all parameters needed to set up the view's initial state.
SPA navigation reuses the Vaadin session, causing server-side events
from previous tests to arrive in the current test. Tests with
CLIENT:false value-change events or wrong initial state fail
consistently. useSpa remains available as a local development flag only.
@sonarqubecloud
Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant