##// END OF EJS Templates
test: clarify some output in `test-transaction-rollback-on-sigpipe`...
marmoute -
r48350:452795b0 default
parent child Browse files
Show More
@@ -1,61 +1,65
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 50 > pretxnchangegroup.break-things=$hook_script
51 51 > EOF
52 52
53 $ hg --cwd ./remote tip -T '{node|short}\n'
54 000000000000
53 55 $ cd local
54 56 $ echo foo > foo ; hg commit -qAm "commit"
55 57 $ hg push -q -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" --remotecmd $remotecmd 2>&1 | grep -v $killable_pipe
56 58 abort: stream ended unexpectedly (got 0 bytes, expected 4)
57 59
58 60 The remote should be left in a good state
61 $ hg --cwd ../remote tip -T '{node|short}\n'
62 000000000000
59 63 $ hg --cwd ../remote recover
60 64 no interrupted transaction available
61 65 [1]
General Comments 0
You need to be logged in to leave comments. Login now