diff --git a/docs/_posts/2000-01-06-docker-swarm.md b/docs/_posts/2000-01-06-docker-swarm.md index 35d1a678ff..ba6ac547d4 100644 --- a/docs/_posts/2000-01-06-docker-swarm.md +++ b/docs/_posts/2000-01-06-docker-swarm.md @@ -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 @@ -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. + + diff --git a/src/main/java/de/zalando/ep/zalenium/container/swarm/SwarmContainerClient.java b/src/main/java/de/zalando/ep/zalenium/container/swarm/SwarmContainerClient.java index 218948538a..1e066aacab 100644 --- a/src/main/java/de/zalando/ep/zalenium/container/swarm/SwarmContainerClient.java +++ b/src/main/java/de/zalando/ep/zalenium/container/swarm/SwarmContainerClient.java @@ -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"; @@ -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 placementList = new ArrayList<>(); + placementList.add("node.role==worker"); + taskSpecBuilder.placement(Placement.create(placementList)); + } + return taskSpecBuilder.build(); }