Whilst running tests using pabot in a Docker container whilst extending Browser library with a JavaScript module some failures occur due to not being able to connect to playwright process. See stack trace at the bottom.
Docker base image is marketsquare/robotframework-browser image.
Some tests do pass however this pass rate varies with each run. Pabot processes is set to 5. Chromium browser running headless.
No issues experienced when running locally with same setup and commands from IDE.
Any ideas as to what could cause this?
line 2: Initializing library ‘Browser’ with arguments [ jsextension=/home/pwuser/.local/lib/python3.8/site-packages//keywords/.js ] failed: Could not connect to the playwright process at port 54121.
Traceback (most recent call last):
File “/home/pwuser/.local/lib/python3.8/site-packages/Browser/browser.py”, line 745, in init
libraries.append(self._initialize_jsextension(jsextension))
File “/home/pwuser/.local/lib/python3.8/site-packages/Browser/browser.py”, line 779, in _initialize_jsextension
with self.playwright.grpc_channel() as stub:
File “/usr/lib/python3.8/contextlib.py”, line 113, in enter
return next(self.gen)
File “/home/pwuser/.local/lib/python3.8/site-packages/Browser/playwright.py”, line 139, in grpc_channel
playwright_process = self._playwright_process
File “/usr/lib/python3.8/functools.py”, line 967, in get
val = self.func(instance)
File “/home/pwuser/.local/lib/python3.8/site-packages/Browser/playwright.py”, line 57, in _playwright_process
self.wait_until_server_up()
File “/home/pwuser/.local/lib/python3.8/site-packages/Browser/playwright.py”, line 125, in wait_until_server_up
raise RuntimeError(
RuntimeError: Could not connect to the playwright process at port 54121.
We sometimes see this same problem in our CI environment too. Current we don’t have good solution for it, because root cause is unknown for us. If you can dig any information out from your system. Like is process actually running, is there something in the nix logs or something similar we would be greatly interested. Perhaps we can find something to solve the problem
@aaltat At long last, after the issue creeping up now and again over several months, I have been able to get a workaround that thus far has not thrown the error.
I am currently using marketsquare/robotframework-browser:16.0.2 as my base image in my Dockerfile.
After building the image in our CI pipeline I run the following steps:
run container with interactive and detached flags (-i -d) to bash shell
e.g. docker run --rm -i -d --name containerName imageName bash
run a new command on the container using docker exec command to start playwright process on a specified port
e.g. docker exec -i containerNamenode /home/pwuser/.local/lib/python3.8/site-packages/Browser/wrapper/index.js $(playwrightProcessPort) &
Execute robot tests which import Browser with optional argument playwright_process_port passing as a variable the same port we used to start the playwright process at previous step
e.g. docker exec -i containerNamenode pabot --pabotlib --testlevelsplit --processes -A argfile -v PlaywrightProcessPort:$(playwrightProcessPort) ./TestSuites
For us the problem is not that severe anymore, we did not find the root cause but where we able to see that one utest is problematic in Mac, but not in others. So we do not run that test anymore in Mac. Our current assumption is that in our CI, Mac sometimes runs out of resources and just hangs. For Windows or Linux we have not seem similar problems.