c6b2e04f6a745efbb999cb0f4ed13b722b646ffc
[cloudstore.git] / test.sh
1 #!/bin/sh -xe
2
3 user_dir=/srv/cloudstore/users/test/
4 rm -Rvf $user_dir/log/* #$user_dir/blob/*
5
6 RSYNC_LOGIN=u2000
7
8 push() {
9         file=`shift`
10         RSYNC_PASSWORD=secret rsync $* $file rsync://$RSYNC_LOGIN@127.0.0.1:6501/$RSYNC_LOGIN/localhost/$file
11 }
12 pull() {
13         from=$1
14         to=$2
15         test -z "$to" && to=$1
16         RSYNC_PASSWORD=secret rsync rsync://$RSYNC_LOGIN@127.0.0.1:6501/$RSYNC_LOGIN/localhost/$from $to
17 }
18
19
20 sudo ./remove-user.sh test@example.com
21 sudo ./remove-user.sh test2@example.com
22
23 RSYNC_LOGIN=`sudo ./create-user.sh test@example.com secret 500k`
24 RSYNC_LOGIN2=`sudo ./create-user.sh test2@example.com secret 20k`
25
26 dir=/tmp/test
27 rm -Rf "$dir"
28 mkdir /tmp/test
29 cd $dir
30
31 if true ; then # skip tests if false
32
33 push . --recursive --delete -v
34 ps ax > foo
35 push foo -v
36 push foo -v
37 ps ax > bar
38 push bar -v
39 touch --date='2000-01-01' bar
40 push bar -v
41 pull bar baz
42 push baz -v
43 ps ax >> baz
44 push baz -v
45 cp baz baz2
46 push baz baz2 -v
47
48 mkdir dir-test
49 # deduplicate?
50 cp foo bar dir-test/
51 uptime > "dir-test/file with spaces"
52 push dir-test --recursive -v
53
54 find . type -f | xargs -i md5sum {} > /tmp/md5sum
55
56 rm foo bar
57 push dir-test --recursive --delete -v
58 rm -Rf dir-test
59
60 pull non-existing || true
61
62 cp /tmp/md5sum md5sum
63 mkdir clone
64 # test md5 import from directory
65 mv md5sum clone/
66 push clone -r -v
67 # client should hardlink or copy files locally to avoid wastefull pull
68 # but we test server-side hardlink here
69 pull clone -r -v
70
71 md5sum clone/* | sed -e 's!  !  _import/foo/bar/baz!' > md5sum
72 cat md5sum
73 push md5sum -v
74
75 fi # skip tests
76
77 # test unused md5 pool quota
78
79 ps ax > tmp
80 push tmp -v
81 rm tmp
82 push . -r --delete -v
83
84 exit
85
86 # test send
87
88 ps ax >> sent-to-$RSYNC_LOGIN2
89 push sent-to-$RSYNC_LOGIN2 # must be done before first send
90
91 mkdir -p .send/$RSYNC_LOGIN2/received
92 ln -s ../../../sent-to-$RSYNC_LOGIN2 .send/$RSYNC_LOGIN2/received/new-name
93
94 push .send -rvl