From 21c7d423e4c5083449b2422471c0b92956549a0b Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Fri, 6 Mar 2015 17:39:36 -0800 Subject: [PATCH] integration: Add constraints integration tests. Signed-off-by: Andrea Luzzardi --- test/integration/constraints.bats | 57 +++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 test/integration/constraints.bats diff --git a/test/integration/constraints.bats b/test/integration/constraints.bats new file mode 100644 index 0000000000..72a89fa872 --- /dev/null +++ b/test/integration/constraints.bats @@ -0,0 +1,57 @@ +#!/usr/bin/env bats + +load helpers + +function teardown() { + stop_manager + stop_docker +} + +@test "node constraint" { + start_docker 2 + start_manager + + run docker_swarm run --name c1 -e constraint:node==node-0 -d busybox:latest sh + [ "$status" -eq 0 ] + run docker_swarm run --name c2 -e constraint:node==node-1 -d busybox:latest sh + [ "$status" -eq 0 ] + run docker_swarm run --name c3 -e constraint:node==node-1 -d busybox:latest sh + [ "$status" -eq 0 ] + + run docker_swarm inspect c1 + [ "$status" -eq 0 ] + [[ "${output}" == *'"Name": "node-0"'* ]] + + run docker_swarm inspect c2 + [ "$status" -eq 0 ] + [[ "${output}" == *'"Name": "node-1"'* ]] + + run docker_swarm inspect c3 + [ "$status" -eq 0 ] + [[ "${output}" == *'"Name": "node-1"'* ]] +} + +@test "label constraints" { + start_docker 1 --label foo=a + start_docker 1 --label foo=b + start_manager + + run docker_swarm run --name c1 -e constraint:foo==a -d busybox:latest sh + [ "$status" -eq 0 ] + run docker_swarm run --name c2 -e constraint:foo==b -d busybox:latest sh + [ "$status" -eq 0 ] + run docker_swarm run --name c3 -e constraint:foo==b -d busybox:latest sh + [ "$status" -eq 0 ] + + run docker_swarm inspect c1 + [ "$status" -eq 0 ] + [[ "${output}" == *'"Name": "node-0"'* ]] + + run docker_swarm inspect c2 + [ "$status" -eq 0 ] + [[ "${output}" == *'"Name": "node-1"'* ]] + + run docker_swarm inspect c3 + [ "$status" -eq 0 ] + [[ "${output}" == *'"Name": "node-1"'* ]] +}