Revert "Investigating fixes for same recordings"

This reverts commit c5780918a2c1dd63763baa4c14ae958e5fcef1fa.
diff --git a/spock-container-test-app/src/integration-test/groovy/org/demo/spock/DownloadSupportSpec.groovy b/spock-container-test-app/src/integration-test/groovy/org/demo/spock/DownloadSupportSpec.groovy
index 4aecd45..0244a14 100644
--- a/spock-container-test-app/src/integration-test/groovy/org/demo/spock/DownloadSupportSpec.groovy
+++ b/spock-container-test-app/src/integration-test/groovy/org/demo/spock/DownloadSupportSpec.groovy
@@ -13,12 +13,4 @@
         then:
         downloadText().contains('Welcome to Grails')
     }
-
-    void 'should display the correct title on the home page'() {
-        when: 'visiting the home page'
-        go '/'
-
-        then: 'the page title is correct'
-        title == 'Welcome to Grails'
-    }
 }
\ No newline at end of file
diff --git a/src/testFixtures/groovy/grails/plugin/geb/GebRecordingTestListener.groovy b/src/testFixtures/groovy/grails/plugin/geb/GebRecordingTestListener.groovy
index 43976f9..2586d65 100644
--- a/src/testFixtures/groovy/grails/plugin/geb/GebRecordingTestListener.groovy
+++ b/src/testFixtures/groovy/grails/plugin/geb/GebRecordingTestListener.groovy
@@ -16,15 +16,9 @@
 package grails.plugin.geb
 
 import groovy.transform.CompileStatic
-import groovy.util.logging.Slf4j
-import org.junit.runner.Description
 import org.spockframework.runtime.AbstractRunListener
 import org.spockframework.runtime.model.ErrorInfo
 import org.spockframework.runtime.model.IterationInfo
-import org.testcontainers.containers.BrowserWebDriverContainer
-import org.testcontainers.containers.DefaultRecordingFileFactory
-import org.testcontainers.containers.RecordingFileFactory
-import org.testcontainers.containers.VncRecordingContainer
 
 /**
  * A test listener that reports the test result to {@link org.testcontainers.containers.BrowserWebDriverContainer} so
@@ -35,71 +29,23 @@
  * @author James Daugherty
  * @since 4.1
  */
-@Slf4j
 @CompileStatic
 class GebRecordingTestListener extends AbstractRunListener {
 
-    ErrorInfo errorInfo
-    VncRecordingContainer recordingContainer
     WebDriverContainerHolder containerHolder
-    RecordingFileFactory recordingFileFactory = new DefaultRecordingFileFactory()
+    ErrorInfo errorInfo
 
     GebRecordingTestListener(WebDriverContainerHolder containerHolder) {
         this.containerHolder = containerHolder
     }
 
     @Override
-    void beforeIteration(IterationInfo iteration) {
-        recordingContainer = new VncRecordingContainer(containerHolder.currentContainer)
-                .withVncPassword("secret")
-                .withVncPort(5900)
-                .withVideoFormat(containerHolder.grailsGebSettings.recordingFormat)
-
-        recordingContainer.start()
-    }
-
-    @Override
     void afterIteration(IterationInfo iteration) {
-        ContainerGebTestDescription description = new ContainerGebTestDescription(iteration)
-
-        retainRecordingIfNeeded(description.getFilesystemFriendlyName(), errorInfo?.exception == null)
+        containerHolder.currentContainer.afterTest(
+                new ContainerGebTestDescription(iteration),
+                Optional.ofNullable(errorInfo?.exception)
+        )
         errorInfo = null
-
-        recordingContainer.stop()
-        recordingContainer = null
-    }
-
-    /**
-     * This method is copied from BrowserWebDriverContainer until upstream allows triggering a recording
-     */
-    private void retainRecordingIfNeeded(String prefix, boolean succeeded) {
-        final boolean shouldRecord
-        switch (containerHolder.grailsGebSettings.recordingMode) {
-            case BrowserWebDriverContainer.VncRecordingMode.RECORD_ALL:
-                shouldRecord = true
-                break
-            case BrowserWebDriverContainer.VncRecordingMode.RECORD_FAILING:
-                shouldRecord = !succeeded
-                break
-            default:
-                shouldRecord = false
-                break
-        }
-
-        if (shouldRecord) {
-            File recordingFile = recordingFileFactory.recordingFileForTest(
-                    containerHolder.grailsGebSettings.recordingDirectory,
-                    prefix,
-                    succeeded,
-                    recordingContainer.getVideoFormat()
-            )
-            log.info("Screen recordings for test {} will be stored at: {}", prefix, recordingFile)
-            //TODO: There's some type of race condition here, since the file will always exist if you use the debugger, but when running the test through it errors with a message like:
-            /*
-            Status 404: {"message":"Could not find the file /newScreen.mp4 in container 044005e429dd268d8149b5c8cda5b1c29d815f6b84705545bc62962bbde9851f"}
-             */
-            recordingContainer.saveRecordingToFile(recordingFile)
-        }
     }
 
     @Override
diff --git a/src/testFixtures/groovy/grails/plugin/geb/WebDriverContainerHolder.groovy b/src/testFixtures/groovy/grails/plugin/geb/WebDriverContainerHolder.groovy
index f938d2a..a287f1b 100644
--- a/src/testFixtures/groovy/grails/plugin/geb/WebDriverContainerHolder.groovy
+++ b/src/testFixtures/groovy/grails/plugin/geb/WebDriverContainerHolder.groovy
@@ -16,7 +16,6 @@
 package grails.plugin.geb
 
 import com.github.dockerjava.api.model.ContainerNetwork
-import com.google.common.collect.ImmutableSet
 import geb.Browser
 import geb.Configuration
 import geb.spock.SpockGebTestManagerBuilder
@@ -25,7 +24,6 @@
 import groovy.transform.EqualsAndHashCode
 import groovy.transform.PackageScope
 import groovy.util.logging.Slf4j
-import org.jetbrains.annotations.NotNull
 import org.openqa.selenium.WebDriver
 import org.openqa.selenium.chrome.ChromeOptions
 import org.openqa.selenium.remote.RemoteWebDriver
@@ -33,7 +31,6 @@
 import org.spockframework.runtime.model.SpecInfo
 import org.testcontainers.Testcontainers
 import org.testcontainers.containers.BrowserWebDriverContainer
-import org.testcontainers.containers.Network
 import org.testcontainers.containers.PortForwardingContainer
 
 import java.time.Duration
@@ -101,12 +98,11 @@
         }
 
         currentConfiguration = specConfiguration
-
-        // Recording needs to be restarted after every test, so do the configuration in the listener
-        currentContainer = new GrailsBrowserWebDriverContainer(grailsGebSettings.recordingMode)
-        .withRecordingMode(BrowserWebDriverContainer.VncRecordingMode.SKIP, null)
-        .withNetwork(Network.SHARED) as BrowserWebDriverContainer
-
+        currentContainer = new BrowserWebDriverContainer().withRecordingMode(
+                grailsGebSettings.recordingMode,
+                grailsGebSettings.recordingDirectory,
+                grailsGebSettings.recordingFormat
+        )
         currentContainer.tap {
             withEnv('SE_ENABLE_TRACING', grailsGebSettings.tracingEnabled)
             withAccessToHost(true)
@@ -216,33 +212,3 @@
     }
 }
 
-/**
- * The only reason this class exists is so we can set the correct liveness ports so the container isn't considered started
- * until both the selenium server & vnc server are running
- */
-class GrailsBrowserWebDriverContainer<SELF extends GrailsBrowserWebDriverContainer<SELF>>
-        extends BrowserWebDriverContainer<SELF> {
-    private BrowserWebDriverContainer.VncRecordingMode recordingMode
-
-    GrailsBrowserWebDriverContainer(BrowserWebDriverContainer.VncRecordingMode recordingMode) {
-        // parent recording mode will be set to skip, this is here to just expose the correct liveness check
-        this.recordingMode = recordingMode
-    }
-
-    // Must override to ensure the container isn't considered "ready" until it's vnc server is
-    @NotNull
-    @Override
-    protected Set<Integer> getLivenessCheckPorts() {
-        Integer seleniumPort = getMappedPort(4444) // selenium port
-        if (recordingMode == BrowserWebDriverContainer.VncRecordingMode.SKIP) {
-            return ImmutableSet.of(seleniumPort);
-        } else {
-            return ImmutableSet.of(seleniumPort, getMappedPort(5900)) // VNC port
-        }
-    }
-
-    // This is likely a groovy bug, should not be required since there's a default implementation on Startable
-    void close() {
-        stop()
-    }
-}