From 4bb035e41a48bca3d5b725cacf72e4d049276d6d Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Fri, 8 May 2015 19:26:22 -0700 Subject: [PATCH 1/3] integration: Fix API races related to delay in refresh. Signed-off-by: Andrea Luzzardi --- test/integration/api/cp.bats | 18 ++++++++---------- test/integration/api/diff.bats | 10 ++++------ test/integration/api/exec.bats | 14 +++++--------- test/integration/api/kill.bats | 13 +++++-------- test/integration/api/pause.bats | 14 ++++++-------- test/integration/api/port.bats | 6 ++---- test/integration/api/restart.bats | 15 ++++++++------- test/integration/api/rm.bats | 6 ++---- test/integration/api/run.bats | 8 +++----- test/integration/api/start.bats | 11 +++++------ test/integration/api/stats.bats | 16 ++++++---------- test/integration/api/stop.bats | 12 ++++-------- test/integration/api/top.bats | 6 ++---- test/integration/api/unpause.bats | 19 ++++++------------- test/integration/api/wait.bats | 9 +-------- 15 files changed, 67 insertions(+), 110 deletions(-) diff --git a/test/integration/api/cp.bats b/test/integration/api/cp.bats index aecb205008..249c3baa44 100644 --- a/test/integration/api/cp.bats +++ b/test/integration/api/cp.bats @@ -18,11 +18,9 @@ function teardown() { # create the container docker_swarm run -d --name test_container busybox sleep 500 - # make sure container is up and no comming file - run docker_swarm ps -l - [ "${#lines[@]}" -eq 2 ] - [[ "${lines[1]}" == *"test_container"* ]] - [[ "${lines[1]}" == *"Up"* ]] + # make sure container is up + # FIXME(#748): Retry required because of race condition. + retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" # grab the checksum of the test file inside the container. run docker_swarm exec test_container md5sum $test_file @@ -30,10 +28,10 @@ function teardown() { [ "${#lines[@]}" -ge 1 ] # get the checksum number - container_checksum=`echo ${lines[0]} | awk '{print $1}'` + container_checksum=$(echo ${lines[0]} | awk '{print $1}') # host file - host_file=$temp_dest/`basename $test_file` + host_file=$temp_dest/$(basename $test_file) [ ! -f $host_file ] # copy the test file from the container to the host. @@ -44,10 +42,10 @@ function teardown() { run md5sum $host_file [ "$status" -eq 0 ] [ "${#lines[@]}" -ge 1 ] - host_checksum=`echo ${lines[0]} | awk '{print $1}'` + host_checksum=$(echo ${lines[0]} | awk '{print $1}') # Verify that they match. - [[ "${container_checksum}" == "${host_checksum}" ]] + [ "${container_checksum}" == "${host_checksum}" ] # after ok, remove temp directory and file - rm -rf $temp_dest + rm -rf "$temp_dest" } diff --git a/test/integration/api/diff.bats b/test/integration/api/diff.bats index a68ee361d7..6b72e995dc 100644 --- a/test/integration/api/diff.bats +++ b/test/integration/api/diff.bats @@ -13,12 +13,10 @@ function teardown() { docker_swarm run -d --name test_container busybox sleep 500 # make sure container is up - run docker_swarm ps -l - [ "${#lines[@]}" -eq 2 ] - [[ "${lines[1]}" == *"test_container"* ]] - [[ "${lines[1]}" == *"Up"* ]] + # FIXME(#748): Retry required because of race condition. + retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" - # no changs + # no changes run docker_swarm diff test_container [ "$status" -eq 0 ] [ "${#lines[@]}" -eq 0 ] @@ -29,5 +27,5 @@ function teardown() { # verify run docker_swarm diff test_container [ "$status" -eq 0 ] - [[ "${lines[*]}" == *"diff.txt"* ]] + [[ "${output}" == *"diff.txt"* ]] } diff --git a/test/integration/api/exec.bats b/test/integration/api/exec.bats index 45a241c9fd..3886782a50 100644 --- a/test/integration/api/exec.bats +++ b/test/integration/api/exec.bats @@ -20,15 +20,11 @@ function teardown() { docker_swarm start test_container # make sure container is up and not paused - run docker_swarm ps -l - [ "${#lines[@]}" -eq 2 ] - [[ "${lines[1]}" == *"test_container"* ]] - [[ "${lines[1]}" == *"Up"* ]] - [[ "${lines[1]}" != *"Paused"* ]] + # FIXME(#748): Retry required because of race condition. + retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" + [ $(docker_swarm inspect -f '{{ .State.Paused }}' test_container) == 'false' ] - run docker_swarm exec test_container ls + run docker_swarm exec test_container echo foobar [ "$status" -eq 0 ] - [ "${#lines[@]}" -ge 2 ] - [[ "${lines[0]}" == *"bin"* ]] - [[ "${lines[1]}" == *"dev"* ]] + [ "$output" == "foobar" ] } diff --git a/test/integration/api/kill.bats b/test/integration/api/kill.bats index e59b5b51dd..758a9c7a51 100644 --- a/test/integration/api/kill.bats +++ b/test/integration/api/kill.bats @@ -14,17 +14,14 @@ function teardown() { docker_swarm run -d --name test_container busybox sleep 1000 # make sure container is up before killing - run docker_swarm ps -l - [ "${#lines[@]}" -eq 2 ] - [[ "${lines[1]}" == *"test_container"* ]] - [[ "${lines[1]}" == *"Up"* ]] + # FIXME(#748): Retry required because of race condition. + retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" # kill docker_swarm kill test_container # verify - run docker_swarm ps -l - [ "${#lines[@]}" -eq 2 ] - [[ "${lines[1]}" == *"test_container"* ]] - [[ "${lines[1]}" == *"Exited"* ]] + # FIXME(#748): Retry required because of race condition. + retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'false' ]" + [ $(docker_swarm inspect -f '{{ .State.ExitCode }}' test_container) -eq 137 ] } diff --git a/test/integration/api/pause.bats b/test/integration/api/pause.bats index be794fabf6..d17a70c4b1 100644 --- a/test/integration/api/pause.bats +++ b/test/integration/api/pause.bats @@ -14,18 +14,16 @@ function teardown() { docker_swarm run -d --name test_container busybox sleep 1000 # make sure container is up - run docker_swarm ps -l - [ "${#lines[@]}" -eq 2 ] - [[ "${lines[1]}" == *"test_container"* ]] - [[ "${lines[1]}" == *"Up"* ]] + # FIXME(#748): Retry required because of race condition. + retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" + [ $(docker_swarm inspect -f '{{ .State.Paused }}' test_container) == 'false' ] docker_swarm pause test_container # verify - run docker_swarm ps -l - [ "${#lines[@]}" -eq 2 ] - [[ "${lines[1]}" == *"test_container"* ]] - [[ "${lines[1]}" == *"Paused"* ]] + # FIXME(#748): Retry required because of race condition. + retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Paused }}' test_container) == 'true ']" + [ docker_swarm inspect -f '{{ .State.Running }}' test_container == 'false' ] # if the state of the container is paused, it can't be removed(rm -f) docker_swarm unpause test_container diff --git a/test/integration/api/port.bats b/test/integration/api/port.bats index 2db3f416a5..43e4eae985 100644 --- a/test/integration/api/port.bats +++ b/test/integration/api/port.bats @@ -13,10 +13,8 @@ function teardown() { docker_swarm run -d -p 8000 --name test_container busybox sleep 500 # make sure container is up - run docker_swarm ps -l - [ "${#lines[@]}" -eq 2 ] - [[ "${lines[1]}" == *"test_container"* ]] - [[ "${lines[1]}" == *"Up"* ]] + # FIXME(#748): Retry required because of race condition. + retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" # port verify run docker_swarm port test_container diff --git a/test/integration/api/restart.bats b/test/integration/api/restart.bats index 4c7f53cf3c..aa076318a7 100644 --- a/test/integration/api/restart.bats +++ b/test/integration/api/restart.bats @@ -14,17 +14,18 @@ function teardown() { docker_swarm run -d --name test_container busybox sleep 1000 # make sure container is up - run docker_swarm ps -l - [ "${#lines[@]}" -eq 2 ] - [[ "${lines[1]}" == *"test_container"* ]] - [[ "${lines[1]}" == *"Up"* ]] + # FIXME(#748): Retry required because of race condition. + retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" + + # Keep track of when the container was started. + local started_at=$(docker_swarm inspect -f '{{ .State.StartedAt }}' test_container) # restart docker_swarm restart test_container # verify run docker_swarm ps -l - [ "${#lines[@]}" -eq 2 ] - [[ "${lines[1]}" == *"test_container"* ]] - [[ "${lines[1]}" == *"Up"* ]] + # FIXME(#748): Retry required because of race condition. + retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" + [ $(docker_swarm inspect -f '{{ .State.StartedAt }}' test_container) != "$started_at" ] } diff --git a/test/integration/api/rm.bats b/test/integration/api/rm.bats index 5b190ee9b3..70a26685a3 100644 --- a/test/integration/api/rm.bats +++ b/test/integration/api/rm.bats @@ -32,10 +32,8 @@ function teardown() { docker_swarm run -d --name test_container busybox sleep 500 # make sure container exsists and is up - run docker_swarm ps -a - [ "${#lines[@]}" -eq 2 ] - [[ "${lines[1]}" == *"test_container"* ]] - [[ "${lines[1]}" == *"Up"* ]] + # FIXME(#748): Retry required because of race condition. + retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" # rm, remove a running container, return error run docker_swarm rm test_container diff --git a/test/integration/api/run.bats b/test/integration/api/run.bats index 6b736b61f0..2b8414373c 100644 --- a/test/integration/api/run.bats +++ b/test/integration/api/run.bats @@ -18,9 +18,7 @@ function teardown() { # run docker_swarm run -d --name test_container busybox sleep 100 - # verify, container exists - run docker_swarm ps -l - [ "${#lines[@]}" -eq 2 ] - [[ "${output}" == *"test_container"* ]] - [[ "${output}" == *"Up"* ]] + # verify, container is running + # FIXME(#748): Retry required because of race condition. + retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" } diff --git a/test/integration/api/start.bats b/test/integration/api/start.bats index 0dada7294c..6c84c15d72 100644 --- a/test/integration/api/start.bats +++ b/test/integration/api/start.bats @@ -20,10 +20,9 @@ function teardown() { [[ "${lines[1]}" == *"test_container"* ]] # start - run docker_swarm start test_container - [ "$status" -eq 0 ] - run docker_swarm ps -l - [ "${#lines[@]}" -eq 2 ] - [[ "${lines[1]}" == *"test_container"* ]] - [[ "${lines[1]}" == *"Up"* ]] + docker_swarm start test_container + + # Verify + # FIXME(#748): Retry required because of race condition. + retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" } diff --git a/test/integration/api/stats.bats b/test/integration/api/stats.bats index d79505cfb4..641b92e3f9 100644 --- a/test/integration/api/stats.bats +++ b/test/integration/api/stats.bats @@ -16,23 +16,19 @@ function teardown() { docker_swarm run -d --name test_container busybox sleep 50 # make sure container is up - run docker_swarm ps -l - [ "${#lines[@]}" -eq 2 ] - [[ "${lines[1]}" == *"test_container"* ]] - [[ "${lines[1]}" == *"Up"* ]] + # FIXME(#748): Retry required because of race condition. + retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" # storage the stats output in TEMP_FILE # it will stop automatically when manager stop docker_swarm stats test_container > $TEMP_FILE & # retry until TEMP_FILE is not empty - retry 5 1 [ -s $TEMP_FILE ] + retry 5 1 eval "[ -s $TEMP_FILE ]" - # if "CPU %" in TEMP_FILE, status is 0 - run grep "CPU %" $TEMP_FILE - [ "$status" -eq 0 ] - run grep "MEM USAGE/LIMIT" $TEMP_FILE - [ "$status" -eq 0 ] + # verify content + grep -q "CPU %" "$TEMP_FILE" + grep -q "MEM USAGE/LIMIT" "$TEMP_FILE" rm -f $TEMP_FILE } diff --git a/test/integration/api/stop.bats b/test/integration/api/stop.bats index 627a00efca..345efce251 100644 --- a/test/integration/api/stop.bats +++ b/test/integration/api/stop.bats @@ -14,17 +14,13 @@ function teardown() { docker_swarm run -d --name test_container busybox sleep 500 # make sure container is up before stop - run docker_swarm ps -l - [ "${#lines[@]}" -eq 2 ] - [[ "${lines[1]}" == *"test_container"* ]] - [[ "${lines[1]}" == *"Up"* ]] + # FIXME(#748): Retry required because of race condition. + retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" # stop docker_swarm stop test_container # verify - run docker_swarm ps -l - [ "${#lines[@]}" -eq 2 ] - [[ "${lines[1]}" == *"test_container"* ]] - [[ "${lines[1]}" == *"Exited"* ]] + # FIXME(#748): Retry required because of race condition. + retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'false' ]" } diff --git a/test/integration/api/top.bats b/test/integration/api/top.bats index 3655774575..5f4a1b7cd6 100644 --- a/test/integration/api/top.bats +++ b/test/integration/api/top.bats @@ -14,10 +14,8 @@ function teardown() { docker_swarm run -d --name test_container busybox sleep 500 # make sure container is running - run docker_swarm ps -l - [ "${#lines[@]}" -eq 2 ] - [[ "${lines[1]}" == *"test_container"* ]] - [[ "${lines[1]}" == *"Up"* ]] + # FIXME(#748): Retry required because of race condition. + retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" run docker_swarm top test_container [ "$status" -eq 0 ] diff --git a/test/integration/api/unpause.bats b/test/integration/api/unpause.bats index 4ebf023b78..7ca946b2ee 100644 --- a/test/integration/api/unpause.bats +++ b/test/integration/api/unpause.bats @@ -14,26 +14,19 @@ function teardown() { docker_swarm run -d --name test_container busybox sleep 1000 # make sure container is up - run docker_swarm ps -l - [ "${#lines[@]}" -eq 2 ] - [[ "${lines[1]}" == *"test_container"* ]] - [[ "${lines[1]}" == *"Up"* ]] + # FIXME(#748): Retry required because of race condition. + retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" + [ $(docker_swarm inspect -f '{{ .State.Paused }}' test_container) == 'false' ] # pause docker_swarm pause test_container - run docker_swarm ps -l - [ "${#lines[@]}" -eq 2 ] - [[ "${lines[1]}" == *"test_container"* ]] - [[ "${lines[1]}" == *"Paused"* ]] + # FIXME(#748): Retry required because of race condition. + retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Paused }}' test_container) == 'true ']" # unpause docker_swarm unpause test_container # verify - run docker_swarm ps -l - [ "${#lines[@]}" -eq 2 ] - [[ "${lines[1]}" == *"test_container"* ]] - [[ "${lines[1]}" == *"Up"* ]] - [[ "${lines[1]}" != *"Paused"* ]] + retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Paused }}' test_container) == 'false ']" } diff --git a/test/integration/api/wait.bats b/test/integration/api/wait.bats index feb42350e5..86df0ddc26 100644 --- a/test/integration/api/wait.bats +++ b/test/integration/api/wait.bats @@ -14,15 +14,8 @@ function teardown() { # run after 1 seconds, test_container will exit docker_swarm run -d --name test_container busybox sleep 1 - # make sure container exists and is up - run docker_swarm ps -l - [ "${#lines[@]}" -eq 2 ] - [[ "${lines[1]}" == *"test_container"* ]] - [[ "${lines[1]}" == *"Up"* ]] - # wait until exist(after 1 seconds) run timeout 5 docker -H $SWARM_HOST wait test_container - - [ "${#lines[@]}" -eq 1 ] + [ "$status" -eq 0 ] [[ "${output}" == "0" ]] } From a0973e6f917a43fff44f7cf5b611ce8fa1a0e95e Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Fri, 8 May 2015 19:52:49 -0700 Subject: [PATCH 2/3] integration: Fix pause test and make sure the cleanup is done properly. Signed-off-by: Andrea Luzzardi --- test/integration/api/pause.bats | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/integration/api/pause.bats b/test/integration/api/pause.bats index d17a70c4b1..a1297be50a 100644 --- a/test/integration/api/pause.bats +++ b/test/integration/api/pause.bats @@ -3,6 +3,8 @@ load ../helpers function teardown() { + # if the state of the container is paused, it can't be removed(rm -f) + run docker_swarm unpause test_container swarm_manage_cleanup stop_docker } @@ -22,9 +24,6 @@ function teardown() { # verify # FIXME(#748): Retry required because of race condition. - retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Paused }}' test_container) == 'true ']" + retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Paused }}' test_container) == 'true']" [ docker_swarm inspect -f '{{ .State.Running }}' test_container == 'false' ] - - # if the state of the container is paused, it can't be removed(rm -f) - docker_swarm unpause test_container } From fdd3513cbf35fe80b429b8e3b7d9f8b3769240d1 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Sat, 9 May 2015 16:33:57 -0700 Subject: [PATCH 3/3] integration: check status with ps filter rather than inspect. Signed-off-by: Andrea Luzzardi --- test/integration/api/cp.bats | 2 +- test/integration/api/diff.bats | 2 +- test/integration/api/exec.bats | 3 +-- test/integration/api/kill.bats | 4 ++-- test/integration/api/pause.bats | 6 ++---- test/integration/api/port.bats | 2 +- test/integration/api/restart.bats | 6 +++--- test/integration/api/rm.bats | 2 +- test/integration/api/run.bats | 2 +- test/integration/api/start.bats | 2 +- test/integration/api/stats.bats | 2 +- test/integration/api/stop.bats | 4 ++-- test/integration/api/top.bats | 2 +- test/integration/api/unpause.bats | 8 ++++---- 14 files changed, 22 insertions(+), 25 deletions(-) diff --git a/test/integration/api/cp.bats b/test/integration/api/cp.bats index 249c3baa44..569ad10e0d 100644 --- a/test/integration/api/cp.bats +++ b/test/integration/api/cp.bats @@ -20,7 +20,7 @@ function teardown() { # make sure container is up # FIXME(#748): Retry required because of race condition. - retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" + retry 5 0.5 eval "[ -n $(docker_swarm ps -q --filter=name=test_container --filter=status=running) ]" # grab the checksum of the test file inside the container. run docker_swarm exec test_container md5sum $test_file diff --git a/test/integration/api/diff.bats b/test/integration/api/diff.bats index 6b72e995dc..26f518ad59 100644 --- a/test/integration/api/diff.bats +++ b/test/integration/api/diff.bats @@ -14,7 +14,7 @@ function teardown() { # make sure container is up # FIXME(#748): Retry required because of race condition. - retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" + retry 5 0.5 eval "[ -n $(docker_swarm ps -q --filter=name=test_container --filter=status=running) ]" # no changes run docker_swarm diff test_container diff --git a/test/integration/api/exec.bats b/test/integration/api/exec.bats index 3886782a50..f6b1b4a18a 100644 --- a/test/integration/api/exec.bats +++ b/test/integration/api/exec.bats @@ -21,8 +21,7 @@ function teardown() { # make sure container is up and not paused # FIXME(#748): Retry required because of race condition. - retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" - [ $(docker_swarm inspect -f '{{ .State.Paused }}' test_container) == 'false' ] + retry 5 0.5 eval "[ -n $(docker_swarm ps -q --filter=name=test_container --filter=status=running) ]" run docker_swarm exec test_container echo foobar [ "$status" -eq 0 ] diff --git a/test/integration/api/kill.bats b/test/integration/api/kill.bats index 758a9c7a51..395f86aded 100644 --- a/test/integration/api/kill.bats +++ b/test/integration/api/kill.bats @@ -15,13 +15,13 @@ function teardown() { # make sure container is up before killing # FIXME(#748): Retry required because of race condition. - retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" + retry 5 0.5 eval "[ -n $(docker_swarm ps -q --filter=name=test_container --filter=status=running) ]" # kill docker_swarm kill test_container # verify # FIXME(#748): Retry required because of race condition. - retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'false' ]" + retry 5 0.5 eval "[ -n $(docker_swarm ps -q --filter=name=test_container --filter=status=exited) ]" [ $(docker_swarm inspect -f '{{ .State.ExitCode }}' test_container) -eq 137 ] } diff --git a/test/integration/api/pause.bats b/test/integration/api/pause.bats index a1297be50a..6e0ab45107 100644 --- a/test/integration/api/pause.bats +++ b/test/integration/api/pause.bats @@ -17,13 +17,11 @@ function teardown() { # make sure container is up # FIXME(#748): Retry required because of race condition. - retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" - [ $(docker_swarm inspect -f '{{ .State.Paused }}' test_container) == 'false' ] + retry 5 0.5 eval "[ -n $(docker_swarm ps -q --filter=name=test_container --filter=status=running) ]" docker_swarm pause test_container # verify # FIXME(#748): Retry required because of race condition. - retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Paused }}' test_container) == 'true']" - [ docker_swarm inspect -f '{{ .State.Running }}' test_container == 'false' ] + retry 5 0.5 eval "[ -n $(docker_swarm ps -q --filter=name=test_container --filter=status=paused) ]" } diff --git a/test/integration/api/port.bats b/test/integration/api/port.bats index 43e4eae985..b1f404eb53 100644 --- a/test/integration/api/port.bats +++ b/test/integration/api/port.bats @@ -14,7 +14,7 @@ function teardown() { # make sure container is up # FIXME(#748): Retry required because of race condition. - retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" + retry 5 0.5 eval "[ -n $(docker_swarm ps -q --filter=name=test_container --filter=status=running) ]" # port verify run docker_swarm port test_container diff --git a/test/integration/api/restart.bats b/test/integration/api/restart.bats index aa076318a7..f11fce3cbb 100644 --- a/test/integration/api/restart.bats +++ b/test/integration/api/restart.bats @@ -15,7 +15,7 @@ function teardown() { # make sure container is up # FIXME(#748): Retry required because of race condition. - retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" + retry 5 0.5 eval "[ -n $(docker_swarm ps -q --filter=name=test_container --filter=status=running) ]" # Keep track of when the container was started. local started_at=$(docker_swarm inspect -f '{{ .State.StartedAt }}' test_container) @@ -26,6 +26,6 @@ function teardown() { # verify run docker_swarm ps -l # FIXME(#748): Retry required because of race condition. - retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" - [ $(docker_swarm inspect -f '{{ .State.StartedAt }}' test_container) != "$started_at" ] + retry 5 0.5 eval "[ -n $(docker_swarm ps -q --filter=name=test_container --filter=status=running) ]" + [ "$(docker_swarm inspect -f '{{ .State.StartedAt }}' test_container)" != "$started_at" ] } diff --git a/test/integration/api/rm.bats b/test/integration/api/rm.bats index 70a26685a3..76a25bee25 100644 --- a/test/integration/api/rm.bats +++ b/test/integration/api/rm.bats @@ -33,7 +33,7 @@ function teardown() { # make sure container exsists and is up # FIXME(#748): Retry required because of race condition. - retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" + retry 5 0.5 eval "[ -n $(docker_swarm ps -q --filter=name=test_container --filter=status=running) ]" # rm, remove a running container, return error run docker_swarm rm test_container diff --git a/test/integration/api/run.bats b/test/integration/api/run.bats index 2b8414373c..e49560ffd8 100644 --- a/test/integration/api/run.bats +++ b/test/integration/api/run.bats @@ -20,5 +20,5 @@ function teardown() { # verify, container is running # FIXME(#748): Retry required because of race condition. - retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" + retry 5 0.5 eval "[ -n $(docker_swarm ps -q --filter=name=test_container --filter=status=running) ]" } diff --git a/test/integration/api/start.bats b/test/integration/api/start.bats index 6c84c15d72..2efe977f0e 100644 --- a/test/integration/api/start.bats +++ b/test/integration/api/start.bats @@ -24,5 +24,5 @@ function teardown() { # Verify # FIXME(#748): Retry required because of race condition. - retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" + retry 5 0.5 eval "[ -n $(docker_swarm ps -q --filter=name=test_container --filter=status=running) ]" } diff --git a/test/integration/api/stats.bats b/test/integration/api/stats.bats index 641b92e3f9..47392f0c0b 100644 --- a/test/integration/api/stats.bats +++ b/test/integration/api/stats.bats @@ -17,7 +17,7 @@ function teardown() { # make sure container is up # FIXME(#748): Retry required because of race condition. - retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" + retry 5 0.5 eval "[ -n $(docker_swarm ps -q --filter=name=test_container --filter=status=running) ]" # storage the stats output in TEMP_FILE # it will stop automatically when manager stop diff --git a/test/integration/api/stop.bats b/test/integration/api/stop.bats index 345efce251..188a984e9c 100644 --- a/test/integration/api/stop.bats +++ b/test/integration/api/stop.bats @@ -15,12 +15,12 @@ function teardown() { # make sure container is up before stop # FIXME(#748): Retry required because of race condition. - retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" + retry 5 0.5 eval "[ -n $(docker_swarm ps -q --filter=name=test_container --filter=status=running) ]" # stop docker_swarm stop test_container # verify # FIXME(#748): Retry required because of race condition. - retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'false' ]" + retry 5 0.5 eval "[ -n $(docker_swarm ps -q --filter=name=test_container --filter=status=exited) ]" } diff --git a/test/integration/api/top.bats b/test/integration/api/top.bats index 5f4a1b7cd6..65b3888ef5 100644 --- a/test/integration/api/top.bats +++ b/test/integration/api/top.bats @@ -15,7 +15,7 @@ function teardown() { # make sure container is running # FIXME(#748): Retry required because of race condition. - retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" + retry 5 0.5 eval "[ -n $(docker_swarm ps -q --filter=name=test_container --filter=status=running) ]" run docker_swarm top test_container [ "$status" -eq 0 ] diff --git a/test/integration/api/unpause.bats b/test/integration/api/unpause.bats index 7ca946b2ee..647c1774a7 100644 --- a/test/integration/api/unpause.bats +++ b/test/integration/api/unpause.bats @@ -15,18 +15,18 @@ function teardown() { # make sure container is up # FIXME(#748): Retry required because of race condition. - retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Running }}' test_container) == 'true' ]" - [ $(docker_swarm inspect -f '{{ .State.Paused }}' test_container) == 'false' ] + retry 5 0.5 eval "[ -n $(docker_swarm ps -q --filter=name=test_container --filter=status=running) ]" # pause docker_swarm pause test_container # FIXME(#748): Retry required because of race condition. - retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Paused }}' test_container) == 'true ']" + retry 5 0.5 eval "[ -n $(docker_swarm ps -q --filter=name=test_container --filter=status=paused) ]" # unpause docker_swarm unpause test_container # verify - retry 5 0.5 eval "[ $(docker_swarm inspect -f '{{ .State.Paused }}' test_container) == 'false ']" + # FIXME(#748): Retry required because of race condition. + retry 5 0.5 eval "[ -n $(docker_swarm ps -q --filter=name=test_container --filter=status=running) ]" }