X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=test.sh;h=8518ecfaee8cae4fe896a246efdbd1401de07fb3;hb=925ecfc00ce5ab771ff4337fcb9f1b27dc9570cb;hp=9a3268e1c29d24c546d37e22a7cb8c1e2463f411;hpb=d264b817ba0e710bdfc8c9142fb9996f6b509c86;p=cloudstore.git diff --git a/test.sh b/test.sh index 9a3268e..8518ecf 100755 --- a/test.sh +++ b/test.sh @@ -1,27 +1,37 @@ #!/bin/sh -xe -user_dir=/srv/cloudstore/users/test/ -rm -vf $user_dir/log/* +RSYNC_LOGIN=fake push() { file=`shift` - RSYNC_PASSWORD=secret rsync $* $file rsync://test+localhost@127.0.0.1:6501/test/$file + RSYNC_PASSWORD=secret rsync $* $file rsync://$RSYNC_LOGIN@127.0.0.1:6501/$RSYNC_LOGIN/localhost/$file } pull() { from=$1 to=$2 test -z "$to" && to=$1 - RSYNC_PASSWORD=secret rsync rsync://test@127.0.0.1:6501/test/$from $to + RSYNC_PASSWORD=secret rsync rsync://$RSYNC_LOGIN@127.0.0.1:6501/$RSYNC_LOGIN/localhost/$from $to } -./create-user.sh test secret -./create-user.sh test secret localhost + +#sudo ./remove-user.sh test@example.com +#sudo ./remove-user.sh test2@example.com +base_dir=`pwd` + +RSYNC_LOGIN=`sudo ./create-user.sh test@example.com secret 500000` +RSYNC_LOGIN2=`sudo ./create-user.sh test2@example.com secret 100000` + +. ./env.sh dir=/tmp/test rm -Rf "$dir" mkdir /tmp/test cd $dir + push . --recursive --delete -v + +if [ ! -z "$ALL" ] ; then # skip tests if false + ps ax > foo push foo -v push foo -v @@ -41,17 +51,86 @@ mkdir dir-test cp foo bar dir-test/ uptime > "dir-test/file with spaces" push dir-test --recursive -v + +find . type -f | xargs -i md5sum {} > /tmp/md5sum + rm foo bar push dir-test --recursive --delete -v rm -Rf dir-test pull non-existing || true -tail -20 $user_dir/log/* +cp /tmp/md5sum md5sum +mkdir clone +# test md5 import from directory +mv md5sum clone/ +push clone -r -v +# client should hardlink or copy files locally to avoid wastefull pull +# but we test server-side hardlink here +pull clone -r -v + +md5sum clone/* | sed -e 's! ! _import/foo/bar/baz!' > md5sum +cat md5sum +push md5sum -v + +# test unused md5 pool quota + +ps ax > tmp +push tmp -v +rm tmp +push . -r --delete -v + +# test send + +ps ax >> send +mkdir dir1 +ps ax >> dir1/send +mkdir dir2 +ps ax >> dir2/send + +mkdir -p .sync/send +cat << __SEND__ > .sync/send/timestamp +$RSYNC_LOGIN2 send +$RSYNC_LOGIN2 dir1/send +$RSYNC_LOGIN2 dir2/send +__SEND__ + +# order is important! .sync must be last! +push send dir1 dir2 .sync -rv + +# test receiving of sent files +mkdir /tmp/test/$RSYNC_LOGIN2 +RSYNC_PASSWORD=secret rsync -rv rsync://$RSYNC_LOGIN2@127.0.0.1:6501/$RSYNC_LOGIN2/received/ /tmp/test/$RSYNC_LOGIN2 + +fi # skip tests + +# test file move + +ps ax > Jellyfish.jpg +push Jellyfish.jpg + +mkdir -p .sync/pending +cat << __pending__ > .sync/pending/test +MOVED#Jellyfish.jpg#Photos with space/Jellyfish cool.jpg +DELETED#Photos with space/Jellyfish cool.jpg +DELETED#Photos with space +__pending__ + +push .sync -rv + +exit + +ps ax > perms-test +chmod 400 perms-test +push -va perms-test + +sudo sh -xc "ls -al ~$RSYNC_LOGIN/localhost/" + + + -#diff -urw $user_dir/blob $dir/ -#diff -urw $user_dir/json $dir/ +find $SLICE/2001/ -type f | grep -v '/\.' | xargs md5sum | sort > /tmp/test/1 +FULL=1 $base_dir/user-md5sum.pl u2001 | sort > /tmp/test/2 -ls -al $user_dir/blob $user_dir/json +diff /tmp/test/1 /tmp/test/2 && echo "OK - md5 database consistant with filesystem" -#./remove-user.sh test