Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Networking between services and job script in a gitlab-ci files

I have this job in my ci runner. It works if I use Selenium-Standalone-Chrome. But Was trying to get Hubs and Nodes working so I can test more browsers. But I'm having trouble getting the services to connect to each other.

verify_last_chrome_func:
  image: python:2.7
  stage: test_integration
  variables:
    # Grid Options
    GRID_TIMEOUT: '300000'
    SHM_SIZE: '512MB'
    GRID_BROWSER_TIMEOUT: '300000'
    GRID_NEW_SESSION_WAIT_TIMEOUT: '300000'
    GRID_MAX_SESSION: '20'
    # Node Options
    HUB_PORT_4444_TCP_ADDR: 'selenium_hub'
    # HUB_PORT_4444_TCP_ADDR: '172.17.0.4' # This works if I can guess what the address will be. 
    HUB_PORT_4444_TCP_PORT: '4444'
  services:
    - name: selenium/hub:3.9.1-actinium
      alias: selenium_hub
    - name: selenium/node-chrome:3.9.1-actinium
      alias: current_chrome_node
  script:
    - SELENIUM_HUB_ADRESS="http://selenium_hub:4444/wd/hub" python /example_test.py

From their docs it really seems like I should be able to network to the hub with selenium_hub or selenium-hub or by setting the alias to something other than selenium_hub and using that name. But none of those seem to be working for HUB_PORT_4444_TCP_ADDR which the node needs to attach to the hub, instead it errors with Registering the node to the hub: http://selenium_hub:4444/grid/register Couldn't register this node: Error sending the registration request: selenium_hub: Name or service not known Couldn't register this node: The hub is down or not responding: selenium_hub: Name or service not known

And then I would need it for the example environmental variable SELENIUM_HUB_ADRESS="http://selenium_hub:4444/wd/hub" in the command/script option is running.

like image 999
Cynic Avatar asked Nov 20 '25 20:11

Cynic


1 Answers

By default Gitlab uses the old linking of containers for networking, this means that only the build container can access the service containers.

You can use the network per build feature flag in your case your yaml would look like this:

verify_last_chrome_func:
  image: python:2.7
  stage: test_integration
  variables:
    # Enable network connection between services
    FF_NETWORK_PER_BUILD: 1
    # Grid Options
    GRID_TIMEOUT: '300000'
    SHM_SIZE: '512MB'
    GRID_BROWSER_TIMEOUT: '300000'
    GRID_NEW_SESSION_WAIT_TIMEOUT: '300000'
    GRID_MAX_SESSION: '20'
    # Node Options
    HUB_PORT_4444_TCP_ADDR: 'selenium_hub'
    # HUB_PORT_4444_TCP_ADDR: '172.17.0.4' # This works if I can guess what the address will be. 
    HUB_PORT_4444_TCP_PORT: '4444'
  services:
    - name: selenium/hub:3.9.1-actinium
      alias: selenium_hub
    - name: selenium/node-chrome:3.9.1-actinium
      alias: current_chrome_node
  script:
    - SELENIUM_HUB_ADRESS="http://selenium_hub:4444/wd/hub" python /example_test.py
like image 174
Rwky Avatar answered Nov 23 '25 15:11

Rwky



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!