Skip to content
Permalink
Browse files

Fix race in tty integration test with slow startup

Signed-off-by: Jordan Liggitt <liggitt@google.com>
  • Loading branch information
liggitt committed Dec 18, 2019
1 parent 7496a96 commit 52951a7c1967c073496f8315c2b0a01eef573b9e
Showing with 11 additions and 3 deletions.
  1. +10 −2 tests/integration/helpers.bash
  2. +1 −1 tests/integration/tty.bats
@@ -218,12 +218,16 @@ function wait_for_container() {
local attempts=$1
local delay=$2
local cid=$3
# optionally wait for a specific status
local wait_for_status="${4:-}"
local i

for ((i = 0; i < attempts; i++)); do
runc state $cid
if [[ "$status" -eq 0 ]]; then
return 0
if [[ "${output}" == *"${wait_for_status}"* ]]; then
return 0
fi
fi
sleep $delay
done
@@ -237,12 +241,16 @@ function wait_for_container_inroot() {
local attempts=$1
local delay=$2
local cid=$3
# optionally wait for a specific status
local wait_for_status="${4:-}"
local i

for ((i = 0; i < attempts; i++)); do
ROOT=$4 runc state $cid
if [[ "$status" -eq 0 ]]; then
return 0
if [[ "${output}" == *"${wait_for_status}"* ]]; then
return 0
fi
fi
sleep $delay
done
@@ -205,7 +205,7 @@ EOF
__runc run test_busybox
) &

wait_for_container 15 1 test_busybox
wait_for_container 15 1 test_busybox running
testcontainer test_busybox running

# Kill the container.

0 comments on commit 52951a7

Please sign in to comment.
You can’t perform that action at this time.