be55b540cd037f9260e65fd6d60c19bc86f7f55f
[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
23 ./remove-user.sh test2
24 ./create-user.sh test2 secret
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-test2
75 push sent-to-test2 # must be done before first send
76
77 mkdir -p .send/test2/received
78 ln -s ../../../sent-to-test2 .send/test2/received/new-name
79
80 push .send -rvl
81
82 tail -20 $user_dir/log/*
83
84 #diff -urw $user_dir/blob $dir/
85 #diff -urw $user_dir/json $dir/
86
87 ls -al $user_dir/blob