2

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?

Nick Slavsky
  • 1,300
  • 3
  • 19
  • 39

1 Answers1

1

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

BountyHunter
  • 1,413
  • 21
  • 35
  • Thanks! Running some checks now... I'm getting this warning "Tini is not running as PID 1 and isn't registered as a child subreaper..." Are you sure you don't need to add `-s` to the entrypoint? – Nick Slavsky May 14 '18 at 13:26
  • I am overriding the entry point since I am using a custom docker image. You may update it or leave it to default – BountyHunter May 14 '18 at 16:07