
Running ginkgo tests in parallel causes problems with dhcp_test.go. BeforeEach() is run once for each spec before any actual dhcp test starts. This results in setting up two dhcp4servers that run concurrently. Both try to Listen and use unix socketPath file /run/cni/dhcp.sock at the same time. AfterEach() for one test runs when test completes, deleting /run/cni/dhcp.sock. But other test still needs the file resulting in test failing. Often, the next dhcp test hasn't started yet. When test does start it waits 15 seconds for dhcp4server to create /run/cni/dhcp.sock (which has just been deleted) so test fails. Other times dhcp tests fail because /run/cni/dhcp.sock is deleted while still being used.
42 lines
903 B
Bash
Executable File
42 lines
903 B
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Run CNI plugin tests.
|
|
#
|
|
# This needs sudo, as we'll be creating net interfaces.
|
|
#
|
|
set -e
|
|
|
|
source ./build.sh
|
|
|
|
echo "Running tests"
|
|
|
|
GINKGO_FLAGS="-nodes=1 --randomizeAllSpecs --randomizeSuites --failOnPending --progress"
|
|
|
|
# user has not provided PKG override
|
|
if [ -z "$PKG" ]; then
|
|
GINKGO_FLAGS="$GINKGO_FLAGS -r ."
|
|
LINT_TARGETS="./..."
|
|
|
|
# user has provided PKG override
|
|
else
|
|
GINKGO_FLAGS="$GINKGO_FLAGS $PKG"
|
|
LINT_TARGETS="$PKG"
|
|
fi
|
|
|
|
sudo -E bash -c "umask 0; cd ${GOPATH}/src/${REPO_PATH}; PATH=${GOROOT}/bin:$(pwd)/bin:${PATH} ginkgo ${GINKGO_FLAGS}"
|
|
|
|
cd ${GOPATH}/src/${REPO_PATH};
|
|
echo "Checking gofmt..."
|
|
fmtRes=$(go fmt $LINT_TARGETS)
|
|
if [ -n "${fmtRes}" ]; then
|
|
echo -e "go fmt checking failed:\n${fmtRes}"
|
|
exit 255
|
|
fi
|
|
|
|
echo "Checking govet..."
|
|
vetRes=$(go vet $LINT_TARGETS)
|
|
if [ -n "${vetRes}" ]; then
|
|
echo -e "govet checking failed:\n${vetRes}"
|
|
exit 255
|
|
fi
|