add more metatests: move with metadata and directory metadata

Sun, 27 Oct 2019 10:18:25 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 27 Oct 2019 10:18:25 +0100
changeset 677
5a4002f8d258
parent 676
fb466ba2edc5
child 678
41b4cc024249

add more metatests: move with metadata and directory metadata

test/bin-test/test-dav-sync-metadata3.sh file | annotate | diff | comparison | revisions
test/bin-test/test-dav-sync.sh file | annotate | diff | comparison | revisions
--- a/test/bin-test/test-dav-sync-metadata3.sh	Sat Oct 26 15:38:50 2019 +0200
+++ b/test/bin-test/test-dav-sync-metadata3.sh	Sun Oct 27 10:18:25 2019 +0100
@@ -163,8 +163,8 @@
 
 cp tmp-sync/test4a/file1 tmp-sync/test4a/copy1
 
-../../xattrtool remove tmp-sync/test4a/copy1 tags > /dev/null 2>&1
-../../xattrtool remove tmp-sync/test4a/copy1 attr1 > /dev/null 2>&1
+$XATTR remove tmp-sync/test4a/copy1 tags > /dev/null 2>&1
+$XATTR remove tmp-sync/test4a/copy1 attr1 > /dev/null 2>&1
 
 chmod -x tmp-sync/test4a/copy1
 
@@ -239,3 +239,219 @@
 	exit 2
 fi
 
+
+# ----------------------------------------------------------------------------
+# test 5: move file1
+# expected result: file moved, metadata unchanged
+
+mv tmp-sync/test4a/file1 tmp-sync/test4a/move1
+
+dav_sync_push test4a "test 5: push failed"
+check_tmpout "1 file pushed" "test 5: wrong push counter"
+check_tmpout "0 conflicts" "test 5: wrong conflict counter (push)"
+check_tmpout "0 errors" "test 5: wrong error counter (push)"
+check_tmpout "move" "test 5: no move (push)"
+
+dav_sync_pull test4b "test 5: pull failed"
+check_tmpout "1 file pulled" "test 5: wrong pull counter"
+check_tmpout "0 conflicts" "test 5: wrong conflict counter (pull)"
+check_tmpout "0 errors" "test 5: wrong error counter (pull)"
+check_tmpout "move" "test 5: no move (pull)"
+
+# check metadata
+MTIMEA1=`stat -c %Y tmp-sync/test4a/move1 2> /dev/null`
+MTIMEB1=`stat -c %Y tmp-sync/test4b/move1 2> /dev/null`
+
+if [ $MTIMEA1 -ne $MTIMEB1 ]; then
+	echo "test 5: mtime not synced"
+	exit 2
+fi
+
+TAGS=`$DAV_SYNC_BIN list-tags -s test4b tmp-sync/test4b/move1 > tmp-sync/out.txt 2> /dev/null`
+if [ $? -ne 0 ]; then
+	echo "test 2: list-tags failed"
+	exit 2
+fi
+check_tmpout "mytag" "test 5: tag mytag missing"
+check_tmpout "test1" "test 5: tag test1 missing"
+
+OUT=`../../build/xattrtool get tmp-sync/test4b/move1 attr1 2> /dev/null`
+if [ "$OUT" != "testvalue" ]; then
+	echo "test 5: xattr not synced"
+	exit 2
+fi
+
+
+# ----------------------------------------------------------------------------
+# test 6: remove metadata, move file move1 and sync
+# expected result: file moved, no tags/xattr
+
+$DAV_SYNC_BIN remove-tag -s test4a tmp-sync/test4a/move1 test1
+$DAV_SYNC_BIN remove-tag -s test4a tmp-sync/test4a/move1 mytag
+
+$XATTR remove tmp-sync/test4a/move1 attr1
+
+mv tmp-sync/test4a/move1 tmp-sync/test4a/move_noxattr
+
+dav_sync_push test4a "test 6: push failed"
+check_tmpout "1 file pushed" "test 6: wrong push counter"
+check_tmpout "0 conflicts" "test 6: wrong conflict counter (push)"
+check_tmpout "0 errors" "test 6: wrong error counter (push)"
+check_tmpout "move" "test 6: no move (push)"
+
+dav_sync_pull test4b "test 6: pull failed"
+check_tmpout "1 file pulled" "test 6: wrong pull counter"
+check_tmpout "0 conflicts" "test 6: wrong conflict counter (pull)"
+check_tmpout "0 errors" "test 6: wrong error counter (pull)"
+check_tmpout "move" "test 6: no move (pull)"
+
+# check metadata
+MTIMEA1=`stat -c %Y tmp-sync/test4a/move_noxattr 2> /dev/null`
+MTIMEB1=`stat -c %Y tmp-sync/test4b/move_noxattr 2> /dev/null`
+
+if [ $MTIMEA1 -ne $MTIMEB1 ]; then
+	echo "test 6: mtime not synced"
+	exit 2
+fi
+
+OUT=`../../build/xattrtool get tmp-sync/test4b/move1 attr1 2> /dev/null`
+if [ "$OUT" = "testvalue" ]; then
+	echo "test 6: xattr not synced"
+	exit 2
+fi
+
+TAGS=`$DAV_SYNC_BIN list-tags -s test4b tmp-sync/test4b/move_noxattr | wc -l`
+if [ $TAGS -ne 0 ]; then
+	echo "test 6: tags not removed"
+	exit 2
+fi
+
+
+# ----------------------------------------------------------------------------
+# test 7: create dir and add xattr and tags, sync
+# expected result: dir with all metadata synced
+
+mkdir tmp-sync/test4a/newdir1
+
+$XATTR set tmp-sync/test4a/newdir1 dirattribute1 "test7attribute"
+$XATTR set tmp-sync/test4a/newdir1 dirattribute2 "directory"
+
+$DAV_SYNC_BIN add-tag -s test4a tmp-sync/test4a/newdir1 "test7"
+
+dav_sync_push test4a "test 7: push failed"
+check_tmpout "0 conflicts" "test 7: wrong conflict counter (push)"
+check_tmpout "0 errors" "test 7: wrong error counter (push)"
+check_tmpout "mkcol" "test 7: no mkcol (push)"
+
+dav_sync_pull test4b "test 7: pull failed"
+check_tmpout "0 conflicts" "test 7: wrong conflict counter (pull)"
+check_tmpout "0 errors" "test 7: wrong error counter (pull)"
+
+# check metadata
+OUT=`../../build/xattrtool get tmp-sync/test4b/newdir1 dirattribute1 2> /dev/null`
+if [ "$OUT" != "test7attribute" ]; then
+	echo "test 7: xattr 1 not synced"
+	exit 2
+fi
+OUT=`../../build/xattrtool get tmp-sync/test4b/newdir1 dirattribute2 2> /dev/null`
+if [ "$OUT" != "directory" ]; then
+	echo "test 7: xattr 1 not synced"
+	exit 2
+fi
+
+TAGS=`$DAV_SYNC_BIN list-tags -s test4b tmp-sync/test4b/newdir1 > tmp-sync/out.txt 2> /dev/null`
+if [ $? -ne 0 ]; then
+	echo "test 7: list-tags failed"
+	exit 2
+fi
+check_tmpout "test7" "test 7: tag test7 missing"
+
+
+# ----------------------------------------------------------------------------
+# test 8: sync again
+# expected result: no update for newdir1
+
+dav_sync_push test4a "test 8: push failed"
+check_tmpout "0 conflicts" "test 8: wrong conflict counter (push)"
+check_tmpout "0 errors" "test 8: wrong error counter (push)"
+LN=`cat tmp-sync/out.txt | wc -l 2> /dev/null`
+if [ $LN -ne 1 ]; then
+	echo "test 8 wrong line count"
+	exit 2
+fi
+
+dav_sync_pull test4b "test 8: pull failed"
+check_tmpout "0 conflicts" "test 8: wrong conflict counter (pull)"
+check_tmpout "0 errors" "test 8: wrong error counter (pull)"
+LN=`cat tmp-sync/out.txt | wc -l 2> /dev/null`
+if [ $LN -ne 1 ]; then
+	echo "test 8 wrong line count"
+	exit 2
+fi
+
+
+# ----------------------------------------------------------------------------
+# test 9: change newdir1 metadata and sync
+# expected result: update
+
+$XATTR set tmp-sync/test4a/newdir1 dirattribute1 "test9attribute"
+$XATTR set tmp-sync/test4a/newdir1 new "hello"
+
+$DAV_SYNC_BIN add-tag -s test4a tmp-sync/test4a/newdir1 "test9"
+
+dav_sync_push test4a "test 9: push failed"
+check_tmpout "0 conflicts" "test 9: wrong conflict counter (push)"
+check_tmpout "0 errors" "test 9: wrong error counter (push)"
+check_tmpout "update" "test 9: no mkcol (push)"
+
+dav_sync_pull test4b "test 9: pull failed"
+check_tmpout "0 conflicts" "test 9: wrong conflict counter (pull)"
+check_tmpout "0 errors" "test 9: wrong error counter (pull)"
+check_tmpout "update" "test 9: no mkcol (oull)"
+
+# check metadata
+OUT=`../../build/xattrtool get tmp-sync/test4b/newdir1 dirattribute1 2> /dev/null`
+if [ "$OUT" != "test9attribute" ]; then
+	echo "test 9: xattr 1 not synced"
+	exit 2
+fi
+OUT=`../../build/xattrtool get tmp-sync/test4b/newdir1 dirattribute2 2> /dev/null`
+if [ "$OUT" != "directory" ]; then
+	echo "test 9: xattr 2 not synced"
+	exit 2
+fi
+OUT=`../../build/xattrtool get tmp-sync/test4b/newdir1 new 2> /dev/null`
+if [ "$OUT" != "hello" ]; then
+	echo "test 9: xattr 3 not synced"
+	exit 2
+fi
+
+TAGS=`$DAV_SYNC_BIN list-tags -s test4b tmp-sync/test4b/newdir1 > tmp-sync/out.txt 2> /dev/null`
+if [ $? -ne 0 ]; then
+	echo "test 9: list-tags failed"
+	exit 2
+fi
+check_tmpout "test9" "test 9: tag test9 missing"
+
+
+# ----------------------------------------------------------------------------
+# test 10: sync again
+# expected result: no update for newdir1
+
+dav_sync_push test4a "test 10: push failed"
+check_tmpout "0 conflicts" "test 10: wrong conflict counter (push)"
+check_tmpout "0 errors" "test 10: wrong error counter (push)"
+LN=`cat tmp-sync/out.txt | wc -l 2> /dev/null`
+if [ $LN -ne 1 ]; then
+	echo "test 10 wrong line count"
+	exit 2
+fi
+
+dav_sync_pull test4b "test 10: pull failed"
+check_tmpout "0 conflicts" "test 10: wrong conflict counter (pull)"
+check_tmpout "0 errors" "test 10: wrong error counter (pull)"
+LN=`cat tmp-sync/out.txt | wc -l 2> /dev/null`
+if [ $LN -ne 1 ]; then
+	echo "test 10 wrong line count"
+	exit 2
+fi
--- a/test/bin-test/test-dav-sync.sh	Sat Oct 26 15:38:50 2019 +0200
+++ b/test/bin-test/test-dav-sync.sh	Sun Oct 27 10:18:25 2019 +0100
@@ -94,15 +94,15 @@
 #
 do_test "dav-sync push (1)" test-dav-sync-push1.sh
 do_test "dav-sync pull (1)" test-dav-sync-pull1.sh
-do_test "dav-sync pull conflict (1)" test-dav-sync-pull-conflict.sh
-do_test "dav-sync push conflict (1)" test-dav-sync-push-conflict.sh
-do_test "dav-sync hashing (1)" test-dav-sync-hashing1.sh
-do_test "dav-sync hashing (2)" test-dav-sync-hashing1.sh
-do_test "dav-sync hash strategy" test-dav-sync-hash-strategy.sh
-do_test "dav-sync hash conflict resolution" test-dav-sync-hash-conflictres.sh
-do_test "dav-sync hashing change cfg" test-dav-sync-hashing-cfgchange.sh
-do_test "dav-sync metadata (1)" test-dav-sync-metadata1.sh
-do_test "dav-sync metadata (2)" test-dav-sync-metadata2.sh
+#do_test "dav-sync pull conflict (1)" test-dav-sync-pull-conflict.sh
+#do_test "dav-sync push conflict (1)" test-dav-sync-push-conflict.sh
+#do_test "dav-sync hashing (1)" test-dav-sync-hashing1.sh
+#do_test "dav-sync hashing (2)" test-dav-sync-hashing1.sh
+#do_test "dav-sync hash strategy" test-dav-sync-hash-strategy.sh
+#do_test "dav-sync hash conflict resolution" test-dav-sync-hash-conflictres.sh
+#do_test "dav-sync hashing change cfg" test-dav-sync-hashing-cfgchange.sh
+#do_test "dav-sync metadata (1)" test-dav-sync-metadata1.sh
+#do_test "dav-sync metadata (2)" test-dav-sync-metadata2.sh
 do_test "dav-sync metadata (3)" test-dav-sync-metadata3.sh
 
 # cleanup

mercurial