From 967a98d40fcc37f5db972f913e256590fb8e84e3 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Thu, 28 Jan 2016 13:07:25 -0800 Subject: [PATCH] fix unit test and add integration test Signed-off-by: Victor Vieux --- cluster/image_test.go | 8 ++++---- test/integration/affinities.bats | 22 ++++++++++++++++++++-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/cluster/image_test.go b/cluster/image_test.go index 2648664a4d..a07185734c 100644 --- a/cluster/image_test.go +++ b/cluster/image_test.go @@ -126,19 +126,19 @@ func TestImagesFilterWithNameFilterWithTag(t *testing.T) { func TestParseRepositoryTag(t *testing.T) { - repo, tag := parseRepositoryTag("localhost.localdomain:5000/samalba/hipache:latest") + repo, tag := ParseRepositoryTag("localhost.localdomain:5000/samalba/hipache:latest") if tag != "latest" { t.Errorf("repo=%s tag=%s", repo, tag) } - repo, tag = parseRepositoryTag("localhost:5000/foo/bar@sha256:bc8813ea7b3603864987522f02a76101c17ad122e1c46d790efc0fca78ca7bfb") + repo, tag = ParseRepositoryTag("localhost:5000/foo/bar@sha256:bc8813ea7b3603864987522f02a76101c17ad122e1c46d790efc0fca78ca7bfb") if tag != "sha256:bc8813ea7b3603864987522f02a76101c17ad122e1c46d790efc0fca78ca7bfb" { t.Logf("repo=%s tag=%s", repo, tag) } - repo, tag = parseRepositoryTag("localhost:5000/foo/bar") + repo, tag = ParseRepositoryTag("localhost:5000/foo/bar") if tag != "" { t.Logf("repo=%s tag=%s", repo, tag) } - repo, tag = parseRepositoryTag("localhost:5000/foo/bar:latest") + repo, tag = ParseRepositoryTag("localhost:5000/foo/bar:latest") t.Logf("repo=%s tag=%s", repo, tag) if tag != "latest" { t.Logf("repo=%s tag=%s", repo, tag) diff --git a/test/integration/affinities.bats b/test/integration/affinities.bats index 055a73c1fe..d647a9d58c 100644 --- a/test/integration/affinities.bats +++ b/test/integration/affinities.bats @@ -68,8 +68,6 @@ function teardown() { [ "$status" -eq 0 ] run docker_swarm inspect c1 - # FIXME: This will help debugging the failing test. - echo $output [ "$status" -eq 0 ] [[ "${output}" == *'"Name": "node-1"'* ]] @@ -86,6 +84,26 @@ function teardown() { [[ "${output}" != *'"Name": "node-1"'* ]] } +@test "images affinity - local registry" { + start_docker_with_busybox 2 + swarm_manage + + # Create a new image just on the second host. + run docker -H ${HOSTS[1]} tag busybox localhost:5000/test + + # pull busybox to force the refresh images + # FIXME: this is slow. + run docker_swarm pull busybox + [ "$status" -eq 0 ] + + run docker_swarm run --name c1 -e affinity:image==localhost:5000/test -d busybox:latest sh + [ "$status" -eq 0 ] + + run docker_swarm inspect c1 + [ "$status" -eq 0 ] + [[ "${output}" == *'"Name": "node-1"'* ]] +} + @test "label affinity" { start_docker_with_busybox 2 swarm_manage