diff --git a/Makefile b/Makefile index 7047f901..710a166c 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/prog/plugin/main_test.go b/prog/plugin/main_test.go new file mode 100644 index 00000000..1873f4a3 --- /dev/null +++ b/prog/plugin/main_test.go @@ -0,0 +1,12 @@ +package main + +import ( + "testing" + + weavetest "github.com/weaveworks/weave/testing" +) + +func TestMain(t *testing.T) { + weavetest.TrimTestArgs() + main() +} diff --git a/test/830_cni_plugin_test.sh b/test/830_cni_plugin_test.sh index 63b07778..4631d97b 100755 --- a/test/830_cni_plugin_test.sh +++ b/test/830_cni_plugin_test.sh @@ -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 </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() { diff --git a/weave b/weave index 98278ffe..b8aa87c2 100755 --- a/weave +++ b/weave @@ -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