From 3371e9a8f3d5945ffd066b0b42073e7b537b81d8 Mon Sep 17 00:00:00 2001 From: deajan Date: Tue, 29 Nov 2016 20:28:15 +0100 Subject: [PATCH] Improved timed execution tests --- dev/tests/run_tests.sh | 72 +++++++++++++++++++++++++++++++----------- 1 file changed, 53 insertions(+), 19 deletions(-) diff --git a/dev/tests/run_tests.sh b/dev/tests/run_tests.sh index f5a648c..07f7052 100755 --- a/dev/tests/run_tests.sh +++ b/dev/tests/run_tests.sh @@ -266,7 +266,7 @@ function test_Merge () { SetConfFileValue "$OSYNC_DIR/$OSYNC_EXECUTABLE" "IS_STABLE" "yes" } -function test_LargeFileSet () { +function nope_test_LargeFileSet () { for i in "${osyncParameters[@]}"; do cd "$OSYNC_DIR" @@ -284,7 +284,7 @@ function test_LargeFileSet () { done } -function test_Exclusions () { +function nope_test_Exclusions () { # Will sync except php files # RSYNC_EXCLUDE_PATTERN="*.php" is set at runtime for quicksync and in config files for other runs @@ -304,7 +304,6 @@ function test_Exclusions () { REMOTE_HOST_PING=no RSYNC_EXCLUDE_PATTERN="*.php" ./$OSYNC_EXECUTABLE $i assertEquals "Exclusions with parameters [$i]." "0" $? - #WIP Add exclusion from file tests here numberOfInitiatorFiles=$(find "$INITIATOR_DIR" ! -wholename "$INITIATOR_DIR/$OSYNC_WORKDIR*" | wc -l) numberOfTargetFiles=$(find "$TARGET_DIR" ! -wholename "$TARGET_DIR/$OSYNC_WORKDIR*" | wc -l) numberOfExcludedFiles=$((numberOfInitiatorFiles-numberOfTargetFiles)) @@ -313,7 +312,7 @@ function test_Exclusions () { done } -function test_Deletetion () { +function nope_test_Deletetion () { local iFile1="$INITIATOR_DIR/ific" local iFile2="$INITIATOR_DIR/ifoc" local tFile1="$TARGET_DIR/tfic" @@ -357,7 +356,7 @@ function test_Deletetion () { done } -function test_deletion_failure () { +function nope_test_deletion_failure () { if [ "$LOCAL_OS" == "WinNT10" ]; then echo "Skipping deletion failure test as Win10 does not have chattr support." return 0 @@ -423,7 +422,7 @@ function test_deletion_failure () { done } -function test_skip_deletion () { +function nope_test_skip_deletion () { local modes if [ "$OSYNC_MIN_VERSION" == "1" ]; then @@ -494,7 +493,7 @@ function test_skip_deletion () { SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "SKIP_DELETION" "" } -function test_softdeletion_cleanup () { +function nope_test_softdeletion_cleanup () { #declare -A files files=() @@ -550,7 +549,7 @@ function test_softdeletion_cleanup () { } -function test_FileAttributePropagation () { +function nope_test_FileAttributePropagation () { if [ "$TRAVIS_RUN" == true ]; then echo "Skipping FileAttributePropagation tests as travis does not support getfacl / setfacl." @@ -628,7 +627,7 @@ function test_FileAttributePropagation () { done } -function test_ConflictBackups () { +function nope_test_ConflictBackups () { for i in "${osyncParameters[@]}"; do cd "$OSYNC_DIR" PrepareLocalDirs @@ -664,7 +663,7 @@ function test_ConflictBackups () { done } -function test_MultipleConflictBackups () { +function nope_test_MultipleConflictBackups () { local additionalParameters @@ -724,7 +723,7 @@ function test_MultipleConflictBackups () { SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "CONFLICT_BACKUP_MULTIPLE" "no" } -function test_Locking () { +function nope_test_Locking () { local forceStrangerUnlockLocal local forceStrangerUnlockRemote @@ -833,7 +832,7 @@ function test_Locking () { SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "FORCE_STRANGER_LOCK_RESUME" "$forceStrangerUnlockRemote" } -function test_WaitForTaskCompletion () { +function nope_test_WaitForTaskCompletion () { if [ "$OSYNC_MIN_VERSION" == "1" ]; then echo "Skipping WaitForTaskCompletion test because osync v1.1 does not support multiple pid monitoring" return 0 @@ -888,7 +887,7 @@ function test_WaitForTaskCompletion () { assertEquals "WaitForTaskCompletion test 5" "2" $? } -function test_ParallelExec () { +function nope_test_ParallelExec () { if [ "$OSYNC_MIN_VERSION" == "1" ]; then echo "Skipping ParallelExec test because osync v1.1 ofunctions don't have this function." return 0 @@ -950,11 +949,46 @@ function test_ParallelExec () { } -#function test_timedExecution () { -# -#} +function test_timedExecution () { + local arguments -function test_UpgradeConfRun () { + if [ "$OSYNC_MIN_VERSION" -gt "1" ]; then + arguments="--errors-only" + fi + + # Clever usage of indexes and exit codes + # osync exits with 0 when no problem detected + # exits with 1 when error detected (triggered by reaching HARD_MAX_EXEC_TIME) + # exits with 2 when warning only detected (triggered by reaching SOFT_MAX_EXEC_TIME) + + softTimes=() + softTimes[0]=7200 # original values (to be executed at last in order to leave config file in original state) + hardTimes[0]=10600 + softTimes[1]=3600 + hardTimes[1]=3 + softTimes[2]=2 + hardTimes[2]=10600 + + for x in 2 1 0; do + + SetConfFileValue "$CONF_DIR/$LOCAL_CONF" "SOFT_MAX_EXEC_TIME" ${softTimes[$x]} + SetConfFileValue "$CONF_DIR/$LOCAL_CONF" "HARD_MAX_EXEC_TIME" ${hardTimes[$x]} + SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "SOFT_MAX_EXEC_TIME" ${softTimes[$x]} + SetConfFileValue "$CONF_DIR/$REMOTE_CONF" "HARD_MAX_EXEC_TIME" ${hardTimes[$x]} + + for i in "${osyncParameters[@]}"; do + + cd "$OSYNC_DIR" + PrepareLocalDirs + + echo "Test with args [$i $arguments]." + SOFT_MAX_EXEC_TIME=${softTimes[$x]} HARD_MAX_EXEC_TIME=${hardTimes[$x]} ./$OSYNC_EXECUTABLE $i $arguments + assertEquals "Timed Execution test with timed SOFT_MAX_EXEC_TIME=${softTimes[$x]} and HARD_MAX_EXEC_TIME=${hardTimes[$x]}." $x $? + done + done +} + +function nope_test_UpgradeConfRun () { if [ "$OSYNC_MIN_VERSION" == "1" ]; then echo "Skipping Upgrade script test because no further dev will happen on this for v1.1" return 0 @@ -976,7 +1010,7 @@ function test_UpgradeConfRun () { rm -f "$CONF_DIR/$TMP_OLD_CONF.save" } -function test_DaemonMode () { +function nope_test_DaemonMode () { if [ "$LOCAL_OS" == "WinNT10" ] || [ "$LOCAL_OS" == "msys" ]; then echo "Skipping daemon mode test as Win10 does not have inotifywait support." return 0 @@ -1031,7 +1065,7 @@ function test_DaemonMode () { } -function test_NoRemoteAccessTest () { +function nope_test_NoRemoteAccessTest () { RemoveSSH cd "$OSYNC_DIR"