|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +## This file is for livenessprove which runs in a pair with csi |
| 4 | +## hostpath |
| 5 | + |
| 6 | +## Must be run from the root of the repo |
| 7 | +UDS="/tmp/e2e-csi-sanity.sock" |
| 8 | +CSI_ENDPOINT="unix://${UDS}" |
| 9 | +CSI_MOUNTPOINT="/mnt" |
| 10 | +APP=hostpathplugin |
| 11 | + |
| 12 | +SKIP="WithCapacity" |
| 13 | +if [ x${TRAVIS} = x"true" ] ; then |
| 14 | + SKIP="WithCapacity|NodeUnpublishVolume|NodePublishVolume" |
| 15 | +fi |
| 16 | + |
| 17 | +git clone https://github.com/kubernetes-csi/drivers ./"$APP" |
| 18 | +pushd hostpathplugin |
| 19 | +# Build |
| 20 | +make hostpath; ret=$? |
| 21 | +if [ $ret -ne 0 ]; then |
| 22 | + echo "Failed to build hostpath plugin, file a bug against drivers repo" |
| 23 | + exit 1 |
| 24 | +fi |
| 25 | +popd |
| 26 | + |
| 27 | +sudo rm -rf "$UDS" || true |
| 28 | + |
| 29 | +# Start hostpathplugin in the background |
| 30 | +sudo ./hostpathplugin/_output/$APP --endpoint=$CSI_ENDPOINT --nodeid=1 --v=5 & |
| 31 | + |
| 32 | +# Start liveness probe in the background |
| 33 | +sudo ./bin/livenessprobe --csi-address=$CSI_ENDPOINT & |
| 34 | + |
| 35 | +# Give time to CSI hostpathplugin and livenessprobe to initialize |
| 36 | +sleep 3 |
| 37 | + |
| 38 | +# Requesting health |
| 39 | +health=$(curl -I http://localhost:9808 | grep HTTP | awk '{print $2}' |
| 40 | +if [[ "x$health" != "x200" ]]; then |
| 41 | + echo "Health check failed, but it was not supposed to, exiting..." |
| 42 | + exit 1 |
| 43 | +fi |
| 44 | +
|
| 45 | +# Killing hostpathplugin |
| 46 | +sudo kill -9 $(pidof hostpathplugin) |
| 47 | +sleep 3 |
| 48 | +
|
| 49 | +# Requesting health, should fail since hostpathplugin is gone |
| 50 | +health=$(curl -I http://localhost:9808 | grep HTTP | awk '{print $2}' |
| 51 | +if [[ "x$health" != "x500" ]]; then |
| 52 | + echo "Health check did not detect driver failure, returned code: $health, exiting..." |
| 53 | + exit 1 |
| 54 | +fi |
| 55 | +
|
| 56 | +sudo rm -f $UDS |
| 57 | +exit 0 |
0 commit comments