runsvinit/zombietest/test.bash

49 lines
838 B
Bash
Raw Normal View History

2015-09-28 20:30:44 +00:00
#!/bin/bash
2015-09-28 20:46:18 +00:00
function zombies() {
if [ -z "$CIRCLECI" ]
then
docker exec $C ps -o pid,stat | grep Z | wc -l
else
# https://circleci.com/docs/docker#docker-exec
sudo lxc-attach -n "$(docker inspect --format '{{.Id}}' $C)" -- sh -c "ps -o pid,stat | grep Z | wc -l"
fi
}
function stop_rm() {
2015-10-07 13:39:45 +00:00
docker stop $1 >/dev/null
#docker logs $1
docker rm $1 >/dev/null
2015-09-28 20:46:18 +00:00
}
2015-09-28 20:30:44 +00:00
SLEEP=1
2015-09-28 20:46:18 +00:00
RC=0
2015-09-28 20:30:44 +00:00
2015-10-07 13:39:45 +00:00
C=$(docker run -d zombietest /runsvinit -reap=false -debug)
2015-09-28 20:30:44 +00:00
sleep $SLEEP
2015-09-28 20:46:18 +00:00
NOREAP=$(zombies)
2015-09-28 20:30:44 +00:00
echo -n without reaping, we have $NOREAP zombies...
if [ "$NOREAP" -le "0" ]
then
echo " FAIL"
RC=1
else
echo " good"
fi
2015-09-28 20:46:18 +00:00
stop_rm $C
2015-09-28 20:30:44 +00:00
2015-10-07 13:39:45 +00:00
C=$(docker run -d zombietest /runsvinit -debug)
2015-09-28 20:30:44 +00:00
sleep $SLEEP
2015-09-28 20:46:18 +00:00
YESREAP=$(zombies)
2015-09-28 20:30:44 +00:00
echo -n with reaping, we have $YESREAP zombies...
if [ "$YESREAP" -gt "0" ]
then
echo " FAIL"
RC=1
else
echo " good"
fi
2015-09-28 20:46:18 +00:00
stop_rm $C
2015-09-28 20:30:44 +00:00
exit $RC