port md5 support to TokyoCabinet
[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
20 RSYNC_LOGIN=`sudo ./create-user.sh test@example.com secret 500k`
21 RSYNC_LOGIN2=`sudo ./create-user.sh test2@example.com secret 20k`
22
23 dir=/tmp/test
24 rm -Rf "$dir"
25 mkdir /tmp/test
26 cd $dir
27
28 push . --recursive --delete -v
29
30 if true ; then # skip tests if false
31
32 ps ax > foo
33 push foo -v
34 push foo -v
35 ps ax > bar
36 push bar -v
37 touch --date='2000-01-01' bar
38 push bar -v
39 pull bar baz
40 push baz -v
41 ps ax >> baz
42 push baz -v
43 cp baz baz2
44 push baz baz2 -v
45
46 mkdir dir-test
47 # deduplicate?
48 cp foo bar dir-test/
49 uptime > "dir-test/file with spaces"
50 push dir-test --recursive -v
51
52 find . type -f | xargs -i md5sum {} > /tmp/md5sum
53
54 rm foo bar
55 push dir-test --recursive --delete -v
56 rm -Rf dir-test
57
58 pull non-existing || true
59
60 cp /tmp/md5sum md5sum
61 mkdir clone
62 # test md5 import from directory
63 mv md5sum clone/
64 push clone -r -v
65 # client should hardlink or copy files locally to avoid wastefull pull
66 # but we test server-side hardlink here
67 pull clone -r -v
68
69 md5sum clone/* | sed -e 's!  !  _import/foo/bar/baz!' > md5sum
70 cat md5sum
71 push md5sum -v
72
73 # test unused md5 pool quota
74
75 ps ax > tmp
76 push tmp -v
77 rm tmp
78 push . -r --delete -v
79
80 # test send
81
82 ps ax >> send
83 mkdir dir1
84 ps ax >> dir1/send
85 mkdir dir2
86 ps ax >> dir2/send
87
88 mkdir -p .sync/send
89 cat << __SEND__ > .sync/send/timestamp
90 $RSYNC_LOGIN2 send
91 $RSYNC_LOGIN2 dir1/send
92 $RSYNC_LOGIN2 dir2/send
93 __SEND__
94
95 # order is important! .sync must be last!
96 push send dir1 dir2 .sync -rv
97
98
99 fi # skip tests
100
101 # test file move
102
103 pending=/tmp/pending.0610201109464117
104 grep ^MOVED $pending | cut -d\# -f2 | xargs -i sh -c "ps ax > {}"
105 push . -rv
106
107 mkdir -p .sync/pending
108 cp $pending .sync/pending/
109 push .sync -rv