use logins from create-user.sh
[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 200k`
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 push . --recursive --delete -v
31 ps ax > foo
32 push foo -v
33 push foo -v
34 ps ax > bar
35 push bar -v
36 touch --date='2000-01-01' bar
37 push bar -v
38 pull bar baz
39 push baz -v
40 ps ax >> baz
41 push baz -v
42 cp baz baz2
43 push baz baz2 -v
44
45 mkdir dir-test
46 # deduplicate?
47 cp foo bar dir-test/
48 uptime > "dir-test/file with spaces"
49 push dir-test --recursive -v
50
51 find . type -f | xargs -i md5sum {} > /tmp/md5sum
52
53 rm foo bar
54 push dir-test --recursive --delete -v
55 rm -Rf dir-test
56
57 pull non-existing || true
58
59 cp /tmp/md5sum md5sum
60 mkdir clone
61 # test md5 import from directory
62 mv md5sum clone/
63 push clone -r -v
64 # client should hardlink or copy files locally to avoid wastefull pull
65 # but we test server-side hardlink here
66 pull clone -r -v
67
68 md5sum clone/* | sed -e 's!  !  _import/foo/bar/baz!' > md5sum
69 cat md5sum
70 push md5sum -v
71
72 # test send
73
74 ps ax >> sent-to-$RSYNC_LOGIN2
75 push sent-to-$RSYNC_LOGIN2 # must be done before first send
76
77 mkdir -p .send/$RSYNC_LOGIN2/received
78 ln -s ../../../sent-to-$RSYNC_LOGIN2 .send/$RSYNC_LOGIN2/received/new-name
79
80 push .send -rvl