diff --git a/java/src/org/openqa/selenium/grid/node/docker/DockerAssetsPath.java b/java/src/org/openqa/selenium/grid/node/docker/DockerAssetsPath.java index 804d90491f9bf..c4ea2c03dc281 100644 --- a/java/src/org/openqa/selenium/grid/node/docker/DockerAssetsPath.java +++ b/java/src/org/openqa/selenium/grid/node/docker/DockerAssetsPath.java @@ -30,6 +30,10 @@ public DockerAssetsPath(String hostPath, String containerPath) { this.containerPath = containerPath; } + public String getHostPath() { + return this.hostPath; + } + public String getHostPath(SessionId id) { return this.hostPath + File.separator + id; } diff --git a/java/src/org/openqa/selenium/grid/node/docker/DockerOptions.java b/java/src/org/openqa/selenium/grid/node/docker/DockerOptions.java index 8c752c8ae39fd..5866375988ddb 100644 --- a/java/src/org/openqa/selenium/grid/node/docker/DockerOptions.java +++ b/java/src/org/openqa/selenium/grid/node/docker/DockerOptions.java @@ -61,7 +61,7 @@ public class DockerOptions { static final String DOCKER_SECTION = "docker"; static final String DEFAULT_ASSETS_PATH = "/opt/selenium/assets"; static final String DEFAULT_DOCKER_URL = "unix:/var/run/docker.sock"; - static final String DEFAULT_VIDEO_IMAGE = "selenium/video:latest"; + static final String DEFAULT_VIDEO_IMAGE = "false"; static final int DEFAULT_MAX_SESSIONS = Runtime.getRuntime().availableProcessors(); private static final String DEFAULT_DOCKER_NETWORK = "bridge"; private static final Logger LOG = Logger.getLogger(DockerOptions.class.getName()); @@ -159,7 +159,9 @@ public Map> getDockerSessionFactories( loadImages(docker, kinds.keySet().toArray(new String[0])); Image videoImage = getVideoImage(docker); - loadImages(docker, videoImage.getName()); + if (videoImage != null) { + loadImages(docker, videoImage.getName()); + } // Hard coding the config section value "node" to avoid an extra dependency int maxContainerCount = @@ -224,6 +226,9 @@ protected List getDevicesMapping() { private Image getVideoImage(Docker docker) { String videoImage = config.get(DOCKER_SECTION, "video-image").orElse(DEFAULT_VIDEO_IMAGE); + if (videoImage.equalsIgnoreCase("false")) { + return null; + } return docker.getImage(videoImage); } diff --git a/java/src/org/openqa/selenium/grid/node/docker/DockerSessionFactory.java b/java/src/org/openqa/selenium/grid/node/docker/DockerSessionFactory.java index 3cc1d4ab68911..65b322674662f 100644 --- a/java/src/org/openqa/selenium/grid/node/docker/DockerSessionFactory.java +++ b/java/src/org/openqa/selenium/grid/node/docker/DockerSessionFactory.java @@ -286,7 +286,15 @@ private Capabilities addForwardCdpEndpoint( } private Container createBrowserContainer(int port, Capabilities sessionCapabilities) { - Map browserContainerEnvVars = getBrowserContainerEnvVars(sessionCapabilities); + Map browserContainerEnvVars = new HashMap<>(); + // Enable env var to trigger video recording if session capabilities request and external video + // container is disabled + if (videoImage == null && recordVideoForSession(sessionCapabilities)) { + browserContainerEnvVars.put("SE_RECORD_VIDEO", "true"); + browserContainerEnvVars.put("SE_VIDEO_FILE_NAME", "auto"); + browserContainerEnvVars.put("SE_VIDEO_RECORD_STANDALONE", "true"); + } + browserContainerEnvVars.putAll(getBrowserContainerEnvVars(sessionCapabilities)); long browserContainerShmMemorySize = 2147483648L; // 2GB ContainerConfig containerConfig = image(browserImage) @@ -295,6 +303,10 @@ private Container createBrowserContainer(int port, Capabilities sessionCapabilit .network(networkName) .devices(devices) .applyHostConfig(hostConfig, hostConfigKeys); + Optional path = ofNullable(this.assetsPath); + if (path.isPresent() && videoImage == null && recordVideoForSession(sessionCapabilities)) { + containerConfig.bind(Collections.singletonMap(this.assetsPath.getHostPath(), "/videos")); + } if (!runningInDocker) { containerConfig = containerConfig.map(Port.tcp(4444), Port.tcp(port)); } @@ -335,7 +347,7 @@ private void setCapsToEnvVars( private Container startVideoContainer( Capabilities sessionCapabilities, String browserContainerIp, String hostPath) { - if (!recordVideoForSession(sessionCapabilities)) { + if (videoImage == null || !recordVideoForSession(sessionCapabilities)) { return null; } int videoPort = 9000;