Skip to content
Snippets Groups Projects
Commit 6c52f477 authored by Michael Davis's avatar Michael Davis
Browse files

[ci] Creates top-level EOS directory for gRPC tests

parent b71eff69
No related branches found
No related tags found
No related merge requests found
......@@ -30,7 +30,7 @@ castor.max_num_connections 1
castor.batch_size 100
castor.prefix /castor/cern.ch
eos.dry_run false
eos.prefix /eos/grpc
eos.prefix /eos/grpctest
eos.endpoint ${EOS_HOSTNAME}:50051
eos.token ${EOS_AUTH_KEY}
EOF
......
......@@ -48,6 +48,8 @@ CTA_PROC_DIR=/eos/${EOS_INSTANCE}/proc/cta
CTA_WF_DIR=${CTA_PROC_DIR}/workflow
# dir for cta tests only for eosusers and powerusers
CTA_TEST_DIR=/eos/${EOS_INSTANCE}/cta
# dir for gRPC tests, should be the same as eos.prefix in client.sh
GRPC_TEST_DIR=/eos/grpctest
# dir for eos instance basic tests writable and readable by anyone
EOS_TMP_DIR=/eos/${EOS_INSTANCE}/tmp
......@@ -212,18 +214,16 @@ fi
#
# 1. Map requests to EOS virtual identities
eos -r 0 0 vid add gateway eoscta grpc
# 2. Add authorisation key
#
# Note: EOS_GRPC_USER and EOS_AUTH_KEY must be the same as those specified in client.sh
EOS_GRPC_USER=daemon
EOS_GRPC_GROUP=${EOS_GRPC_USER}
# Note: EOS_AUTH_KEY must be the same as the one specified in client.sh
EOS_AUTH_KEY=migration-test-token
# daemon is already in EOS sudo group (see above)
#eos vid set membership ${EOS_GRPC_USER} +sudo
eos -r 0 0 vid set map -grpc key:${EOS_AUTH_KEY} vuid:${EOS_GRPC_USER} vgid:${EOS_GRPC_GROUP}
eos -r 0 0 vid set map -grpc key:${EOS_AUTH_KEY} vuid:2 vgid:2
echo "gRPC authorized uid and gid:"
eos -r 0 0 vid ls | grep grpc:
# 3. Create top-level directory and set permissions to writeable by all
eos mkdir ${GRPC_TEST_DIR}
eos chmod 777 ${GRPC_TEST_DIR}
# ${CTA_TEST_DIR} must be writable by eosusers and powerusers
# but as there is no sticky bit in eos, we need to remove deletion for non owner to eosusers members
......@@ -232,7 +232,6 @@ fi
eos mkdir ${CTA_TEST_DIR}
eos chmod 555 ${CTA_TEST_DIR}
eos attr set sys.acl=g:eosusers:rwx!d,u:poweruser1:rwx+dp,u:poweruser2:rwx+dp /eos/ctaeos/cta
eos attr set CTA_StorageClass=ctaStorageClass ${CTA_TEST_DIR}
# Link the attributes of CTA worklow directory to the test directory
......
#!/bin/sh
# Migration tools parameters
EOS_GRPC_USER=daemon
EOS_TEST_DIR_INJECT=/usr/bin/eos-test-dir-inject
CONFIG_FILE=/etc/cta/castor-migration.conf
TMPFILE=/tmp/eos-test-inject-sh.$$
......@@ -30,19 +29,13 @@ echoc()
echo -e "${COLOUR}$*${NC}"
}
test_dir_inject()
{
COMMAND="${EOS_TEST_DIR_INJECT} $*"
sudo -u ${EOS_GRPC_USER} bash -c "${COMMAND}"
}
[ -x ${EOS_TEST_DIR_INJECT} ] || error "Can't find executable ${EOS_TEST_DIR_INJECT}"
[ -r ${CONFIG_FILE} ] || error "Can't find configuration file ${CONFIG_FILE}"
CASTOR_PREFIX=$(awk '/^castor.prefix[ ]/ { print $2 }' ${CONFIG_FILE})
EOS_PREFIX=$(awk '/^eos.prefix[ ]/ { print $2 }' ${CONFIG_FILE})
# Ping the gRPC interface
test_dir_inject ping || error "gRPC ping failed"
${EOS_TEST_DIR_INJECT} ping || error "gRPC ping failed"
# 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.
......@@ -50,7 +43,7 @@ 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"
test_dir_inject --path ${CASTOR_PREFIX}/my_test_dir >${TMPFILE}
${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}
......@@ -60,7 +53,7 @@ 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"
test_dir_inject --fileid 9876543210 --path ${CASTOR_PREFIX}/my_test_dir >${TMPFILE}
${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}
......@@ -68,14 +61,14 @@ eos fileinfo ${EOS_PREFIX}/my_test_dir
# Try again -- should fail
echoc $LT_GREEN "Creating directory with the same file id (should fail)"
test_dir_inject --fileid 9876543210 --path ${CASTOR_PREFIX}/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_PREFIX}/my_test_dir
echoc $LT_BLUE "Recreate the directory with self-assigned file id (should succeed this time)"
test_dir_inject --fileid 9876543210 --path ${CASTOR_PREFIX}/my_test_dir >/dev/null
${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
......
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