# HG changeset patch # User Olaf Wintermann # Date 1573291138 -3600 # Node ID 41b4cc024249ac94234b62e858bab77a542e6da1 # Parent 5a4002f8d258d9d9923327729445ab1d2387ede0 add tests for tag conflict resolution diff -r 5a4002f8d258 -r 41b4cc024249 test/bin-test/dav-home/sync.xml --- a/test/bin-test/dav-home/sync.xml Sun Oct 27 10:18:25 2019 +0100 +++ b/test/bin-test/dav-home/sync.xml Sat Nov 09 10:18:58 2019 +0100 @@ -147,4 +147,40 @@ all + + + test4akl + $HOME/tmp-sync/test4akl + dav-test-repo + /sync/test4 + .trash + dav-sync-tests-test4akl-db.xml + + true + + + xattr + true + keep_local + + all + + + + test4bkr + $HOME/tmp-sync/test4bkr + dav-test-repo + /sync/test4 + .trash + dav-sync-tests-test4bkr-db.xml + + true + + + xattr + true + keep_remote + + all + diff -r 5a4002f8d258 -r 41b4cc024249 test/bin-test/test-dav-sync-metadata4.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/bin-test/test-dav-sync-metadata4.sh Sat Nov 09 10:18:58 2019 +0100 @@ -0,0 +1,262 @@ +#!/bin/sh +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# +# Copyright 2019 Olaf Wintermann. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +if [ -z "$DAV_BIN" ]; +then + echo "DAV_BIN variable not set" + exit 1 +fi +if [ -z "$DAV_SYNC_BIN" ]; +then + echo "DAV_BIN variable not set" + exit 1 +fi + +XATTR=../../build/xattrtool + +# checks if tmp-sync/out.txt contains a specific text +# arg1: pattern +# arg2: errormsg +check_tmpout() +{ + TEST=`cat tmp-sync/out.txt | grep "$1"` + if [ $? -ne 0 ]; + then + echo "$2" + exit 2 + fi +} + +# checks if tmp-sync/out.txt does not contain a specific text +# arg1: pattern +# arg2: errormsg +ncheck_tmpout() +{ + TEST=`cat tmp-sync/out.txt | grep "$1"` + if [ $? -eq 0 ]; + then + echo "$2" + exit 2 + fi +} + +# do dav-sync push and check return value +# arg1: dir +# arg2: errormsg +dav_sync_push() +{ + $DAV_SYNC_BIN push $1 > tmp-sync/out.txt + if [ $? -ne 0 ]; + then + echo "$2" + exit 2 + fi +} +# do dav-sync pull and check return value +# arg1: dir +# arg2: errormsg +dav_sync_pull() +{ + $DAV_SYNC_BIN pull $1 > tmp-sync/out.txt + if [ $? -ne 0 ]; + then + echo "$2" + exit 2 + fi +} + +rm -f .dav/dav-sync-tests-test4akl-db.xml +rm -f .dav/dav-sync-tests-test4bkr-db.xml + +$DAV_BIN rm dav-test-repo/sync/test4 2> /dev/null + +$DAV_BIN mkcol dav-test-repo/sync/test4 2> /dev/null + +# tmp sync dir +rm -Rf tmp-sync +mkdir tmp-sync +mkdir tmp-sync/test4akl +mkdir tmp-sync/test4bkr + +# ---------------------------------------------------------------------------- +# test 1: add some files with tags and sync +# expected result: everything synced + +cp synctest/file1 tmp-sync/test4akl/ +cp synctest/file2 tmp-sync/test4akl/ +cp synctest/file3 tmp-sync/test4akl/ + +$DAV_SYNC_BIN add-tag -s test4akl tmp-sync/test4akl/file1 mytag1 +$DAV_SYNC_BIN add-tag -s test4akl tmp-sync/test4akl/file2 mytag1 +$DAV_SYNC_BIN add-tag -s test4akl tmp-sync/test4akl/file3 mytag1 + +$DAV_SYNC_BIN add-tag -s test4akl tmp-sync/test4akl/file1 tt1 +$DAV_SYNC_BIN add-tag -s test4akl tmp-sync/test4akl/file2 tt1 +$DAV_SYNC_BIN add-tag -s test4akl tmp-sync/test4akl/file3 tt1 + +dav_sync_push test4akl "test 1: push failed" +check_tmpout "3 files pushed" "test 1: wrong push counter" +check_tmpout "0 conflicts" "test 1: wrong conflict counter (push)" +check_tmpout "0 errors" "test 1: wrong error counter (push)" + +dav_sync_pull test4bkr "test 1: pull failed" +check_tmpout "3 files pulled" "test 1: wrong pull counter" +check_tmpout "0 conflicts" "test 1: wrong conflict counter (pull)" +check_tmpout "0 errors" "test 1: wrong error counter (pull)" + +TAGS=`$DAV_SYNC_BIN list-tags -s test4bkr tmp-sync/test4bkr/file1 > tmp-sync/out.txt 2> /dev/null` +if [ $? -ne 0 ]; then + echo "test 1: list-tags failed (file1)" + exit 2 +fi +check_tmpout "mytag1" "test 1: file1: missing tag mytag1" +check_tmpout "tt1" "test 1: file1: missing tag tt1" + +TAGS=`$DAV_SYNC_BIN list-tags -s test4bkr tmp-sync/test4bkr/file2 > tmp-sync/out.txt 2> /dev/null` +if [ $? -ne 0 ]; then + echo "test 1: list-tags failed (file2)" + exit 2 +fi +check_tmpout "mytag1" "test 1: file2: missing tag mytag1" +check_tmpout "tt1" "test 1: file2: missing tag tt1" + +TAGS=`$DAV_SYNC_BIN list-tags -s test4bkr tmp-sync/test4bkr/file3 > tmp-sync/out.txt 2> /dev/null` +if [ $? -ne 0 ]; then + echo "test 1: list-tags failed (file3)" + exit 2 +fi +check_tmpout "mytag1" "test 1: file3: missing tag mytag1" +check_tmpout "tt1" "test 1: file3: missing tag tt1" + + +# ---------------------------------------------------------------------------- +# test 2: modify tags on both sides and push b, push a, pull b +# expected result: tags from a used + +# changes in test4kl +$DAV_SYNC_BIN remove-tag -s test4akl tmp-sync/test4akl/file1 mytag1 +$DAV_SYNC_BIN set-tags -s test4akl tmp-sync/test4akl/file2 tt2a +$DAV_SYNC_BIN add-tag -s test4akl tmp-sync/test4akl/file3 mytag2 + +# changes in test4bkr +$DAV_SYNC_BIN add-tag -s test4bkr tmp-sync/test4bkr/file1 tt2b +$DAV_SYNC_BIN set-tags -s test4bkr tmp-sync/test4bkr/file2 tt2b +$DAV_SYNC_BIN remove-tag -s test4bkr tmp-sync/test4bkr/file3 mytag1 + +dav_sync_push test4bkr "test 2: push b failed" +check_tmpout "0 conflicts" "test 2: wrong conflict counter (push b)" +check_tmpout "0 errors" "test 2: wrong error counter (push b)" + +dav_sync_push test4akl "test 2: push failed" +check_tmpout "0 conflicts" "test 2: wrong conflict counter (push)" +check_tmpout "0 errors" "test 2: wrong error counter (push)" + +dav_sync_pull test4bkr "test 2: pull failed" +check_tmpout "0 conflicts" "test 2: wrong conflict counter (pull)" +check_tmpout "0 errors" "test 2: wrong error counter (pull)" + +TAGS=`$DAV_SYNC_BIN list-tags -s test4bkr tmp-sync/test4bkr/file1 > tmp-sync/out.txt 2> /dev/null` +if [ $? -ne 0 ]; then + echo "test 1: list-tags failed (file1)" + exit 2 +fi +ncheck_tmpout "mytag1" "test 2: file1: tag mytag1" +check_tmpout "tt1" "test 2: file1: tag tt1" +ncheck_tmpout "tt2" "test 2: file1: tag tt2" + +TAGS=`$DAV_SYNC_BIN list-tags -s test4bkr tmp-sync/test4bkr/file2 > tmp-sync/out.txt 2> /dev/null` +if [ $? -ne 0 ]; then + echo "test 2: list-tags failed (file2)" + exit 2 +fi +check_tmpout "tt2a" "test 2: file2: tt2a" +ncheck_tmpout "tt2b" "test 2: file2: tt2b" + +TAGS=`$DAV_SYNC_BIN list-tags -s test4bkr tmp-sync/test4bkr/file3 > tmp-sync/out.txt 2> /dev/null` +if [ $? -ne 0 ]; then + echo "test 2: list-tags failed (file3)" + exit 2 +fi +check_tmpout "mytag1" "test 3: file3: tag mytag1" +check_tmpout "tt1" "test 3: file3: tag tt1" +check_tmpout "mytag2" "test 3: file3: tag mytag2" + + +# ---------------------------------------------------------------------------- +# test 3: modify tags on both sides and push a, push b, pull a +# expected result: tags from a used + +# changes in test4kl +$DAV_SYNC_BIN add-tag -s test4akl tmp-sync/test4akl/file1 mytag3 +$DAV_SYNC_BIN set-tags -s test4akl tmp-sync/test4akl/file2 tt3a +$DAV_SYNC_BIN remove-tag -s test4akl tmp-sync/test4akl/file3 mytag2 + +# changes in test4bkr +$DAV_SYNC_BIN remove-tag -s test4bkr tmp-sync/test4bkr/file1 tt1 +$DAV_SYNC_BIN set-tags -s test4bkr tmp-sync/test4bkr/file2 tt3b +$DAV_SYNC_BIN add-tag -s test4bkr tmp-sync/test4bkr/file3 mytag3 + +dav_sync_push test4akl "test 3: push a failed" +check_tmpout "0 conflicts" "test 3: wrong conflict counter (push a)" +check_tmpout "0 errors" "test 3: wrong error counter (push a)" + +dav_sync_push test4bkr "test 3: push failed" +check_tmpout "0 conflicts" "test 3: wrong conflict counter (push)" +check_tmpout "0 errors" "test 3: wrong error counter (push)" + +dav_sync_pull test4akl "test 3: pull failed" +check_tmpout "0 conflicts" "test 3: wrong conflict counter (pull)" +check_tmpout "0 errors" "test 3: wrong error counter (pull)" + +TAGS=`$DAV_SYNC_BIN list-tags -s test4akl tmp-sync/test4akl/file1 > tmp-sync/out.txt 2> /dev/null` +if [ $? -ne 0 ]; then + echo "test 3: list-tags failed (file1)" + exit 2 +fi +check_tmpout "mytag3" "test 3: file1: tag mytag3" +check_tmpout "tt1" "test 3: file1: tag tt1" + +TAGS=`$DAV_SYNC_BIN list-tags -s test4akl tmp-sync/test4akl/file2 > tmp-sync/out.txt 2> /dev/null` +if [ $? -ne 0 ]; then + echo "test 3: list-tags failed (file2)" + exit 2 +fi +check_tmpout "tt3a" "test 2: file2: tt3a" +ncheck_tmpout "tt3b" "test 2: file2: tt3b" + +TAGS=`$DAV_SYNC_BIN list-tags -s test4akl tmp-sync/test4akl/file3 > tmp-sync/out.txt 2> /dev/null` +if [ $? -ne 0 ]; then + echo "test 3: list-tags failed (file3)" + exit 2 +fi +check_tmpout "mytag1" "test 3: file3: tag mytag1" +check_tmpout "tt1" "test 3: file3: tag tt1" +ncheck_tmpout "mytag2" "test 3: file3: tag mytag2" +ncheck_tmpout "mytag2" "test 3: file3: tag mytag3" + diff -r 5a4002f8d258 -r 41b4cc024249 test/bin-test/test-dav-sync.sh --- a/test/bin-test/test-dav-sync.sh Sun Oct 27 10:18:25 2019 +0100 +++ b/test/bin-test/test-dav-sync.sh Sat Nov 09 10:18:58 2019 +0100 @@ -94,16 +94,17 @@ # 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 +do_test "dav-sync metadata (4)" test-dav-sync-metadata4.sh # cleanup $DAV_BIN rm dav-test-repo/sync/test1 > /dev/null 2>&1