Skip to content
Snippets Groups Projects
Commit 178a96db authored by Cedric CAFFY's avatar Cedric CAFFY
Browse files

Added multiple repack test scripts

parent 325dc506
No related branches found
No related tags found
No related merge requests found
......@@ -233,6 +233,11 @@ while test 0 != ${ARCHIVING}; do
echo "${ARCHIVED}/${TO_BE_ARCHIVED} archived"
ARCHIVING=$((${TO_BE_ARCHIVED} - ${ARCHIVED}))
NB_TAPE_NOT_FULL=`admin_cta --json ta ls --all | jq "[.[] | select(.full == false)] | length"`
if test ${NB_TAPE_NOT_FULL} == 0; then
echo "$(date +%s): All tapes are full, exiting archiving loop"
break
fi
done
......
#!/bin/bash
#default CI EOS instance
EOSINSTANCE=ctaeos
EOSBASEDIR=/eos/ctaeos/preprod
#default Repack timeout
WAIT_FOR_REPACK_TIMEOUT=300
die() {
echo "$@" 1>&2
test -z $TAILPID || kill ${TAILPID} &> /dev/null
exit 1
}
usage() { cat <<EOF 1>&2
Usage: $0 -s <size_of_tapes> -n <nb_files_per_tape> -b <repack_buffer_url> [-e <eosinstance>] [-d <eosbasedir>] [-t <timeout>]
size_of_tape : in MB
repack_buffer_url example : /eos/ctaeos/repack
eosinstance : the name of the ctaeos instance to be used (default ctaeos)
eosbasedir : the path in which files will be created for archival
timeout : the timeout in seconds to wait for each repack request to be complete
EOF
exit 1
}
if [ $# -lt 6 ]
then
usage
fi;
while getopts "s:n:e:t:b:d:" o; do
case "${o}" in
s)
SIZE_OF_TAPES=${OPTARG}
;;
n)
NB_FILES_PER_TAPE=${OPTARG}
;;
e)
EOSINSTANCE=${OPTARG}
;;
t)
WAIT_FOR_REPACK_TIMEOUT=${OPTARG}
;;
b)
REPACK_BUFFER_URL=${OPTARG}
;;
d)
EOSBASEDIR=${OPTARG}
;;
*)
usage
;;
esac
done
shift $((OPTIND -1))
if [ -z "${SIZE_OF_TAPES}" ]; then
usage
fi
if [ -z "${NB_FILES_PER_TAPE}" ]; then
usage
fi
if [ -z "${REPACK_BUFFER_URL}" ]; then
usage
fi
echo "Starting multiple repack test"
. /root/client_helper.sh
# Get kerberos credentials for user1
admin_kinit
admin_klist > /dev/null 2>&1 || die "Cannot get kerberos credentials for user ${USER}"
# Get the number of tapes available
# availableTapes=`admin_cta --json ta ls --all | jq -r ".[] | select (.occupancy==\"0\") | .vid"`
availableTapes=`admin_cta --json ta ls --all | jq -r ".[] | select (.full==false) | .vid"`
# Save the available tapes in an array
read -a arrayTapes <<< $availableTapes
nbTapes=${#arrayTapes[@]}
#Get the tapes that we will repack
nbTapesToRepack=$(($nbTapes/2))
tapesToRepack=()
for ((i=0; i<nbTapesToRepack; i++))
do
tapesToRepack+=(${arrayTapes[$i]})
done
destinationTapes=()
for (( i=$(($nbTapesToRepack)); i<nbTapes; i++ ))
do
destinationTapes+=(${arrayTapes[$i]})
done
# Mark repack destination tape as full, we don't want to archive on them
for vid in ${destinationTapes[@]}
do
echo "Marking repack destination tape (${vid}) as full"
admin_cta tape ch --vid $vid --full true
done
nbDestinationTape=${#destinationTapes[@]}
# Compute the number of files to copy and the size of each file
fileSizeToCopy=`perl -e "print int((${SIZE_OF_TAPES} / ${NB_FILES_PER_TAPE}) * 1000)"`
nbFilesToCopy=$(($NB_FILES_PER_TAPE * $nbTapesToRepack))
echo
echo "file size to copy (in KB) = $fileSizeToCopy"
echo "Nb files to copy = $nbFilesToCopy"
bash /root/client_ar.sh -n ${nbFilesToCopy} -s ${fileSizeToCopy} -p 100 -d ${EOSBASEDIR} -v -A || exit 1
for vid in ${destinationTapes[@]}
do
echo "Marking destination tape (${vid}) as not full"
admin_cta tape ch --vid $vid --full false
done
allPid=()
for vid in ${tapesToRepack[@]}
do
echo "Launching repack requests on vid $vid"
bash /root/repack_systemtest.sh -v $vid -b ${REPACK_BUFFER_URL} &
allPid+=($!)
#admin_cta repack add --vid $vid -m -b root://ctaeos//eos/ctaeos/repack
done
oneRepackFailed=0
for pid in ${allPid[@]}
do
wait $pid || oneRepackFailed=1
done
if [[ $oneRepackFailed == 1 ]]
then
die "Fail of multiple_repack test"
fi
echo "End of multiple_repack test"
#WAIT_FOR_REPACK_TIMEOUT=300
#
#while test $nbTapesToRepack != `admin_cta --json re ls | jq "[.[] | select(.status == \"Complete\" or .status == \"Failed\")] | length"`; do
# echo "Waiting for repack request on all tapes to be complete: Seconds passed = $SECONDS_PASSED"
# sleep 1
# let SECONDS_PASSED=SECONDS_PASSED+1
#
# if test ${SECONDS_PASSED} == ${WAIT_FOR_REPACK_TIMEOUT}; then
# echo "Timed out after ${WAIT_FOR_REPACK_TIMEOUT} seconds waiting all tapes to be repacked"
# exit 1
# fi
#done
#
#successfulRepackTapes=`admin_cta --json re ls | jq ".[] | select(.status == \"Complete\") | .vid"`
#failedToRepackTapes=`admin_cta --json re ls | jq ".[] | select(.status == \"Failed\") | .vid"`
#
#read -a arrayFailedToRepackTapes <<< $failedToRepackTapes
#
#if test 0 != ${#arrayFailedToRepackTapes[@]} then
# echo "Repack failed for tapes ${arrayFailedToRepackTapes[@]}."
# exit 1
#else
# for vid in $successfulRepackTapes[@]
# do
# bash /root/repack_generate_report.sh -v $vid
# done
# echo "End of multiple repack test"
# exit 0
#fi
# echo $nb_tapes_to_fill
\ No newline at end of file
#default CI EOS instance
EOSINSTANCE=ctaeos
#default Repack timeout
WAIT_FOR_REPACK_TIMEOUT=300
die() {
echo "$@" 1>&2
test -z $TAILPID || kill ${TAILPID} &> /dev/null
exit 1
}
usage() { cat <<EOF 1>&2
Usage: $0 -n <namespace>
EOF
exit 1
}
while getopts "n:" o; do
case "${o}" in
n)
NAMESPACE=${OPTARG}
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
if [ -z "${NAMESPACE}" ]; then
usage
fi
if [ ! -z "${error}" ]; then
echo -e "ERROR:\n${error}"
exit 1
fi
echo "Preparing namespace for the tests"
./prepare_tests.sh -n ${NAMESPACE}
kubectl -n ${NAMESPACE} cp client_helper.sh client:/root/client_helper.sh
kubectl -n ${NAMESPACE} cp client_ar.sh client:/root/client_ar.sh
kubectl -n ${NAMESPACE} cp multiple_repack.sh client:/root/multiple_repack.sh
kubectl -n ${NAMESPACE} cp repack_systemtest.sh client:/root/repack_systemtest.sh
kubectl -n ${NAMESPACE} cp repack_generate_report.sh client:/root/repack_generate_report.sh
NB_FILES_PER_TAPE=1000
SIZE_OF_TAPES=2
REPACK_BUFFER_URL=/eos/ctaeos/repack
echo "Creating the repack buffer URL directory (${REPACK_BUFFER_URL})"
kubectl -n ${NAMESPACE} exec ctaeos -- eos mkdir ${REPACK_BUFFER_URL}
kubectl -n ${NAMESPACE} exec ctaeos -- eos chmod 1777 ${REPACK_BUFFER_URL}
echo "Enabling all drives"
kubectl -n ${NAMESPACE} exec ctacli -- cta-admin dr up ".*"
kubectl -n ${NAMESPACE} exec client -- bash /root/multiple_repack.sh -n ${NB_FILES_PER_TAPE} -s ${SIZE_OF_TAPES} -b ${REPACK_BUFFER_URL} || exit 1
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment