chiark / gitweb /
Mirroring: Tests: Run some tests
[dgit.git] / tests / tests / mirror
1 #!/bin/bash
2 set -e
3 . tests/lib
4
5 t-drs
6
7 : ---- "setup up the mirror hook in a basic way" ----
8
9 reposmirror=$tmp/git-mirror
10 queuedir=$tmp/git/_mirror-queue
11 mkdir $reposmirror
12
13 mhook=$drs_dispatch/mirror-hook
14 ln -sf ${DGIT_INFRA_PFX}dgit-mirror-rsync $mhook
15 mhook () {
16         "$mhook" "$drs_dispatch" "$@"
17 }
18
19 >$drs_dispatch/mirror-settings
20 mset () { echo >>$drs_dispatch/mirror-settings "$1"; }
21
22 mset remoterepos="$reposmirror"
23
24 check-mirrored () {
25         t-reporefs master
26         t-reporefs mirror $pmirror
27         diff $tmp/show-refs.{master,mirror}
28         cat $queuedir/$p.log
29         t-files-notexist $queuedir/$p.{n,a,lock,err}
30 }
31
32 check-not-mirrored () {
33         # uses previous t-reporefs-master
34         t-reporefs mirror $pmirror
35         diff $tmp/show-refs.{master,mirror}
36 }
37
38 : ---- "basic test" ----
39
40 t-tstunt-parsechangelog
41 t-prep-newpackage example 1.0
42
43 pmirror=$reposmirror/$p.git
44 mhook setup
45
46 cd $p
47 revision=1
48 t-dgit build
49 t-dgit push --new
50
51 check-mirrored
52
53
54 : ---- "stunt ssh test" ----
55
56 sentinel=$tmp/stunt-ssh-sentinel
57
58 cat <<END >$tmp/stunt-ssh
59 #!/bin/sh
60 set -ex
61 : $sentinel
62 cat >&2 $sentinel
63 shift # eat HOST
64 sh -c "\$*"
65 : ${sentinel}2
66 date >${sentinel}2
67 END
68 chmod +x $tmp/stunt-ssh
69
70 mset rsyncssh=$tmp/stunt-ssh
71 mset remoterepos=HOST:$reposmirror
72
73 t-commit "stunt ssh test"
74 t-dgit build
75 t-dgit push --new
76 # ^ mirror should fail due to lack of stunt-ssh-sentinel
77
78 ls -al $queuedir/$p.a
79 check-not-mirrored
80
81 touch $sentinel
82
83 mhook backlog
84 check-mirrored
85
86 : ----- "stall timeout test" -----
87
88 rm -f $sentinel ${sentinel}2
89 mkfifo $sentinel ${sentinel}2
90
91 mset hooktimeout=5
92
93 t-commit "stall timeout test"
94 t-dgit build
95 t-dgit push --new
96
97 check-not-mirrored
98
99 exec 3<>$sentinel
100 exec 3>&-
101 cat ${sentinel}2
102
103 check-mirrored
104
105 echo done.