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