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

Commit 4882d5a

Browse files
tsterndiemol
authored andcommitted
Implement option to deploy browser containers only on workers in a swarm
1 parent 89c010c commit 4882d5a

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Diff for: docs/_posts/2000-01-06-docker-swarm.md

+13
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ Make sure passing the network name with its stack name as prefix.
9090
In our example we named our network "zalenium" and the stack was named "STACK" so the network
9191
will have the name `"STACK_zalenium"`, which we passed to `"--swarmOverlayNetwork"`.
9292

93+
#### Options
94+
95+
If you want browser containers only deployed on workers set `SWARM_RUN_TESTS_ONLY_ON_WORKERS=1`
96+
as environment variable.
9397

9498
### Technical Information
9599

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

113117

118+
### Known Errors
119+
120+
Executed tests run into following forwarding errors:
121+
- `was terminated due to FORWARDING_TO_NODE_FAILED`
122+
- `cannot forward the request unexpected end of stream on Connection`
123+
The docker swarm seems to be overloaded. Try to reduce `--maxDockerSeleniumContainers` to unload
124+
your docker swarm system. A good value is the number of all cpu cores available in the docker swarm.
125+
126+
114127

115128

Diff for: src/main/java/de/zalando/ep/zalenium/container/swarm/SwarmContainerClient.java

+7
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class SwarmContainerClient implements ContainerClient {
3232

3333
private static final String ZALENIUM_SELENIUM_CONTAINER_CPU_LIMIT = "ZALENIUM_SELENIUM_CONTAINER_CPU_LIMIT";
3434
private static final String ZALENIUM_SELENIUM_CONTAINER_MEMORY_LIMIT = "ZALENIUM_SELENIUM_CONTAINER_MEMORY_LIMIT";
35+
private static final String SWARM_RUN_TESTS_ONLY_ON_WORKERS = "SWARM_RUN_TESTS_ONLY_ON_WORKERS";
3536

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

@@ -270,6 +271,12 @@ private TaskSpec buildTaskSpec(ContainerSpec containerSpec) {
270271
.restartPolicy(restartPolicy)
271272
.containerSpec(containerSpec);
272273

274+
if ("1".equals(env.getEnvVariable(SWARM_RUN_TESTS_ONLY_ON_WORKERS))) {
275+
final List<String> placementList = new ArrayList<>();
276+
placementList.add("node.role==worker");
277+
taskSpecBuilder.placement(Placement.create(placementList));
278+
}
279+
273280
return taskSpecBuilder.build();
274281
}
275282

0 commit comments

Comments
 (0)