[grid] Passing env vars along to child containers
Only the ones prefixed with `SE_`.
Fixes
package org.openqa.selenium.grid.node.docker;
-import java.util.List;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.ImmutableCapabilities;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.TimeZone;
@@ -305,11 +305,16 @@ private Container createBrowserContainer(int port, Capabilities sessionCapabilit
ofNullable(getScreenResolution(sessionRequestCapabilities));
Map<String, String> envVars = new HashMap<>();
if (screenResolution.isPresent()) {
- envVars.put("SCREEN_WIDTH", String.valueOf(screenResolution.get().getWidth()));
- envVars.put("SCREEN_HEIGHT", String.valueOf(screenResolution.get().getHeight()));
+ envVars.put("SE_SCREEN_WIDTH", String.valueOf(screenResolution.get().getWidth()));
+ envVars.put("SE_SCREEN_HEIGHT", String.valueOf(screenResolution.get().getHeight()));
}
Optional<TimeZone> timeZone = ofNullable(getTimeZone(sessionRequestCapabilities));
timeZone.ifPresent(zone -> envVars.put("TZ", zone.getID()));
+ // Passing env vars set to the child container
+ Map<String, String> seEnvVars = System.getenv();
+ seEnvVars.entrySet()
+ .stream().filter(entry -> entry.getKey().startsWith("SE_"))
+ .forEach(entry -> envVars.put(entry.getKey(), entry.getValue()));
return envVars;
}
@@ -356,8 +361,10 @@ private Container startVideoContainer(Capabilities sessionCapabilities,
envVars.put("DISPLAY_CONTAINER_NAME", containerIp);
Optional<Dimension> screenResolution =
ofNullable(getScreenResolution(sessionRequestCapabilities));
- screenResolution.ifPresent(dimension -> envVars
- .put("VIDEO_SIZE", String.format("%sx%s", dimension.getWidth(), dimension.getHeight())));
+ screenResolution.ifPresent(dimension -> {
+ envVars.put("SE_SCREEN_WIDTH", String.valueOf(dimension.getWidth()));
+ envVars.put("SE_SCREEN_HEIGHT", String.valueOf(dimension.getHeight()));
+ });
return envVars;
}
