##// END OF EJS Templates
test-sigpipe: run the hook using `sh`...
marmoute -
r48415:a8d1adee default
parent child Browse files
Show More
@@ -1,62 +1,62
1 Test that, when an hg push is interrupted and the remote side receives SIGPIPE,
1 Test that, when an hg push is interrupted and the remote side receives SIGPIPE,
2 the remote hg is able to successfully roll back the transaction.
2 the remote hg is able to successfully roll back the transaction.
3
3
4 $ hg init -q remote
4 $ hg init -q remote
5 $ hg clone -e "\"$PYTHON\" \"$RUNTESTDIR/dummyssh\"" -q ssh://user@dummy/`pwd`/remote local
5 $ hg clone -e "\"$PYTHON\" \"$RUNTESTDIR/dummyssh\"" -q ssh://user@dummy/`pwd`/remote local
6 $ SIGPIPE_REMOTE_DEBUG_FILE="$TESTTMP/DEBUGFILE"
6 $ SIGPIPE_REMOTE_DEBUG_FILE="$TESTTMP/DEBUGFILE"
7 $ SYNCFILE1="$TESTTMP/SYNCFILE1"
7 $ SYNCFILE1="$TESTTMP/SYNCFILE1"
8 $ SYNCFILE2="$TESTTMP/SYNCFILE2"
8 $ SYNCFILE2="$TESTTMP/SYNCFILE2"
9 $ export SIGPIPE_REMOTE_DEBUG_FILE
9 $ export SIGPIPE_REMOTE_DEBUG_FILE
10 $ export SYNCFILE1
10 $ export SYNCFILE1
11 $ export SYNCFILE2
11 $ export SYNCFILE2
12 $ PYTHONUNBUFFERED=1
12 $ PYTHONUNBUFFERED=1
13 $ export PYTHONUNBUFFERED
13 $ export PYTHONUNBUFFERED
14
14
15 On the remote end, run hg, piping stdout and stderr through processes that we
15 On the remote end, run hg, piping stdout and stderr through processes that we
16 know the PIDs of. We will later kill these to simulate an ssh client
16 know the PIDs of. We will later kill these to simulate an ssh client
17 disconnecting.
17 disconnecting.
18
18
19 $ remotecmd="$RUNTESTDIR/testlib/sigpipe-remote.py"
19 $ remotecmd="$RUNTESTDIR/testlib/sigpipe-remote.py"
20
20
21 In the pretxnchangegroup hook, kill the PIDs recorded above to simulate ssh
21 In the pretxnchangegroup hook, kill the PIDs recorded above to simulate ssh
22 disconnecting. Then exit nonzero, to force a transaction rollback.
22 disconnecting. Then exit nonzero, to force a transaction rollback.
23
23
24
24
25 $ cat >remote/.hg/hgrc <<EOF
25 $ cat >remote/.hg/hgrc <<EOF
26 > [hooks]
26 > [hooks]
27 > pretxnchangegroup.00-break-things="$RUNTESTDIR/testlib/wait-on-file" 10 "$SYNCFILE2" "$SYNCFILE1"
27 > pretxnchangegroup.00-break-things=sh "$RUNTESTDIR/testlib/wait-on-file" 10 "$SYNCFILE2" "$SYNCFILE1"
28 > pretxnchangegroup.01-output-things=echo "some remote output to be forward to the closed pipe"
28 > pretxnchangegroup.01-output-things=echo "some remote output to be forward to the closed pipe"
29 > EOF
29 > EOF
30
30
31 $ hg --cwd ./remote tip -T '{node|short}\n'
31 $ hg --cwd ./remote tip -T '{node|short}\n'
32 000000000000
32 000000000000
33 $ cd local
33 $ cd local
34 $ echo foo > foo ; hg commit -qAm "commit"
34 $ echo foo > foo ; hg commit -qAm "commit"
35 $ hg push -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" --remotecmd "$remotecmd"
35 $ hg push -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" --remotecmd "$remotecmd"
36 pushing to ssh://user@dummy/$TESTTMP/remote
36 pushing to ssh://user@dummy/$TESTTMP/remote
37 searching for changes
37 searching for changes
38 remote: adding changesets (py3 !)
38 remote: adding changesets (py3 !)
39 remote: adding manifests (py3 !)
39 remote: adding manifests (py3 !)
40 remote: adding file changes (py3 !)
40 remote: adding file changes (py3 !)
41 remote: adding changesets (no-py3 no-chg !)
41 remote: adding changesets (no-py3 no-chg !)
42 remote: adding manifests (no-py3 no-chg !)
42 remote: adding manifests (no-py3 no-chg !)
43 remote: adding file changes (no-py3 no-chg !)
43 remote: adding file changes (no-py3 no-chg !)
44 abort: stream ended unexpectedly (got 0 bytes, expected 4)
44 abort: stream ended unexpectedly (got 0 bytes, expected 4)
45 [255]
45 [255]
46 $ cat $SIGPIPE_REMOTE_DEBUG_FILE
46 $ cat $SIGPIPE_REMOTE_DEBUG_FILE
47 SIGPIPE-HELPER: Starting
47 SIGPIPE-HELPER: Starting
48 SIGPIPE-HELPER: Mercurial started
48 SIGPIPE-HELPER: Mercurial started
49 SIGPIPE-HELPER: Redirection in place
49 SIGPIPE-HELPER: Redirection in place
50 SIGPIPE-HELPER: SYNCFILE1 detected
50 SIGPIPE-HELPER: SYNCFILE1 detected
51 SIGPIPE-HELPER: pipes closed
51 SIGPIPE-HELPER: pipes closed
52 SIGPIPE-HELPER: creating SYNCFILE2
52 SIGPIPE-HELPER: creating SYNCFILE2
53 SIGPIPE-HELPER: Shutting down
53 SIGPIPE-HELPER: Shutting down
54 SIGPIPE-HELPER: Server process terminated
54 SIGPIPE-HELPER: Server process terminated
55 SIGPIPE-HELPER: Shut down
55 SIGPIPE-HELPER: Shut down
56
56
57 The remote should be left in a good state
57 The remote should be left in a good state
58 $ hg --cwd ../remote tip -T '{node|short}\n'
58 $ hg --cwd ../remote tip -T '{node|short}\n'
59 000000000000
59 000000000000
60 $ hg --cwd ../remote recover
60 $ hg --cwd ../remote recover
61 no interrupted transaction available
61 no interrupted transaction available
62 [1]
62 [1]
General Comments 0
You need to be logged in to leave comments. Login now