Search code examples
dockerselenium-gridzalenium

Run Zalenium Tests from another Docker instance


For our automated testing purposes, I am trying to run UI tests using the Zalenium Docker system.

The tests execute on a Jenkins slave, and are executed from a Pipeline script:

docker run --rm --name zalenium --detach -p 4444:4444 -v /var/run/docker.sock:/var/run/docker.sock -v /tmp/videos:/home/seluser/videos --privileged dosel/zalenium start"

I then use another Docker container to execute the tests:

docker run --privileged --rm --volume=${workingDirectory}:/volume/git --workdir='/volume/git' some-container-name:0.1 mvn -f /project/pom.xml clean test -Dselenium.hub='http://localhost:4444'

When I execute the tests, I see the following error:

    Tests run: 3, Failures: 2, Errors: 0, 
    Skipped: 1, Time elapsed: 1.824  sec <<< FAILURE!
     - in TestSuite setupBrowser(com.skybet.myaccount.login.usingCorrectDetails)  Time elapsed: 1.108 sec  <<< FAILURE!
org.openqa.selenium.remote.UnreachableBrowserException:  
 Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T18:33:54.468Z' 
System info: host: '96a52140dee0', ip: 'X.X.X.X', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-693.5.2.el7.x86_64', java.version: '1.8.0_151' Driver info: driver.version: RemoteWebDriver Caused by: org.apache.http.conn.HttpHostConnectException: Connect to
    127.0.0.1:4444 [/127.0.0.1] failed: Connection refused (Connection refused) Caused by: java.net.ConnectException: Connection refused (Connection    refused)

I'm not really sure what the correct address should be. Any ideas?


Solution

  • I've found that the solution to my issue is to use the --link command, so I could link the Docker instance which executes my tests, to the Zalenium instance which hosts the grid system:

    docker run --privileged --name stg-selenium-client --rm=true --link zalenium:hub hub.platformservices.io/sbg_core_automation/core-test-runner-with-maven-dependencies:0.12 mvn -f /project/pom.xml test -P ui -Denvironment=test5 -Dgroups=smoketest -Dbrowser.name=chrome -Dselenium.hub=hub:4444