docker run -d -p 4444:4444 --name selenium-hub selenium/hub
docker run -d --link selenium-hub:hub -v /dev/shm:/dev/shm selenium/node-chrome
Ubuntu 16.04
after these 2 commands, I have successfully setup a selenium hub and a selenium node. however current maxSession of this node is set to 1, I need increase to 5. How can I do that?
Thanks.
I highly recommend you use a docker compose file.
Below is a simple example you can use.
Just change the MAX_SESSION and MAX_INSTANCES to what you need.
version: "3.1"
services:
hub:
image: selenium/hub
container_name: "hub"
ports:
- "4444:4444"
chrome:
image: selenium/node-chrome
volumes:
- /dev/shm:/dev/shm
shm_size: 2gb
depends_on:
- hub
environment:
- HUB_HOST=hub
- HUB_PORT=4444
- SCREEN_WIDTH=1920
- SCREEN_HEIGHT=1080
- NODE_MAX_INSTANCES=2
- NODE_MAX_SESSION=2
Related
I want to run selenum grid containers in GitLab. They would be: one selenium hub and two chrome node containers connected by a shared network. I know how to deploy those using a yaml file, but I have no idea how to start those containers in gitlab.
Ideally, the 3 cotainers would be started in pipleine, and then I would execute a script that would run some Selenium tests using the grid.
There's my yml file that would start selenium grid locally:
version: '3.7'
services:
selenium-1:
image: selenium/node-chrome:latest
shm_size: '2gb'
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
selenium-2:
image: selenium/node-chrome:latest
shm_size: '2gb'
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
selenium-hub:
image: selenium/hub:latest
expose:
- 4444
There's the script that would start the selenium tests:
#!/usr/bin/env bash
set -e
python -m pytest
The .gitlab-ci.yml I have so far:
stages:
- e2e
e2e:
stage: e2e
interruptible: false
services:
- selenium/hub:latest
- selenium/node-chrome:latest
script:
- bash run_test_page.sh
i basically use dind to run the compose file.
in the snippets below, i am trying to mention the essential bits, you can see a full project example here
also, i am using java and maven, not much change should be needed for python in your case
docker-compose used by the gitlab pipeline -
version: "3"
services:
selenium-chrome-01: &selenium-chrome
image: selenium/node-chrome:4.3.0-20220726
shm_size: 2gb
depends_on:
- selenium-hub
environment:
SE_EVENT_BUS_HOST: ${SELENIUM_SERVER_NAME}
SE_EVENT_BUS_PUBLISH_PORT: 4442
SE_EVENT_BUS_SUBSCRIBE_PORT: 4443
selenium-chrome-02:
<<: *selenium-chrome
selenium-hub:
image: selenium/hub:4.3.0-20220726
shm_size: 2gb
container_name: ${SELENIUM_SERVER_NAME}
ping:
image: alpine/curl
tests:
image: openjdk:11
working_dir: /app
volumes:
- ${CI_PROJECT_DIR}:/app
environment:
ENVIRONMENT: remote
SELENIUM_SERVER_URL: ${SELENIUM_SERVER_URL}
the compose file has 4 containers - 2 worker nodes, 1 hub, 1 to check the status of the hub, and 1 to run the tests
gitlab pipeline file -
stages:
- test
variables:
SELENIUM_SERVER_NAME: selenium
SELENIUM_SERVER_URL: http://${SELENIUM_SERVER_NAME}:4444
DOCKER_HOST: tcp://docker:2375
services:
- docker:20.10.16-dind
test:
stage: test
image: docker/compose
before_script:
- docker-compose up -d selenium-hub selenium-chrome-01 selenium-chrome-02
- sleep 10
- docker-compose run ping curl ${SELENIUM_SERVER_URL}/status
script:
- docker-compose run tests ./mvnw test -Dtest=TestClass
i think if you can configure shm_size on the gitlab runner's config, you can run the selenium grid as services which i feel is a better solution
I'm trying to use Jaeger to manage tracing system. Docker is running locally "all-in-one" image with application (on the same host) without any issues. My question is how to configure jaeger agent on host1 that would send traces jaeger collector on another host2. Host2 is configured with "all-in-one". I can see Jaeger UI on host2 but it doesn't seem getting any traces from host1.
Configure tracer:
var configuration = new Configuration("service-name")
.withSampler(Configuration.SamplerConfiguration.fromEnv())
.withReporter(Configuration.ReporterConfiguration.fromEnv());
GlobalTracer.registerIfAbsent(configuration.getTracer());
return openTracer;
Added environment variables in yaml file on host1:
-e JAEGER_AGENT_HOST=jaeger.hostname.com \
-e JAEGER_AGENT_PORT=6831 \
Added jaeger image in yaml file on host2:
$ docker run -d --name jaeger \
-p 5775:5775/udp \
-p 6831:6831/udp \
-p 6832:6832/udp \
-p 5778:5778 \
-p 16686:16686 \
-p 14268:14268 \
-p 9411:9411 \
jaegertracing/all-in-one:latest
Any suggestions will be appreciated.
In my case.
Host2
version: '2'
services:
hotrod:
image: jaegertracing/example-hotrod:1.28
ports:
- '8080:8080'
- '8083:8083'
command: ["-m","prometheus","all"]
environment:
- JAEGER_AGENT_HOST=jaeger-agent
- JAEGER_AGENT_PORT=6831
- JAEGER_SAMPLER_TYPE=remote
- JAEGER_SAMPLING_ENDPOINT=http://jaeger-agent:5778/sampling
depends_on:
- jaeger-agent
jaeger-collector:
image: jaegertracing/jaeger-collector:1.28
command:
- "--cassandra.keyspace=jaeger_v1_dc1"
- "--cassandra.servers=cassandra"
- "--collector.zipkin.host-port=9411"
- "--sampling.initial-sampling-probability=.5"
- "--sampling.target-samples-per-second=.01"
environment:
- SAMPLING_CONFIG_TYPE=adaptive
ports:
- "14269:14269"
- "14268:14268"
- "14250:14250"
- "9411:9411"
restart: on-failure
depends_on:
- cassandra-schema
jaeger-query:
image: jaegertracing/jaeger-query:1.28
command: ["--cassandra.keyspace=jaeger_v1_dc1", "--cassandra.servers=cassandra"]
ports:
- "16686:16686"
- "16687"
restart: on-failure
depends_on:
- cassandra-schema
jaeger-agent:
image: jaegertracing/jaeger-agent:1.28
command: ["--reporter.grpc.host-port=jaeger-collector:14250"]
ports:
- "5775:5775/udp"
- "6831:6831/udp"
- "6832:6832/udp"
- "5778:5778"
restart: on-failure
depends_on:
- jaeger-collector
cassandra:
image: cassandra:4.0
cassandra-schema:
image: jaegertracing/jaeger-cassandra-schema:1.28
depends_on:
- cassandra
host1 is
version: '2'
services:
jaeger-agent:
image: jaegertracing/jaeger-agent:1.28
command: ["--reporter.grpc.host-port=host2:14250"]
ports:
- "5775:5775/udp"
- "6831:6831/udp"
- "6832:6832/udp"
- "5778:5778"
restart: on-failure
it works well for me
I am trying to execute my selenium test on Jenkins node (Ubuntu) which has docker already installed. I added docker-compose build step plugin to my Jenkins project. When i try to build the project, I am getting an error in console -
$ docker-compose -f /home/jenkins/workspace/OM/TestWDM/docker-compose.yml up -d
Build step 'Docker Compose Build Step' changed build result to FAILURE
I am able to execute the project successfully on my local machine. I do have docker-compose.yml file in the root directory. I tried docker ps -a command just to see if it's partially . working, but it's not.
docker-compose file:
version: "3"
services:
selenium-hub:
restart: always
image: selenium/hub:latest
ports:
- "4444:4444"
#selenium-chrome
selenium-chrome:
restart: always
image: selenium/node-chrome-debug
stdin_open: true
links:
- selenium-hub:hub
#selenium-firefox
selenium-firefox:
restart: always
image: selenium/node-firefox-debug
links:
- selenium-hub:hub
chrome:
image: selenium/node-chrome
depends_on:
- selenium-hub
environment:
- HUB_PORT_4444_TCP_ADDR=selenium-hub
- HUB_PORT_4444_TCP_PORT=4444
firefox:
image: selenium/node-firefox
depends_on:
- selenium-hub
environment:
- HUB_PORT_4444_TCP_ADDR=selenium-hub
- HUB_PORT_4444_TCP_PORT=4444
The reason I am trying to use docker here because I was facing an issue with chrome binary not found without it. My expectation over here was to have my test run successfully on Jenkins node.
i want to launch 5 chrome and 5 firefox in docker container. I am using the below command but its giving the following error
The scale command is deprecated. Use the up command with the --scale flag instead.
ERROR: No such service: nodechrome
docker-compose scale nodechrome=5 nodefirefox=5
My docker-compose.yml file
version: '2'
services:
firefoxnode:
image: selenium/node-firefox-debug
volumes:
- /dev/shm:/dev/shm
depends_on:
- hub
environment:
HUB_HOST: hub
ports:
- "32772:5900"
chromenode:
image: selenium/node-chrome-debug
volumes:
- /dev/shm:/dev/shm
depends_on:
- hub
environment:
HUB_HOST: hub
ports:
- "32773:5900"
hub:
image: selenium/hub
ports:
- "4444:4444"
From where these names came? nodechrome and nodefirefox
Correct your command instead:
from:
docker-compose scale nodechrome=5 nodefirefox=5
to:
docker-compose scale chromenode=5 firefoxnode=5
Try this command:
docker-compose up --scale chrome=5
Verify the Grid by visiting: http://localhost:4444/ui/index.html#/
Refer: Documentation
I use Docker to start my Selenium grid in network_mode = "host" so that I can access my local development site.
Both the hub and node started, but when I check http://localhost:4444/grid/console, there's no node. I wonder if there is any way to solve it.
More info:
Image(s): hub, node-chrome-debug
Docker-Selenium Image Version(s): 3.14.0-arsenic
Docker Version: 18.06.0-ce, build 0ffa825
OS: Ubuntu 18.04
My docker-compose file:
version: "3"
services:
selenium-hub:
image: selenium/hub:latest
container_name: selenium-hub
network_mode: "host"
ports:
- "4444:4444"
chrome:
image: selenium/node-chrome-debug:latest
depends_on:
- selenium-hub
network_mode: "host"
ports:
- "5900:5900"
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444
Diego Molina figured out why it did not work.
It is because Chrome container will try to register to the name selenium-hub, which does not exist in the "host" network, and would only exist in the network that docker-compose creates.
To make it works, just set HUB_HOST=localhost.