100k quota for test user u2002
[cloudstore.git] / test.sh
1 #!/bin/sh -xe
2
3 RSYNC_LOGIN=fake
4
5 push() {
6         file=`shift`
7         RSYNC_PASSWORD=secret rsync $* $file rsync://$RSYNC_LOGIN@127.0.0.1:6501/$RSYNC_LOGIN/localhost/$file
8 }
9 pull() {
10         from=$1
11         to=$2
12         test -z "$to" && to=$1
13         RSYNC_PASSWORD=secret rsync rsync://$RSYNC_LOGIN@127.0.0.1:6501/$RSYNC_LOGIN/localhost/$from $to
14 }
15
16
17 sudo ./remove-user.sh test@example.com
18 sudo ./remove-user.sh test2@example.com
19 base_dir=`pwd`
20
21 RSYNC_LOGIN=`sudo ./create-user.sh test@example.com secret 500k`
22 RSYNC_LOGIN2=`sudo ./create-user.sh test2@example.com secret 100k`
23
24 dir=/tmp/test
25 rm -Rf "$dir"
26 mkdir /tmp/test
27 cd $dir
28
29 push . --recursive --delete -v
30
31 if [ ! -z "$ALL" ] ; then # skip tests if false
32
33 ps ax > foo
34 push foo -v
35 push foo -v
36 ps ax > bar
37 push bar -v
38 touch --date='2000-01-01' bar
39 push bar -v
40 pull bar baz
41 push baz -v
42 ps ax >> baz
43 push baz -v
44 cp baz baz2
45 push baz baz2 -v
46
47 mkdir dir-test
48 # deduplicate?
49 cp foo bar dir-test/
50 uptime > "dir-test/file with spaces"
51 push dir-test --recursive -v
52
53 find . type -f | xargs -i md5sum {} > /tmp/md5sum
54
55 rm foo bar
56 push dir-test --recursive --delete -v
57 rm -Rf dir-test
58
59 pull non-existing || true
60
61 cp /tmp/md5sum md5sum
62 mkdir clone
63 # test md5 import from directory
64 mv md5sum clone/
65 push clone -r -v
66 # client should hardlink or copy files locally to avoid wastefull pull
67 # but we test server-side hardlink here
68 pull clone -r -v
69
70 md5sum clone/* | sed -e 's!  !  _import/foo/bar/baz!' > md5sum
71 cat md5sum
72 push md5sum -v
73
74 # test unused md5 pool quota
75
76 ps ax > tmp
77 push tmp -v
78 rm tmp
79 push . -r --delete -v
80
81 # test send
82
83 ps ax >> send
84 mkdir dir1
85 ps ax >> dir1/send
86 mkdir dir2
87 ps ax >> dir2/send
88
89 mkdir -p .sync/send
90 cat << __SEND__ > .sync/send/timestamp
91 $RSYNC_LOGIN2 send
92 $RSYNC_LOGIN2 dir1/send
93 $RSYNC_LOGIN2 dir2/send
94 __SEND__
95
96 # order is important! .sync must be last!
97 push send dir1 dir2 .sync -rv
98
99 # test receiving of sent files
100 mkdir /tmp/test/$RSYNC_LOGIN2
101 RSYNC_PASSWORD=secret rsync -rv rsync://$RSYNC_LOGIN2@127.0.0.1:6501/$RSYNC_LOGIN2/received/ /tmp/test/$RSYNC_LOGIN2
102
103
104 # test file move
105
106 pending=/tmp/pending.0610201109464117
107 grep ^MOVED $pending | cut -d\# -f2 | xargs -i sh -c "ps ax > {}"
108 push . -rv
109
110 mkdir -p .sync/pending
111 cp $pending .sync/pending/
112 push .sync -rv
113
114
115 ps ax > perms-test
116 chmod 400 perms-test
117 push -va perms-test
118
119 sudo sh -xc "ls -al ~$RSYNC_LOGIN/localhost/"
120
121 pull
122
123
124 fi # skip tests
125
126
127 find /test/s1/2001/ -type f | grep -v '/\.' | xargs md5sum | sort > /tmp/test/1
128 FULL=1 $base_dir/user-md5sum.pl u2001 | sort > /tmp/test/2
129
130 diff /tmp/test/1 /tmp/test/2 && echo "OK - md5 database consistant with filesystem"
131