-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Affinity labels like -e affinity:com.example.type==test
#667
Changes from all commits
4f6df97
f388d70
28a358d
77f0ac9
a2dc4b8
dce5d6f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| #!/usr/bin/env bats | ||
|
|
||
| load helpers | ||
|
|
||
| function teardown() { | ||
| swarm_manage_cleanup | ||
| stop_docker | ||
| } | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you mind adding an image affinity test since you already made most of the work?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| @test "container affinty" { | ||
| start_docker 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 affinity:container==c1 -d busybox:latest sh | ||
| [ "$status" -eq 0 ] | ||
| run docker_swarm run --name c3 -e affinity:container!=c1 -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-0"'* ]] | ||
|
|
||
| run docker_swarm inspect c3 | ||
| [ "$status" -eq 0 ] | ||
| [[ "${output}" != *'"Name": "node-0"'* ]] | ||
| } | ||
|
|
||
| @test "image affinity" { | ||
| start_docker 2 | ||
| swarm_manage | ||
|
|
||
| run docker -H ${HOSTS[0]} pull busybox | ||
| [ "$status" -eq 0 ] | ||
| run docker_swarm run --name c1 -e affinity:image==busybox -d busybox:latest sh | ||
| [ "$status" -eq 0 ] | ||
| run docker_swarm run --name c2 -e affinity:image!=busybox -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-0"'* ]] | ||
| } | ||
|
|
||
| @test "label affinity" { | ||
| start_docker 2 | ||
| swarm_manage | ||
|
|
||
| run docker_swarm run --name c1 --label test.label=true -e constraint:node==node-0 -d busybox:latest sh | ||
| [ "$status" -eq 0 ] | ||
| run docker_swarm run --name c2 -e affinity:test.label==true -d busybox:latest sh | ||
| [ "$status" -eq 0 ] | ||
| run docker_swarm run --name c3 -e affinity:test.label!=true -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-0"'* ]] | ||
|
|
||
| run docker_swarm inspect c3 | ||
| [ "$status" -eq 0 ] | ||
| [[ "${output}" != *'"Name": "node-0"'* ]] | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A tiny bit unsure about the effect on the regex:
.is supposed to mean any character.Is this being interpreted as a dot or as any character and do we need to escape it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll test, but I'm not sure it counts as
any charwhen it's within[]There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good to me