Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run tests in Pytest in parallel inside the Docker container?

I ran into a problem when running GUI tests in parallel inside a Docker container. I use a bunch: Selenium webdriver + Pytest + Xdist + Chrome.

I use following command to run the tests:

pytest -v -n=4 --headless=True --production=True --browser=chrome --dist=loadfile --junitxml=test.xml

But all the tests fail. If I do the same outside the docker container or use 1 thread - it's working fine.

So, how can I resolve this problem and execute tests in parallel inside the docker container? Thanks a lot)

I have this in logs:

selenium.common.exceptions.WebDriverException: Message: chrome not reachable   (Session info: headless chrome=73.0.3683.86)   (Driver info: chromedriver=73.0.3683.20 (8e2b610813e167eee3619ac4ce6e42e3ec622017),platform=Linux 4.15.0-46-generic x86_64)
like image 692
Sergei Avatar asked Nov 06 '22 18:11

Sergei


1 Answers

Try to use boxed processes + tx flag: (--tx 3*popen//python=python3.6 --boxed, so run your tests with the command below:

pytest -v --headless=True --production=True --browser=chrome --dist=loadfile --junitxml=test.xml --tx 3*popen//python=python3.6 --boxed

More information of how you can run your tests in parallel is available under that SO answer .

Good Luck !

like image 131
Andriy Ivaneyko Avatar answered Nov 14 '22 21:11

Andriy Ivaneyko