Mercurial > hg
annotate tests/test-ssh @ 8820:e8cb1fa0d4a9
test-convert-cvsnt-mergepoints: make it work on OS X.
- don't create file 'cvs' where directory 'CVS' already exists
author | Greg Ward <greg-hg@gerg.ca> |
---|---|
date | Mon, 15 Jun 2009 20:35:19 -0400 |
parents | 9f76df0edb7d |
children | 4c94b6d0fb1c |
rev | line source |
---|---|
1110 | 1 #!/bin/sh |
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 | 5 # This test tries to exercise the ssh functionality with a dummy script |
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 | 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 | 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 | 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 | 28 EOF |
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 | 35 echo "# creating 'remote'" |
36 hg init remote | |
37 cd remote | |
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 | 45 |
46 cd .. | |
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 | 60 |
61 echo "# verify" | |
62 cd local | |
63 hg verify | |
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 | 68 echo "# empty default pull" |
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 | 71 |
72 echo "# local change" | |
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 | 75 |
76 echo "# updating rc" | |
77 echo "default-push = ssh://user@dummy/remote" >> .hg/hgrc | |
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 | 80 |
81 echo "# find outgoing" | |
82 hg out ssh://user@dummy/remote | |
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 | 87 echo "# push" |
88 hg push | |
89 | |
90 cd ../remote | |
91 | |
92 echo "# check remote tip" | |
93 hg tip | |
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 | 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 | 110 cd .. |
111 cat dummylog |