tests/test-ssh
author Patrick Mezard <pmezard@gmail.com>
Thu, 25 Oct 2007 00:09:13 +0200
changeset 5477 f00ed7c5877b
parent 4298 58517f6eb1ad
permissions -rwxr-xr-x
Merge with crew-stable
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
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    30
echo "# creating 'remote'"
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    31
hg init remote
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    32
cd remote
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    33
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
    34
echo this > fooO
c0b449154a90 switch to the .hg/store layout, fix the tests
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3684
diff changeset
    35
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
    36
echo '[server]' > .hg/hgrc
2622
064aef9162cc rename stream hgrc option to compressed.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2621
diff changeset
    37
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
    38
echo '[hooks]' >> .hg/hgrc
4291
35b2e02367a5 test-ssh: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3853
diff changeset
    39
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
    40
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    41
cd ..
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    42
3274
7ae37d99d47e ssh: make the error message more clear, add a testcase
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3092
diff changeset
    43
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
    44
hg clone -e "python ./dummyssh" ssh://user@dummy/nonexistent local
3274
7ae37d99d47e ssh: make the error message more clear, add a testcase
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3092
diff changeset
    45
2612
ffb895f16925 add support for streaming clone.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2439
diff changeset
    46
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
    47
hg clone -e "python ./dummyssh" --uncompressed ssh://user@dummy/remote local-stream 2>&1 | \
3012
fa4229c60dd7 Allow for MB/sec transfer rates in test-http-proxy and test-ssh.
Lee Cantey <lcantey@gmail.com>
parents: 2673
diff changeset
    48
  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
    49
cd local-stream
ffb895f16925 add support for streaming clone.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2439
diff changeset
    50
hg verify
ffb895f16925 add support for streaming clone.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2439
diff changeset
    51
cd ..
ffb895f16925 add support for streaming clone.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2439
diff changeset
    52
ffb895f16925 add support for streaming clone.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2439
diff changeset
    53
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
    54
hg clone -e "python ./dummyssh" ssh://user@dummy/remote local
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    55
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    56
echo "# verify"
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    57
cd local
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    58
hg verify
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    59
2673
109a22f5434a hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2622
diff changeset
    60
echo '[hooks]' >> .hg/hgrc
4291
35b2e02367a5 test-ssh: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3853
diff changeset
    61
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
    62
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    63
echo "# empty default pull"
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    64
hg paths
4298
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
    65
hg pull -e "python ../dummyssh"
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    66
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    67
echo "# local change"
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    68
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
    69
hg ci -m "add" -d "1000000 0"
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    70
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    71
echo "# updating rc"
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    72
echo "default-push = ssh://user@dummy/remote" >> .hg/hgrc
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    73
echo "[ui]" >> .hg/hgrc
4298
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
    74
echo "ssh = python ../dummyssh" >> .hg/hgrc
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 "# find outgoing"
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    77
hg out ssh://user@dummy/remote
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    78
1982
70ba0c86da8b Added test for incoming via ssh.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1933
diff changeset
    79
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
    80
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
    81
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    82
echo "# push"
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    83
hg push
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    84
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    85
cd ../remote
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    86
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    87
echo "# check remote tip"
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    88
hg tip
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    89
hg verify
3092
25857e00af8e cat: default to working dir parent instead of tip
Brendan Cully <brendan@kublai.com>
parents: 3012
diff changeset
    90
hg cat -r tip foo
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
    91
2439
e8c4f3d3df8c extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1982
diff changeset
    92
echo z > z
e8c4f3d3df8c extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1982
diff changeset
    93
hg ci -A -m z -d '1000001 0' z
e8c4f3d3df8c extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1982
diff changeset
    94
e8c4f3d3df8c extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1982
diff changeset
    95
cd ../local
e8c4f3d3df8c extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1982
diff changeset
    96
echo r > r
e8c4f3d3df8c extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1982
diff changeset
    97
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
    98
3684
975c2469c316 correct remote heads test in prepush
Matt Mackall <mpm@selenic.com>
parents: 3274
diff changeset
    99
echo "# push should succeed"
2439
e8c4f3d3df8c extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1982
diff changeset
   100
hg push
e8c4f3d3df8c extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1982
diff changeset
   101
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
   102
cd ..
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
   103
cat dummylog