cleanup log before test runs
[cloudstore.git] / test.sh
diff --git a/test.sh b/test.sh
index 7889eec..25c77c9 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -1,5 +1,42 @@
-#!/bin/sh
+#!/bin/sh -xe
+
+log=/srv/cloudstore/users/dpavlin/log/
+rm -v $log/*
+
+push() {
+       file=`shift`
+       RSYNC_PASSWORD=secret rsync $* $file rsync://dpavlin@127.0.0.1:6501/dpavlin/$file
+}
+pull() {
+       from=$1
+       to=$2
+       test -z "$to" && to=$1
+       RSYNC_PASSWORD=secret rsync rsync://dpavlin@127.0.0.1:6501/dpavlin/$from $to
+}
+
+
+dir=/tmp/test
+rm -Rf "$dir"
+mkdir /tmp/test
+cd $dir
+push . --recursive --delete -v
+ps ax > foo
+push foo -v
+ps ax > bar
+push bar -v
+pull bar baz
+ps ax >> baz
+push bar -v
+mkdir dir-test
+# deduplicate?
+cp foo bar dir-test/
+uptime > "dir-test/file with spaces"
+push dir-test --recursive -v
+rm foo bar
+push dir-test --recursive --delete -v
+rm -Rf dir-test
+
+tail -20 $log/*
+
+pull non-existing # dies, must be last
 
-ps ax > /tmp/foo
-RSYNC_PASSWORD=secret rsync /tmp/foo rsync://dpavlin@127.0.0.1:6501/dpavlin
-RSYNC_PASSWORD=secret rsync rsync://dpavlin@127.0.0.1:6501/dpavlin/foo /tmp/foo