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