0
votes

I am writing gitlab-ci.yml to enable check result e2e test on Gitlab: Step 1: Run “docker-compose up -d” Step 2: Run “gradle test –info” The following current gitlab-ci.yml file (02 job with 02 image):

build:
  stage: build
  image: docker/compose:latest
  services:
    - name: docker:dind
    #- name: gradle:5.4.1
  script:
    - docker-compose version 
    - docker-compose up -d
    #- gradle test --info
    #- docker compose down
test:
  image: gradle:alpine
  #stage: test
  script:
  - gradle -v
  - gradle test --info

The following docker-compose.yaml file:

services:
  selenium-hub:
    image: selenium/hub:3.141.59-20200409
    container_name: selenium-hub
    ports:
      - "4444:4444"
  chrome:
    image: selenium/node-chrome-debug:3.141.59-20200409
    volumes:
      - /dev/shm:/dev/shm
    depends_on:
      - selenium-hub
    environment:
      - HUB_HOST=selenium-hub
      - HUB_PORT=4444
    ports:
      - "5900:5900"

When i run pipeline and throws exception:

Driver info: driver.version: RemoteWebDriver Caused by:java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:4444 I run successfully in locally. But on Gitlab runner, seems selenium/hub container not started when run gradle test. Please tell me how to use configuration run 1 job with multi image. Many thanks

1

1 Answers

0
votes

Add network to the docker-compose or use bridge.

Example:

services:
  selenium-hub:
    image: selenium/hub:3.141.59-20200409
    container_name: selenium-hub
    ports:
      - "4444:4444"
    networks:
      - selenium
  chrome:
    image: selenium/node-chrome-debug:3.141.59-20200409
    volumes:
      - /dev/shm:/dev/shm
    depends_on:
      - selenium-hub
    environment:
      - HUB_HOST=selenium-hub
      - HUB_PORT=4444
    ports:
      - "5900:5900"
    networks:
      - selenium
networks:
    selenium:
        name: selenium-network
        driver: bridge