Added directory soft deletion tests

This commit is contained in:
deajan 2016-12-13 01:59:25 +01:00
parent 81571c605d
commit 4de0a657c2
1 changed files with 58 additions and 28 deletions

View File

@ -7,7 +7,7 @@
## On CYGWIN / MSYS, ACL and extended attributes aren't supported ## On CYGWIN / MSYS, ACL and extended attributes aren't supported
# osync test suite 2016120901 # osync test suite 2016121202
# 4 tests: # 4 tests:
# quicklocal # quicklocal
@ -151,8 +151,15 @@ function DownloadLargeFileSet() {
function CreateOldFile () { function CreateOldFile () {
local drive local drive
local filePath="${1}" local filePath="${1}"
local type="${2:-false}"
if [ $type == true ]; then
mkdir -p "$filePath"
else
mkdir -p "$(dirname $filePath)"
touch "$filePath" touch "$filePath"
fi
assertEquals "touch [$filePath]" "0" $? assertEquals "touch [$filePath]" "0" $?
# Get current drive # Get current drive
@ -221,7 +228,7 @@ function oneTimeSetUp () {
osyncDaemonParameters[$__local]="$CONF_DIR/$LOCAL_CONF --on-changes" osyncDaemonParameters[$__local]="$CONF_DIR/$LOCAL_CONF --on-changes"
if [ "$LOCAL_OS" != "msys" ] || [ "$LOCAL_OS" == "Cygwin" ]; then if [ "$LOCAL_OS" != "msys" ] && [ "$LOCAL_OS" != "Cygwin" ]; then
osyncParameters[$__quickRemote]="--initiator=$INITIATOR_DIR --target=ssh://localhost:$SSH_PORT/$TARGET_DIR --rsakey=${HOME}/.ssh/id_rsa_local --instance-id=quickremote" osyncParameters[$__quickRemote]="--initiator=$INITIATOR_DIR --target=ssh://localhost:$SSH_PORT/$TARGET_DIR --rsakey=${HOME}/.ssh/id_rsa_local --instance-id=quickremote"
osyncParameters[$__confRemote]="$CONF_DIR/$REMOTE_CONF" osyncParameters[$__confRemote]="$CONF_DIR/$REMOTE_CONF"
@ -388,7 +395,7 @@ function test_Deletetion () {
} }
function test_deletion_failure () { function test_deletion_failure () {
if [ "$LOCAL_OS" == "WinNT10" ] || [ "$LOCAL_OS" == "msys" ]; then if [ "$LOCAL_OS" == "WinNT10" ] || [ "$LOCAL_OS" == "msys" ] || [ "$LOCAL_OS" == "Cygwin" ]; then
echo "Skipping deletion failure test as Win10 does not have chattr support." echo "Skipping deletion failure test as Win10 does not have chattr support."
return 0 return 0
fi fi
@ -720,13 +727,16 @@ function test_softdeletion_cleanup () {
files[2]="$INITIATOR_DIR/$OSYNC_BACKUP_DIR/someBackedUpFileInitiator" files[2]="$INITIATOR_DIR/$OSYNC_BACKUP_DIR/someBackedUpFileInitiator"
files[3]="$TARGET_DIR/$OSYNC_BACKUP_DIR/someBackedUpFileTarget" files[3]="$TARGET_DIR/$OSYNC_BACKUP_DIR/someBackedUpFileTarget"
DirA="$INITIATOR_DIR/$OSYNC_DELETE_DIR/somedir"
DirB="$TARGET_DIR/$OSYNC_DELETE_DIR/someotherdir"
for i in "${osyncParameters[@]}"; do for i in "${osyncParameters[@]}"; do
cd "$OSYNC_DIR" cd "$OSYNC_DIR"
PrepareLocalDirs PrepareLocalDirs
# First run # First run
REMOTE_HOST_PING=no ./$OSYNC_EXECUTABLE $i #REMOTE_HOST_PING=no ./$OSYNC_EXECUTABLE $i
assertEquals "First deletion run with parameters [$i]." "0" $? #assertEquals "First deletion run with parameters [$i]." "0" $?
# Get current drive # Get current drive
drive=$(df "$OSYNC_DIR" | tail -1 | awk '{print $1}') drive=$(df "$OSYNC_DIR" | tail -1 | awk '{print $1}')
@ -746,6 +756,12 @@ function test_softdeletion_cleanup () {
CreateOldFile "$file.old" CreateOldFile "$file.old"
fi fi
done done
if [ "$TRAVIS_RUN" == true ] || [ "$LOCAL_OS" == "BSD" ] || [ "$LOCAL_OS" == "MacOSX" ] || [ "$LOCAL_OS" == "WinNT10" ] || [ "$LOCAL_OS" == "msys" ] || [ "$LOCAL_OS" == "Cygwin" ]; then
echo "Skipping changing ctime on dir too"
else
CreateOldFile "$DirA" true
CreateOldFile "$DirB" true
fi
# Second run # Second run
REMOTE_HOST_PING=no ./$OSYNC_EXECUTABLE $i REMOTE_HOST_PING=no ./$OSYNC_EXECUTABLE $i
@ -763,6 +779,18 @@ function test_softdeletion_cleanup () {
assertEquals "Old softdeleted / backed up file [$file.old] is deleted permanently." "1" $? assertEquals "Old softdeleted / backed up file [$file.old] is deleted permanently." "1" $?
fi fi
done done
if [ "$TRAVIS_RUN" == true ] || [ "$LOCAL_OS" == "BSD" ] || [ "$LOCAL_OS" == "MacOSX" ] || [ "$LOCAL_OS" == "WinNT10" ] || [ "$LOCAL_OS" == "msys" ] || [ "$LOCAL_OS" == "Cygwin" ]; then
[ ! -d "$DirA" ]
assertEquals "Old softdeleted / backed up directory [$dirA] is deleted permanently." "0" $?
[ ! -d "$DirB" ]
assertEquals "Old softdeleted / backed up directory [$dirB] is deleted permanently." "0" $?
else
[ ! -d "$DirA" ]
assertEquals "Old softdeleted / backed up directory [$DirA] is deleted permanently." "1" $?
[ ! -d "$DirB" ]
assertEquals "Old softdeleted / backed up directory [$DirB] is deleted permanently." "1" $?
fi
done done
} }
@ -774,7 +802,7 @@ function test_FileAttributePropagation () {
return 0 return 0
fi fi
if [ "$LOCAL_OS" == "MacOSX" ] || [ "$LOCAL_OS" == "msys" ]; then if [ "$LOCAL_OS" == "MacOSX" ] || [ "$LOCAL_OS" == "msys" ] || [ "$LOCAL_OS" == "Cygwin" ]; then
echo "Skipping FileAttributePropagation tests because [$LOCAL_OS] does not support ACL." echo "Skipping FileAttributePropagation tests because [$LOCAL_OS] does not support ACL."
return 0 return 0
fi fi
@ -895,6 +923,8 @@ function test_MultipleConflictBackups () {
for i in "${osyncParameters[@]}"; do for i in "${osyncParameters[@]}"; do
echo "Running with parameters [$î]."
cd "$OSYNC_DIR" cd "$OSYNC_DIR"
PrepareLocalDirs PrepareLocalDirs
@ -980,7 +1010,7 @@ function test_Locking () {
REMOTE_HOST_PING=no ./$OSYNC_EXECUTABLE ${osyncParameters[$__confLocal]} REMOTE_HOST_PING=no ./$OSYNC_EXECUTABLE ${osyncParameters[$__confLocal]}
assertEquals "Should be able to resume locked target with same instance_id in confLocal mode." "0" $? assertEquals "Should be able to resume locked target with same instance_id in confLocal mode." "0" $?
if [ "$LOCAL_OS" != "msys" ]; then if [ "$LOCAL_OS" != "msys" ] && [ "$LOCAL_OS" != "Cygwin" ]; then
PrepareLocalDirs PrepareLocalDirs
mkdir -p "$TARGET_DIR/$OSYNC_WORKDIR" mkdir -p "$TARGET_DIR/$OSYNC_WORKDIR"
echo 65536@quickremote > "$TARGET_DIR/$OSYNC_WORKDIR/lock" echo 65536@quickremote > "$TARGET_DIR/$OSYNC_WORKDIR/lock"
@ -1011,7 +1041,7 @@ function test_Locking () {
REMOTE_HOST_PING=no ./$OSYNC_EXECUTABLE ${osyncParameters[$__confLocal]} REMOTE_HOST_PING=no ./$OSYNC_EXECUTABLE ${osyncParameters[$__confLocal]}
assertEquals "Should be able to resume locked local target with bogus instance_id in confLocal mode." "0" $? assertEquals "Should be able to resume locked local target with bogus instance_id in confLocal mode." "0" $?
if [ "$LOCAL_OS" != "msys" ]; then if [ "$LOCAL_OS" != "msys" ] && [ "$LOCAL_OS" != "Cygwin" ]; then
PrepareLocalDirs PrepareLocalDirs
mkdir -p "$TARGET_DIR/$OSYNC_WORKDIR" mkdir -p "$TARGET_DIR/$OSYNC_WORKDIR"
echo 65536@bogusinstance > "$TARGET_DIR/$OSYNC_WORKDIR/lock" echo 65536@bogusinstance > "$TARGET_DIR/$OSYNC_WORKDIR/lock"