summaryrefslogtreecommitdiff
path: root/tests/tests/mirror
blob: 49476880aa2d446b282f330af9855ee896469b81 (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
#!/bin/bash
set -e
. tests/lib
. $troot/lib-mirror

t-dependencies rsync

t-drs

: ---- "basic test" ----

t-tstunt-parsechangelog
t-prep-newpackage example 1.0

t-mirror-setup

cd $p
revision=1
t-dgit build
t-dgit push --new

t-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 "\$*"
END
chmod +x $tmp/stunt-ssh

t-mirror-set rsyncssh=$tmp/stunt-ssh
t-mirror-set remoterepos=HOST:$reposmirror

# mirror should fail due to lack of stunt-ssh-sentinel

t-commit-build-push-expect-log "stunt ssh test" \
	E:'mirror hook failed: .*exited'

ls -al $queuedir/$p.a
t-check-not-mirrored

touch $sentinel

t-mirror-hook backlog
t-check-mirrored

: ----- "stall timeout test" -----

rm -f $sentinel
mkfifo $sentinel

t-mirror-set hooktimeout=5

t-commit-build-push-expect-log "stall timeout test" \
	E:'mirror hook failed: .*timeout'

t-check-not-mirrored

exec 3<>$sentinel
exec 3>&-

attempts=100
while [ -f $queuedir/$p.lock ]; do
	if [ $attempts = 0 ]; then \
		fail "timed out waiting for lock to go away"
	fi
	attempts=$(( $attempts - 1 ))
	sleep 0.1
done

t-check-mirrored

t-ok