|
1 | 1 | # Compose |
2 | 2 | Scale up and down the nodes by using [docker-compose](https://docs.docker.com/compose/). |
3 | | -Install the tooling by following that link and make sure you have latest stable versions of both tools. |
4 | 3 |
|
5 | | -## Requisites |
6 | | -Docker and docker-compose: |
| 4 | +For using it by sharing the host (localhost) network interface see [share-host](./share-host.md) |
7 | 5 |
|
8 | | - docker --version #=> 1.11.2 |
9 | | - docker-compose --version #=> 1.7.1 |
| 6 | +For requirements check [README#requisites](../README.md#requisites) |
10 | 7 |
|
11 | 8 | ## Usage |
12 | | -Either clone this repository or download the file [docker-compose.yml](../docker-compose.yml) using `wget` |
| 9 | +Either clone this repository or download the file [docker-compose.yml][] using `wget` |
13 | 10 |
|
14 | 11 | wget -nv "https://raw.githubusercontent.com/elgalu/docker-selenium/master/docker-compose.yml" |
| 12 | + docker-compose -p selenium down #ensure is not already running |
15 | 13 |
|
16 | 14 | ### Run |
17 | | -Either start with `docker-compose ... scale` as shown in below example or you can also use `docker-compose up` and scale after in a second command. |
| 15 | +Start it with `docker-compose up` then **scale** it: |
18 | 16 |
|
19 | | - SELENIUM_HUB_PORT=4444 docker-compose -p selenium up -d |
20 | | - docker-compose -p selenium scale chrome=3 firefox=3 |
| 17 | + export SELENIUM_HUB_PORT=4444 NODES=3 |
| 18 | + docker-compose -p selenium up -d |
| 19 | + docker-compose -p selenium scale chrome=${NODES} firefox=${NODES} |
21 | 20 |
|
22 | 21 | Wait until the grid starts properly before starting the tests _(Optional but recommended)_ |
23 | 22 |
|
24 | | - docker-compose -p selenium exec -T --index=3 chrome wait_all_done 30s |
| 23 | + docker exec selenium_hub_1 wait_all_done 30s |
| 24 | + for ((i=1; i<=${NODES}; i++)); do |
| 25 | + docker-compose -p selenium exec -T --index=$i chrome wait_all_done 30s |
| 26 | + docker-compose -p selenium exec -T --index=$i firefox wait_all_done 30s |
| 27 | + done |
| 28 | + |
| 29 | +### Test |
| 30 | +You can now run your tests by using the `--seleniumUrl="http://localhost:4444/wd/hub"`. |
| 31 | + |
| 32 | +However if your web application under test is running in localhost, e.g. `--appHost=localhost` |
| 33 | +you should instead either dockerize your application and add it to the [docker-compose.yml][] file as another [service](https://docs.docker.com/compose/compose-file/#/service-configuration-reference) or somehow replace `--appHost=localhost` with `--appHost=d.host.loc.dev` in the config file of your testing framework. The string `d.host.loc.dev` is a place holder inside the docker container that points to the IP of your localhost. |
25 | 34 |
|
26 | 35 | ### Cleanup |
27 | | -The `down` compose command stops and remove containers, networks, volumes, and images created by `up` or `scale` |
| 36 | +Once your tests are done you can clean up: |
28 | 37 |
|
29 | 38 | docker-compose -p selenium down |
| 39 | + |
| 40 | +The `down` compose command stops and remove containers, networks, volumes, and images created by `up` or `scale` |
| 41 | + |
| 42 | +[docker-compose.yml]: ../docker-compose.yml |
0 commit comments