Repository navigation
Recover per-test VNC recording after a failed restart - #16405
Merged
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ 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 🚀 New features to boost your workflow:
|
jdaugherty
approved these changes
Sep 25, 2026
✅ All tests passed ✅🏷️ Commit: 1df16ec Learn more about TestLens at testlens.app/docs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #16031.
Problem
With
grails.geb.recording.restartRecordingContainerPerTestenabled,WebDriverContainerHolder#restartVncRecordingContainerstops 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:GebRecordingTestListenercaughtNullPointerExceptionto detect the missing recording container. With per-test restart enabled, that swallowed every NPE fromafterIterationat debug level, including ones unrelated to recording.Changes
restartVncRecordingContainernow 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.WebDriverContainerHolder#isRecordingContainerAvailable(). The listener skips saving when recording is enabled but no recording container is available. Any other exception now propagates.protected createVncRecordingContainer().PerTestRecordingSpecasserts 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:
VncRecordingContainerconstructor (a bare mock returnsnullnetwork aliases), sostart()and the new cleanup path were never reached.Mock(IterationInfo), soContainerGebTestDescriptionthrew an NPE beforeafterTestwas called. Both the "swallows" and the "re-throws" cases were asserting against that NPE.Changes to the specs:
WebDriverContainerHolderSpecsupplies replacement containers throughcreateVncRecordingContainer(). It covers a normal restart, a replacement that fails to start and is stopped, and recovery on the next restart.GebRecordingTestListenerSpecpasses the running iteration (specificationContext.currentIteration) and asserts the recording name passed to the container.@RestoreSystemPropertiesinstead of hand-rolled save/restore of thegrails.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:integrationTestagainst Docker: all specs pass, includingPerTestRecordingSpec3/3:grails-geb:codeStyle: passesBackport
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:testpasses there. With this PR merged first, the backported files match 8.0.x, so the merge-up should not conflict.