Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[grid] Dynamic Grid is able to disable video container spawn up #15047

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ public Map<Capabilities, Collection<SessionFactory>> 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 =
Expand Down Expand Up @@ -224,6 +226,9 @@ protected List<Device> 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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,15 @@ private Capabilities addForwardCdpEndpoint(

private Container createBrowserContainer(int port, Capabilities sessionCapabilities) {
Map<String, String> browserContainerEnvVars = getBrowserContainerEnvVars(sessionCapabilities);
// 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");
if (runningInDocker) {
browserContainerEnvVars.put("SE_VIDEO_RECORD_STANDALONE", "true");
}
}
long browserContainerShmMemorySize = 2147483648L; // 2GB
ContainerConfig containerConfig =
image(browserImage)
Expand All @@ -295,6 +304,10 @@ private Container createBrowserContainer(int port, Capabilities sessionCapabilit
.network(networkName)
.devices(devices)
.applyHostConfig(hostConfig, hostConfigKeys);
Optional<DockerAssetsPath> 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));
}
Expand Down Expand Up @@ -335,7 +348,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;
Expand Down
Loading