Hi, all
In our project we have one persistent problem - our UI tests very flaky and dependent on machine resources. Sometimes tests passed perfect, sometimes fails, even when memory usage is low.
Main reason - selenium/standalone-chrome container is dropping in the middle of execution.
Our approximate docker configuration (docker-compose file):
version: "2.3"
services:
tests:
mem_limit: 1500m
memswap_limit: 3g
oom_score_adj: -500
extends:
file: docker-compose.build.yml
service: jdk-mvn
depends_on:
- selenium
environment:
- SELENIUM_PORT_4444_TCP_ADDR=selenium
- SELENIUM_PORT_4444_TCP_PORT=4444
command: >
sh -c "mvn -B -U clean install -DskipTests -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
&& mvn -B test -pl module -Pprofile -Denvironment=staging -Dbrowser.type=REMOTE_CHROME_LINUX"
selenium:
container_name: selenium
image: selenium/standalone-chrome:3.141.59
shm_size: '2gb'
mem_limit: 1100m
memswap_limit: 4g
oom_score_adj: -1000
oom_kill_disable: true
expose:
- 4444
Tests is running by maven command from tests
container. We use several forks (3-4) for parallel execution via maven-surefire-plugin
, so tests is running in several JVMs.
Often we get such error:
org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
Build info: version: '4.1.1', revision: 'e8fcc2cecf'
System info: host: '58877d6015f7', ip: '172.23.0.6', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-1128-aws', java.version: '11.0.4'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Command: [009beb8f09ce87a15690dd3cbe53ca77, getAlertText {}]
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 86.0.4240.75, chrome: {chromedriverVersion: 86.0.4240.22 (398b0743353ff..., userDataDir: /tmp/.com.google.Chrome.W5uYnf}, goog:chromeOptions: {debuggerAddress: localhost:44673}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true, webdriver.remote.sessionid: 009beb8f09ce87a15690dd3cbe5...}
Session ID: 009beb8f09ce87a15690dd3cbe53ca77
...
Caused by: java.io.UncheckedIOException: java.net.UnknownHostException: selenium: Try again
Line
java.net.UnknownHostException: selenium: Try again
means that selenium container was dropped.
All this options: shm-size
, mem_limit
etc. was added to improve somehow current situation.
It helped, nut not so much. Even if we prevent container itself from dropping, browser sessions inside container start dropping.
In general, question is: how to improve this situation? I mean, any points are appreciated: docker, selenium settings, JVM argument, code refactoring to reduce memory usage etc. Main, but not only point of this issue seems to be limited machine resources