die on rsync error
[cloudstore.git] / test.sh
1 #!/bin/sh -xe
2
3 user_dir=/srv/cloudstore/users/test/
4 rm -vf $user_dir/log/*
5
6 push() {
7         file=`shift`
8         RSYNC_PASSWORD=secret rsync $* $file rsync://test+localhost@127.0.0.1:6501/test/$file
9 }
10 pull() {
11         from=$1
12         to=$2
13         test -z "$to" && to=$1
14         RSYNC_PASSWORD=secret rsync rsync://test@127.0.0.1:6501/test/$from $to
15 }
16
17 ./create-user.sh test secret
18 ./create-user.sh test secret localhost
19
20 dir=/tmp/test
21 rm -Rf "$dir"
22 mkdir /tmp/test
23 cd $dir
24 push . --recursive --delete -v
25 ps ax > foo
26 push foo -v
27 push foo -v
28 ps ax > bar
29 push bar -v
30 touch --date='2000-01-01' bar
31 push bar -v
32 pull bar baz
33 push baz -v
34 ps ax >> baz
35 push baz -v
36 cp baz baz2
37 push baz baz2 -v
38
39 mkdir dir-test
40 # deduplicate?
41 cp foo bar dir-test/
42 uptime > "dir-test/file with spaces"
43 push dir-test --recursive -v
44 rm foo bar
45 push dir-test --recursive --delete -v
46 rm -Rf dir-test
47
48 pull non-existing || true
49
50 tail -20 $user_dir/log/*
51
52 #diff -urw $user_dir/blob $dir/
53 #diff -urw $user_dir/json $dir/
54
55 ls -al $user_dir/blob $user_dir/json
56
57 #./remove-user.sh test