X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=blobdiff_plain;f=tests%2Ftests%2Fmirror;h=49476880aa2d446b282f330af9855ee896469b81;hp=874120e588ad1655992f65ede1af3dc39695353f;hb=63911b5d576e7250c132d117c53e66aaf34b7f47;hpb=ff142bf101bd67db5414ab613787812f9ba99d8c diff --git a/tests/tests/mirror b/tests/tests/mirror index 874120e5..49476880 100755 --- a/tests/tests/mirror +++ b/tests/tests/mirror @@ -1,55 +1,25 @@ #!/bin/bash set -e . tests/lib +. $troot/lib-mirror -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" "$@" -} +t-dependencies rsync ->$drs_dispatch/mirror-settings -mset () { echo >>$drs_dispatch/mirror-settings "$1"; } - -mset remoterepos="$reposmirror" - -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} -} +t-drs : ---- "basic test" ---- t-tstunt-parsechangelog t-prep-newpackage example 1.0 -pmirror=$reposmirror/$p.git -mhook setup +t-mirror-setup cd $p revision=1 t-dgit build t-dgit push --new -check-mirrored - +t-check-mirrored : ---- "stunt ssh test" ---- @@ -62,44 +32,49 @@ set -ex 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 +t-mirror-set rsyncssh=$tmp/stunt-ssh +t-mirror-set remoterepos=HOST:$reposmirror -t-commit "stunt ssh test" -t-dgit build -t-dgit push --new -# ^ mirror should fail due to lack of stunt-ssh-sentinel +# 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 -check-not-mirrored +t-check-not-mirrored touch $sentinel -mhook backlog -check-mirrored +t-mirror-hook backlog +t-check-mirrored : ----- "stall timeout test" ----- -rm -f $sentinel ${sentinel}2 -mkfifo $sentinel ${sentinel}2 +rm -f $sentinel +mkfifo $sentinel -mset hooktimeout=5 +t-mirror-set hooktimeout=5 -t-commit "stall timeout test" -t-dgit build -t-dgit push --new +t-commit-build-push-expect-log "stall timeout test" \ + E:'mirror hook failed: .*timeout' -check-not-mirrored +t-check-not-mirrored exec 3<>$sentinel exec 3>&- -cat ${sentinel}2 -check-mirrored +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 -echo done. +t-ok