Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to access a service from another service in Pipelines ?

Alexandre LAHURE October 26, 2017

Hi all,

I use a selenium grid to run end-to-end tests, so I use 3 services in BitBucket Pipelines :

  • selenium/hub
  • selenium/node-chrome
  • selenium/node-firefox

I understand that the hub service will be accessible at localhost:4444 from the main container, but what about the other service containers ?

I tried the following values for HUB_PORT_4444_TCP_ADDR:

  • localhost
  • hub

...without success.

The hub log show the following message :

Nodes should register to http://10.244.107.3:4444/grid/register/

Obviously I have no way to guess the dynamically attributed IP address of this service container. Maybe there is a secret environment variable ?

Here is the full content of my bitbucket-pipelines.yml for your viewing pleasure.

image: mrjoops/node:latest

pipelines:
  branches:
    feature/*:
      - step:
          caches:
            - node
          name: Run tests
          script:
            - make install
            - make SELENIUM_HOST=localhost test
          services:
            - chrome
            - firefox
            - hub
    hotfix/*:
      - step:
          caches:
            - node
          name: Run tests
          script:
            - make install
            - make SELENIUM_HOST=localhost test
          services:
            - chrome
            - firefox
            - hub
definitions:
  services:
    chrome:
      environment:
        HUB_PORT_4444_TCP_ADDR: hub
        HUB_PORT_4444_TCP_PORT: 4444
      image: selenium/node-chrome
    firefox:
      environment:
        HUB_PORT_4444_TCP_ADDR: hub
        HUB_PORT_4444_TCP_PORT: 4444
      image: selenium/node-firefox
    hub:
      image: selenium/hub

Note that I have a similar and working config with Docker Compose.

Thank you in advance for your answers.

2 answers

1 accepted

2 votes
Answer accepted
Alexandre LAHURE December 11, 2017

Thanked to the Atlassian Support Team, I managed to solve the issue.

Here is a working services definition :

definitions:
  services:
    chrome:
      environment:
        HUB_PORT_4444_TCP_ADDR: localhost
        HUB_PORT_4444_TCP_PORT: 4444
      image: selenium/node-chrome
    firefox:
      environment:
        DISPLAY: :88
        HUB_PORT_4444_TCP_ADDR: localhost
        HUB_PORT_4444_TCP_PORT: 4444
        SE_OPTS: -port 5556
      image: selenium/node-firefox
    hub:
      environment:
        SE_OPTS: -host 127.0.0.1
      image: selenium/hub

In short you have to tell Selenium to run on localhost (and use the SE_OPTS env var for hub), and since everything run on localhost in BitBucket Pipelines, you have to ensure there aren't any port conflict between the services (and map either chrome or firefox on different ports).

That said, this leads to a configuration where you only have 1Gb per service, and dockerized Firefox have known issues regarding "low" memory management (I have to run docker with shm_size: 2g for FF to work), so I couldn't run my E2E tests on both browsers : Firefox dies silently shortly after beginning the test suite.

Hopefully the memory issue in Firefox will be solved one day (:fingers_crossed:) and this configuration will work !

0 votes
Deleted user December 11, 2017

I understand that the hub service will be accessible at localhost:4444 from the main container, but what about the other service containers ?

You need to use localhost as well for these, so in your bitbucket-pipelines.yml

environment:
        HUB_PORT_4444_TCP_ADDR: hub
        HUB_PORT_4444_TCP_PORT: 4444

should be

environment:
        HUB_PORT_4444_TCP_ADDR: localhost
        HUB_PORT_4444_TCP_PORT: 4444 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events