983558e6a7a3ba1a5b1b12a987ffc8ba4e771dfe
[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+localhost@127.0.0.1:6501/test/$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
23 dir=/tmp/test
24 rm -Rf "$dir"
25 mkdir /tmp/test
26 cd $dir
27 push . --recursive --delete -v
28 ps ax > foo
29 push foo -v
30 push foo -v
31 ps ax > bar
32 push bar -v
33 touch --date='2000-01-01' bar
34 push bar -v
35 pull bar baz
36 push baz -v
37 ps ax >> baz
38 push baz -v
39 cp baz baz2
40 push baz baz2 -v
41
42 mkdir dir-test
43 # deduplicate?
44 cp foo bar dir-test/
45 uptime > "dir-test/file with spaces"
46 push dir-test --recursive -v
47 rm foo bar
48 push dir-test --recursive --delete -v
49 rm -Rf dir-test
50
51 pull non-existing || true
52
53 md5sum * > md5sum
54 mkdir clone
55 # test md5 import from directory
56 mv md5sum clone/
57 push clone -r -v
58 # client should hardlink or copy files locally to avoid wastefull pull
59 # but we test server-side hardlink here
60 pull clone -r -v
61
62 tail -20 $user_dir/log/*
63
64 #diff -urw $user_dir/blob $dir/
65 #diff -urw $user_dir/json $dir/
66
67 ls -al $user_dir/blob $user_dir/json