Skip to content

Recover per-test VNC recording after a failed restart - #16405

Merged
jdaugherty merged 1 commit into
8.0.xfrom
fix/geb-vnc-recording-restart-recovery
Sep 28, 2026
Merged

jdaugherty merged 1 commit into
8.0.xfrom
fix/geb-vnc-recording-restart-recovery

Conversation

@matrei

@matrei matrei commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #16031.

Problem

With grails.geb.recording.restartRecordingContainerPerTest enabled, WebDriverContainerHolder#restartVncRecordingContainer stops the current VNC recording container before each test and starts a replacement. Since #16031, the stopped container is cleared first, so a failed start no longer leaves a reference to a removed container. But it left two problems:

  • One failed restart disabled recording for the rest of the browser container's life. With nothing left to stop, every later restart skipped entirely. All remaining tests ran unrecorded, and the only trace was a single warning.
  • GebRecordingTestListener caught NullPointerException to detect the missing recording container. With per-test restart enabled, that swallowed every NPE from afterIteration at debug level, including ones unrelated to recording.

Changes

  • Restart recovers. restartVncRecordingContainer now starts a new recording container even when there is none to stop, so recording resumes with the next test after a failure. A replacement that fails to start is still stopped, so it isn't left attached to the browser container.
  • Explicit check instead of the NPE catch. New WebDriverContainerHolder#isRecordingContainerAvailable(). The listener skips saving when recording is enabled but no recording container is available. Any other exception now propagates.
  • Replacement creation is overridable. It moves into protected createVncRecordingContainer().
  • PerTestRecordingSpec asserts the minimum recording size directly. The recordings are saved synchronously before the comparing feature runs, so polling their size could not change the result. It only delayed the failure by 10 s.

Tests

The specs added in #16031 passed without exercising what they described:

  • The "replacement fails to start" case failed in the VncRecordingContainer constructor (a bare mock returns null network aliases), so start() and the new cleanup path were never reached.
  • The listener specs passed a bare Mock(IterationInfo), so ContainerGebTestDescription threw an NPE before afterTest was called. Both the "swallows" and the "re-throws" cases were asserting against that NPE.

Changes to the specs:

  • WebDriverContainerHolderSpec supplies replacement containers through createVncRecordingContainer(). It covers a normal restart, a replacement that fails to start and is stopped, and recovery on the next restart.
  • GebRecordingTestListenerSpec passes the running iteration (specificationContext.currentIteration) and asserts the recording name passed to the container.
  • Assertions no longer read the private Testcontainers field. It is still set by reflection in the setup, as the production code does.
  • Both specs use @RestoreSystemProperties instead of hand-rolled save/restore of the grails.geb.* properties.

I checked each fix by reverting it: the recovery, stopping the failed replacement, and the listener skip. Each revert fails exactly the test written for it.

Verification

  • :grails-geb:test: 15/15 pass
  • :grails-test-examples-geb:integrationTest against Docker: all specs pass, including PerTestRecordingSpec 3/3
  • :grails-geb:codeStyle: passes

Backport

This will be backported to 7.0.x once merged, together with #16031 and the per-run recording directory scoping from c179aac, which 7.0.x also lacks. A trial cherry-pick applies cleanly and :grails-geb:test passes there. With this PR merged first, the backported files match 8.0.x, so the merge-up should not conflict.

A failed restart of the VNC recording container left no recording
container behind, and every later restart skipped because there was
nothing to stop, so recording stayed off for all remaining tests on
that browser container. A restart now starts a new recording container
even when there is none to stop, so recording resumes with the next
test.

GebRecordingTestListener no longer infers a missing recording container
from a NullPointerException, which also swallowed unrelated failures.
It checks WebDriverContainerHolder#isRecordingContainerAvailable and
skips saving instead, and lets any other exception propagate.

Creating the replacement moves into an overridable
createVncRecordingContainer() so the cleanup of a replacement that fails
to start is covered by a test. The previous test failed in the
VncRecordingContainer constructor and never reached start(), and the
listener specs failed in ContainerGebTestDescription before reaching
the container; they now use the running iteration.

PerTestRecordingSpec asserts the recording size directly. The recordings
are saved synchronously before the comparing feature runs, so polling
their size could not change the outcome.
@codecov

codecov Bot commented Sep 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.8014%. Comparing base (e4cde3c) to head (1df16ec).
⚠️ Report is 42 commits behind head on 8.0.x.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##                8.0.x     #16405   +/-   ##
=============================================
  Coverage     57.8014%   57.8014%           
  Complexity      22798      22798           
=============================================
  Files            2135       2135           
  Lines          104456     104456           
  Branches        18747      18747           
=============================================
  Hits            60377      60377           
  Misses          35752      35752           
  Partials         8327       8327           

see 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@testlens-app

testlens-app Bot commented Sep 25, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 1df16ec
▶️ Tests: 96075 executed
⚪️ Checks: 84/84 completed


Learn more about TestLens at testlens.app/docs.

@jdaugherty jdaugherty added this to the grails:8.0.0-RC2 milestone Sep 28, 2026
@jdaugherty
jdaugherty merged commit 7ce779e into 8.0.x Sep 28, 2026
87 checks passed
@jdaugherty
jdaugherty deleted the fix/geb-vnc-recording-restart-recovery branch September 28, 2026 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants