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 71
|
#!/usr/bin/env bash
# macOS, as of now, cannot run this test because of the 'declare -A'
# command that we use later, so we just skip this test (sorry apple users)
if [[ $(uname) == "Darwin" ]]; then
exit 0
fi
# we probably need all of these still
: ${XRDCP:=$(command -v xrdcp)}
: ${XRDFS:=$(command -v xrdfs)}
: ${TIMEOUTCMD:=$(command -v timeout)}
: ${HOST_SRV1:=root://localhost:10981}
: ${HOST_SRV2:=root://localhost:10982}
# checking for command presence
for PROG in ${XRDCP} ${XRDFS} ${TIMEOUTCMD}; do
if [[ ! -x "${PROG}" ]]; then
echo 1>&2 "$(basename $0): error: '${PROG}': command not found"
exit 1
fi
done
# This script assumes that ${host} exports an empty / as read/write.
# It also assumes that any authentication required is already setup.
set -xe
${XRDCP} --version
# hostname-address pair, so that we can keep track of files more easily
declare -A hosts
hosts["srv1"]="${HOST_SRV1}"
hosts["srv2"]="${HOST_SRV2}"
for host in "${!hosts[@]}"; do
${XRDFS} ${hosts[$host]} query config version
done
# query some common server configurations
CONFIG_PARAMS=( version role sitename )
for PARAM in ${CONFIG_PARAMS[@]}; do
for host in "${!hosts[@]}"; do
${XRDFS} ${hosts[$host]} query config ${PARAM}
done
done
XRD_CONNECTIONRETRY=0 ${TIMEOUTCMD} 10 ${XRDCP} /etc/hosts ${HOST_SRV1}//file1
XRD_CONNECTIONRETRY=0 ${TIMEOUTCMD} 10 ${XRDCP} -f ${HOST_SRV2}//file1 /dev/null
dd if=/dev/zero of=data/srv-pfc/file1 bs=1 count=1 conv=notrunc
set +e
XRD_CONNECTIONRETRY=0 ${TIMEOUTCMD} 10 ${XRDCP} -f ${HOST_SRV2}//file1 /dev/null 2> /tmp/err.txt
ret1=$?
grep -q "Run: \[ERROR\] Server responded with an error: \[3019\]" /tmp/err.txt
ret2=$?
cat /tmp/err.txt
if [ $ret1 -ne 54 -o $ret2 -ne 0 ]; then
echo "${host}: did not get the expected error on corrupted file"
exit 1
fi
set -e
rm -f /tmp/err.txt
echo "ALL TESTS PASSED"
exit 0
|