tests/test-ssh
author David Soria Parra <dsp@php.net>
Sun, 20 Jun 2010 12:26:48 +0200
branchstable
changeset 11431 cac256790aa4
parent 6266 9f76df0edb7d
child 12156 4c94b6d0fb1c
permissions -rwxr-xr-x
bookmarks: Add -B option to incoming/outgoing to compare bookmarks We add a -B/--bookmarks option to hg incmoing and hg outgoing. If the option is passed we compare bookmarks instead of changesets. This can be used to see which bookmarks do not exists on the remote site.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
     1
#!/bin/sh
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
     2
4291
35b2e02367a5 test-ssh: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3853
diff changeset
     3
cp "$TESTDIR"/printenv.py .
35b2e02367a5 test-ssh: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3853
diff changeset
     4
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
     5
# This test tries to exercise the ssh functionality with a dummy script
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
     6
4298
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
     7
cat <<EOF > dummyssh
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
     8
import sys
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
     9
import os
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    10
4298
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
    11
os.chdir(os.path.dirname(sys.argv[0]))
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
    12
if sys.argv[1] != "user@dummy":
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
    13
    sys.exit(-1)
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
    14
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
    15
if not os.path.exists("dummyssh"):
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
    16
    sys.exit(-1)
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    17
4298
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
    18
os.environ["SSH_CLIENT"] = "127.0.0.1 1 2"
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    19
4298
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
    20
log = open("dummylog", "ab")
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
    21
log.write("Got arguments")
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
    22
for i, arg in enumerate(sys.argv[1:]):
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
    23
    log.write(" %d:%s" % (i+1, arg))
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
    24
log.write("\n")
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
    25
log.close()
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
    26
r = os.system(sys.argv[2])
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
    27
sys.exit(bool(r))
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    28
EOF
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    29
5978
7939c71f3132 sshrepo: be more careful while reading data
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4298
diff changeset
    30
cat <<EOF > badhook
7939c71f3132 sshrepo: be more careful while reading data
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4298
diff changeset
    31
import sys
6266
9f76df0edb7d hook.py: fix redirections introduced by 323b9c55b328
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5978
diff changeset
    32
sys.stdout.write("KABOOM\n")
5978
7939c71f3132 sshrepo: be more careful while reading data
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4298
diff changeset
    33
EOF
7939c71f3132 sshrepo: be more careful while reading data
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4298
diff changeset
    34
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    35
echo "# creating 'remote'"
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    36
hg init remote
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    37
cd remote
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    38
echo this > foo
3853
c0b449154a90 switch to the .hg/store layout, fix the tests
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3684
diff changeset
    39
echo this > fooO
c0b449154a90 switch to the .hg/store layout, fix the tests
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3684
diff changeset
    40
hg ci -A -m "init" -d "1000000 0" foo fooO
2621
5a5852a417b1 clone: disable stream support on server side by default.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
    41
echo '[server]' > .hg/hgrc
2622
064aef9162cc rename stream hgrc option to compressed.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2621
diff changeset
    42
echo 'uncompressed = True' >> .hg/hgrc
2673
109a22f5434a hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2622
diff changeset
    43
echo '[hooks]' >> .hg/hgrc
4291
35b2e02367a5 test-ssh: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3853
diff changeset
    44
echo 'changegroup = python ../printenv.py changegroup-in-remote 0 ../dummylog' >> .hg/hgrc
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    45
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    46
cd ..
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    47
3275
7ae37d99d47e ssh: make the error message more clear, add a testcase
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3095
diff changeset
    48
echo "# repo not found error"
4298
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
    49
hg clone -e "python ./dummyssh" ssh://user@dummy/nonexistent local
3275
7ae37d99d47e ssh: make the error message more clear, add a testcase
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3095
diff changeset
    50
2612
ffb895f16925 add support for streaming clone.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2439
diff changeset
    51
echo "# clone remote via stream"
4298
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
    52
hg clone -e "python ./dummyssh" --uncompressed ssh://user@dummy/remote local-stream 2>&1 | \
3015
fa4229c60dd7 Allow for MB/sec transfer rates in test-http-proxy and test-ssh.
Lee Cantey <lcantey@gmail.com>
parents: 2673
diff changeset
    53
  sed -e 's/[0-9][0-9.]*/XXX/g' -e 's/[KM]\(B\/sec\)/X\1/'
2612
ffb895f16925 add support for streaming clone.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2439
diff changeset
    54
cd local-stream
ffb895f16925 add support for streaming clone.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2439
diff changeset
    55
hg verify
ffb895f16925 add support for streaming clone.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2439
diff changeset
    56
cd ..
ffb895f16925 add support for streaming clone.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2439
diff changeset
    57
ffb895f16925 add support for streaming clone.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2439
diff changeset
    58
echo "# clone remote via pull"
4298
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
    59
hg clone -e "python ./dummyssh" ssh://user@dummy/remote local
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    60
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    61
echo "# verify"
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    62
cd local
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    63
hg verify
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    64
2673
109a22f5434a hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2622
diff changeset
    65
echo '[hooks]' >> .hg/hgrc
4291
35b2e02367a5 test-ssh: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3853
diff changeset
    66
echo 'changegroup = python ../printenv.py changegroup-in-local 0 ../dummylog' >> .hg/hgrc
2673
109a22f5434a hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2622
diff changeset
    67
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    68
echo "# empty default pull"
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    69
hg paths
4298
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
    70
hg pull -e "python ../dummyssh"
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    71
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    72
echo "# local change"
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    73
echo bleah > foo
1933
7544700fd931 Use 'hg ci -d "1000000 0"' in tests to circumvent problem with leading zero.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1168
diff changeset
    74
hg ci -m "add" -d "1000000 0"
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    75
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    76
echo "# updating rc"
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    77
echo "default-push = ssh://user@dummy/remote" >> .hg/hgrc
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    78
echo "[ui]" >> .hg/hgrc
4298
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
    79
echo "ssh = python ../dummyssh" >> .hg/hgrc
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    80
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    81
echo "# find outgoing"
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    82
hg out ssh://user@dummy/remote
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    83
1982
70ba0c86da8b Added test for incoming via ssh.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1933
diff changeset
    84
echo "# find incoming on the remote side"
4298
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
    85
hg incoming -R ../remote -e "python ../dummyssh" ssh://user@dummy/local
1982
70ba0c86da8b Added test for incoming via ssh.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1933
diff changeset
    86
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    87
echo "# push"
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    88
hg push
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    89
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    90
cd ../remote
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    91
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    92
echo "# check remote tip"
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    93
hg tip
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    94
hg verify
3095
25857e00af8e cat: default to working dir parent instead of tip
Brendan Cully <brendan@kublai.com>
parents: 3015
diff changeset
    95
hg cat -r tip foo
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    96
2439
e8c4f3d3df8c extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1982
diff changeset
    97
echo z > z
e8c4f3d3df8c extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1982
diff changeset
    98
hg ci -A -m z -d '1000001 0' z
5978
7939c71f3132 sshrepo: be more careful while reading data
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4298
diff changeset
    99
# a bad, evil hook that prints to stdout
7939c71f3132 sshrepo: be more careful while reading data
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4298
diff changeset
   100
echo 'changegroup.stdout = python ../badhook' >> .hg/hgrc
2439
e8c4f3d3df8c extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1982
diff changeset
   101
e8c4f3d3df8c extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1982
diff changeset
   102
cd ../local
e8c4f3d3df8c extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1982
diff changeset
   103
echo r > r
e8c4f3d3df8c extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1982
diff changeset
   104
hg ci -A -m z -d '1000002 0' r
e8c4f3d3df8c extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1982
diff changeset
   105
5978
7939c71f3132 sshrepo: be more careful while reading data
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4298
diff changeset
   106
echo "# push should succeed even though it has an unexpected response"
2439
e8c4f3d3df8c extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1982
diff changeset
   107
hg push
5978
7939c71f3132 sshrepo: be more careful while reading data
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4298
diff changeset
   108
hg -R ../remote heads
2439
e8c4f3d3df8c extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1982
diff changeset
   109
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
   110
cd ..
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
   111
cat dummylog