##// END OF EJS Templates
test-ssh: avoid a shell script
Alexis S. L. Carvalho -
r4298:58517f6e default
parent child Browse files
Show More
@@ -1,102 +1,103
1 #!/bin/sh
1 #!/bin/sh
2
2
3 cp "$TESTDIR"/printenv.py .
3 cp "$TESTDIR"/printenv.py .
4
4
5 # This test tries to exercise the ssh functionality with a dummy script
5 # This test tries to exercise the ssh functionality with a dummy script
6
6
7 cat <<'EOF' > dummyssh
7 cat <<EOF > dummyssh
8 #!/bin/sh
8 import sys
9 # this attempts to deal with relative pathnames
9 import os
10 cd `dirname $0`
11
10
12 # check for proper args
11 os.chdir(os.path.dirname(sys.argv[0]))
13 if [ $1 != "user@dummy" ] ; then
12 if sys.argv[1] != "user@dummy":
14 exit -1
13 sys.exit(-1)
15 fi
14
15 if not os.path.exists("dummyssh"):
16 sys.exit(-1)
16
17
17 # check that we're in the right directory
18 os.environ["SSH_CLIENT"] = "127.0.0.1 1 2"
18 if [ ! -x dummyssh ] ; then
19 exit -1
20 fi
21
19
22 SSH_CLIENT='127.0.0.1 1 2'
20 log = open("dummylog", "ab")
23 export SSH_CLIENT
21 log.write("Got arguments")
24 echo Got arguments 1:$1 2:$2 3:$3 4:$4 5:$5 >> dummylog
22 for i, arg in enumerate(sys.argv[1:]):
25 $2
23 log.write(" %d:%s" % (i+1, arg))
24 log.write("\n")
25 log.close()
26 r = os.system(sys.argv[2])
27 sys.exit(bool(r))
26 EOF
28 EOF
27 chmod +x dummyssh
28
29
29 echo "# creating 'remote'"
30 echo "# creating 'remote'"
30 hg init remote
31 hg init remote
31 cd remote
32 cd remote
32 echo this > foo
33 echo this > foo
33 echo this > fooO
34 echo this > fooO
34 hg ci -A -m "init" -d "1000000 0" foo fooO
35 hg ci -A -m "init" -d "1000000 0" foo fooO
35 echo '[server]' > .hg/hgrc
36 echo '[server]' > .hg/hgrc
36 echo 'uncompressed = True' >> .hg/hgrc
37 echo 'uncompressed = True' >> .hg/hgrc
37 echo '[hooks]' >> .hg/hgrc
38 echo '[hooks]' >> .hg/hgrc
38 echo 'changegroup = python ../printenv.py changegroup-in-remote 0 ../dummylog' >> .hg/hgrc
39 echo 'changegroup = python ../printenv.py changegroup-in-remote 0 ../dummylog' >> .hg/hgrc
39
40
40 cd ..
41 cd ..
41
42
42 echo "# repo not found error"
43 echo "# repo not found error"
43 hg clone -e ./dummyssh ssh://user@dummy/nonexistent local
44 hg clone -e "python ./dummyssh" ssh://user@dummy/nonexistent local
44
45
45 echo "# clone remote via stream"
46 echo "# clone remote via stream"
46 hg clone -e ./dummyssh --uncompressed ssh://user@dummy/remote local-stream 2>&1 | \
47 hg clone -e "python ./dummyssh" --uncompressed ssh://user@dummy/remote local-stream 2>&1 | \
47 sed -e 's/[0-9][0-9.]*/XXX/g' -e 's/[KM]\(B\/sec\)/X\1/'
48 sed -e 's/[0-9][0-9.]*/XXX/g' -e 's/[KM]\(B\/sec\)/X\1/'
48 cd local-stream
49 cd local-stream
49 hg verify
50 hg verify
50 cd ..
51 cd ..
51
52
52 echo "# clone remote via pull"
53 echo "# clone remote via pull"
53 hg clone -e ./dummyssh ssh://user@dummy/remote local
54 hg clone -e "python ./dummyssh" ssh://user@dummy/remote local
54
55
55 echo "# verify"
56 echo "# verify"
56 cd local
57 cd local
57 hg verify
58 hg verify
58
59
59 echo '[hooks]' >> .hg/hgrc
60 echo '[hooks]' >> .hg/hgrc
60 echo 'changegroup = python ../printenv.py changegroup-in-local 0 ../dummylog' >> .hg/hgrc
61 echo 'changegroup = python ../printenv.py changegroup-in-local 0 ../dummylog' >> .hg/hgrc
61
62
62 echo "# empty default pull"
63 echo "# empty default pull"
63 hg paths
64 hg paths
64 hg pull -e ../dummyssh
65 hg pull -e "python ../dummyssh"
65
66
66 echo "# local change"
67 echo "# local change"
67 echo bleah > foo
68 echo bleah > foo
68 hg ci -m "add" -d "1000000 0"
69 hg ci -m "add" -d "1000000 0"
69
70
70 echo "# updating rc"
71 echo "# updating rc"
71 echo "default-push = ssh://user@dummy/remote" >> .hg/hgrc
72 echo "default-push = ssh://user@dummy/remote" >> .hg/hgrc
72 echo "[ui]" >> .hg/hgrc
73 echo "[ui]" >> .hg/hgrc
73 echo "ssh = ../dummyssh" >> .hg/hgrc
74 echo "ssh = python ../dummyssh" >> .hg/hgrc
74
75
75 echo "# find outgoing"
76 echo "# find outgoing"
76 hg out ssh://user@dummy/remote
77 hg out ssh://user@dummy/remote
77
78
78 echo "# find incoming on the remote side"
79 echo "# find incoming on the remote side"
79 hg incoming -R ../remote -e ../dummyssh ssh://user@dummy/local
80 hg incoming -R ../remote -e "python ../dummyssh" ssh://user@dummy/local
80
81
81 echo "# push"
82 echo "# push"
82 hg push
83 hg push
83
84
84 cd ../remote
85 cd ../remote
85
86
86 echo "# check remote tip"
87 echo "# check remote tip"
87 hg tip
88 hg tip
88 hg verify
89 hg verify
89 hg cat -r tip foo
90 hg cat -r tip foo
90
91
91 echo z > z
92 echo z > z
92 hg ci -A -m z -d '1000001 0' z
93 hg ci -A -m z -d '1000001 0' z
93
94
94 cd ../local
95 cd ../local
95 echo r > r
96 echo r > r
96 hg ci -A -m z -d '1000002 0' r
97 hg ci -A -m z -d '1000002 0' r
97
98
98 echo "# push should succeed"
99 echo "# push should succeed"
99 hg push
100 hg push
100
101
101 cd ..
102 cd ..
102 cat dummylog
103 cat dummylog
@@ -1,90 +1,90
1 # creating 'remote'
1 # creating 'remote'
2 # repo not found error
2 # repo not found error
3 remote: abort: repository nonexistent not found!
3 remote: abort: repository nonexistent not found!
4 abort: no suitable response from remote hg!
4 abort: no suitable response from remote hg!
5 # clone remote via stream
5 # clone remote via stream
6 streaming all changes
6 streaming all changes
7 XXX files to transfer, XXX bytes of data
7 XXX files to transfer, XXX bytes of data
8 transferred XXX bytes in XXX seconds (XXX XB/sec)
8 transferred XXX bytes in XXX seconds (XXX XB/sec)
9 XXX files updated, XXX files merged, XXX files removed, XXX files unresolved
9 XXX files updated, XXX files merged, XXX files removed, XXX files unresolved
10 checking changesets
10 checking changesets
11 checking manifests
11 checking manifests
12 crosschecking files in changesets and manifests
12 crosschecking files in changesets and manifests
13 checking files
13 checking files
14 2 files, 1 changesets, 2 total revisions
14 2 files, 1 changesets, 2 total revisions
15 # clone remote via pull
15 # clone remote via pull
16 requesting all changes
16 requesting all changes
17 adding changesets
17 adding changesets
18 adding manifests
18 adding manifests
19 adding file changes
19 adding file changes
20 added 1 changesets with 2 changes to 2 files
20 added 1 changesets with 2 changes to 2 files
21 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
21 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
22 # verify
22 # verify
23 checking changesets
23 checking changesets
24 checking manifests
24 checking manifests
25 crosschecking files in changesets and manifests
25 crosschecking files in changesets and manifests
26 checking files
26 checking files
27 2 files, 1 changesets, 2 total revisions
27 2 files, 1 changesets, 2 total revisions
28 # empty default pull
28 # empty default pull
29 default = ssh://user@dummy/remote
29 default = ssh://user@dummy/remote
30 pulling from ssh://user@dummy/remote
30 pulling from ssh://user@dummy/remote
31 searching for changes
31 searching for changes
32 no changes found
32 no changes found
33 # local change
33 # local change
34 # updating rc
34 # updating rc
35 # find outgoing
35 # find outgoing
36 comparing with ssh://user@dummy/remote
36 comparing with ssh://user@dummy/remote
37 searching for changes
37 searching for changes
38 changeset: 1:572896fe480d
38 changeset: 1:572896fe480d
39 tag: tip
39 tag: tip
40 user: test
40 user: test
41 date: Mon Jan 12 13:46:40 1970 +0000
41 date: Mon Jan 12 13:46:40 1970 +0000
42 summary: add
42 summary: add
43
43
44 # find incoming on the remote side
44 # find incoming on the remote side
45 comparing with ssh://user@dummy/local
45 comparing with ssh://user@dummy/local
46 searching for changes
46 searching for changes
47 changeset: 1:572896fe480d
47 changeset: 1:572896fe480d
48 tag: tip
48 tag: tip
49 user: test
49 user: test
50 date: Mon Jan 12 13:46:40 1970 +0000
50 date: Mon Jan 12 13:46:40 1970 +0000
51 summary: add
51 summary: add
52
52
53 # push
53 # push
54 pushing to ssh://user@dummy/remote
54 pushing to ssh://user@dummy/remote
55 searching for changes
55 searching for changes
56 remote: adding changesets
56 remote: adding changesets
57 remote: adding manifests
57 remote: adding manifests
58 remote: adding file changes
58 remote: adding file changes
59 remote: added 1 changesets with 1 changes to 1 files
59 remote: added 1 changesets with 1 changes to 1 files
60 # check remote tip
60 # check remote tip
61 changeset: 1:572896fe480d
61 changeset: 1:572896fe480d
62 tag: tip
62 tag: tip
63 user: test
63 user: test
64 date: Mon Jan 12 13:46:40 1970 +0000
64 date: Mon Jan 12 13:46:40 1970 +0000
65 summary: add
65 summary: add
66
66
67 checking changesets
67 checking changesets
68 checking manifests
68 checking manifests
69 crosschecking files in changesets and manifests
69 crosschecking files in changesets and manifests
70 checking files
70 checking files
71 2 files, 2 changesets, 3 total revisions
71 2 files, 2 changesets, 3 total revisions
72 bleah
72 bleah
73 # push should succeed
73 # push should succeed
74 pushing to ssh://user@dummy/remote
74 pushing to ssh://user@dummy/remote
75 searching for changes
75 searching for changes
76 note: unsynced remote changes!
76 note: unsynced remote changes!
77 remote: adding changesets
77 remote: adding changesets
78 remote: adding manifests
78 remote: adding manifests
79 remote: adding file changes
79 remote: adding file changes
80 remote: added 1 changesets with 1 changes to 1 files
80 remote: added 1 changesets with 1 changes to 1 files
81 Got arguments 1:user@dummy 2:hg -R nonexistent serve --stdio 3: 4: 5:
81 Got arguments 1:user@dummy 2:hg -R nonexistent serve --stdio
82 Got arguments 1:user@dummy 2:hg -R remote serve --stdio 3: 4: 5:
82 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
83 Got arguments 1:user@dummy 2:hg -R remote serve --stdio 3: 4: 5:
83 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
84 Got arguments 1:user@dummy 2:hg -R remote serve --stdio 3: 4: 5:
84 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
85 Got arguments 1:user@dummy 2:hg -R remote serve --stdio 3: 4: 5:
85 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
86 Got arguments 1:user@dummy 2:hg -R local serve --stdio 3: 4: 5:
86 Got arguments 1:user@dummy 2:hg -R local serve --stdio
87 Got arguments 1:user@dummy 2:hg -R remote serve --stdio 3: 4: 5:
87 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
88 changegroup-in-remote hook: HG_NODE=572896fe480d7581849806ee402175c49cb20037 HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1
88 changegroup-in-remote hook: HG_NODE=572896fe480d7581849806ee402175c49cb20037 HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1
89 Got arguments 1:user@dummy 2:hg -R remote serve --stdio 3: 4: 5:
89 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
90 changegroup-in-remote hook: HG_NODE=ac7448082955a0b2ff5cb4512c1e061c779bbc79 HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1
90 changegroup-in-remote hook: HG_NODE=ac7448082955a0b2ff5cb4512c1e061c779bbc79 HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1
General Comments 0
You need to be logged in to leave comments. Login now