forked from contiv/netplugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunittests
More file actions
executable file
·70 lines (61 loc) · 1.89 KB
/
unittests
File metadata and controls
executable file
·70 lines (61 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# a wrapper script to run the unit-tests. On the host it shall setup a one node
# vagrant environment and trigger the unit tests in the sandbox vm. This is
# needed since some unit-tests depend on the external daemon like ovs, etcd
# etc to be setup.
USAGE="${0} -vagrant"
PATH=$PATH:/usr/local/go/bin
run_in_vagrant=false
test_packages="github.com/contiv/netplugin/drivers \
github.com/contiv/netplugin/state \
github.com/contiv/netplugin/plugin \
github.com/contiv/netplugin/netutils \
github.com/contiv/netplugin/crt \
github.com/contiv/netplugin/gstate \
github.com/contiv/netplugin/netmaster/master \
github.com/contiv/netplugin/netmaster/mastercfg \
github.com/contiv/netplugin/netmaster/client \
github.com/contiv/netplugin/resources \
github.com/contiv/netplugin/core \
github.com/contiv/netplugin/utils \
"
while [ "${#}" -gt 0 ]
do
case "${1}" in
-vagrant)
run_in_vagrant=true
break;;
*)
echo "${USAGE}" 1>&2
exit 1;;
esac
shift
done
# running on host
if ${run_in_vagrant}; then
(CONTIV_NODE_OS="${CONTIV_NODE_OS}" CONTIV_NODES=1 vagrant up)
ret=$?
if [ ${ret} -ne 0 ]; then
(CONTIV_NODES=1 vagrant destroy -f)
exit 1
fi
# XXX: running unit-tests require root permission due to dependence on ovs
# utilities. Need to find a way without 'sudo'.
(CONTIV_NODES=1 vagrant ssh netplugin-node1 -c 'sudo -E PATH=$PATH $GOSRC/github.com/contiv/netplugin/'${0})
ret=$?
if [ ${ret} -ne 0 ]; then
(CONTIV_NODES=1 vagrant destroy -f)
exit 1
fi
(CONTIV_NODES=1 vagrant destroy -f)
echo "Host: Tests succeeded!"
exit 0
fi
for pkg in ${test_packages}
do
# running in the sand box
(cd $GOSRC/github.com/contiv/netplugin && \
$GOBIN/godep go test ${pkg}) || exit 1
done
echo "Sandbox: Tests succeeded!"
exit 0