Skip to content

Commit

Permalink
Merge pull request #185 from pohly/e2e-enhancements
Browse files Browse the repository at this point in the history
e2e.sh: simplify cleanup
  • Loading branch information
k8s-ci-robot authored Mar 27, 2019
2 parents 34d1ee3 + 6f77363 commit 5421d9f
Showing 1 changed file with 43 additions and 77 deletions.
120 changes: 43 additions & 77 deletions hack/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,86 +7,70 @@ UDS_CONTROLLER="/tmp/e2e-csi-sanity-ctrl.sock"
CSI_ENDPOINTS="$CSI_ENDPOINTS ${UDS}"
CSI_MOCK_VERSION="master"

# cleanup mock_driver_pid files...
cleanup () {
local pid="$1"
shift
kill -9 "$pid"
# We don't care about the 'hack/e2e.sh: line 15: 117018 Killed CSI_ENDPOINT=$1 ./bin/mock-driver'
wait "$pid" 2>/dev/null
rm -f "$@"
}

#
# $1 - endpoint for mock.
# $2 - endpoint for csi-sanity in Grpc format.
# See https://github.com/grpc/grpc/blob/master/doc/naming.md
runTest()
{
(
CSI_ENDPOINT=$1 ./bin/mock-driver &
local pid=$!
trap 'cleanup $pid $1' EXIT

./cmd/csi-sanity/csi-sanity $TESTARGS --csi.endpoint=$2 --csi.testnodevolumeattachlimit; ret=$?
kill -9 $pid

if [ $ret -ne 0 ] ; then
exit $ret
fi
}
./cmd/csi-sanity/csi-sanity $TESTARGS --csi.endpoint=$2 --csi.testnodevolumeattachlimit
)

runTestWithDifferentAddresses()
{
(
CSI_ENDPOINT=$1 CSI_CONTROLLER_ENDPOINT=$2 ./bin/mock-driver &
local pid=$!
trap 'cleanup $pid $1' EXIT

./cmd/csi-sanity/csi-sanity $TESTARGS --csi.endpoint=$1 --csi.controllerendpoint=$2; ret=$?
kill -9 $pid

if [ $ret -ne 0 ] ; then
exit $ret
fi
}
./cmd/csi-sanity/csi-sanity $TESTARGS --csi.endpoint=$1 --csi.controllerendpoint=$2
)

runTestWithCreds()
{
(
CSI_ENDPOINT=$1 CSI_ENABLE_CREDS=true ./bin/mock-driver &
local pid=$!
trap 'cleanup $pid $1' EXIT

./cmd/csi-sanity/csi-sanity $TESTARGS --csi.endpoint=$2 --csi.secrets=mock/mocksecret.yaml --csi.testnodevolumeattachlimit; ret=$?
kill -9 $pid

if [ $ret -ne 0 ] ; then
exit $ret
fi
}
./cmd/csi-sanity/csi-sanity $TESTARGS --csi.endpoint=$2 --csi.secrets=mock/mocksecret.yaml --csi.testnodevolumeattachlimit
)

runTestAPI()
{
(
CSI_ENDPOINT=$1 ./bin/mock-driver &
local pid=$!
trap 'cleanup $pid $1' EXIT

GOCACHE=off go test -v ./hack/_apitest/api_test.go; ret=$?

if [ $ret -ne 0 ] ; then
exit $ret
fi

GOCACHE=off go test -v ./hack/_embedded/embedded_test.go; ret=$?
kill -9 $pid

if [ $ret -ne 0 ] ; then
exit $ret
fi
}
GOCACHE=off go test -v ./hack/_apitest/api_test.go && \
GOCACHE=off go test -v ./hack/_embedded/embedded_test.go
)

runTestAPIWithCustomTargetPaths()
{
(
CSI_ENDPOINT=$1 ./bin/mock-driver &
local pid=$!
trap 'cleanup $pid $1' EXIT

# Running a specific test to verify that the custom target paths are called
# a deterministic number of times.
GOCACHE=off go test -v ./hack/_apitest2/api_test.go -ginkgo.focus="NodePublishVolume"; ret=$?

if [ $ret -ne 0 ] ; then
exit $ret
fi
}
GOCACHE=off go test -v ./hack/_apitest2/api_test.go -ginkgo.focus="NodePublishVolume"
)

runTestWithCustomTargetPaths()
{
CSI_ENDPOINT=$1 ./bin/mock-driver &
local pid=$!
(

# Create a script for custom target path creation.
echo '#!/bin/bash
Expand All @@ -104,47 +88,29 @@ rm -rf $@
local creationscriptpath="$PWD/custompathcreation.bash"
local removalscriptpath="$PWD/custompathremoval.bash"

CSI_ENDPOINT=$1 ./bin/mock-driver &
local pid=$!
trap 'cleanup $pid $1; rm $creationscriptpath $removalscriptpath' EXIT

./cmd/csi-sanity/csi-sanity $TESTARGS \
--csi.endpoint=$2 \
--csi.mountdir="foo/target/mount" \
--csi.stagingdir="foo/staging/mount" \
--csi.createmountpathcmd=$creationscriptpath \
--csi.createstagingpathcmd=$creationscriptpath \
--csi.removemountpathcmd=$removalscriptpath \
--csi.removestagingpathcmd=$removalscriptpath; ret=$?
kill -9 $pid

# Delete the script.
rm $creationscriptpath $removalscriptpath

if [ $ret -ne 0 ] ; then
exit $ret
fi
}
--csi.removestagingpathcmd=$removalscriptpath
)

make

cd cmd/csi-sanity
make clean install || exit 1
cd ../..

runTest "${UDS}" "${UDS}"
rm -f $UDS

runTestWithCreds "${UDS}" "${UDS}"
rm -f $UDS

runTestAPI "${UDS}"
rm -f $UDS

runTestWithDifferentAddresses "${UDS_NODE}" "${UDS_CONTROLLER}"
rm -f $UDS_NODE
rm -f $UDS_CONTROLLER

runTestAPIWithCustomTargetPaths "${UDS}"
rm -rf $UDS

runTest "${UDS}" "${UDS}" &&
runTestWithCreds "${UDS}" "${UDS}" &&
runTestAPI "${UDS}" &&
runTestWithDifferentAddresses "${UDS_NODE}" "${UDS_CONTROLLER}" &&
runTestAPIWithCustomTargetPaths "${UDS}" &&
runTestWithCustomTargetPaths "${UDS}" "${UDS}"
rm -rf $UDS

exit 0

0 comments on commit 5421d9f

Please sign in to comment.