add more push conflict tests

Tue, 03 Sep 2019 21:24:17 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 03 Sep 2019 21:24:17 +0200
changeset 636
cbd62e87b1c5
parent 635
a6b1ec1b7ba0
child 637
20241338740c

add more push conflict tests

test/bin-test/test-dav-sync-push-conflict.sh file | annotate | diff | comparison | revisions
--- a/test/bin-test/test-dav-sync-push-conflict.sh	Thu Aug 29 20:49:05 2019 +0200
+++ b/test/bin-test/test-dav-sync-push-conflict.sh	Tue Sep 03 21:24:17 2019 +0200
@@ -81,6 +81,18 @@
 	fi
 }
 
+# check if files in test1a and test1b are equal
+# arg1: path
+# arg2: error
+compare_files()
+{
+	diff tmp-sync/test1a/$1 tmp-sync/test1a/$1 > /dev/null 2>&1
+	if [ $? -ne 0 ]; then
+		echo "$2"
+		exit 2
+	fi
+}
+
 rm -f .dav/dav-sync-tests-test1a-db.xml
 rm -f .dav/dav-sync-tests-test1b-db.xml
 
@@ -261,6 +273,8 @@
 # 9. test: multiple files modified locally and on the server, push
 # expected result: multiple conflicts
 
+sleep 3
+
 # modify 6 files in test1a
 echo "test9conflict_a" >> tmp-sync/test1a/file1
 echo "test9conflict_a" >> tmp-sync/test1a/file2
@@ -281,10 +295,289 @@
 echo "test9conflict_b" >> tmp-sync/test1b/dir1/file2
 echo "test9conflict_b" >> tmp-sync/test1b/dir1/subdir1/empty2
 
+# modify 3 files in test1b, that are NOT modified in test1a
+echo "test9change_b" >> tmp-sync/test1b/dir1/file3
+echo "test9change_b" >> tmp-sync/test1b/dir1/file4
+echo "test9change_b" >> tmp-sync/test1b/dir1/subdir1/file1
+
 dav_sync_push test1b "test 9: push test1a failed"
 check_tmpout "3 files pushed" "test 9: wrong test1b push counter"
 check_tmpout "3 conflicts" "test 9: wrong test1b conflict counter"
 check_tmpout "0 errors" "test 9: wrong test1b error counter"
 
 
+# ----------------------------------------------------------------------------
+# 10. test: pull -c to override local changes, modify again and push
+# expected result: 3 files pulled, 3 files pushed
 
+sleep 3
+
+$DAV_SYNC_BIN pull -c test1b > tmp-sync/out.txt
+if [ $? -ne 0 ];
+then
+	echo "test 10: pull failed"
+	exit 2
+fi
+check_tmpout "6 files pulled" "test 10: wrong pull counter"
+check_tmpout "0 conflicts" "test 10: wrong conflict counter (pull)"
+check_tmpout "0 errors" "test 10: wrong error counter (pull)"
+
+# modify 3 files in test1b, which are also modified in test1a
+echo "test9conflict_b" >> tmp-sync/test1b/file2
+echo "test9conflict_b" >> tmp-sync/test1b/dir1/file2
+echo "test9conflict_b" >> tmp-sync/test1b/dir1/subdir1/empty2
+
+dav_sync_push test1b "test 10: push failed"
+check_tmpout "3 files pushed" "test 10: wrong push counter"
+check_tmpout "0 conflicts" "test 10: wrong conflict counter (push)"
+check_tmpout "0 errors" "test 10: wrong error counter (push)"
+
+
+# ----------------------------------------------------------------------------
+# 11. test: create 3 conflicts, push, push again with -c
+# expected result: first push: 3 conflicts, second push: 3 files pushed
+
+# prepare test1a (like test 8)
+dav_sync_pull test1a "test 11: pull failed"
+check_tmpout "0 conflicts" "test 11: wrong conflict counter (pull test1a)"
+check_tmpout "0 errors" "test 11: wrong error counter (pull test1a)"
+TEST=`cat tmp-sync/out.txt | wc -l`
+if [ $TEST == "1" ]; then
+	echo "test 11: no files pulled"
+	exit 2
+fi
+
+# change some files in test1a and push the changes
+echo "test11_change_a" >> tmp-sync/test1a/file1
+echo "test11_change_a" >> tmp-sync/test1a/file2
+echo "test11_change_a" >> tmp-sync/test1a/dir1/file1
+echo "test11_change_a" >> tmp-sync/test1a/dir1/file4
+echo "test11_change_a" >> tmp-sync/test1a/dir1/subdir1/file3
+echo "test11_change_a" >> tmp-sync/test1a/dir1/subdir1/file4
+echo "test11_change_a" >> tmp-sync/test1a/dir1/subdir1/empty2
+
+dav_sync_push test1a "test 11: push test1a failed"
+check_tmpout "7 files pushed" "test 11: wrong push counter (test1a)"
+check_tmpout "0 conflicts" "test 11: wrong conflict counter (test1a)"
+check_tmpout "0 errors" "test 11: wrong error counter (test1a)"
+check_tmpout "put: /dir1/subdir1/empty2" "empty2 not pushed (test1a)"
+
+# create conflicts
+echo "test11_change_a" >> tmp-sync/test1b/file2
+echo "test11_change_a" >> tmp-sync/test1b/dir1/file4
+echo "test11_change_a" >> tmp-sync/test1b/dir1/subdir1/empty2
+
+# first push with conflicts
+dav_sync_push test1b "test 11: push test1b failed"
+check_tmpout "0 files pushed" "test 11: wrong push counter (test1b 1)"
+check_tmpout "3 conflicts" "test 11: wrong conflict counter (test1b 1)"
+check_tmpout "0 errors" "test 11: wrong error counter (test1b 1)"
+
+# second push without conflict detection
+$DAV_SYNC_BIN push -c test1b > tmp-sync/out.txt
+if [ $? -ne 0 ];
+then
+	echo "test 11: push test1b failed (2)"
+	exit 2
+fi
+check_tmpout "3 files pushed" "test 11: wrong push counter (test1b 2)"
+check_tmpout "0 conflicts" "test 11: wrong conflict counter (test1b 2)"
+check_tmpout "0 errors" "test 11: wrong error counter (test1b 2)"
+
+
+# ----------------------------------------------------------------------------
+# 12. test: create new file with same name on both sides
+# expected result: conflict
+
+# prepare test1b
+dav_sync_pull test1b "test 12: prepare test1b failed"
+check_tmpout "0 conflicts" "test 12: wrong conflict counter (prepare)"
+
+# create new file in test1a and push the file
+echo "test12_new_a" >> tmp-sync/test1a/file_new1
+
+dav_sync_push test1a "test 12: push test1a failed"
+check_tmpout "1 file pushed" "test 12: wrong push counter (test1a)"
+check_tmpout "0 conflicts" "test 12: wrong conflict counter (test1a)"
+check_tmpout "0 errors" "test 12: wrong error counter (test1a)"
+
+# create new file in test1b and try push the file (conflict)
+echo "test12_new_b" >> tmp-sync/test1b/file_new1
+
+dav_sync_push test1b "test 12: push test1b failed"
+check_tmpout "0 files pushed" "test 12: wrong push counter (test1b 1)"
+check_tmpout "1 conflict" "test 12: wrong conflict counter (test1b 1)"
+check_tmpout "0 errors" "test 12: wrong error counter (test1b 1)"
+
+# pull changes to resolve conflict
+dav_sync_pull test1b "test 12: pull test1b failed"
+check_tmpout "1 file pulled" "test 12: wrong pull counter"
+check_tmpout "1 conflict" "test 12: wrong conflict counter (pull)"
+check_tmpout "0 errors" "test 12: wrong error counter (pull)"
+
+$DAV_SYNC_BIN resolve-conflicts test1b > tmp-sync/out.txt
+if [ $? -ne 0 ];
+then
+	echo "test 12: resolve-conflicts failed"
+	exit 2
+fi
+
+dav_sync_push test1b "test 12: push test1b failed (2)"
+check_tmpout "1 file pushed" "test 12: wrong push counter (test1b 2)"
+check_tmpout "0 conflicts" "test 12: wrong conflict counter (test1b 2)"
+check_tmpout "0 errors" "test 12: wrong error counter (test1b 2)"
+
+
+# ----------------------------------------------------------------------------
+# 13. test: 2 new, 2 mod files with conflict
+#           2 new, 2 mod files without conflict
+# expected result: 4 conflicts, 4 files pushed
+
+sleep 3
+
+echo "test13_change_a" >> tmp-sync/test1a/file1
+echo "test13_change_a" >> tmp-sync/test1a/dir1/file4
+echo "test13_change_a" >> tmp-sync/test1a/dir1/subdir1/file4
+echo "test13_change_a" >> tmp-sync/test1a/dir1/subdir1/empty2
+
+echo "test13_new_a" >> tmp-sync/test1a/test12_newfile1
+echo "test13_new_a" >> tmp-sync/test1a/dir1/test12_newfile2
+mkdir tmp-sync/test1a/test12/
+echo "test13_new_a" >> tmp-sync/test1a/test12/newfile3
+echo "test13_new_a" >> tmp-sync/test1a/test12/newfile4
+
+dav_sync_push test1a "test 13: push test1a failed"
+check_tmpout "8 files pushed" "test 13: wrong push counter (test1a)"
+check_tmpout "0 conflicts" "test 13: wrong conflict counter (test1a)"
+check_tmpout "0 errors" "test 13: wrong error counter (test1a)"
+
+echo "test13_change_b" >> tmp-sync/test1b/file2
+echo "test13_change_b" >> tmp-sync/test1b/dir1/file4
+echo "test13_change_b" >> tmp-sync/test1b/dir1/subdir1/file3
+echo "test13_change_b" >> tmp-sync/test1b/dir1/subdir1/empty2
+
+echo "test13_new_b" >> tmp-sync/test1b/test12_newfile1
+echo "test13_new_b" >> tmp-sync/test1b/dir1/test12_newfile_b1
+mkdir tmp-sync/test1b/test12/
+echo "test13_new_b" >> tmp-sync/test1b/test12/newfile3
+echo "test13_new_b" >> tmp-sync/test1b/test12/newfile_b1
+
+dav_sync_push test1b "test 13: push test1b failed"
+check_tmpout "4 files pushed" "test 13: wrong push counter (test1b)"
+check_tmpout "4 conflicts" "test 13: wrong conflict counter (test1b)"
+check_tmpout "0 errors" "test 13: wrong error counter (test1b)"
+
+# second push without conflict detection
+$DAV_SYNC_BIN push -c test1b > tmp-sync/out.txt
+if [ $? -ne 0 ];
+then
+	echo "test 13: push test1b failed (2)"
+	exit 2
+fi
+check_tmpout "4 files pushed" "test 13: wrong push counter (test1b 2)"
+check_tmpout "0 conflicts" "test 13: wrong conflict counter (test1b 2)"
+check_tmpout "0 errors" "test 13: wrong error counter (test1b 2)"
+
+
+# ----------------------------------------------------------------------------
+# 14. pull test1a and compare files
+# expected result: no conflicts, content of tested files is the same
+
+dav_sync_pull test1a "test 14: pull failed (test1a)"
+check_tmpout "0 conflicts" "test 14: wrong pull counter (test1a)"
+check_tmpout "0 errors" "test 14: wrong error counter (test1a)"
+TEST=`cat tmp-sync/out.txt | wc -l`
+if [ $TEST == "1" ]; then
+	echo "test 14: no files pulled (test1a)"
+	exit 2
+fi
+
+dav_sync_pull test1b "test 14: pull failed (test1b)"
+check_tmpout "0 conflicts" "test 14: wrong pull counter (test1b)"
+check_tmpout "0 errors" "test 14: wrong error counter (test1b)"
+TEST=`cat tmp-sync/out.txt | wc -l`
+if [ $TEST == "1" ]; then
+	echo "test 14: no files pulled (test1b)"
+	exit 2
+fi
+
+# compare new files
+compare_files "file1"                  "test 14: file1 not equal"			  
+compare_files "dir1/file4"             "test 14: dir1/file4 not equal"  	  
+compare_files "dir1/file3"             "test 14: dir1/file3 not equal"  	  
+compare_files "dir1/file2"             "test 14: dir1/file2 not equal"  	  
+compare_files "dir1/file1"             "test 14: dir1/file1 not equal"  	  
+compare_files "dir1/subdir1/file1"     "test 14: dir1/subdir1/file1 not equal"
+compare_files "dir1/subdir1/file2"     "test 14: dir1/subdir1/file2 not equal"
+compare_files "dir1/subdir1/file3"     "test 14: dir1/subdir1/file3 not equal"
+compare_files "dir1/subdir1/file4"     "test 14: dir1/subdir1/file4 not equal"
+compare_files "dir1/subdir1/empty1"    "test 14: dir1/subdir1/empty1 not equal"
+compare_files "dir1/subdir1/empty1"    "test 14: dir1/subdir1/empty2 not equal"
+compare_files "test12_newfile1"        "test 14: test12_newfile not equal"
+compare_files "dir1/test12_newfile2"   "test 14: dir1/test12_newfile2 not equal"
+compare_files "test12/newfile3"        "test 14: test12/newfile3 not equal"
+compare_files "test12/newfile4"        "test 14: test12/newfile4 not equal"
+compare_files "dir1/test12_newfile_b1" "test 14: dir1/test12_newfile_b1 not equal"
+compare_files "test12/newfile_b1"      "test 14: test12/newfile_b1 not equal"
+
+
+# ----------------------------------------------------------------------------
+# 15. modify file in test1a, delete in test1b
+# expected result: 0 delete
+
+echo "test15_change_a" >> tmp-sync/test1a/file1
+
+dav_sync_push test1a "test 15: push failed (test1a)"
+check_tmpout "1 file pushed" "test 15: wrong push counter (test1a)"
+check_tmpout "0 conflicts" "test 15: wrong conflict counter (test1a)"
+check_tmpout "0 errors" "test 15: wrong error counter (test1a)"
+
+rm tmp-sync/test1b/file1
+
+dav_sync_push test1b "test 15: push failed (test1b)"
+check_tmpout "0 files pushed" "test 15: wrong push counter (test1b)"
+# not sure if we have to check the conflict counter
+check_tmpout "0 errors" "test 15: wrong error counter (test1b)"
+
+dav_sync_pull test1b "test 15: pull failed"
+check_tmpout "1 file pulled" "test 15: wrong pull counter"
+check_tmpout "0 conflicts" "test 15: wrong conflict counter (pull)"
+check_tmpout "0 errors" "test 15: wrong error counter (pull)"
+
+dav_sync_push test1b "test 15: push failed (test1b 2)"
+check_tmpout "0 files pushed" "test 15: wrong push counter (test1b 2)"
+check_tmpout "0 conflicts" "test 15: wrong conflict counter (test1b 2)"
+check_tmpout "0 errors" "test 15: wrong error counter (test1b 2)"
+
+
+# ----------------------------------------------------------------------------
+# 16. modify file in test1a/dir1/, delete dir1 in test1b
+# expected result: many files deleted, modified file not deleted
+
+sleep 3
+
+echo "test16_change_a" >> tmp-sync/test1a/dir1/file3
+echo "test16_change_a" >> tmp-sync/test1a/file2
+
+dav_sync_push test1a "test 16: push failed (test1a)"
+check_tmpout "2 files pushed" "test 16: wrong push counter (test1a)"
+check_tmpout "0 conflicts" "test 16: wrong conflict counter (test1a)"
+check_tmpout "0 errors" "test 16: wrong error counter (test1a)"
+
+rm -Rf tmp-sync/test1b/dir1/
+
+dav_sync_push test1b "test 16: push failed (test1b)"
+TEST=`cat tmp-sync/out.txt | grep "delete: /dir1/file3"`
+if [ $? -eq 0 ]; then
+	echo "test 16: /dir1/file3 deleted"
+	exit 2
+fi
+check_tmpout "delete: /dir1/subdir1/" "test 16: missing delete subdir1"
+
+TEST=`$DAV_BIN list -lR dav-test-repo/sync/test1/dir1 | wc -l`
+if [ $TEST != "1" ]; then
+	echo "test 16: wrong resource count"
+	exit 2
+fi
+
+

mercurial