Skip to content

README improvements and fixes #803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 44 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Images included:
- __selenium/standalone-chrome-debug__: Selenium Standalone with Chrome installed and runs a VNC server
- __selenium/standalone-firefox-debug__: Selenium Standalone with Firefox installed and runs a VNC server

##
##

## Running the images
:exclamation: When executing `docker run` for an image with Chrome or Firefox please either mount `-v /dev/shm:/dev/shm` or use the flag `--shm-size=2g` to use the host's shared memory.
Expand Down Expand Up @@ -78,7 +78,7 @@ When you are done using the grid and the containers have exited, the network can
``` bash
# Remove all unused networks
$ docker network prune
# OR
# OR
# Removes the grid network
$ docker network rm grid
```
Expand Down Expand Up @@ -146,10 +146,43 @@ services:

To stop the grid and cleanup the created containers, run `docker-compose down`.

##### Version 3 with Swarm support
```yaml
# To start Docker in Swarm mode, you need to run `docker swarm init`
# To deploy the Grid, `docker stack deploy -c docker-compose.yml grid`
# Stop with `docker stack rm grid`

version: '3.7'

services:
hub:
image: selenium/hub:3.14.0-francium
ports:
- "4444:4444"

chrome:
image: selenium/node-chrome:3.14.0-francium
environment:
HUB_HOST: hub
HUB_PORT: 4444
deploy:
replicas: 1
entrypoint: bash -c 'SE_OPTS="-host $$HOSTNAME" /opt/bin/entry_point.sh'

firefox:
image: selenium/node-firefox:3.14.0-francium
environment:
HUB_HOST: hub
HUB_PORT: 4444
deploy:
replicas: 1
entrypoint: bash -c 'SE_OPTS="-host $$HOSTNAME" /opt/bin/entry_point.sh'
```

#### Using `--link`
This option can be used for a single host scenario (hub and nodes running in a single machine), but it is not recommended
for longer term usage since this is a docker [legacy feature](https://docs.docker.com/compose/compose-file/#links).
It could serve you as an option for a proof of concept, and for simplicity it is used in the examples shown from now on.
It could serve you as an option for a proof of concept, and for simplicity it is used in the examples shown from now on.

``` bash
$ docker run -d -p 4444:4444 --name selenium-hub selenium/hub:3.14.0-francium
Expand Down Expand Up @@ -188,16 +221,16 @@ or `REMOTE_HOST` can be used.
You can pass the `HUB_HOST` and `HUB_PORT` options to provide the hub address to a node when needed.

``` bash
# Assuming a hub was already started
# Assuming a hub was already started on the default port
$ docker run -d -e HUB_HOST=<hub_ip|hub_name> -e HUB_PORT=4444 selenium/node-chrome:3.14.0-francium
```

Some network topologies might prevent the hub to reach the node through the url given at registration time, `REMOTE_HOST`
can be used to supply the hub a url where the node is reachable under your specific network configuration
can be used to supply the hub a url where the node is reachable under your specific network configuration

``` bash
# Assuming a hub was already started
$ docker run -d -e HUB_HOST=<hub_ip|hub_name> -e REMOTE_HOST="http://node_ip|node_name:node_port" selenium/node-firefox:3.14.0-francium
# Assuming a hub was already started on the default port
$ docker run -d -p <node_port>:5555 -e HUB_HOST=<hub_ip|hub_name> -e HUB_PORT=4444 -e REMOTE_HOST="http://<node_ip|node_name>:<node_port>" selenium/node-firefox:3.14.0-francium
```

### Setting Screen Resolution
Expand All @@ -214,7 +247,7 @@ By default, each image will only allow one slot per container, which is what we
container resources and variables will be used for that browser, and this helps to have more stable tests.

Nevertheless, if you would like to have more slots per node, this can be configured via environment variables with the
environment variable `NODE_MAX_INSTANCES`. For example, a Firefox node with 5 slots:
environment variable `NODE_MAX_INSTANCES`. For example, a Firefox node with 5 slots:

``` bash
# Assuming a hub was already started
Expand Down Expand Up @@ -303,7 +336,7 @@ A Grid that is ready, composed by a hub and a node, could look like this:
}
```

The `"ready": true` value indicates that the Grid is ready to receive requests. This status can be polled through a
The `"ready": true` value indicates that the Grid is ready to receive requests. This status can be polled through a
script before running any test, or it can be added as a [HEALTHCHECK](https://docs.docker.com/engine/reference/run/#healthcheck)
when the docker container is started.

Expand Down Expand Up @@ -359,15 +392,15 @@ done
exec $cmd
```
**Note:** If needed, replace `localhost` and `4444` for the correct values in your environment. Also, this script is polling indefinitely, you might want
to tweak it and establish a timeout.
to tweak it and establish a timeout.

Let's say that the normal command to execute your tests is `mvn clean test`. Here is a way to use the above script and execute your tests:

```bash
$ ./wait-for-grid.sh mvn clean test
```

Like this, the script will poll until the Grid is ready, and then your tests will start.
Like this, the script will poll until the Grid is ready, and then your tests will start.

## Debugging

Expand Down