Merge branch 'master' of git.rot13.org:/git/cloudstore
[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 push() {
7         file=`shift`
8         RSYNC_PASSWORD=secret rsync $* $file rsync://test+localhost@127.0.0.1:6501/test/localhost/$file
9 }
10 pull() {
11         from=$1
12         to=$2
13         test -z "$to" && to=$1
14         RSYNC_PASSWORD=secret rsync rsync://test+localhost@127.0.0.1:6501/test/localhost/$from $to
15 }
16
17
18 ./remove-user.sh test
19
20 ./create-user.sh test secret
21 ./create-user.sh test secret localhost
22 ./store-fsck.pl test
23
24 ./remove-user.sh test2
25 ./create-user.sh test2 secret
26
27 dir=/tmp/test
28 rm -Rf "$dir"
29 mkdir /tmp/test
30 cd $dir
31 push . --recursive --delete -v
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 send
74
75 ps ax >> sent-to-test2
76 push sent-to-test2 # must be done before first send
77
78 mkdir -p .send/test2/received
79 ln -s ../../../sent-to-test2 .send/test2/received/new-name
80
81 push .send -rvl
82
83 tail -20 $user_dir/log/*
84
85 #diff -urw $user_dir/blob $dir/
86 #diff -urw $user_dir/json $dir/
87
88 ls -al $user_dir/blob