annotate tests/test-ssh @ 12409:0eaf7d32a5d8

test-ssh: test absolute paths in SSH URLs
author Brodie Rao <brodie@bitheap.org>
date Fri, 24 Sep 2010 15:50:57 -0500
parents 4c94b6d0fb1c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
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
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 6266
diff changeset
40 hg ci -A -m "init" 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
12409
0eaf7d32a5d8 test-ssh: test absolute paths in SSH URLs
Brodie Rao <brodie@bitheap.org>
parents: 12156
diff changeset
51 echo "# non-existent absolute path"
0eaf7d32a5d8 test-ssh: test absolute paths in SSH URLs
Brodie Rao <brodie@bitheap.org>
parents: 12156
diff changeset
52 hg clone -e "python ./dummyssh" ssh://user@dummy//$HGTMP/nonexistent local
0eaf7d32a5d8 test-ssh: test absolute paths in SSH URLs
Brodie Rao <brodie@bitheap.org>
parents: 12156
diff changeset
53
2612
ffb895f16925 add support for streaming clone.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2439
diff changeset
54 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
55 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
56 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
57 cd local-stream
ffb895f16925 add support for streaming clone.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2439
diff changeset
58 hg verify
ffb895f16925 add support for streaming clone.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2439
diff changeset
59 cd ..
ffb895f16925 add support for streaming clone.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2439
diff changeset
60
ffb895f16925 add support for streaming clone.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2439
diff changeset
61 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
62 hg clone -e "python ./dummyssh" ssh://user@dummy/remote local
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
63
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
64 echo "# verify"
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
65 cd local
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
66 hg verify
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
67
2673
109a22f5434a hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2622
diff changeset
68 echo '[hooks]' >> .hg/hgrc
4291
35b2e02367a5 test-ssh: use printenv.py
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3853
diff changeset
69 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
70
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
71 echo "# empty default pull"
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
72 hg paths
4298
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
73 hg pull -e "python ../dummyssh"
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
74
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
75 echo "# local change"
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
76 echo bleah > foo
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 6266
diff changeset
77 hg ci -m "add"
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
78
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
79 echo "# updating rc"
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
80 echo "default-push = ssh://user@dummy/remote" >> .hg/hgrc
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
81 echo "[ui]" >> .hg/hgrc
4298
58517f6eb1ad test-ssh: avoid a shell script
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4291
diff changeset
82 echo "ssh = python ../dummyssh" >> .hg/hgrc
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
83
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
84 echo "# find outgoing"
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
85 hg out ssh://user@dummy/remote
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
86
1982
70ba0c86da8b Added test for incoming via ssh.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1933
diff changeset
87 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
88 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
89
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
90 echo "# push"
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
91 hg push
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
92
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
93 cd ../remote
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
94
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
95 echo "# check remote tip"
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
96 hg tip
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
97 hg verify
3095
25857e00af8e cat: default to working dir parent instead of tip
Brendan Cully <brendan@kublai.com>
parents: 3015
diff changeset
98 hg cat -r tip foo
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
99
2439
e8c4f3d3df8c extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1982
diff changeset
100 echo z > z
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 6266
diff changeset
101 hg ci -A -m z z
5978
7939c71f3132 sshrepo: be more careful while reading data
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4298
diff changeset
102 # 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
103 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
104
e8c4f3d3df8c extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1982
diff changeset
105 cd ../local
e8c4f3d3df8c extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1982
diff changeset
106 echo r > r
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 6266
diff changeset
107 hg ci -A -m z r
2439
e8c4f3d3df8c extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1982
diff changeset
108
5978
7939c71f3132 sshrepo: be more careful while reading data
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4298
diff changeset
109 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
110 hg push
5978
7939c71f3132 sshrepo: be more careful while reading data
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4298
diff changeset
111 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
112
1110
1032a505488c Add a simple dummy ssh test
mpm@selenic.com
parents:
diff changeset
113 cd ..
12409
0eaf7d32a5d8 test-ssh: test absolute paths in SSH URLs
Brodie Rao <brodie@bitheap.org>
parents: 12156
diff changeset
114 cat dummylog | sed -e "s,$HGTMP,HGTMP,"