Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

Commit

Permalink
Implement option to deploy browser containers only on workers in a swarm
Browse files Browse the repository at this point in the history
  • Loading branch information
tstern authored and diemol committed Jun 28, 2019
1 parent 89c010c commit 4882d5a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/_posts/2000-01-06-docker-swarm.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ Make sure passing the network name with its stack name as prefix.
In our example we named our network "zalenium" and the stack was named "STACK" so the network
will have the name `"STACK_zalenium"`, which we passed to `"--swarmOverlayNetwork"`.

#### Options

If you want browser containers only deployed on workers set `SWARM_RUN_TESTS_ONLY_ON_WORKERS=1`
as environment variable.

### Technical Information

Expand All @@ -111,5 +115,14 @@ will happen that docker will remove a browser container with a running test to f
number of replicas.


### Known Errors

Executed tests run into following forwarding errors:
- `was terminated due to FORWARDING_TO_NODE_FAILED`
- `cannot forward the request unexpected end of stream on Connection`
The docker swarm seems to be overloaded. Try to reduce `--maxDockerSeleniumContainers` to unload
your docker swarm system. A good value is the number of all cpu cores available in the docker swarm.




Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class SwarmContainerClient implements ContainerClient {

private static final String ZALENIUM_SELENIUM_CONTAINER_CPU_LIMIT = "ZALENIUM_SELENIUM_CONTAINER_CPU_LIMIT";
private static final String ZALENIUM_SELENIUM_CONTAINER_MEMORY_LIMIT = "ZALENIUM_SELENIUM_CONTAINER_MEMORY_LIMIT";
private static final String SWARM_RUN_TESTS_ONLY_ON_WORKERS = "SWARM_RUN_TESTS_ONLY_ON_WORKERS";

private static final String SWARM_EXEC_IMAGE = "datagridsys/skopos-plugin-swarm-exec:latest";

Expand Down Expand Up @@ -270,6 +271,12 @@ private TaskSpec buildTaskSpec(ContainerSpec containerSpec) {
.restartPolicy(restartPolicy)
.containerSpec(containerSpec);

if ("1".equals(env.getEnvVariable(SWARM_RUN_TESTS_ONLY_ON_WORKERS))) {
final List<String> placementList = new ArrayList<>();
placementList.add("node.role==worker");
taskSpecBuilder.placement(Placement.create(placementList));
}

return taskSpecBuilder.build();
}

Expand Down

0 comments on commit 4882d5a

Please sign in to comment.