Commit 51560c4c authored by Michael Davis's avatar Michael Davis
Browse files

[migration] Some improvements to eos-test-inject script

parent 591c5c48
......@@ -201,7 +201,7 @@ int main(int argc, const char* argv[])
}
} catch(std::runtime_error &ex) {
std::cerr << ex.what() << std::endl;
return -1;
return 1;
}
return 0;
}
......@@ -230,7 +230,7 @@ int main(int argc, const char* argv[])
}
} catch(std::runtime_error &ex) {
std::cerr << ex.what() << std::endl;
return -1;
return 1;
}
return 0;
}
......@@ -24,38 +24,70 @@ echoc()
echo -e "${COLOUR}$*${NC}"
}
clean()
{
echoc $LT_GREEN "Cleaning up: removing tombstones and removing injected directories"
eos rmdir ${EOS_PREFIX}/my_test_dir 2>/dev/null
eos rmdir ${EOS_PREFIX}/my_test_dir2 2>/dev/null
sudo systemctl restart eos@mgm
sleep 5
eos rmdir ${EOS_PREFIX}/my_test_dir 2>/dev/null
eos rmdir ${EOS_PREFIX}/my_test_dir2 2>/dev/null
}
TEST_PATH=$(which eos-test-dir-inject)
[ -x ${TEST_PATH} ] || error "Can't find executable eos-test-dir-inject"
eos mkdir -p /eos/grpc
CONFIG_FILE=/etc/cta/castor-migration.conf
[ -r ${CONFIG_FILE} ] || error "Can't find configuration file ${CONFIG_FILE}"
TMPFILE=/tmp/eos-test-inject-sh.$$
CASTOR_PREFIX=$(awk '/^castor.prefix[ ]/ { print $2 }' ${CONFIG_FILE})
EOS_PREFIX=$(awk '/^eos.prefix[ ]/ { print $2 }' ${CONFIG_FILE})
if [ "$1" = "clean" ]
then
clean
exit 0
fi
# Create the top-level directory. GNU coreutils "mkdir -p" does not return an error if the directory
# already exists; "eos mkdir -p" does return an error, which we explicitly ignore.
eos mkdir -p ${EOS_PREFIX} 2>/dev/null
# Create directory with system-assigned file id -- should succeed
echoc $LT_BLUE "Creating directory with auto-assigned file id"
eos-test-dir-inject --path /castor/cern.ch/my_test_dir | json-pretty-print.sh
eos ls -l /eos/grpc
eos fileinfo /eos/grpc/my_test_dir
eos rmdir /eos/grpc/my_test_dir
eos-test-dir-inject --path ${CASTOR_PREFIX}/my_test_dir >${TMPFILE}
[ $? -eq 0 ] || error "Creating directory with auto-assigned file id failed"
json-pretty-print.sh ${TMPFILE}
rm ${TMPFILE}
eos ls -l ${EOS_PREFIX}
eos fileinfo ${EOS_PREFIX}/my_test_dir
eos rmdir ${EOS_PREFIX}/my_test_dir
# Create directory with self-assigned file id -- should succeed
echoc $LT_BLUE "Creating directory with self-assigned file id"
eos-test-dir-inject --fileid 9876543210 --path /castor/cern.ch/my_test_dir | json-pretty-print.sh
eos fileinfo /eos/grpc/my_test_dir
eos-test-dir-inject --fileid 9876543210 --path ${CASTOR_PREFIX}/my_test_dir >${TMPFILE}
[ $? -eq 0 ] || error "Creating directory with self-assigned file id failed"
json-pretty-print.sh ${TMPFILE}
rm ${TMPFILE}
eos fileinfo ${EOS_PREFIX}/my_test_dir
# Try again -- should fail
echoc $LT_GREEN "Creating directory with the same file id (should fail)"
eos-test-dir-inject --fileid 9876543210 --path /castor/cern.ch/my_test_dir2 >/dev/null
eos-test-dir-inject --fileid 9876543210 --path ${CASTOR_PREFIX}/my_test_dir2 >/dev/null
[ $? -ne 0 ] || error "Creating directory with self-assigned file id succeeded when it should have failed"
# Remove and try again -- should succeed after restarting EOS
echoc $LT_GREEN "Remove the directory and restart EOS to remove the tombstone"
eos rmdir /eos/grpc/my_test_dir
sudo systemctl restart eos@*
eos rmdir ${EOS_PREFIX}/my_test_dir
sudo systemctl restart eos@mgm
sleep 3
echoc $LT_BLUE "Recreate the directory with self-assigned file id (should succeed this time)"
eos-test-dir-inject --fileid 9876543210 --path /castor/cern.ch/my_test_dir >/dev/null
eos fileinfo /eos/grpc/my_test_dir
eos-test-dir-inject --fileid 9876543210 --path ${CASTOR_PREFIX}/my_test_dir >/dev/null
[ $? -eq 0 ] || error "Creating directory with self-assigned file id failed with error $?"
eos fileinfo ${EOS_PREFIX}/my_test_dir
# Restart EOS once more to remove the tombstone
echoc $LT_GREEN "Cleaning up: remove the directory and restart EOS to remove the tombstone"
eos rmdir /eos/grpc/my_test_dir
sudo systemctl restart eos@*
sleep 3
clean
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment