I have my Selenium Java tests running inside a Docker container. I need to use BrowserStackLocal, because I use BrowserMob proxy to intercept and check the analytics sent by our web App. Each time there is a call to BrowserStackLocal.stop() inside Docker - it just hangs. When I connect to this running container, I see this:
# ps -eo pid,ppid,state,cmd | awk '$3=="Z"'
63 1 Z [BrowserStackLoc] <defunct>
I came across the following issue for NodeJS, but apparently it was not ported to Java implementation: https://github.com/browserstack/browserstack-local-nodejs/issues/25
I'm fine with a workaround, but I have tried the following combinations inside my Dockerfile (using a workaround from similar issue with browserstack-local-nodejs) to no avail:
CMD ["java", "-cp", "target/.jar", "org.testng.TestNG", "testng.xml"]
CMD ["/bin/bash", "-c", "set -e && java -cp .jar org.testng.TestNG testng.xml"]
the only thing works is commenting the browserStackLocal.stop() call. Is there a workaround that might help?
This is quite likely an issue related to --init(https://blog.phusion.nl/2015/01/20/docker-and-the-pid-1-zombie-reaping-problem).
Possible solution in this case would be to use tini (https://github.com/krallin/tini). Tini (commonly referred as tiny init) will take care of the reaping of child process.
Here is a working sample docker file for running Tini inside docker which should solve your concern:
FROM node:7.10.0
# Add Tini
ENV TINI_VERSION v0.14.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini
ENTRYPOINT ["/tini", "--"]
WORKDIR /app
COPY package.json /app
RUN ["npm", "install"]
COPY . /app
CMD ["npm", "test"]
You may modify the RUN and CMD commands based on your requirement