Docker for AWS and Selenium Grid - Connection refu

2019-06-03 08:53发布

What I am trying to achieve is a scalable and on-demand test infrastructure using Selenium Grid.

I can get everything up and running but what I end up with is this:

enter image description here

Here are all the pieces:

  1. Docker for AWS (CloudFormation Stack)
  2. docker-selenium
  3. Docker compose file (below)

The "implied" software used are:

Docker swarm

Stacks

Here is what I can accomplish:

  1. Create, log into, and ping all hosts & nodes within the stack, following the guidelines here: deploy Docker for AWS

  2. Deploy using the compose the file at the end of this inquiry by running:

    docker stack deploy -c docker-compose.yml grid
    
  3. View Selenium Grid console using the public facing DNS name automatically provided by AWS (upon successful creation of the stack). Here is a helpful entry on the subject: Docker Swarm Mode.

Here is are the contents of the compose file I am using:

version: '3'

services:
  hub:
    image: selenium/hub:3.4.0-chromium
    ports:
      - 4444:4444
    networks:
      - selenium
    environment:
      - JAVA_OPTS=-Xmx1024m
    deploy:
      update_config:
        parallelism: 1
        delay: 10s
      placement:
        constraints: [node.role == manager]

  chrome:
    image: selenium/node-chrome:3.4.0-chromium  
    networks:
      - selenium
    depends_on:
      - hub
    environment:
      - HUB_PORT_4444_TCP_ADDR=hub
      - HUB_PORT_4444_TCP_PORT=4444
    deploy:
    placement:
      constraints: [node.role == worker]

  firefox:
    image: selenium/node-firefox:3.4.0-chromium
    networks:
      - selenium
    depends_on:
      - hub
    environment:
      - HUB_PORT_4444_TCP_ADDR=hub
      - HUB_PORT_4444_TCP_PORT=4444
    deploy:
    placement:
      constraints: [node.role == worker]

networks:
  selenium:

Any guidance on this issue will be greatly appreciated. Thank you.

I have also tried opening up ports across the swarm:

swarm-exec docker service update --publish-add 5555:5555 gird

1条回答
太酷不给撩
2楼-- · 2019-06-03 09:02

A quick Google brought up https://github.com/SeleniumHQ/docker-selenium/issues/255. You need to add the following to the Chrome and Firefox nodes:

entrypoint: bash -c 'SE_OPTS="-host $$HOSTNAME" /opt/bin/entry_point.sh'

This is because the containers have two IP addresses in Swarm Mode and the nodes are picking up the wrong address and advertising that to the hub. This change will have the nodes advertise their hostname so the hub can find the nodes by DNS instead.

查看更多
登录 后发表回答