diff --git a/continuousintegration/test/simple_test b/continuousintegration/test/simple_test index 2ac52f74e79751e1eb559b62f1324289c8b9c75e..a7f7b263f40bb8ebb8b95bb7de24c1989f39ce2d 100755 --- a/continuousintegration/test/simple_test +++ b/continuousintegration/test/simple_test @@ -13,17 +13,17 @@ CTA_TAPED_LOG=/var/log/cta/cta-taped.log # Colours NC='\033[0m' # No Color RED='\033[0;31m' -LIGHT_RED='\033[1;31m' +LT_RED='\033[1;31m' GREEN='\033[0;32m' -LIGHT_GREEN='\033[1;32m' +LT_GREEN='\033[1;32m' ORANGE='\033[0;33m' YELLOW='\033[1;33m' BLUE='\033[0;34m' -LIGHT_BLUE='\033[1;34m' +LT_BLUE='\033[1;34m' echo_start() { - echo -ne ${LIGHT_BLUE}$* + echo -ne ${LT_BLUE}$* } echo_end() @@ -31,9 +31,11 @@ echo_end() echo -e $*${NC} } -echo_blue() +echoc() { - echo -e ${LIGHT_BLUE}$*${NC} + COLOUR=$1 + shift + echo -e ${COLOUR}$*${NC} } error() @@ -85,15 +87,28 @@ getArchiveID() getTapeLog() { FILEID=$1 - shift + if [ $# -gt 2 ] + then + LAST_MSG=$2 + shift + fi + CURRENT_MSG=$2 for i in {1..15} do LOGLINE=$(grep " fileId=\"${FILEID}\" " $CTA_TAPED_LOG | grep " LVL=\"Info\" ") - echo $LOGLINE | grep "$*" >/dev/null + echo $LOGLINE | grep "${CURRENT_MSG}" >/dev/null [ $? -ne 0 ] || break wait_dot done [ "${LOGLINE}" != "" ] || error "Archive request fileID=\"${1}\" not found in ${CTA_TAPED_LOG}" + + # If this is the retrieve log, delete the archive log items + if [ "${LAST_MSG}" != "" ] + then + LOGLINE=$(echo -e "${LOGLINE}" | awk -v LAST_MSG="${LAST_MSG}" 'BEGIN { is_retrieve = 0; } + is_retrieve { print $0; } + $0 ~ LAST_MSG { is_retrieve = 1; }') + fi } getFrontendLog() @@ -114,12 +129,13 @@ getFrontendLog() FILENAME=file.$$ # Copy small file into EOS +echoc $LT_GREEN "Copying file into EOS..." eos cp /etc/motd ${EOS_TEST_DIR}/${FILENAME} -echo_blue "\nDisk file info:" +echoc $LT_BLUE "\nDisk file info:" eos fileinfo ${EOS_TEST_DIR}/${FILENAME} getEOSDiskFileInfo ${EOS_TEST_DIR}/${FILENAME} -echo_blue "EOS Disk ID: $EOS_DISK_ID\nDisk copies: $DISK_COPIES\nTape copies: $TAPE_COPIES\n" +echoc $LT_BLUE "EOS Disk ID: $EOS_DISK_ID\nDisk copies: $DISK_COPIES\nTape copies: $TAPE_COPIES\n" echo_start "\nWaiting for SYNC::CREATE event." getEOSWFE SYNC::CREATE ${EOS_TEST_DIR}/${FILENAME} @@ -139,11 +155,11 @@ echo_end "done" echo -e "$LOGLINE\n" echo_start "Waiting for file to be archived to tape." -getTapeLog $ARCHIVE_FILE_ID "Reported to the client a full file archival" +getTapeLog $ARCHIVE_FILE_ID 'Reported to the client a full file archival' echo_end "done" echo -e "$LOGLINE\n" -echo_blue "List archived file on tape:" +echoc $LT_BLUE "List archived file on tape:" cta-admin af ls --instance ${EOS_INSTANCE} --diskid ${EOS_DISK_ID} --header echo_start "\nWaiting for ARCHIVED event." @@ -152,16 +168,17 @@ echo_end "done" echo -e "$LOGLINE\n" getEOSDiskFileInfo ${EOS_TEST_DIR}/${FILENAME} -echo_blue "Disk copies: $DISK_COPIES\nTape copies: $TAPE_COPIES\n" +echoc $LT_BLUE "Disk copies: $DISK_COPIES\nTape copies: $TAPE_COPIES\n" ## ## Retrieval ## +echoc $LT_GREEN "Retrieving file from CTA..." XrdSecPROTOCOL=sss XrdSecSSSKT=/etc/cta/eos.sss.keytab |\ sudo xrdfs root://localhost/ prepare -s "${EOS_TEST_DIR}/${FILENAME}?eos.ruid=${EOS_RUID}" -echo_start "\nWaiting for SYNC::PREPARE event." +echo_start "Waiting for SYNC::PREPARE event." getEOSWFE SYNC::PREPARE ${EOS_TEST_DIR}/${FILENAME} echo_end "done" echo -e "$LOGLINE\n" @@ -172,10 +189,21 @@ echo_end "done" echo -e "$LOGLINE\n" echo_start "Waiting for file to be retrieved from tape." -getTapeLog $ARCHIVE_FILE_ID "File successfully transfered to disk" +getTapeLog $ARCHIVE_FILE_ID 'Reported to the client a full file archival' 'File successfully transfered to disk' echo_end "done" echo -e "$LOGLINE\n" getEOSDiskFileInfo ${EOS_TEST_DIR}/${FILENAME} -echo_blue "Disk copies: $DISK_COPIES\nTape copies: $TAPE_COPIES\n" - +echoc $LT_BLUE "Disk copies: $DISK_COPIES\nTape copies: $TAPE_COPIES\n" + +echoc $LT_GREEN "Copying file out of EOS..." +eos cp ${EOS_TEST_DIR}/${FILENAME} /tmp/${FILENAME} +ls -l /tmp/${FILENAME} +diff /tmp/${FILENAME} /etc/motd +if [ $? -eq 0 ] +then + echoc $LT_GREEN "Files match, OK." +else + error "Files differ." +fi +rm -f /tmp/${FILENAME}