chiark / gitweb /
Test suite: mirror: Synchronise properly with drs background mirror
[dgit.git] / tests / tests / mirror
1 #!/bin/bash
2 set -e
3 . tests/lib
4 . $troot/lib-mirror
5
6 t-drs
7
8 : ---- "basic test" ----
9
10 t-tstunt-parsechangelog
11 t-prep-newpackage example 1.0
12
13 t-mirror-setup
14
15 cd $p
16 revision=1
17 t-dgit build
18 t-dgit push --new
19
20 t-check-mirrored
21
22 : ---- "stunt ssh test" ----
23
24 sentinel=$tmp/stunt-ssh-sentinel
25
26 cat <<END >$tmp/stunt-ssh
27 #!/bin/sh
28 set -ex
29 : $sentinel
30 cat >&2 $sentinel
31 shift # eat HOST
32 sh -c "\$*"
33 END
34 chmod +x $tmp/stunt-ssh
35
36 t-mirror-set rsyncssh=$tmp/stunt-ssh
37 t-mirror-set remoterepos=HOST:$reposmirror
38
39 # mirror should fail due to lack of stunt-ssh-sentinel
40
41 t-commit-build-push-expect-log "stunt ssh test" \
42         E:'mirror hook failed: .*exited'
43
44 ls -al $queuedir/$p.a
45 t-check-not-mirrored
46
47 touch $sentinel
48
49 t-mirror-hook backlog
50 t-check-mirrored
51
52 : ----- "stall timeout test" -----
53
54 rm -f $sentinel
55 mkfifo $sentinel
56
57 t-mirror-set hooktimeout=5
58
59 t-commit-build-push-expect-log "stall timeout test" \
60         E:'mirror hook failed: .*timeout'
61
62 t-check-not-mirrored
63
64 exec 3<>$sentinel
65 exec 3>&-
66
67 attempts=100
68 while [ -f $queuedir/$p.lock ]; do
69         if [ $attempts = 0 ]; then \
70                 fail "timed out waiting for lock to go away"
71         fi
72         attempts=$(( $attempts - 1 ))
73         sleep 0.1
74 done
75
76 t-check-mirrored
77
78 echo done.