Code coverage for smoke tests.

Allow non-circle people to build coverage reports.
This commit is contained in:
Tom Wilkie committed 2015-07-10 14:45:14 +00:00
1 parent da41604229
commit 00a7490a1d
12 files changed
+211 -14

No files matched your search

+4 -4
View File
@@ -4,15 +4,15 @@
start_suite "Run weave with --local"
run_on $HOST1 sudo weave --local reset
run_on $HOST1 sudo COVERAGE=$COVERAGE weave --local reset
run_on $HOST1 sudo weave --local launch --ipalloc-range 10.2.5.0/24
run_on $HOST1 sudo COVERAGE=$COVERAGE weave --local launch --ipalloc-range 10.2.5.0/24
assert_raises "docker_on $HOST1 ps | grep weave"
run_on $HOST1 sudo weave --local run 10.2.6.5/24 -ti --name=c1 $SMALL_IMAGE /bin/sh
run_on $HOST1 sudo COVERAGE=$COVERAGE weave --local run 10.2.6.5/24 -ti --name=c1 $SMALL_IMAGE /bin/sh
assert_raises "exec_on $HOST1 c1 $CHECK_ETHWE_UP"
run_on $HOST1 sudo weave --local run -ti --name=c2 $SMALL_IMAGE /bin/sh
run_on $HOST1 sudo COVERAGE=$COVERAGE weave --local run -ti --name=c2 $SMALL_IMAGE /bin/sh
assert_raises "exec_on $HOST1 c2 $CHECK_ETHWE_UP"
end_suite
+1 -1
View File
@@ -33,7 +33,7 @@ assert_raises "exec_on $HOST1 c1 $PING $C2"
# Forget everyone and disconnect
assert_raises "weave_on $HOST2 forget $HOST1 $HOST2"
assert_raises "weave_on $HOST1 stop-router"
assert_raises "weave_stop_router $HOST1"
assert_raises "weave_on $HOST1 launch-router"
assert_peers $HOST2 ""
assert_raises "exec_on $HOST1 c1 sh -c '! $PING $C2'"
+22
View File
@@ -113,6 +113,15 @@ weave_on() {
DOCKER_HOST=tcp://$host:$DOCKER_PORT $WEAVE "$@"
}
weave_stop_router() {
host=$1
shift 1
docker_on $host stop weave 1>/dev/null 2>&1 || true
if [ -n "$COVERAGE" ] ; then
collect_coverage $host
fi
}
exec_on() {
host=$1
container=$2
@@ -196,6 +205,19 @@ start_suite() {
end_suite() {
whitely assert_end
for host in $HOSTS; do
weave_stop_router $host
done
}
collect_coverage() {
host=$1
rm -f cover.router.prof
docker_on $host cp weave:/home/weave/cover.router.prof . || true
# ideally we'd know the name of the test here, and put that in the filename
mkdir -p ./coverage
mv cover.router.prof $(mktemp -u ./coverage/integration.XXXXXXXX) || true
}
WEAVE=$DIR/../weave
+15
View File
@@ -0,0 +1,15 @@
#!/bin/bash
set -eux
if [ -n "$CIRCLECI" ]; then
for i in $(seq 1 $(($CIRCLE_NODE_TOTAL - 1))); do
scp node$i:/home/ubuntu/src/github.com/weaveworks/weave/test/coverage/* ./coverage/ || true
done
fi
go get github.com/weaveworks/weave/testing/cover
cover ./coverage/* >profile.cov
go tool cover -html=profile.cov -o coverage.html
go tool cover -func=profile.cov -o coverage.txt
tar czf coverage.tar.gz ./coverage