/[pdpsoft]/trunk/nl.nikhef.ndpf.tools/cvmfs/test/test.sh
ViewVC logotype

Contents of /trunk/nl.nikhef.ndpf.tools/cvmfs/test/test.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2767 - (show annotations) (download) (as text)
Wed Feb 18 16:04:27 2015 UTC (6 years, 11 months ago) by dennisvd
File MIME type: application/x-shellscript
File size: 4012 byte(s)
add a test to check that cvmfs.modified works even in the top directory.

1 #!/bin/sh
2
3 # test script for the rsync program
4
5 # set debug to non-zero for extra output
6 debug=1
7
8 if [ -z "$srcdir" ]; then
9 testsrcdir=`dirname $0`
10 else
11 testsrcdir="$srcdir"
12 fi
13 script="$testsrcdir/../cvmfs-rsync-multi.sh"
14
15 if [ ! -f $script ] ; then
16 echo "Can't find $script. Stop" >&2
17 exit 1
18 fi
19
20 # tree_01 is for testing to see that the proper
21 # parts get synced, and not others
22
23 testsrc=tree_01
24
25 # repo is the repository to sync, defaults to 'test'
26 repo=test
27 # subdir can be used as an alternative rsync source path
28 # e.g. /rob.
29 subdir=
30
31 # Run the tests inside a temporary directory, relative
32 # to $cwd.
33 tmp=`mktemp -d rsynctest.XXXXXXXXXX`
34 if [ $? -ne 0 ]; then
35 echo "can't create temporary directory ?! Bye."
36 exit 2
37 fi
38
39 # the password file that the client uses to contact the rsync daemon
40 cvmfssecret=$tmp/cvmfs.secret
41
42 runtestout=$tmp/runtest.out
43 runtesterr=$tmp/runtest.err
44
45
46 mkdir $tmp/test
47 echo "Starting test suite in $tmp"
48
49 # Make a pristine copy of the test tree
50 rsync -rt --chmod u+rw $testsrcdir/tree_01 $tmp/
51
52 # Start a local daemon for testing interaction with the daemon
53 echo "Starting a local test rsync daemon"
54 # generate the appropriate configuration file
55 cat > $tmp/rsyncd-test.conf <<EOF
56 [cvmfs]
57 path = $PWD/$tmp/$testsrc
58 fake super = yes
59 read only = yes
60 secrets file = $PWD/$tmp/rsyncd.secrets
61 use chroot = no
62 auth users = cvmfs
63 uid = `id -u`
64 EOF
65 echo "cvmfs:verysecret" > $tmp/rsyncd.secrets
66 echo "verysecret" > $cvmfssecret
67 chmod 600 $tmp/rsyncd.secrets $cvmfssecret
68 rsync --daemon --address=127.0.0.1 --config=$tmp/rsyncd-test.conf --no-detach --port=8873 --log-file=$tmp/rsyncd-test.log &
69 rsyncdpid=$!
70 trap "kill $rsyncdpid" EXIT;
71
72 # The title function prints the name of the next test
73 title() {
74 printf "%70s" "$* ... "
75 }
76 # The check function takes the same argument as test;
77 # an outcome of true is considered success.
78 check() {
79 if test "$@" ; then
80 echo OK
81 return 0
82 else
83 echo FAIL
84 return 1
85 fi
86 }
87
88 # just shorthand for running the script
89 runtest() {
90 if [ $debug -ne 0 ]; then
91 extrashopts="-x"
92 else
93 extrashopts=
94 fi
95 ( sh $extrashopts $testsrcdir/stubcvmfs.sh $script \
96 -r $repo \
97 -s rsync://cvmfs@localhost:8873/cvmfs$subdir \
98 -R `pwd`/$tmp/$repo$subdir \
99 -S $cvmfssecret \
100 -d `pwd`/$tmp$subdir "$@" >> $runtestout 2>> $runtesterr )
101 }
102
103 # Test #1: synchronise into a new tree
104 runtest
105
106 # see if we can find key files in the test dir
107 title "copying correct file on fresh tree"
108 check -e $tmp/test/harry/cvmfs.tree/good
109
110 # check that files outside of the tree are not copied
111 title "do not include file outside tree"
112 check ! -e $tmp/test/harry/wrong
113
114 # Rob doesn't have a cvmfs.modified file
115 title "don't include non-requested trees"
116 check ! -e $tmp/test/rob/cvmfs.tree/wrong
117
118
119 # Test #2: resynchronise the same tree
120 rsync -rt $tmp/test/ $tmp/test2/
121 title "repeat run does not update"
122 runtest
123 # There should be no difference to the tree
124 diff -rq $tmp/test $tmp/test2 > /dev/null 2>&1
125 check $? -eq 0
126
127 # test #3: update the tree and resync. No files should appear
128 echo update > $tmp/$testsrc/rob/cvmfs.tree/update
129 title "update of file not visible if not requested"
130 runtest
131 check ! -e $tmp/test/rob/cvmfs.tree/update
132
133 # test #4: touch the cvmfs.published file. Update should appear
134 title "update visible if requested"
135 touch $tmp/$testsrc/rob/cvmfs.modified
136 runtest
137 check -e $tmp/test/rob/cvmfs.tree/update
138
139 # test #5: use an exclude file to exclude paul
140 title "exclude file option works"
141 echo "- /paul" > $tmp/exclude-paul
142 mv $tmp/test $tmp/test-4
143 mkdir $tmp/test
144 runtest -i $tmp/exclude-paul
145 check -d $tmp/test/harry -a ! -d $tmp/test/paul
146
147 # test #6: rsync source directly contains cvmfs.modified
148 # The sync is done from a different source: one directory
149 # down from the original tree.
150 title "rsync source top directory contains cvmfs.modified"
151 subdir=/rob
152 echo update > $tmp/$testsrc/rob/cvmfs.tree/update2
153 touch $tmp/$testsrc/rob/cvmfs.modified
154 mkdir -p $tmp/rob/test
155 runtest
156 check -e $tmp/rob/test/cvmfs.tree/update2

Properties

Name Value
svn:executable *

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28