aerokube / selenoid

Selenium Hub successor running browsers within containers. Scalable, immutable, self hosted Selenium-Grid on any platform with single binary.
https://aerokube.com/selenoid/latest/
Apache License 2.0
2.57k stars 322 forks source link

[Help needed] selenoid nodes are not connected with ggr #1268

Closed HarryFree closed 1 year ago

HarryFree commented 1 year ago

Hi, I have two Linux servers, one is hosted as ggr + selenoid and another machine with selenoid.

host 1

  1. test.xml file
  2. browsers.json
  3. selenoid, selenoid ui, ggr, ggr-ui using docker-compose

test.xml file

<qa:browsers xmlns:qa="urn:config.gridrouter.qatools.ru">
<browser name="chrome" defaultVersion="100.0">
    <version number="100.0">
        <region name="1">
            <host name="ip1" port="4444" count="1"/>
            <host name="ip2" port="4444" count="1"/>
        </region>
    </version>
</browser>
</qa:browsers>

browsers.json

{
  "chrome": {
    "default": "105.0",
    "versions": {
      "105.0": {
        "image": "selenoid/vnc_chrome:105.0",
        "port": "4444",
        "path": "/",
        "env": [
          "TZ=Asia/Singapore"
        ],
        "screen": "1920x1080x24",
        "volumes": [
          "./resources/videos:/opt/docker/video"
        ]
      }
    }
  }
}

run docker compose up to start selenoid & chrome containers in both host 1 & 2

version: '3.8'
services:
  selenoid:
    container_name: selenoid
    image: aerokube/selenoid:latest
    restart: unless-stopped
    network_mode: bridge
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "/etc/selenoid/video/:/opt/selenoid/video/"
      - "/etc/selenoid/logs/:/opt/selenoid/logs/"
      - "/etc/selenoid/config/:/opt/selenoid/config/"
      - "./core/browser-config/:/etc/selenoid/"
      - "./resources/videos/:/etc/selenoid/videos/"
    environment:
      #- OVERRIDE_VIDEO_OUTPUT_DIR=$PWD
      - TZ=Asia/Singapore
    command:
      [
        "-conf",
        "/etc/selenoid/browsers.json",
        "-limit",
        "8",
        "-timeout",
        "20m",
        "-video-output-dir",
        "/etc/selenoid/video",
        "-log-output-dir",
        "/etc/selenoid/logs",
        "-save-all-logs"
      ]
    ports:
      - 4444:4444

  chrome:
    container_name: chrome
    image: selenoid/vnc_chrome:105.0
    depends_on:
      - selenoid
    links:
      - selenoid
    volumes:
      - "/dev/shm:/dev/shm"
    ports:
      - 4446:4444

then on host1 start selenoid ui, ggr, ggr-ui

version: "3.8"
services:
  selenoid-ui:
    container_name: selenoid-ui
    image: aerokube/selenoid-ui:latest
    restart: unless-stopped
    network_mode: bridge
    external_links:
      - selenoid
    ports:
      - 8080:8080
    command: [ "--selenoid-uri", "http://selenoid:4444" ]

  ggr:
    container_name: ggr
    image: aerokube/ggr:latest
    restart: unless-stopped
    network_mode: bridge
    volumes:
      - "/etc/grid-router/:/etc/grid-router/:ro"
    external_links:
      - selenoid
    ports:
      - 4445:4444

  ggr-ui:
    container_name: ggr-ui
    image: aerokube/ggr-ui:latest
    restart: unless-stopped
    network_mode: bridge
    volumes:
      - "/etc/grid-router/:/etc/grid-router/:ro"
    external_links:
      - selenoid
    depends_on:
      - ggr
    ports:
      - 8888:8888

when i ping the status in both host machines respond but when i check the status on selenoid ui, it shows only 8 quota

http://ip1:4444/status

{
"total": 8,
"used": 0,
"queued": 0,
"pending": 0,
"browsers": {
"chrome": {
"100.0": {}
}
}
}

http://ip2:4444/status

{
"total": 8,
"used": 0,
"queued": 0,
"pending": 0,
"browsers": {
"chrome": {
"100.0": {}
}
}
}

but on http://ip1:8080/#/ it shows 8 instead of 16. what am i doing wrong here... could someone help

image

vania-pooh commented 1 year ago

@HarryFree should be command: [ "--selenoid-uri", "http://ggr-ui:8888 ] https://aerokube.com/selenoid-ui/latest/#_using_with_ggr_or_moon

HarryFree commented 1 year ago

@vania-pooh thanks for your message. I tried to replace it but got an issue on selenoid-ui

selenoid-ui:
    container_name: selenoid-ui
    image: aerokube/selenoid-ui:latest
    restart: unless-stopped
    network_mode: bridge
    external_links:
      - selenoid
    ports:
      - 8080:8080
    command: [ "--selenoid-uri", "http://ggr-ui:8888" ]

error

2022/09/26 09:03:44 [INIT] [Listening on :8080]
2022/09/26 09:03:46 Client added. 1 registered clients
2022/09/26 09:03:49 [ERROR] [Can't get status: Get "http://ggr-ui:8888/status": dial tcp: lookup ggr-ui on 192.168.65.5:53: no such host]
2022/09/26 09:03:54 [ERROR] [Can't get status: Get "http://ggr-ui:8888/status": dial tcp: lookup ggr-ui on 192.168.65.5:53: no such host]
2022/09/26 09:03:59 [ERROR] [Can't get status: Get "http://ggr-ui:8888/status": dial tcp: lookup ggr-ui on 192.168.65.5:53: no such host]
vania-pooh commented 1 year ago

@HarryFree probably you also need to add ggr-ui to links for selenoid-ui:

    external_links:
      - ggr-ui

This is not related to our tools, this is how Docker works.

HarryFree commented 1 year ago

@vania-pooh I have single docker-compose to run selenoid-ui, ggr and ggr-ui so i added links: - ggr-ui but got an error

version: "3.8"
services:
  selenoid-ui:
    container_name: selenoid-ui
    image: aerokube/selenoid-ui:latest
    restart: unless-stopped
    network_mode: bridge
    external_links:
      - selenoid
    ports:
      - 8080:8080
    links:
      - ggr-ui
    command: [ "--selenoid-uri", "http://ggr-ui:8888" ]
    # command: [ "--selenoid-uri", "http://selenoid:4444" ]

  ggr:
    container_name: ggr
    image: aerokube/ggr:latest
    restart: unless-stopped
    network_mode: bridge
    volumes:
      - "/etc/grid-router/:/etc/grid-router/:ro"
    external_links:
      - selenoid
    ports:
      - 4445:4444

  ggr-ui:
    container_name: ggr-ui
    image: aerokube/ggr-ui:latest
    restart: unless-stopped
    network_mode: bridge
    volumes:
      - "/etc/grid-router/:/etc/grid-router/:ro"
    external_links:
      - selenoid
    depends_on:
      - ggr
    ports:
      - 8888:8888

error

2022/09/26 09:20:11 [ERROR] [Can't get status: invalid character 'B' looking for beginning of value]
2022/09/26 09:20:16 [ERROR] [Can't get status: invalid character 'B' looking for beginning of value]
2022/09/26 09:20:21 [ERROR] [Can't get status: invalid character 'B' looking for beginning of value]
HarryFree commented 1 year ago

@vania-pooh I followed your link and it is working fine

https://github.com/aerokube/selenoid-ui/issues/391#issuecomment-724711318

Thank you