2015-03-09 17:33:47 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -o errexit
|
2019-07-03 05:31:48 +00:00
|
|
|
set -o pipefail
|
2015-03-09 17:33:47 +00:00
|
|
|
|
2016-02-05 12:24:13 +00:00
|
|
|
source test-utils.sh
|
2015-02-24 01:58:38 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
function test_append_file {
|
2016-02-05 12:24:13 +00:00
|
|
|
describe "Testing append to file ..."
|
2019-08-21 01:19:25 +00:00
|
|
|
TEST_INPUT="echo ${TEST_TEXT} to ${TEST_TEXT_FILE}"
|
2017-08-11 14:09:43 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
# Write a small test file
|
|
|
|
for x in `seq 1 $TEST_TEXT_FILE_LENGTH`
|
|
|
|
do
|
2019-08-21 01:19:25 +00:00
|
|
|
echo $TEST_INPUT
|
2015-09-11 23:09:00 +00:00
|
|
|
done > ${TEST_TEXT_FILE}
|
2015-08-16 22:48:05 +00:00
|
|
|
|
2019-08-21 01:19:25 +00:00
|
|
|
check_file_size "${TEST_TEXT_FILE}" $(($TEST_TEXT_FILE_LENGTH * $(echo $TEST_INPUT | wc -c)))
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
rm_test_file
|
|
|
|
}
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-11-04 05:47:15 +00:00
|
|
|
function test_truncate_file {
|
2016-02-05 12:24:13 +00:00
|
|
|
describe "Testing truncate file ..."
|
2015-11-04 05:47:15 +00:00
|
|
|
# Write a small test file
|
|
|
|
echo "${TEST_TEXT}" > ${TEST_TEXT_FILE}
|
2016-02-05 12:24:13 +00:00
|
|
|
|
2015-11-04 05:47:15 +00:00
|
|
|
# Truncate file to 0 length. This should trigger open(path, O_RDWR | O_TRUNC...)
|
|
|
|
: > ${TEST_TEXT_FILE}
|
2016-02-05 12:24:13 +00:00
|
|
|
|
2019-08-21 01:19:25 +00:00
|
|
|
check_file_size "${TEST_TEXT_FILE}" 0
|
|
|
|
|
2015-11-04 05:47:15 +00:00
|
|
|
rm_test_file
|
|
|
|
}
|
|
|
|
|
2016-04-22 06:49:37 +00:00
|
|
|
function test_truncate_empty_file {
|
2016-11-19 23:36:02 +00:00
|
|
|
describe "Testing truncate empty file ..."
|
2016-04-22 06:49:37 +00:00
|
|
|
# Write an empty test file
|
|
|
|
touch ${TEST_TEXT_FILE}
|
|
|
|
|
|
|
|
# Truncate the file to 1024 length
|
|
|
|
t_size=1024
|
|
|
|
truncate ${TEST_TEXT_FILE} -s $t_size
|
|
|
|
|
2019-08-21 01:19:25 +00:00
|
|
|
check_file_size "${TEST_TEXT_FILE}" $t_size
|
|
|
|
|
2016-04-22 06:49:37 +00:00
|
|
|
rm_test_file
|
|
|
|
}
|
2015-11-04 05:47:15 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
function test_mv_file {
|
2016-02-05 12:24:13 +00:00
|
|
|
describe "Testing mv file function ..."
|
2015-08-16 22:48:05 +00:00
|
|
|
# if the rename file exists, delete it
|
|
|
|
if [ -e $ALT_TEST_TEXT_FILE ]
|
|
|
|
then
|
|
|
|
rm $ALT_TEST_TEXT_FILE
|
|
|
|
fi
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
if [ -e $ALT_TEST_TEXT_FILE ]
|
|
|
|
then
|
|
|
|
echo "Could not delete file ${ALT_TEST_TEXT_FILE}, it still exists"
|
2016-02-05 12:24:13 +00:00
|
|
|
return 1
|
2015-08-16 22:48:05 +00:00
|
|
|
fi
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
# create the test file again
|
|
|
|
mk_test_file
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2017-08-11 14:09:43 +00:00
|
|
|
# save file length
|
|
|
|
ALT_TEXT_LENGTH=`wc -c $TEST_TEXT_FILE | awk '{print $1}'`
|
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
#rename the test file
|
|
|
|
mv $TEST_TEXT_FILE $ALT_TEST_TEXT_FILE
|
|
|
|
if [ ! -e $ALT_TEST_TEXT_FILE ]
|
|
|
|
then
|
|
|
|
echo "Could not move file"
|
2016-02-05 12:24:13 +00:00
|
|
|
return 1
|
2015-08-16 22:48:05 +00:00
|
|
|
fi
|
2019-08-29 05:25:09 +00:00
|
|
|
|
|
|
|
#check the renamed file content-type
|
|
|
|
if [ -f "/etc/mime.types" ]
|
|
|
|
then
|
|
|
|
check_content_type "$1/$ALT_TEST_TEXT_FILE" "text/plain"
|
|
|
|
fi
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
# Check the contents of the alt file
|
|
|
|
ALT_FILE_LENGTH=`wc -c $ALT_TEST_TEXT_FILE | awk '{print $1}'`
|
|
|
|
if [ "$ALT_FILE_LENGTH" -ne "$ALT_TEXT_LENGTH" ]
|
|
|
|
then
|
|
|
|
echo "moved file length is not as expected expected: $ALT_TEXT_LENGTH got: $ALT_FILE_LENGTH"
|
2016-02-05 12:24:13 +00:00
|
|
|
return 1
|
2015-08-16 22:48:05 +00:00
|
|
|
fi
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
# clean up
|
|
|
|
rm_test_file $ALT_TEST_TEXT_FILE
|
|
|
|
}
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2019-01-23 06:12:05 +00:00
|
|
|
function test_mv_empty_directory {
|
2016-02-05 12:24:13 +00:00
|
|
|
describe "Testing mv directory function ..."
|
2015-08-16 22:48:05 +00:00
|
|
|
if [ -e $TEST_DIR ]; then
|
|
|
|
echo "Unexpected, this file/directory exists: ${TEST_DIR}"
|
2016-02-05 12:24:13 +00:00
|
|
|
return 1
|
2015-08-16 22:48:05 +00:00
|
|
|
fi
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
mk_test_dir
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
mv ${TEST_DIR} ${TEST_DIR}_rename
|
|
|
|
if [ ! -d "${TEST_DIR}_rename" ]; then
|
|
|
|
echo "Directory ${TEST_DIR} was not renamed"
|
2016-02-05 12:24:13 +00:00
|
|
|
return 1
|
2015-08-16 22:48:05 +00:00
|
|
|
fi
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
rmdir ${TEST_DIR}_rename
|
|
|
|
if [ -e "${TEST_DIR}_rename" ]; then
|
|
|
|
echo "Could not remove the test directory, it still exists: ${TEST_DIR}_rename"
|
2016-02-05 12:24:13 +00:00
|
|
|
return 1
|
2015-08-16 22:48:05 +00:00
|
|
|
fi
|
|
|
|
}
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2019-01-23 06:12:05 +00:00
|
|
|
function test_mv_nonempty_directory {
|
|
|
|
describe "Testing mv directory function ..."
|
|
|
|
if [ -e $TEST_DIR ]; then
|
|
|
|
echo "Unexpected, this file/directory exists: ${TEST_DIR}"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
mk_test_dir
|
|
|
|
|
|
|
|
touch ${TEST_DIR}/file
|
|
|
|
|
|
|
|
mv ${TEST_DIR} ${TEST_DIR}_rename
|
|
|
|
if [ ! -d "${TEST_DIR}_rename" ]; then
|
|
|
|
echo "Directory ${TEST_DIR} was not renamed"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -r ${TEST_DIR}_rename
|
|
|
|
if [ -e "${TEST_DIR}_rename" ]; then
|
|
|
|
echo "Could not remove the test directory, it still exists: ${TEST_DIR}_rename"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
function test_redirects {
|
2016-02-05 12:24:13 +00:00
|
|
|
describe "Testing redirects ..."
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
mk_test_file ABCDEF
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
CONTENT=`cat $TEST_TEXT_FILE`
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2016-02-05 12:24:13 +00:00
|
|
|
if [ "${CONTENT}" != "ABCDEF" ]; then
|
2015-08-16 22:48:05 +00:00
|
|
|
echo "CONTENT read is unexpected, got ${CONTENT}, expected ABCDEF"
|
2016-02-05 12:24:13 +00:00
|
|
|
return 1
|
2015-08-16 22:48:05 +00:00
|
|
|
fi
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
echo XYZ > $TEST_TEXT_FILE
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
CONTENT=`cat $TEST_TEXT_FILE`
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
if [ ${CONTENT} != "XYZ" ]; then
|
|
|
|
echo "CONTENT read is unexpected, got ${CONTENT}, expected XYZ"
|
2016-02-05 12:24:13 +00:00
|
|
|
return 1
|
2015-08-16 22:48:05 +00:00
|
|
|
fi
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
echo 123456 >> $TEST_TEXT_FILE
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
LINE1=`sed -n '1,1p' $TEST_TEXT_FILE`
|
|
|
|
LINE2=`sed -n '2,2p' $TEST_TEXT_FILE`
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
if [ ${LINE1} != "XYZ" ]; then
|
|
|
|
echo "LINE1 was not as expected, got ${LINE1}, expected XYZ"
|
2016-02-05 12:24:13 +00:00
|
|
|
return 1
|
2015-08-16 22:48:05 +00:00
|
|
|
fi
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
if [ ${LINE2} != "123456" ]; then
|
|
|
|
echo "LINE2 was not as expected, got ${LINE2}, expected 123456"
|
2016-02-05 12:24:13 +00:00
|
|
|
return 1
|
2015-08-16 22:48:05 +00:00
|
|
|
fi
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
# clean up
|
|
|
|
rm_test_file
|
|
|
|
}
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
function test_mkdir_rmdir {
|
2016-02-05 12:24:13 +00:00
|
|
|
describe "Testing creation/removal of a directory"
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
if [ -e $TEST_DIR ]; then
|
|
|
|
echo "Unexpected, this file/directory exists: ${TEST_DIR}"
|
2016-02-05 12:24:13 +00:00
|
|
|
return 1
|
2015-08-16 22:48:05 +00:00
|
|
|
fi
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
mk_test_dir
|
|
|
|
rm_test_dir
|
|
|
|
}
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
function test_chmod {
|
2016-02-05 12:24:13 +00:00
|
|
|
describe "Testing chmod file function ..."
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
# create the test file again
|
|
|
|
mk_test_file
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2017-08-11 14:09:43 +00:00
|
|
|
if [ `uname` = "Darwin" ]; then
|
|
|
|
ORIGINAL_PERMISSIONS=$(stat -f "%p" $TEST_TEXT_FILE)
|
|
|
|
else
|
|
|
|
ORIGINAL_PERMISSIONS=$(stat --format=%a $TEST_TEXT_FILE)
|
|
|
|
fi
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
chmod 777 $TEST_TEXT_FILE;
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
# if they're the same, we have a problem.
|
2017-08-11 14:09:43 +00:00
|
|
|
if [ `uname` = "Darwin" ]; then
|
|
|
|
CHANGED_PERMISSIONS=$(stat -f "%p" $TEST_TEXT_FILE)
|
|
|
|
else
|
|
|
|
CHANGED_PERMISSIONS=$(stat --format=%a $TEST_TEXT_FILE)
|
|
|
|
fi
|
|
|
|
if [ $CHANGED_PERMISSIONS == $ORIGINAL_PERMISSIONS ]
|
2015-08-16 22:48:05 +00:00
|
|
|
then
|
|
|
|
echo "Could not modify $TEST_TEXT_FILE permissions"
|
2016-02-05 12:24:13 +00:00
|
|
|
return 1
|
2015-08-16 22:48:05 +00:00
|
|
|
fi
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
# clean up
|
|
|
|
rm_test_file
|
|
|
|
}
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
function test_chown {
|
2016-02-05 12:24:13 +00:00
|
|
|
describe "Testing chown file function ..."
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
# create the test file again
|
|
|
|
mk_test_file
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2017-08-11 14:09:43 +00:00
|
|
|
if [ `uname` = "Darwin" ]; then
|
|
|
|
ORIGINAL_PERMISSIONS=$(stat -f "%u:%g" $TEST_TEXT_FILE)
|
|
|
|
else
|
|
|
|
ORIGINAL_PERMISSIONS=$(stat --format=%u:%g $TEST_TEXT_FILE)
|
|
|
|
fi
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2020-01-28 10:32:55 +00:00
|
|
|
# [NOTE]
|
|
|
|
# Prevents test interruptions due to permission errors, etc.
|
|
|
|
# If the chown command fails, an error will occur with the
|
|
|
|
# following judgment statement. So skip the chown command error.
|
|
|
|
# '|| true' was added due to a problem with Travis CI and MacOS
|
|
|
|
# and ensure_diskfree option.
|
|
|
|
#
|
|
|
|
chown 1000:1000 $TEST_TEXT_FILE || true
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
# if they're the same, we have a problem.
|
2017-08-11 14:09:43 +00:00
|
|
|
if [ `uname` = "Darwin" ]; then
|
|
|
|
CHANGED_PERMISSIONS=$(stat -f "%u:%g" $TEST_TEXT_FILE)
|
|
|
|
else
|
|
|
|
CHANGED_PERMISSIONS=$(stat --format=%u:%g $TEST_TEXT_FILE)
|
|
|
|
fi
|
|
|
|
if [ $CHANGED_PERMISSIONS == $ORIGINAL_PERMISSIONS ]
|
2015-08-16 22:48:05 +00:00
|
|
|
then
|
2016-09-11 13:37:53 +00:00
|
|
|
if [ $ORIGINAL_PERMISSIONS == "1000:1000" ]
|
2016-09-11 13:41:50 +00:00
|
|
|
then
|
2016-09-11 13:37:53 +00:00
|
|
|
echo "Could not be strict check because original file permission 1000:1000"
|
|
|
|
else
|
|
|
|
echo "Could not modify $TEST_TEXT_FILE ownership($ORIGINAL_PERMISSIONS to 1000:1000)"
|
|
|
|
return 1
|
2016-09-11 13:41:50 +00:00
|
|
|
fi
|
2015-08-16 22:48:05 +00:00
|
|
|
fi
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
# clean up
|
|
|
|
rm_test_file
|
|
|
|
}
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
function test_list {
|
2016-02-05 12:24:13 +00:00
|
|
|
describe "Testing list"
|
2015-08-16 22:48:05 +00:00
|
|
|
mk_test_file
|
|
|
|
mk_test_dir
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
file_cnt=$(ls -1 | wc -l)
|
|
|
|
if [ $file_cnt != 2 ]; then
|
|
|
|
echo "Expected 2 file but got $file_cnt"
|
2016-02-05 12:24:13 +00:00
|
|
|
return 1
|
2015-08-16 22:48:05 +00:00
|
|
|
fi
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
rm_test_file
|
|
|
|
rm_test_dir
|
|
|
|
}
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
function test_remove_nonempty_directory {
|
2016-02-05 12:24:13 +00:00
|
|
|
describe "Testing removing a non-empty directory"
|
2015-08-16 22:48:05 +00:00
|
|
|
mk_test_dir
|
|
|
|
touch "${TEST_DIR}/file"
|
2019-07-03 05:31:48 +00:00
|
|
|
(
|
|
|
|
set +o pipefail
|
|
|
|
rmdir "${TEST_DIR}" 2>&1 | grep -q "Directory not empty"
|
|
|
|
)
|
2015-08-16 22:48:05 +00:00
|
|
|
rm "${TEST_DIR}/file"
|
|
|
|
rm_test_dir
|
|
|
|
}
|
2015-02-24 01:58:38 +00:00
|
|
|
|
2019-06-22 02:46:25 +00:00
|
|
|
function test_external_modification {
|
|
|
|
describe "Test external modification to an object"
|
|
|
|
echo "old" > ${TEST_TEXT_FILE}
|
|
|
|
OBJECT_NAME="$(basename $PWD)/${TEST_TEXT_FILE}"
|
|
|
|
sleep 2
|
2019-08-29 05:25:09 +00:00
|
|
|
echo "new new" | aws_cli s3 cp - "s3://${TEST_BUCKET_1}/${OBJECT_NAME}"
|
2019-06-22 02:46:25 +00:00
|
|
|
cmp ${TEST_TEXT_FILE} <(echo "new new")
|
|
|
|
rm -f ${TEST_TEXT_FILE}
|
|
|
|
}
|
|
|
|
|
2019-08-01 23:09:34 +00:00
|
|
|
function test_read_external_object() {
|
|
|
|
describe "create objects via aws CLI and read via s3fs"
|
|
|
|
OBJECT_NAME="$(basename $PWD)/${TEST_TEXT_FILE}"
|
2019-08-06 10:55:38 +00:00
|
|
|
sleep 3
|
2019-08-29 05:25:09 +00:00
|
|
|
echo "test" | aws_cli s3 cp - "s3://${TEST_BUCKET_1}/${OBJECT_NAME}"
|
2019-08-01 23:09:34 +00:00
|
|
|
cmp ${TEST_TEXT_FILE} <(echo "test")
|
|
|
|
rm -f ${TEST_TEXT_FILE}
|
|
|
|
}
|
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
function test_rename_before_close {
|
2016-02-05 12:24:13 +00:00
|
|
|
describe "Testing rename before close ..."
|
2015-08-16 22:48:05 +00:00
|
|
|
(
|
|
|
|
echo foo
|
|
|
|
mv $TEST_TEXT_FILE ${TEST_TEXT_FILE}.new
|
|
|
|
) > $TEST_TEXT_FILE
|
2015-02-24 01:58:38 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
if ! cmp <(echo foo) ${TEST_TEXT_FILE}.new; then
|
|
|
|
echo "rename before close failed"
|
2016-02-05 12:24:13 +00:00
|
|
|
return 1
|
2015-08-16 22:48:05 +00:00
|
|
|
fi
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
rm_test_file ${TEST_TEXT_FILE}.new
|
|
|
|
rm -f ${TEST_TEXT_FILE}
|
|
|
|
}
|
2015-01-12 22:46:24 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
function test_multipart_upload {
|
2016-02-05 12:24:13 +00:00
|
|
|
describe "Testing multi-part upload ..."
|
2017-08-11 14:09:43 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
dd if=/dev/urandom of="/tmp/${BIG_FILE}" bs=$BIG_FILE_LENGTH count=1
|
|
|
|
dd if="/tmp/${BIG_FILE}" of="${BIG_FILE}" bs=$BIG_FILE_LENGTH count=1
|
2015-03-03 00:58:11 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
# Verify contents of file
|
|
|
|
echo "Comparing test file"
|
|
|
|
if ! cmp "/tmp/${BIG_FILE}" "${BIG_FILE}"
|
|
|
|
then
|
2016-02-05 12:24:13 +00:00
|
|
|
return 1
|
2015-08-16 22:48:05 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
rm -f "/tmp/${BIG_FILE}"
|
|
|
|
rm_test_file "${BIG_FILE}"
|
|
|
|
}
|
2015-03-03 00:58:11 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
function test_multipart_copy {
|
2016-02-05 12:24:13 +00:00
|
|
|
describe "Testing multi-part copy ..."
|
2017-08-11 14:09:43 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
dd if=/dev/urandom of="/tmp/${BIG_FILE}" bs=$BIG_FILE_LENGTH count=1
|
|
|
|
dd if="/tmp/${BIG_FILE}" of="${BIG_FILE}" bs=$BIG_FILE_LENGTH count=1
|
|
|
|
mv "${BIG_FILE}" "${BIG_FILE}-copy"
|
2015-07-27 22:47:08 +00:00
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
# Verify contents of file
|
|
|
|
echo "Comparing test file"
|
|
|
|
if ! cmp "/tmp/${BIG_FILE}" "${BIG_FILE}-copy"
|
|
|
|
then
|
2016-02-05 12:24:13 +00:00
|
|
|
return 1
|
2015-08-16 22:48:05 +00:00
|
|
|
fi
|
2015-07-27 22:47:08 +00:00
|
|
|
|
2019-08-29 05:25:09 +00:00
|
|
|
#check the renamed file content-type
|
|
|
|
check_content_type "$1/${BIG_FILE}-copy" "application/octet-stream"
|
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
rm -f "/tmp/${BIG_FILE}"
|
|
|
|
rm_test_file "${BIG_FILE}-copy"
|
|
|
|
}
|
2015-07-27 22:47:08 +00:00
|
|
|
|
2019-09-26 02:30:58 +00:00
|
|
|
function test_multipart_mix {
|
|
|
|
describe "Testing multi-part mix ..."
|
|
|
|
|
|
|
|
if [ `uname` = "Darwin" ]; then
|
|
|
|
cat /dev/null > $BIG_FILE
|
|
|
|
fi
|
|
|
|
dd if=/dev/urandom of="/tmp/${BIG_FILE}" bs=$BIG_FILE_LENGTH seek=0 count=1
|
|
|
|
dd if="/tmp/${BIG_FILE}" of="${BIG_FILE}" bs=$BIG_FILE_LENGTH seek=0 count=1
|
|
|
|
|
|
|
|
# (1) Edit the middle of an existing file
|
|
|
|
# modify directly(seek 7.5MB offset)
|
|
|
|
# In the case of nomultipart and nocopyapi,
|
|
|
|
# it makes no sense, but copying files is because it leaves no cache.
|
|
|
|
#
|
|
|
|
cp /tmp/${BIG_FILE} /tmp/${BIG_FILE}-mix
|
|
|
|
cp ${BIG_FILE} ${BIG_FILE}-mix
|
|
|
|
|
|
|
|
MODIFY_START_BLOCK=$((15*1024*1024/2/4))
|
|
|
|
echo -n "0123456789ABCDEF" | dd of="${BIG_FILE}-mix" bs=4 count=4 seek=$MODIFY_START_BLOCK conv=notrunc
|
|
|
|
echo -n "0123456789ABCDEF" | dd of="/tmp/${BIG_FILE}-mix" bs=4 count=4 seek=$MODIFY_START_BLOCK conv=notrunc
|
|
|
|
|
|
|
|
# Verify contents of file
|
|
|
|
echo "Comparing test file (1)"
|
|
|
|
if ! cmp "/tmp/${BIG_FILE}-mix" "${BIG_FILE}-mix"
|
|
|
|
then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# (2) Write to an area larger than the size of the existing file
|
|
|
|
# modify directly(over file end offset)
|
|
|
|
#
|
|
|
|
cp /tmp/${BIG_FILE} /tmp/${BIG_FILE}-mix
|
|
|
|
cp ${BIG_FILE} ${BIG_FILE}-mix
|
|
|
|
|
|
|
|
OVER_FILE_BLOCK_POS=$((26*1024*1024/4))
|
|
|
|
echo -n "0123456789ABCDEF" | dd of="${BIG_FILE}-mix" bs=4 count=4 seek=$OVER_FILE_BLOCK_POS conv=notrunc
|
|
|
|
echo -n "0123456789ABCDEF" | dd of="/tmp/${BIG_FILE}-mix" bs=4 count=4 seek=$OVER_FILE_BLOCK_POS conv=notrunc
|
|
|
|
|
|
|
|
# Verify contents of file
|
|
|
|
echo "Comparing test file (2)"
|
|
|
|
if ! cmp "/tmp/${BIG_FILE}-mix" "${BIG_FILE}-mix"
|
|
|
|
then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# (3) Writing from the 0th byte
|
|
|
|
#
|
|
|
|
cp /tmp/${BIG_FILE} /tmp/${BIG_FILE}-mix
|
|
|
|
cp ${BIG_FILE} ${BIG_FILE}-mix
|
|
|
|
|
|
|
|
echo -n "0123456789ABCDEF" | dd of="${BIG_FILE}-mix" bs=4 count=4 seek=0 conv=notrunc
|
|
|
|
echo -n "0123456789ABCDEF" | dd of="/tmp/${BIG_FILE}-mix" bs=4 count=4 seek=0 conv=notrunc
|
|
|
|
|
|
|
|
# Verify contents of file
|
|
|
|
echo "Comparing test file (3)"
|
|
|
|
if ! cmp "/tmp/${BIG_FILE}-mix" "${BIG_FILE}-mix"
|
|
|
|
then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# (4) Write to the area within 5MB from the top
|
|
|
|
# modify directly(seek 1MB offset)
|
|
|
|
#
|
|
|
|
cp /tmp/${BIG_FILE} /tmp/${BIG_FILE}-mix
|
|
|
|
cp ${BIG_FILE} ${BIG_FILE}-mix
|
|
|
|
|
|
|
|
MODIFY_START_BLOCK=$((1*1024*1024))
|
|
|
|
echo -n "0123456789ABCDEF" | dd of="${BIG_FILE}-mix" bs=4 count=4 seek=$MODIFY_START_BLOCK conv=notrunc
|
|
|
|
echo -n "0123456789ABCDEF" | dd of="/tmp/${BIG_FILE}-mix" bs=4 count=4 seek=$MODIFY_START_BLOCK conv=notrunc
|
|
|
|
|
|
|
|
# Verify contents of file
|
|
|
|
echo "Comparing test file (4)"
|
|
|
|
if ! cmp "/tmp/${BIG_FILE}-mix" "${BIG_FILE}-mix"
|
|
|
|
then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -f "/tmp/${BIG_FILE}"
|
|
|
|
rm -f "/tmp/${BIG_FILE}-mix"
|
|
|
|
rm_test_file "${BIG_FILE}"
|
|
|
|
rm_test_file "${BIG_FILE}-mix"
|
|
|
|
}
|
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
function test_special_characters {
|
2016-02-05 12:24:13 +00:00
|
|
|
describe "Testing special characters ..."
|
2015-07-27 22:47:08 +00:00
|
|
|
|
2019-07-03 05:31:48 +00:00
|
|
|
(
|
|
|
|
set +o pipefail
|
|
|
|
ls 'special' 2>&1 | grep -q 'No such file or directory'
|
|
|
|
ls 'special?' 2>&1 | grep -q 'No such file or directory'
|
|
|
|
ls 'special*' 2>&1 | grep -q 'No such file or directory'
|
|
|
|
ls 'special~' 2>&1 | grep -q 'No such file or directory'
|
|
|
|
ls 'specialµ' 2>&1 | grep -q 'No such file or directory'
|
|
|
|
)
|
2020-02-02 09:43:20 +00:00
|
|
|
|
|
|
|
mkdir "TOYOTA TRUCK 8.2.2"
|
2015-08-16 22:48:05 +00:00
|
|
|
}
|
|
|
|
|
2015-10-22 21:07:39 +00:00
|
|
|
function test_symlink {
|
2016-02-05 12:24:13 +00:00
|
|
|
describe "Testing symlinks ..."
|
2015-10-22 21:07:39 +00:00
|
|
|
|
|
|
|
rm -f $TEST_TEXT_FILE
|
|
|
|
rm -f $ALT_TEST_TEXT_FILE
|
|
|
|
echo foo > $TEST_TEXT_FILE
|
|
|
|
|
|
|
|
ln -s $TEST_TEXT_FILE $ALT_TEST_TEXT_FILE
|
|
|
|
cmp $TEST_TEXT_FILE $ALT_TEST_TEXT_FILE
|
|
|
|
|
|
|
|
rm -f $TEST_TEXT_FILE
|
|
|
|
|
|
|
|
[ -L $ALT_TEST_TEXT_FILE ]
|
|
|
|
[ ! -f $ALT_TEST_TEXT_FILE ]
|
2020-01-26 13:04:10 +00:00
|
|
|
|
|
|
|
rm -f $ALT_TEST_TEXT_FILE
|
2015-10-22 21:07:39 +00:00
|
|
|
}
|
|
|
|
|
2015-08-16 22:48:05 +00:00
|
|
|
function test_extended_attributes {
|
2016-02-05 12:24:13 +00:00
|
|
|
describe "Testing extended attributes ..."
|
2015-08-16 22:48:05 +00:00
|
|
|
|
|
|
|
rm -f $TEST_TEXT_FILE
|
|
|
|
touch $TEST_TEXT_FILE
|
|
|
|
|
|
|
|
# set value
|
2019-07-03 09:54:01 +00:00
|
|
|
set_xattr key1 value1 $TEST_TEXT_FILE
|
|
|
|
get_xattr key1 $TEST_TEXT_FILE | grep -q '^value1$'
|
2015-08-16 22:48:05 +00:00
|
|
|
|
|
|
|
# append value
|
2019-07-03 09:54:01 +00:00
|
|
|
set_xattr key2 value2 $TEST_TEXT_FILE
|
|
|
|
get_xattr key1 $TEST_TEXT_FILE | grep -q '^value1$'
|
|
|
|
get_xattr key2 $TEST_TEXT_FILE | grep -q '^value2$'
|
2015-08-16 22:48:05 +00:00
|
|
|
|
|
|
|
# remove value
|
2019-07-03 09:54:01 +00:00
|
|
|
del_xattr key1 $TEST_TEXT_FILE
|
|
|
|
! get_xattr key1 $TEST_TEXT_FILE
|
|
|
|
get_xattr key2 $TEST_TEXT_FILE | grep -q '^value2$'
|
2020-01-26 13:04:10 +00:00
|
|
|
|
|
|
|
rm_test_file
|
2015-08-16 22:48:05 +00:00
|
|
|
}
|
2015-07-27 22:47:08 +00:00
|
|
|
|
2015-11-24 08:29:54 +00:00
|
|
|
function test_mtime_file {
|
2016-02-05 12:24:13 +00:00
|
|
|
describe "Testing mtime preservation function ..."
|
2015-11-24 08:29:54 +00:00
|
|
|
|
|
|
|
# if the rename file exists, delete it
|
2015-12-03 13:44:43 +00:00
|
|
|
if [ -e $ALT_TEST_TEXT_FILE -o -L $ALT_TEST_TEXT_FILE ]
|
2015-11-24 08:29:54 +00:00
|
|
|
then
|
|
|
|
rm $ALT_TEST_TEXT_FILE
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -e $ALT_TEST_TEXT_FILE ]
|
|
|
|
then
|
|
|
|
echo "Could not delete file ${ALT_TEST_TEXT_FILE}, it still exists"
|
2016-02-05 12:24:13 +00:00
|
|
|
return 1
|
2015-11-24 08:29:54 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# create the test file again
|
|
|
|
mk_test_file
|
|
|
|
sleep 2 # allow for some time to pass to compare the timestamps between test & alt
|
|
|
|
|
|
|
|
#copy the test file with preserve mode
|
|
|
|
cp -p $TEST_TEXT_FILE $ALT_TEST_TEXT_FILE
|
2019-01-07 01:51:42 +00:00
|
|
|
testmtime=`get_mtime $TEST_TEXT_FILE`
|
|
|
|
altmtime=`get_mtime $ALT_TEST_TEXT_FILE`
|
2015-11-24 08:29:54 +00:00
|
|
|
if [ "$testmtime" -ne "$altmtime" ]
|
|
|
|
then
|
|
|
|
echo "File times do not match: $testmtime != $altmtime"
|
2016-02-05 12:24:13 +00:00
|
|
|
return 1
|
2015-11-24 08:29:54 +00:00
|
|
|
fi
|
2020-01-26 13:04:10 +00:00
|
|
|
|
|
|
|
rm_test_file
|
|
|
|
rm_test_file $ALT_TEST_TEXT_FILE
|
2015-11-24 08:29:54 +00:00
|
|
|
}
|
|
|
|
|
2019-01-07 01:51:42 +00:00
|
|
|
function test_update_time() {
|
|
|
|
describe "Testing update time function ..."
|
|
|
|
|
|
|
|
# create the test
|
|
|
|
mk_test_file
|
|
|
|
mtime=`get_ctime $TEST_TEXT_FILE`
|
|
|
|
ctime=`get_mtime $TEST_TEXT_FILE`
|
|
|
|
|
|
|
|
sleep 2
|
|
|
|
chmod +x $TEST_TEXT_FILE
|
|
|
|
|
|
|
|
ctime2=`get_ctime $TEST_TEXT_FILE`
|
|
|
|
mtime2=`get_mtime $TEST_TEXT_FILE`
|
|
|
|
if [ $ctime -eq $ctime2 -o $mtime -ne $mtime2 ]; then
|
|
|
|
echo "Expected updated ctime: $ctime != $ctime2 and same mtime: $mtime == $mtime2"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
sleep 2
|
|
|
|
chown $UID:$UID $TEST_TEXT_FILE;
|
|
|
|
|
|
|
|
ctime3=`get_ctime $TEST_TEXT_FILE`
|
|
|
|
mtime3=`get_mtime $TEST_TEXT_FILE`
|
|
|
|
if [ $ctime2 -eq $ctime3 -o $mtime2 -ne $mtime3 ]; then
|
|
|
|
echo "Expected updated ctime: $ctime2 != $ctime3 and same mtime: $mtime2 == $mtime3"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2019-07-03 09:54:01 +00:00
|
|
|
sleep 2
|
|
|
|
set_xattr key value $TEST_TEXT_FILE
|
2019-01-07 01:51:42 +00:00
|
|
|
|
2019-07-03 09:54:01 +00:00
|
|
|
ctime4=`get_ctime $TEST_TEXT_FILE`
|
|
|
|
mtime4=`get_mtime $TEST_TEXT_FILE`
|
|
|
|
if [ $ctime3 -eq $ctime4 -o $mtime3 -ne $mtime4 ]; then
|
|
|
|
echo "Expected updated ctime: $ctime3 != $ctime4 and same mtime: $mtime3 == $mtime4"
|
|
|
|
return 1
|
2019-01-07 01:51:42 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
sleep 2
|
|
|
|
echo foo >> $TEST_TEXT_FILE
|
|
|
|
|
|
|
|
ctime5=`get_ctime $TEST_TEXT_FILE`
|
|
|
|
mtime5=`get_mtime $TEST_TEXT_FILE`
|
|
|
|
if [ $ctime4 -eq $ctime5 -o $mtime4 -eq $mtime5 ]; then
|
|
|
|
echo "Expected updated ctime: $ctime4 != $ctime5 and updated mtime: $mtime4 != $mtime5"
|
|
|
|
return 1
|
|
|
|
fi
|
2020-01-26 13:04:10 +00:00
|
|
|
|
|
|
|
rm_test_file
|
2019-01-07 01:51:42 +00:00
|
|
|
}
|
|
|
|
|
2016-02-05 12:24:13 +00:00
|
|
|
function test_rm_rf_dir {
|
|
|
|
describe "Test that rm -rf will remove directory with contents"
|
|
|
|
# Create a dir with some files and directories
|
|
|
|
mkdir dir1
|
|
|
|
mkdir dir1/dir2
|
|
|
|
touch dir1/file1
|
|
|
|
touch dir1/dir2/file2
|
|
|
|
|
|
|
|
# Remove the dir with recursive rm
|
|
|
|
rm -rf dir1
|
|
|
|
|
|
|
|
if [ -e dir1 ]; then
|
|
|
|
echo "rm -rf did not remove $PWD/dir1"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-08-11 07:42:48 +00:00
|
|
|
function test_copy_file {
|
|
|
|
describe "Test simple copy"
|
|
|
|
|
|
|
|
dd if=/dev/urandom of=/tmp/simple_file bs=1024 count=1
|
|
|
|
cp /tmp/simple_file copied_simple_file
|
|
|
|
cmp /tmp/simple_file copied_simple_file
|
|
|
|
|
2019-08-13 14:21:42 +00:00
|
|
|
rm_test_file /tmp/simple_file
|
|
|
|
rm_test_file copied_simple_file
|
2019-08-11 07:42:48 +00:00
|
|
|
}
|
|
|
|
|
2016-03-15 18:27:46 +00:00
|
|
|
function test_write_after_seek_ahead {
|
|
|
|
describe "Test writes succeed after a seek ahead"
|
|
|
|
dd if=/dev/zero of=testfile seek=1 count=1 bs=1024
|
2019-08-13 14:21:42 +00:00
|
|
|
rm_test_file testfile
|
2016-03-15 18:27:46 +00:00
|
|
|
}
|
|
|
|
|
2019-01-23 03:52:53 +00:00
|
|
|
function test_overwrite_existing_file_range {
|
|
|
|
describe "Test overwrite range succeeds"
|
|
|
|
dd if=<(seq 1000) of=${TEST_TEXT_FILE}
|
|
|
|
dd if=/dev/zero of=${TEST_TEXT_FILE} seek=1 count=1 bs=1024 conv=notrunc
|
|
|
|
cmp ${TEST_TEXT_FILE} <(
|
|
|
|
seq 1000 | head -c 1024
|
|
|
|
dd if=/dev/zero count=1 bs=1024
|
|
|
|
seq 1000 | tail -c +2049
|
|
|
|
)
|
2019-08-13 14:21:42 +00:00
|
|
|
rm_test_file
|
2019-01-23 03:52:53 +00:00
|
|
|
}
|
2016-03-15 18:27:46 +00:00
|
|
|
|
2019-03-04 08:57:03 +00:00
|
|
|
function test_concurrency {
|
2019-06-22 02:46:25 +00:00
|
|
|
describe "Test concurrent updates to a directory"
|
2019-07-15 07:16:01 +00:00
|
|
|
for i in `seq 5`; do echo foo > $i; done
|
|
|
|
for process in `seq 10`; do
|
|
|
|
for i in `seq 5`; do
|
|
|
|
file=$(ls `seq 5` | sed -n "$(($RANDOM % 5 + 1))p")
|
2019-03-04 08:57:03 +00:00
|
|
|
cat $file >/dev/null || true
|
|
|
|
rm -f $file
|
2019-07-15 07:16:01 +00:00
|
|
|
echo foo > $file || true
|
2019-03-04 08:57:03 +00:00
|
|
|
done &
|
|
|
|
done
|
|
|
|
wait
|
2019-07-15 07:16:01 +00:00
|
|
|
rm -f `seq 5`
|
2019-03-04 08:57:03 +00:00
|
|
|
}
|
|
|
|
|
2019-07-16 19:55:14 +00:00
|
|
|
function test_concurrent_writes {
|
|
|
|
describe "Test concurrent updates to a file"
|
|
|
|
dd if=/dev/urandom of=${TEST_TEXT_FILE} bs=$BIG_FILE_LENGTH count=1
|
|
|
|
for process in `seq 10`; do
|
|
|
|
dd if=/dev/zero of=${TEST_TEXT_FILE} seek=$(($RANDOM % $BIG_FILE_LENGTH)) count=1 bs=1024 conv=notrunc &
|
|
|
|
done
|
|
|
|
wait
|
|
|
|
rm_test_file
|
|
|
|
}
|
|
|
|
|
2019-05-05 00:05:28 +00:00
|
|
|
function test_open_second_fd {
|
|
|
|
describe "read from an open fd"
|
2019-08-14 12:39:38 +00:00
|
|
|
rm_test_file second_fd_file
|
|
|
|
RESULT=$( (echo foo ; wc -c < second_fd_file >&2) 2>& 1>second_fd_file)
|
2019-05-05 00:05:28 +00:00
|
|
|
if [ "$RESULT" -ne 4 ]; then
|
|
|
|
echo "size mismatch, expected: 4, was: ${RESULT}"
|
|
|
|
return 1
|
|
|
|
fi
|
2019-08-14 12:39:38 +00:00
|
|
|
rm_test_file second_fd_file
|
2019-05-05 00:05:28 +00:00
|
|
|
}
|
2019-03-04 08:57:03 +00:00
|
|
|
|
2019-09-26 02:21:22 +00:00
|
|
|
function test_write_multiple_offsets {
|
|
|
|
describe "test writing to multiple offsets"
|
2019-10-22 15:09:19 +00:00
|
|
|
../../write_multiple_offsets.py ${TEST_TEXT_FILE}
|
|
|
|
rm_test_file ${TEST_TEXT_FILE}
|
2019-09-26 02:21:22 +00:00
|
|
|
}
|
|
|
|
|
2019-09-07 06:23:05 +00:00
|
|
|
function test_clean_up_cache() {
|
|
|
|
describe "Test clean up cache"
|
|
|
|
|
|
|
|
dir="many_files"
|
2020-01-30 14:00:01 +00:00
|
|
|
count=25
|
2019-09-07 06:23:05 +00:00
|
|
|
mkdir -p $dir
|
|
|
|
|
|
|
|
for x in $(seq $count); do
|
2020-01-30 14:00:01 +00:00
|
|
|
dd if=/dev/urandom of=$dir/file-$x bs=10485760 count=1
|
2019-09-07 06:23:05 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
file_cnt=$(ls $dir | wc -l)
|
|
|
|
if [ $file_cnt != $count ]; then
|
|
|
|
echo "Expected $count files but got $file_cnt"
|
|
|
|
rm -rf $dir
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
CACHE_DISK_AVAIL_SIZE=`get_disk_avail_size $CACHE_DIR`
|
|
|
|
if [ "$CACHE_DISK_AVAIL_SIZE" -lt "$ENSURE_DISKFREE_SIZE" ];then
|
|
|
|
echo "Cache disk avail size:$CACHE_DISK_AVAIL_SIZE less than ensure_diskfree size:$ENSURE_DISKFREE_SIZE"
|
|
|
|
rm -rf $dir
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
rm -rf $dir
|
|
|
|
}
|
|
|
|
|
2020-02-02 13:01:56 +00:00
|
|
|
function test_content_type() {
|
|
|
|
describe "Test Content-Type detection"
|
|
|
|
|
|
|
|
DIR_NAME="$(basename $PWD)"
|
|
|
|
|
|
|
|
touch "test.txt"
|
|
|
|
CONTENT_TYPE=$(aws_cli s3api head-object --bucket "${TEST_BUCKET_1}" --key "${DIR_NAME}/test.txt" | grep "ContentType")
|
2020-02-04 14:37:33 +00:00
|
|
|
if [ `uname` = "Darwin" ]; then
|
|
|
|
if ! echo $CONTENT_TYPE | grep -q "application/octet-stream"; then
|
|
|
|
echo "Unexpected Content-Type(MacOS): $CONTENT_TYPE"
|
|
|
|
return 1;
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if ! echo $CONTENT_TYPE | grep -q "text/plain"; then
|
|
|
|
echo "Unexpected Content-Type: $CONTENT_TYPE"
|
|
|
|
return 1;
|
|
|
|
fi
|
2020-02-02 13:01:56 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
touch "test.jpg"
|
|
|
|
CONTENT_TYPE=$(aws_cli s3api head-object --bucket "${TEST_BUCKET_1}" --key "${DIR_NAME}/test.jpg" | grep "ContentType")
|
2020-02-04 14:37:33 +00:00
|
|
|
if [ `uname` = "Darwin" ]; then
|
|
|
|
if ! echo $CONTENT_TYPE | grep -q "application/octet-stream"; then
|
|
|
|
echo "Unexpected Content-Type(MacOS): $CONTENT_TYPE"
|
|
|
|
return 1;
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if ! echo $CONTENT_TYPE | grep -q "image/jpeg"; then
|
|
|
|
echo "Unexpected Content-Type: $CONTENT_TYPE"
|
|
|
|
return 1;
|
|
|
|
fi
|
2020-02-02 13:01:56 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
touch "test.bin"
|
|
|
|
CONTENT_TYPE=$(aws_cli s3api head-object --bucket "${TEST_BUCKET_1}" --key "${DIR_NAME}/test.bin" | grep "ContentType")
|
|
|
|
if ! echo $CONTENT_TYPE | grep -q "application/octet-stream"; then
|
|
|
|
echo "Unexpected Content-Type: $CONTENT_TYPE"
|
|
|
|
return 1;
|
|
|
|
fi
|
2020-02-02 09:43:20 +00:00
|
|
|
|
|
|
|
mkdir "test.dir"
|
|
|
|
CONTENT_TYPE=$(aws_cli s3api head-object --bucket "${TEST_BUCKET_1}" --key "${DIR_NAME}/test.dir/" | grep "ContentType")
|
|
|
|
if ! echo $CONTENT_TYPE | grep -q "application/x-directory"; then
|
|
|
|
echo "Unexpected Content-Type: $CONTENT_TYPE"
|
|
|
|
return 1;
|
|
|
|
fi
|
2020-02-02 13:01:56 +00:00
|
|
|
}
|
|
|
|
|
2016-02-05 12:24:13 +00:00
|
|
|
function add_all_tests {
|
2020-02-04 15:38:19 +00:00
|
|
|
if `ps -ef | grep -v grep | grep s3fs | grep -q ensure_diskfree` && ! `uname | grep -q Darwin`; then
|
2019-09-07 06:23:05 +00:00
|
|
|
add_tests test_clean_up_cache
|
|
|
|
fi
|
2016-02-05 12:24:13 +00:00
|
|
|
add_tests test_append_file
|
|
|
|
add_tests test_truncate_file
|
2016-04-22 06:49:37 +00:00
|
|
|
add_tests test_truncate_empty_file
|
2016-02-05 12:24:13 +00:00
|
|
|
add_tests test_mv_file
|
2019-01-23 06:12:05 +00:00
|
|
|
add_tests test_mv_empty_directory
|
|
|
|
add_tests test_mv_nonempty_directory
|
2016-02-05 12:24:13 +00:00
|
|
|
add_tests test_redirects
|
|
|
|
add_tests test_mkdir_rmdir
|
|
|
|
add_tests test_chmod
|
|
|
|
add_tests test_chown
|
|
|
|
add_tests test_list
|
|
|
|
add_tests test_remove_nonempty_directory
|
2019-06-22 02:46:25 +00:00
|
|
|
add_tests test_external_modification
|
2019-08-01 23:09:34 +00:00
|
|
|
add_tests test_read_external_object
|
2019-01-17 19:55:27 +00:00
|
|
|
add_tests test_rename_before_close
|
2016-02-05 12:24:13 +00:00
|
|
|
add_tests test_multipart_upload
|
2016-11-15 01:13:25 +00:00
|
|
|
add_tests test_multipart_copy
|
2019-09-26 02:30:58 +00:00
|
|
|
add_tests test_multipart_mix
|
2016-02-05 12:24:13 +00:00
|
|
|
add_tests test_special_characters
|
|
|
|
add_tests test_symlink
|
|
|
|
add_tests test_extended_attributes
|
2016-11-19 23:09:25 +00:00
|
|
|
add_tests test_mtime_file
|
2019-01-07 01:51:42 +00:00
|
|
|
add_tests test_update_time
|
2016-02-05 12:24:13 +00:00
|
|
|
add_tests test_rm_rf_dir
|
2019-08-11 07:42:48 +00:00
|
|
|
add_tests test_copy_file
|
2016-03-15 18:27:46 +00:00
|
|
|
add_tests test_write_after_seek_ahead
|
2019-01-23 03:52:53 +00:00
|
|
|
add_tests test_overwrite_existing_file_range
|
2019-03-04 08:57:03 +00:00
|
|
|
add_tests test_concurrency
|
2019-07-16 19:55:14 +00:00
|
|
|
add_tests test_concurrent_writes
|
2019-05-05 00:05:28 +00:00
|
|
|
add_tests test_open_second_fd
|
2019-09-26 02:21:22 +00:00
|
|
|
add_tests test_write_multiple_offsets
|
2020-02-02 13:01:56 +00:00
|
|
|
add_tests test_content_type
|
2015-08-16 22:48:05 +00:00
|
|
|
}
|
|
|
|
|
2016-02-05 12:24:13 +00:00
|
|
|
init_suite
|
|
|
|
add_all_tests
|
|
|
|
run_suite
|