-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tests] Add a simple set of smoke tests for server+client
- Loading branch information
Showing
4 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,5 @@ endif() | |
if( BUILD_CEPH ) | ||
add_subdirectory( XrdCephTests ) | ||
endif() | ||
|
||
add_subdirectory(XRootD) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
if(XRDCL_ONLY) | ||
return() | ||
endif() | ||
|
||
execute_process(COMMAND id -u OUTPUT_VARIABLE UID OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
|
||
if (UID EQUAL 0) | ||
return() | ||
endif() | ||
|
||
set(XRD_TEST_PORT "10940" CACHE STRING "Port for XRootD Test Server") | ||
|
||
list(APPEND XRDENV "XRDCP=$<TARGET_FILE:xrdcp>") | ||
list(APPEND XRDENV "XRDFS=$<TARGET_FILE:xrdfs>") | ||
list(APPEND XRDENV "CRC32C=$<TARGET_FILE:xrdcrc32c>") | ||
list(APPEND XRDENV "ADLER32=$<TARGET_FILE:xrdadler32>") | ||
list(APPEND XRDENV "HOST=root://localhost:${XRD_TEST_PORT}") | ||
|
||
configure_file(xrootd.cfg xrootd.cfg @ONLY) | ||
|
||
add_test(NAME XRootD::start | ||
COMMAND sh -c "mkdir -p data && \ | ||
$<TARGET_FILE:xrootd> -b -k fifo -l xrootd.log -s xrootd.pid -c xrootd.cfg") | ||
set_tests_properties(XRootD::start PROPERTIES FIXTURES_SETUP XRootD) | ||
|
||
add_test(NAME XRootD::stop COMMAND sh -c "sleep 1 && rm -rf data && kill $(< xrootd.pid)") | ||
set_tests_properties(XRootD::stop PROPERTIES FIXTURES_CLEANUP XRootD) | ||
|
||
add_test(NAME XRootD::smoke-test | ||
COMMAND sh -c "${CMAKE_CURRENT_SOURCE_DIR}/smoke.sh") | ||
|
||
set_tests_properties(XRootD::smoke-test PROPERTIES | ||
ENVIRONMENT "${XRDENV}" FIXTURES_REQUIRED XRootD) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#!/usr/bin/env bash | ||
|
||
: ${ADLER32:=$(command -v xrdadler32)} | ||
: ${CRC32C:=$(command -v xrdcrc32c)} | ||
: ${XRDCP:=$(command -v xrdcp)} | ||
: ${XRDFS:=$(command -v xrdfs)} | ||
: ${OPENSSL:=$(command -v openssl)} | ||
: ${HOST:=root://localhost:${PORT:-1094}} | ||
|
||
for PROG in ${ADLER32} ${CRC32C} ${XRDCP} ${XRDFS} ${OPENSSL}; 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 -e | ||
|
||
${XRDCP} --version | ||
${XRDFS} ${HOST} query config version | ||
|
||
# query some common server configurations | ||
|
||
CONFIG_PARAMS=( version role sitename ) | ||
|
||
for PARAM in ${CONFIG_PARAMS[@]}; do | ||
${XRDFS} ${HOST} query config ${PARAM} | ||
done | ||
|
||
# some extra query commands that don't make any changes | ||
|
||
${XRDFS} ${HOST} stat / | ||
${XRDFS} ${HOST} statvfs / | ||
${XRDFS} ${HOST} spaceinfo / | ||
|
||
# create local temporary directory | ||
TMPDIR=$(mktemp -d /tmp/xrdfs-test-XXXXXX) | ||
|
||
# cleanup after ourselves if something fails | ||
trap "rm -rf ${TMPDIR}" EXIT | ||
|
||
# create remote temporary directory | ||
# this will get cleaned up by CMake upon fixture tear down | ||
${XRDFS} ${HOST} mkdir -p ${TMPDIR} | ||
|
||
# create local files with random contents using OpenSSL | ||
|
||
FILES=$(seq -w 1 ${NFILES:-10}) | ||
|
||
for i in $FILES; do | ||
${OPENSSL} rand -out "${TMPDIR}/${i}.ref" $((1024 * $RANDOM)) | ||
done | ||
|
||
# upload local files to the server in parallel | ||
|
||
for i in $FILES; do | ||
${XRDCP} ${TMPDIR}/${i}.ref ${HOST}/${TMPDIR}/${i}.ref | ||
done | ||
|
||
# list uploaded files, then download them to check for corruption | ||
|
||
${XRDFS} ${HOST} ls -l ${TMPDIR} | ||
|
||
for i in $FILES; do | ||
${XRDCP} ${HOST}/${TMPDIR}/${i}.ref ${TMPDIR}/${i}.dat | ||
done | ||
|
||
# check that all checksums for downloaded files match | ||
|
||
for i in $FILES; do | ||
REF32C=$(${CRC32C} -< ${TMPDIR}/${i}.ref | cut -d' ' -f1) | ||
NEW32C=$(${CRC32C} -< ${TMPDIR}/${i}.dat | cut -d' ' -f1) | ||
SRV32C=$(${XRDFS} ${HOST} query checksum ${TMPDIR}/${i}.ref?cks.type=crc32c | cut -d' ' -f2) | ||
|
||
REFA32=$(${ADLER32} < ${TMPDIR}/${i}.ref | cut -d' ' -f1) | ||
NEWA32=$(${ADLER32} < ${TMPDIR}/${i}.dat | cut -d' ' -f1) | ||
SRVA32=$(${XRDFS} ${HOST} query checksum ${TMPDIR}/${i}.ref?cks.type=adler32 | cut -d' ' -f2) | ||
echo "${i}: crc32c: reference: ${REF32C}, server: ${SRV32C}, downloaded: ${REFA32}" | ||
echo "${i}: adler32: reference: ${NEW32C}, server: ${SRVA32}, downloaded: ${NEWA32}" | ||
|
||
if [[ "${NEWA32}" != "${REFA32}" || "${SRVA32}" != "${REFA32}" ]]; then | ||
echo 1>&2 "$(basename $0): error: adler32 checksum check failed for file: ${i}.dat" | ||
exit 1 | ||
fi | ||
if [[ "${NEW32C}" != "${REF32C}" || "${SRV32C}" != "${REF32C}" ]]; then | ||
echo 1>&2 "$(basename $0): error: crc32 checksum check failed for file: ${i}.dat" | ||
exit 1 | ||
fi | ||
done | ||
|
||
for i in $FILES; do | ||
${XRDFS} ${HOST} rm ${TMPDIR}/${i}.ref & | ||
done | ||
|
||
wait | ||
|
||
${XRDFS} ${HOST} rmdir ${TMPDIR} | ||
|
||
echo "ALL TESTS PASSED" | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# This minimal configuration file starts a standalone server | ||
# that exports the data directory as / without authentication. | ||
|
||
all.export / | ||
all.sitename XRootD | ||
oss.localroot @CMAKE_CURRENT_BINARY_DIR@/data | ||
xrd.port @XRD_TEST_PORT@ | ||
xrootd.chksum chkcgi adler32 crc32c |