1
0
mirror of https://github.com/peterbourgon/runsvinit.git synced 2024-12-16 14:57:04 +00:00
runsvinit/zombietest/test.bash

48 lines
785 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() {
docker stop $1
docker rm $1
}
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
C=$(docker run -d zombietest /runsvinit -reap=false)
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
C=$(docker run -d zombietest /runsvinit)
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