How to get rid of Connection refused error while running tests

selenium
docker
python

#1

Hi all!
I need a help in configuring my tests and config files for my tests. I’m new to CircleCi and automation testing and cannot adjust all the stuff propperly :frowning:

Erlier we had our e2e tests running in Gitlab on the remote machine in Docker. All the set up was made by other collague. Now we decided to move to CircleCi and I try to make our tests run again. Unfortunatelly, I get the same error evety time
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='51.15.52.174', port=4444): Max retries exceeded with url: /wd/hub/session (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9d88d71048>: Failed to establish a new connection: [Errno 111] Connection refused',))

To make it more clear here is my config.yml

    version: 2
   jobs:
      e2e_tests:
        working_directory: ~/
        docker:
          - image: circleci/python:3.6
        steps:
          - setup_remote_docker:
              docker_layer_caching: true
          - run:
              name: install selenoid server
              command: |
                curl -s https://aerokube.com/cm/bash | bash \
                && ./cm selenoid start --vnc \
                && docker run -d --name selenoid-ui  \
                    -p 8080:8080                     \
                    --link selenoid                 \
                    aerokube/selenoid-ui --selenoid-uri=http://selenoid:4444 \
                && sleep 20

     - run:
          name: checkout
          command: git clone https://xxxxxxxxxxxxxx@github.com/paulcamper/e2e-test

     - run:
         name: install deps
          command: sudo pip install pytest pytest-xdist httplib2 beautifulsoup4 pytest-rerunfailures pytest-html requests selenium six faker
          working_directory: e2e-test

      - run:
          name: create folder for reports
          command: mkdir test-reports

     - run:
          name: test user creation
          command: |
           py.test --html=login_tests.html --self-contained-html -n 5 --reruns 5 test_login.py
           py.test --html=signup_tests.html --self-contained-html -n 5 --reruns 5 test_signup.py
          working_directory: e2e-test/TESTS/USER

      - store_test_results:
          path: test-reports/

      `- store_artifacts:`
          `path: test-reports/`

`workflows:`
 ` version: 2`
  `e2e_tests:`
   ` jobs:`
     ` - e2e_tests:`
         ` filters:`
            `branches:`
              `only: master`

And here is my driver config: http://joxi.ru/82Qe5oEcjBnkJ2
While running tests I use remote driver from my DriverConfigurator and get the error about Connection refused.

I do not understand what is wrong with my config files so I would highly appreciate if someone can help me:slightly_smiling_face:


#2

The problem is your port numbers - you cannot do that in the Docker environment. You are in Docker already, and when you do docker run you are setting up “Docker in Docker”. That is fine in itself, but your outer-level Docker does not have sufficient permissions to expose external ports.

You have a couple of options though:

  • Run it as a secondary image in the docker section where you do have permissions to expose ports
  • Run it in a Docker Compose where the thing that connects to the server runs in another container (all networking is internal, and so you do not need to expose any ports).