testcontainers / testcontainers/testcontainers-java
BrowserWebDriverContainer does not start if shared memory not set under WSL2
Nessuno ha ancora preso questa issue.
- Lingua principale
- Java
- Stelle
- 8.7k
- Fork
- 1.9k
- Merge medio
- 2g 17h
- PR unite (30g)
- 9
Descrizione
Hi there,
I've been trying to run my UI Tests under Windows out of curiosity. If I use the old Docker engine for Windows, everything works fine (as does under "real" Linux, for that matter). When employing the WSL2 based engine, the tests fail because the container for the web driver (image selenium/standalone-firefox-debug:3.141.59) does not start.
I've been creating the container like so:
private BrowserWebDriverContainer<?> container = new BrowserWebDriverContainer<>()
.withCapabilities(new FirefoxOptions());
If I try to run the tests with WSL 2-based Docker -- no matter if from the IDE or with mvn -- I get the following Exception:
com.github.dockerjava.api.exception.InternalServerErrorException: {"message":"error while creating mount source path '/dev/shm': mkdir /dev/shm: file exists"}
The same happens if I issue docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-firefox from Powershell. It does NOT happen if I issue it under WSL 2's Bash.
FYI: As a workaround, I manually set shared memory on container instantiation:
private BrowserWebDriverContainer<?> container = new BrowserWebDriverContainer<>()
.withSharedMemorySize(2147483648L)
.withCapabilities(new FirefoxOptions());
When preemptively setting shm I can bypass the bind creation in BrowserWebDriverContainer:
if (this.getShmSize() == null) {
this.getBinds().add(new Bind("/dev/shm", new Volume("/dev/shm"), AccessMode.rw));
}
Now, I'm not sure whether this presents as something you can or even want to fix as it seems like it's WSL 2-backed Docker's fault. But here we are. ;)
Besides that, thanks for Testcontainers, it's been nothing but great so far.
Cheers,
rmnbhm
WSL Version: 2
WSL Distro: Ubuntu 18.04
Docker Engine Version: 19.03.8
Windows 10 Version: 2004 (Build 19041.173)
TestContainers Version: 1.12.5
Image used: selenium/standalone-firefox-debug:3.141.59
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con BrowserWebDriverContainer e la sua configurazione del bind mount per la memoria condivisa, in particolare con la condizione getShmSize() mostrata nel report. Riproduci il fallimento del mount di /dev/shm con WSL2 Docker e l’immagine selenium, quindi verifica che il container si avvii senza richiedere ai chiamanti di impostare esplicitamente la memoria condivisa.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- docker, java
- Ambito
- testing
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100