Try Circle

This commit is contained in:
Peter Bourgon 2015-09-28 22:46:18 +02:00
parent 819c47186c
commit f197aa8f6a
3 changed files with 38 additions and 13 deletions

8
circle.yml Normal file
View File

@ -0,0 +1,8 @@
machine:
services:
- docker
test:
override:
- go test -v
- make CIRCLECI=true SUDO=sudo RM= -C zombietest

View File

@ -1,23 +1,27 @@
GO?=go
SUDO?=
RM?=--rm
.PHONY: test clean
test: .test.uptodate
./test.bash
.test.uptodate: runsvinit zombie run-zombie Dockerfile
docker build -t zombietest .
$(SUDO) docker build -t zombietest .
touch $@
runsvinit: ../*.go
env GOOS=linux GOARCH=amd64 go build -o $@ github.com/peterbourgon/runsvinit
env GOOS=linux GOARCH=amd64 $(GO) build -o $@ github.com/peterbourgon/runsvinit
zombie: .build.uptodate
docker run --rm -v $(shell pwd):/mount zombietest-build cc -Wall -Werror -o /mount/zombie /zombie.c
$(SUDO) docker run $(RM) -v $(shell pwd):/mount zombietest-build cc -Wall -Werror -o /mount/zombie /zombie.c
.build.uptodate: build/zombie.c build/Dockerfile
docker build -t zombietest-build build/
$(SUDO) docker build -t zombietest-build build/
touch $@
clean:
rm -rf .test.uptodate .build.uptodate runsvinit zombie
docker stop zombietest zombietest-build >/dev/null 2>&1 || true
docker rm zombietest zombietest-build >/dev/null 2>&1 || true
$(SUDO) docker stop zombietest zombietest-build >/dev/null 2>&1 || true
$(SUDO) docker rm zombietest zombietest-build >/dev/null 2>&1 || true

View File

@ -1,11 +1,26 @@
#!/bin/bash
RC=0
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
}
SLEEP=1
RC=0
C=$(docker run -d zombietest /runsvinit -reap=false)
sleep $SLEEP
NOREAP=$(docker exec $C ps -o pid,stat | grep Z | wc -l)
NOREAP=$(zombies)
echo -n without reaping, we have $NOREAP zombies...
if [ "$NOREAP" -le "0" ]
then
@ -14,12 +29,11 @@ then
else
echo " good"
fi
docker stop $C >/dev/null
docker rm $C >/dev/null
stop_rm $C
C=$(docker run -d zombietest /runsvinit)
sleep $SLEEP
YESREAP=$(docker exec $C ps -o pid,stat | grep Z | wc -l)
YESREAP=$(zombies)
echo -n with reaping, we have $YESREAP zombies...
if [ "$YESREAP" -gt "0" ]
then
@ -28,7 +42,6 @@ then
else
echo " good"
fi
docker stop $C >/dev/null
docker rm $C >/dev/null
stop_rm $C
exit $RC