##// END OF EJS Templates
test: make sure we hit the SIGPIPE in test-transaction-rollback-on-sigpipe...
marmoute -
r48351:640fdb7f default
parent child Browse files
Show More
@@ -1,65 +1,66
1 1 #require bash
2 2 Test that, when an hg push is interrupted and the remote side receives SIGPIPE,
3 3 the remote hg is able to successfully roll back the transaction.
4 4
5 5 $ hg init -q remote
6 6 $ hg clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" -q ssh://user@dummy/`pwd`/remote local
7 7
8 8 $ pidfile=`pwd`/pidfile
9 9 $ >$pidfile
10 10
11 11 $ script() {
12 12 > cat >"$1"
13 13 > chmod +x "$1"
14 14 > }
15 15
16 16 On the remote end, run hg, piping stdout and stderr through processes that we
17 17 know the PIDs of. We will later kill these to simulate an ssh client
18 18 disconnecting.
19 19
20 20 $ killable_pipe=`pwd`/killable_pipe.sh
21 21 $ script $killable_pipe <<EOF
22 22 > #!/usr/bin/env bash
23 23 > echo \$\$ >> $pidfile
24 24 > exec cat
25 25 > EOF
26 26
27 27 $ remotecmd=`pwd`/remotecmd.sh
28 28 $ script $remotecmd <<EOF
29 29 > #!/usr/bin/env bash
30 30 > hg "\$@" 1> >($killable_pipe) 2> >($killable_pipe >&2)
31 31 > EOF
32 32
33 33 In the pretxnchangegroup hook, kill the PIDs recorded above to simulate ssh
34 34 disconnecting. Then exit nonzero, to force a transaction rollback.
35 35
36 36 $ hook_script=`pwd`/pretxnchangegroup.sh
37 37 $ script $hook_script <<EOF
38 38 > #!/usr/bin/env bash
39 39 > for pid in \$(cat $pidfile) ; do
40 40 > kill \$pid
41 41 > while kill -0 \$pid 2>/dev/null ; do
42 42 > sleep 0.1
43 43 > done
44 44 > done
45 45 > exit 1
46 46 > EOF
47 47
48 48 $ cat >remote/.hg/hgrc <<EOF
49 49 > [hooks]
50 > pretxnchangegroup.break-things=$hook_script
50 > pretxnchangegroup.00-break-things=$hook_script
51 > pretxnchangegroup.01-output-things=echo "some remote output to be forward to the closed pipe"
51 52 > EOF
52 53
53 54 $ hg --cwd ./remote tip -T '{node|short}\n'
54 55 000000000000
55 56 $ cd local
56 57 $ echo foo > foo ; hg commit -qAm "commit"
57 58 $ hg push -q -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" --remotecmd $remotecmd 2>&1 | grep -v $killable_pipe
58 59 abort: stream ended unexpectedly (got 0 bytes, expected 4)
59 60
60 61 The remote should be left in a good state
61 62 $ hg --cwd ../remote tip -T '{node|short}\n'
62 63 000000000000
63 64 $ hg --cwd ../remote recover
64 65 no interrupted transaction available
65 66 [1]
General Comments 0
You need to be logged in to leave comments. Login now