##// END OF EJS Templates
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression...
Mitchell Plamann -
r46328:2c6b054e default
parent child Browse files
Show More
@@ -0,0 +1,67 b''
1 Test that, when an hg push is interrupted and the remote side recieves SIGPIPE,
2 the remote hg is able to successfully roll back the transaction.
3
4 $ hg init -q remote
5 $ hg clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" -q ssh://user@dummy/`pwd`/remote local
6
7 $ check_for_abandoned_transaction() {
8 > [[ -f $TESTTMP/remote/.hg/store/journal ]] && echo "Abandoned transaction!"
9 > }
10
11 $ pidfile=`pwd`/pidfile
12 $ >$pidfile
13
14 $ script() {
15 > cat >"$1"
16 > chmod +x "$1"
17 > }
18
19 On the remote end, run hg, piping stdout and stderr through processes that we
20 know the PIDs of. We will later kill these to simulate an ssh client
21 disconnecting.
22
23 $ killable_pipe=`pwd`/killable_pipe.sh
24 $ script $killable_pipe <<EOF
25 > #!/bin/bash
26 > echo \$\$ >> $pidfile
27 > exec cat
28 > EOF
29
30 $ remotecmd=`pwd`/remotecmd.sh
31 $ script $remotecmd <<EOF
32 > #!/bin/bash
33 > hg "\$@" 1> >($killable_pipe) 2> >($killable_pipe >&2)
34 > EOF
35
36 In the pretxnchangegroup hook, kill the PIDs recorded above to simulate ssh
37 disconnecting. Then exit nonzero, to force a transaction rollback.
38
39 $ hook_script=`pwd`/pretxnchangegroup.sh
40 $ script $hook_script <<EOF
41 > #!/bin/bash
42 > for pid in \$(cat $pidfile) ; do
43 > kill \$pid
44 > while kill -0 \$pid 2>/dev/null ; do
45 > sleep 0.1
46 > done
47 > done
48 > exit 1
49 > EOF
50
51 $ cat >remote/.hg/hgrc <<EOF
52 > [hooks]
53 > pretxnchangegroup.break-things=$hook_script
54 > EOF
55
56 $ cd local
57 $ echo foo > foo ; hg commit -qAm "commit"
58 $ hg push -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" --remotecmd $remotecmd 2>&1 | grep -v $killable_pipe
59 pushing to ssh://user@dummy/$TESTTMP/remote
60 searching for changes
61 remote: adding changesets
62 remote: adding manifests
63 remote: adding file changes
64 abort: stream ended unexpectedly (got 0 bytes, expected 4)
65
66 $ check_for_abandoned_transaction
67 Abandoned transaction!
General Comments 0
You need to be logged in to leave comments. Login now