add coverage to plugin
This commit is contained in:
1 parent
254be128b0
commit
718e93bd23
5 files changed
+27
-10
No files matched your search
@@ -88,7 +88,7 @@ $(EXES) tests lint:
|
|||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
$(WEAVER_EXE) $(WEAVEPROXY_EXE):
|
$(WEAVER_EXE) $(WEAVEPROXY_EXE) $(PLUGIN_EXE):
|
||||||
ifeq ($(COVERAGE),true)
|
ifeq ($(COVERAGE),true)
|
||||||
go build -v $(BUILD_FLAGS) -o $@ ./$(@D)
|
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,))
|
$(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
|
# These programs need a separate rule as they fail the netgo check in
|
||||||
# the main build stanza due to not importing net package
|
# 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)
|
go build $(BUILD_FLAGS) -o $@ ./$(@D)
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
weavetest "github.com/weaveworks/weave/testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestMain(t *testing.T) {
|
||||||
|
weavetest.TrimTestArgs()
|
||||||
|
main()
|
||||||
|
}
|
||||||
@@ -4,12 +4,19 @@
|
|||||||
|
|
||||||
start_suite "Test CNI plugin"
|
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() {
|
cni_connect() {
|
||||||
pid=$(container_pid $1 $2)
|
pid=$(container_pid $1 $2)
|
||||||
docker_on $1 run --rm --privileged --net=host --pid=host -i \
|
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_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 \
|
-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",
|
"name": "weave",
|
||||||
"type": "weave-net"
|
"type": "weave-net"
|
||||||
|
|||||||
+4
-6
@@ -127,12 +127,10 @@ stop_router_on() {
|
|||||||
# we don't invoke `weave stop-router` here because that removes
|
# we don't invoke `weave stop-router` here because that removes
|
||||||
# the weave container, which means we a) can't grab coverage
|
# the weave container, which means we a) can't grab coverage
|
||||||
# stats, and b) can't inspect the logs when tests fail.
|
# stats, and b) can't inspect the logs when tests fail.
|
||||||
docker_on $host stop weave 1>/dev/null 2>&1 || true
|
for C in weaveplugin weaveproxy weave ; do
|
||||||
docker_on $host stop weaveproxy 1>/dev/null 2>&1 || true
|
docker_on $host stop $C 1>/dev/null 2>&1 || true
|
||||||
if [ -n "$COVERAGE" ] ; then
|
[ -n "$COVERAGE" ] && collect_coverage $host $C
|
||||||
collect_coverage $host weave
|
done
|
||||||
collect_coverage $host weaveproxy
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exec_on() {
|
exec_on() {
|
||||||
|
|||||||
@@ -1741,7 +1741,7 @@ launch_plugin_if_not_running() {
|
|||||||
--restart=always \
|
--restart=always \
|
||||||
-v /run/docker/plugins:/run/docker/plugins \
|
-v /run/docker/plugins:/run/docker/plugins \
|
||||||
-e WEAVE_HTTP_ADDR \
|
-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
|
wait_for_status $PLUGIN_CONTAINER_NAME http_call_unix $PLUGIN_CONTAINER_NAME status.sock
|
||||||
util_op create-plugin-network weave weavemesh
|
util_op create-plugin-network weave weavemesh
|
||||||
|
|||||||
Reference in new issue
Block a user