Mercurial > hg-stable
annotate tests/test-transaction-rollback-on-sigpipe.t @ 47556:640fdb7fd67b
test: make sure we hit the SIGPIPE in test-transaction-rollback-on-sigpipe
With a coming change, we might not hit the sig pipe without issue and extra line
of output. We do this early to make the next change clearer.
Differential Revision: https://phab.mercurial-scm.org/D10946
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 02 Jul 2021 20:53:23 +0200 |
parents | 452795b0b69a |
children | ed81f2be5527 |
rev | line source |
---|---|
47312
97f04eaafa65
tests: add req on bash for test-transaction-rollback-on-sigpipe (issue6429)
Augie Fackler <augie@google.com>
parents:
47008
diff
changeset
|
1 #require bash |
47317
aa07bcc4f505
test: remove some unnecessary dependency on repo format
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47312
diff
changeset
|
2 Test that, when an hg push is interrupted and the remote side receives SIGPIPE, |
45736
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
3 the remote hg is able to successfully roll back the transaction. |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
4 |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
5 $ hg init -q remote |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
6 $ hg clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" -q ssh://user@dummy/`pwd`/remote local |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
7 |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
8 $ pidfile=`pwd`/pidfile |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
9 $ >$pidfile |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
10 |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
11 $ script() { |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
12 > cat >"$1" |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
13 > chmod +x "$1" |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
14 > } |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
15 |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
16 On the remote end, run hg, piping stdout and stderr through processes that we |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
17 know the PIDs of. We will later kill these to simulate an ssh client |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
18 disconnecting. |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
19 |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
20 $ killable_pipe=`pwd`/killable_pipe.sh |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
21 $ script $killable_pipe <<EOF |
47008
77e73827a02d
tests: don't hard-code /bin/bash
Joerg Sonnenberger <joerg@bec.de>
parents:
45754
diff
changeset
|
22 > #!/usr/bin/env bash |
45736
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
23 > echo \$\$ >> $pidfile |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
24 > exec cat |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
25 > EOF |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
26 |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
27 $ remotecmd=`pwd`/remotecmd.sh |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
28 $ script $remotecmd <<EOF |
47008
77e73827a02d
tests: don't hard-code /bin/bash
Joerg Sonnenberger <joerg@bec.de>
parents:
45754
diff
changeset
|
29 > #!/usr/bin/env bash |
45736
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
30 > hg "\$@" 1> >($killable_pipe) 2> >($killable_pipe >&2) |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
31 > EOF |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
32 |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
33 In the pretxnchangegroup hook, kill the PIDs recorded above to simulate ssh |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
34 disconnecting. Then exit nonzero, to force a transaction rollback. |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
35 |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
36 $ hook_script=`pwd`/pretxnchangegroup.sh |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
37 $ script $hook_script <<EOF |
47008
77e73827a02d
tests: don't hard-code /bin/bash
Joerg Sonnenberger <joerg@bec.de>
parents:
45754
diff
changeset
|
38 > #!/usr/bin/env bash |
45736
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
39 > for pid in \$(cat $pidfile) ; do |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
40 > kill \$pid |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
41 > while kill -0 \$pid 2>/dev/null ; do |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
42 > sleep 0.1 |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
43 > done |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
44 > done |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
45 > exit 1 |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
46 > EOF |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
47 |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
48 $ cat >remote/.hg/hgrc <<EOF |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
49 > [hooks] |
47556
640fdb7fd67b
test: make sure we hit the SIGPIPE in test-transaction-rollback-on-sigpipe
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47555
diff
changeset
|
50 > pretxnchangegroup.00-break-things=$hook_script |
640fdb7fd67b
test: make sure we hit the SIGPIPE in test-transaction-rollback-on-sigpipe
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47555
diff
changeset
|
51 > pretxnchangegroup.01-output-things=echo "some remote output to be forward to the closed pipe" |
45736
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
52 > EOF |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
53 |
47555
452795b0b69a
test: clarify some output in `test-transaction-rollback-on-sigpipe`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47317
diff
changeset
|
54 $ hg --cwd ./remote tip -T '{node|short}\n' |
452795b0b69a
test: clarify some output in `test-transaction-rollback-on-sigpipe`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47317
diff
changeset
|
55 000000000000 |
45736
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
56 $ cd local |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
57 $ echo foo > foo ; hg commit -qAm "commit" |
45754
b713e4cae2d7
test: avoid bashisms in test-transaction-rollback-on-sigpipe.t
Mitchell Plamann <mplamann@janestreet.com>
parents:
45737
diff
changeset
|
58 $ hg push -q -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" --remotecmd $remotecmd 2>&1 | grep -v $killable_pipe |
45736
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
59 abort: stream ended unexpectedly (got 0 bytes, expected 4) |
2c6b054e22d0
test: add test-transaction-rollback-on-sigpipe.t demonstrating py3 regression
Mitchell Plamann <mplamann@janestreet.com>
parents:
diff
changeset
|
60 |
47317
aa07bcc4f505
test: remove some unnecessary dependency on repo format
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47312
diff
changeset
|
61 The remote should be left in a good state |
47555
452795b0b69a
test: clarify some output in `test-transaction-rollback-on-sigpipe`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47317
diff
changeset
|
62 $ hg --cwd ../remote tip -T '{node|short}\n' |
452795b0b69a
test: clarify some output in `test-transaction-rollback-on-sigpipe`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47317
diff
changeset
|
63 000000000000 |
47317
aa07bcc4f505
test: remove some unnecessary dependency on repo format
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47312
diff
changeset
|
64 $ hg --cwd ../remote recover |
aa07bcc4f505
test: remove some unnecessary dependency on repo format
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47312
diff
changeset
|
65 no interrupted transaction available |
45737
b3e8d8e4a40d
hook: ignore EPIPE when flushing stdout/stderr
Mitchell Plamann <mplamann@janestreet.com>
parents:
45736
diff
changeset
|
66 [1] |