forked from docker-archive/classicswarm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconstraints.bats
89 lines (71 loc) · 2.46 KB
/
constraints.bats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env bats
load helpers
function teardown() {
swarm_manage_cleanup
stop_docker
}
@test "node constraint" {
start_docker_with_busybox 2
swarm_manage
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 run --name c4 --label 'com.docker.swarm.constraints=["node==node-1"]' -d busybox:latest sh
[ "$status" -eq 0 ]
run docker_swarm inspect c1
# FIXME: This will help debugging the failing test.
echo $output
[ "$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"'* ]]
run docker_swarm inspect c4
[ "$status" -eq 0 ]
[[ "${output}" == *'"Name": "node-1"'* ]]
}
@test "soft constraint" {
start_docker_with_busybox 2
swarm_manage
docker_swarm run --name c1 -e constraint:storagedriver==~not_exist -e constraint:node==node-0 -d busybox:latest sh
docker_swarm run --name c2 -e constraint:storagedriver==~not_exist -e constraint:node==node-0 -d busybox:latest sh
run docker_swarm inspect c1
[ "$status" -eq 0 ]
[[ "${output}" == *'"Name": "node-0"'* ]]
run docker_swarm inspect c2
[ "$status" -eq 0 ]
[[ "${output}" == *'"Name": "node-0"'* ]]
}
@test "label constraints" {
start_docker_with_busybox 1 --label foo=a
start_docker_with_busybox 1 --label foo=b
swarm_manage
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 run --name c4 --label 'com.docker.swarm.constraints=["foo==b"]' -d busybox:latest sh
[ "$status" -eq 0 ]
run docker_swarm inspect c1
# FIXME: This will help debugging the failing test.
echo $output
[ "$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"'* ]]
run docker_swarm inspect c4
[ "$status" -eq 0 ]
[[ "${output}" == *'"Name": "node-1"'* ]]
}