add coverage to plugin

This commit is contained in:
Matthias Radestock committed 2016-03-30 17:40:32 +01:00
1 parent 254be128b0
commit 718e93bd23
5 files changed
+27 -10

No files matched your search

+2 -2
View File
@@ -88,7 +88,7 @@ $(EXES) tests lint:
else
$(WEAVER_EXE) $(WEAVEPROXY_EXE):
$(WEAVER_EXE) $(WEAVEPROXY_EXE) $(PLUGIN_EXE):
ifeq ($(COVERAGE),true)
go build -v $(BUILD_FLAGS) -o $@ ./$(@D)
$(eval COVERAGE_MODULES := $(shell (go list ./$(@D); go list -f '{{join .Deps "\n"}}' ./$(@D) | grep "^$(PACKAGE_BASE)/") | grep -v "^$(PACKAGE_BASE)/vendor/" | paste -s -d,))
@@ -112,7 +112,7 @@ $(WEAVEWAIT_NOMCAST_EXE):
# These programs need a separate rule as they fail the netgo check in
# the main build stanza due to not importing net package
$(SIGPROXY_EXE) $(PLUGIN_EXE) $(TEST_TLS_EXE) $(WEAVEWAIT_NOOP_EXE):
$(SIGPROXY_EXE) $(TEST_TLS_EXE) $(WEAVEWAIT_NOOP_EXE):
go build $(BUILD_FLAGS) -o $@ ./$(@D)
tests:
+12
View File
@@ -0,0 +1,12 @@
package main
import (
"testing"
weavetest "github.com/weaveworks/weave/testing"
)
func TestMain(t *testing.T) {
weavetest.TrimTestArgs()
main()
}
+8 -1
View File
@@ -4,12 +4,19 @@
start_suite "Test CNI plugin"
coverage_args() {
# no coverage reporting for now; but when the plugin binary has
# been built for coverage reporting we need to prevent it from
# complaining about the non-coverage args.
[ -n "$COVERAGE" ] && echo "--"
}
cni_connect() {
pid=$(container_pid $1 $2)
docker_on $1 run --rm --privileged --net=host --pid=host -i \
-e CNI_VERSION=1 -e CNI_COMMAND=ADD -e CNI_CONTAINERID=c1 \
-e CNI_NETNS=/proc/$pid/ns/net -e CNI_IFNAME=eth0 -e CNI_PATH=/opt/cni/bin \
weaveworks/plugin:latest --cni-net <<EOF
weaveworks/plugin:latest $(coverage_args) --cni-net <<EOF
{
"name": "weave",
"type": "weave-net"
+4 -6
View File
@@ -127,12 +127,10 @@ stop_router_on() {
# we don't invoke `weave stop-router` here because that removes
# the weave container, which means we a) can't grab coverage
# stats, and b) can't inspect the logs when tests fail.
docker_on $host stop weave 1>/dev/null 2>&1 || true
docker_on $host stop weaveproxy 1>/dev/null 2>&1 || true
if [ -n "$COVERAGE" ] ; then
collect_coverage $host weave
collect_coverage $host weaveproxy
fi
for C in weaveplugin weaveproxy weave ; do
docker_on $host stop $C 1>/dev/null 2>&1 || true
[ -n "$COVERAGE" ] && collect_coverage $host $C
done
}
exec_on() {
+1 -1
View File
@@ -1741,7 +1741,7 @@ launch_plugin_if_not_running() {
--restart=always \
-v /run/docker/plugins:/run/docker/plugins \
-e WEAVE_HTTP_ADDR \
$WEAVEPLUGIN_DOCKER_ARGS $PLUGIN_IMAGE \
$WEAVEPLUGIN_DOCKER_ARGS $PLUGIN_IMAGE $COVERAGE_ARGS \
"$@"
wait_for_status $PLUGIN_CONTAINER_NAME http_call_unix $PLUGIN_CONTAINER_NAME status.sock
util_op create-plugin-network weave weavemesh