test: Fix oom test by changing to a sleep loop

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
Mrunal Patel 2017-05-31 16:37:12 -07:00 committed by Mrunal Patel
parent 0413088ffb
commit e3e9936f67

View file

@ -6,6 +6,17 @@ function teardown() {
cleanup_test cleanup_test
} }
function contains () {
string="$1"
substring="$2"
if test "${string#*$substring}" != "$string"
then
return 0 # $substring is in $string
else
return 1 # $substring is not in $string
fi
}
@test "ctr not found correct error message" { @test "ctr not found correct error message" {
start_crio start_crio
run crioctl ctr status --id randomid run crioctl ctr status --id randomid
@ -715,12 +726,19 @@ function teardown() {
run crioctl ctr start --id "$ctr_id" run crioctl ctr start --id "$ctr_id"
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# Wait for container to OOM i=0
run sleep 10 while [ $i -lt 30 ]; do
run crioctl ctr status --id "$ctr_id" run crioctl ctr status --id "$ctr_id"
echo "$output" echo "$output"
[ "$status" -eq 0 ]
if [ contains "$output" "OOMKilled" ]; then
break;
fi
sleep 1
i=$((i+1))
done
[ contains "$output" "OOMKilled" ]
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[[ "$output" =~ "OOMKilled" ]]
run crioctl pod stop --id "$pod_id" run crioctl pod stop --id "$pod_id"
echo "$output" echo "$output"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]