##// END OF EJS Templates
tests: unify test-ssh
Matt Mackall -
r12489:d039c428 default
parent child Browse files
Show More
@@ -1,217 +1,220 b''
1
1
2 $ cp "$TESTDIR"/printenv.py .
2 $ cp "$TESTDIR"/printenv.py .
3
3
4 This test tries to exercise the ssh functionality with a dummy script
4 This test tries to exercise the ssh functionality with a dummy script
5
5
6 $ cat <<EOF > dummyssh
6 $ cat <<EOF > dummyssh
7 > import sys
7 > import sys
8 > import os
8 > import os
9 >
9 > os.chdir(os.path.dirname(sys.argv[0]))
10 > os.chdir(os.path.dirname(sys.argv[0]))
10 > if sys.argv[1] != "user@dummy":
11 > if sys.argv[1] != "user@dummy":
11 > sys.exit(-1)
12 > sys.exit(-1)
13 >
12 > if not os.path.exists("dummyssh"):
14 > if not os.path.exists("dummyssh"):
13 > sys.exit(-1)
15 > sys.exit(-1)
16 >
14 > os.environ["SSH_CLIENT"] = "127.0.0.1 1 2"
17 > os.environ["SSH_CLIENT"] = "127.0.0.1 1 2"
18 >
15 > log = open("dummylog", "ab")
19 > log = open("dummylog", "ab")
16 > log.write("Got arguments")
20 > log.write("Got arguments")
17 > for i, arg in enumerate(sys.argv[1:]):
21 > for i, arg in enumerate(sys.argv[1:]):
18 > log.write(" %d:%s" % (i+1, arg))
22 > log.write(" %d:%s" % (i+1, arg))
19 > log.write("\n")
23 > log.write("\n")
20 > log.close()
24 > log.close()
21 > r = os.system(sys.argv[2])
25 > r = os.system(sys.argv[2])
22 > sys.exit(bool(r))
26 > sys.exit(bool(r))
23 > EOF
27 > EOF
24 $ cat <<EOF > badhook
28 $ cat <<EOF > badhook
25 > import sys
29 > import sys
26 > sys.stdout.write("KABOOM\n")
30 > sys.stdout.write("KABOOM\n")
27 > EOF
31 > EOF
28
32
29 creating 'remote'
33 creating 'remote
30
34
31 $ hg init remote
35 $ hg init remote
32 $ cd remote
36 $ cd remote
33 $ echo this > foo
37 $ echo this > foo
34 $ echo this > fooO
38 $ echo this > fooO
35 $ hg ci -A -m "init" foo fooO
39 $ hg ci -A -m "init" foo fooO
36 $ echo '[server]' > .hg/hgrc
40 $ echo '[server]' > .hg/hgrc
37 $ echo 'uncompressed = True' >> .hg/hgrc
41 $ echo 'uncompressed = True' >> .hg/hgrc
38 $ echo '[hooks]' >> .hg/hgrc
42 $ echo '[hooks]' >> .hg/hgrc
39 $ echo 'changegroup = python ../printenv.py changegroup-in-remote 0 ../dummylog' >> .hg/hgrc
43 $ echo 'changegroup = python ../printenv.py changegroup-in-remote 0 ../dummylog' >> .hg/hgrc
40 $ cd ..
44 $ cd ..
41
45
42 repo not found error
46 repo not found error
43
47
44 $ hg clone -e "python ./dummyssh" ssh://user@dummy/nonexistent local
48 $ hg clone -e "python ./dummyssh" ssh://user@dummy/nonexistent local
45 remote: abort: There is no Mercurial repository here (.hg not found)!
49 remote: abort: There is no Mercurial repository here (.hg not found)!
46 abort: no suitable response from remote hg!
50 abort: no suitable response from remote hg!
47 [255]
51 [255]
48
52
49 non-existent absolute path
53 non-existent absolute path
50
54
51 $ hg clone -e "python ./dummyssh" ssh://user@dummy//$HGTMP/nonexistent local
55 $ hg clone -e "python ./dummyssh" ssh://user@dummy//$HGTMP/nonexistent local
52 remote: abort: There is no Mercurial repository here (.hg not found)!
56 remote: abort: There is no Mercurial repository here (.hg not found)!
53 abort: no suitable response from remote hg!
57 abort: no suitable response from remote hg!
54 [255]
58 [255]
55
59
56 clone remote via stream
60 clone remote via stream
57
61
58 $ hg clone -e "python ./dummyssh" --uncompressed ssh://user@dummy/remote local-stream 2>&1 | \
62 $ hg clone -e "python ./dummyssh" --uncompressed ssh://user@dummy/remote local-stream
59 > sed -e 's/[0-9][0-9.]*/XXX/g' -e 's/[KM]\(B\/sec\)/X\1/'
60 streaming all changes
63 streaming all changes
61 XXX files to transfer, XXX bytes of data
64 4 files to transfer, 392 bytes of data
62 transferred XXX bytes in XXX seconds (XXX XB/sec)
65 transferred 392 bytes in * seconds (*B/sec) (glob)
63 updating to branch default
66 updating to branch default
64 XXX files updated, XXX files merged, XXX files removed, XXX files unresolved
67 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
65 $ cd local-stream
68 $ cd local-stream
66 $ hg verify
69 $ hg verify
67 checking changesets
70 checking changesets
68 checking manifests
71 checking manifests
69 crosschecking files in changesets and manifests
72 crosschecking files in changesets and manifests
70 checking files
73 checking files
71 2 files, 1 changesets, 2 total revisions
74 2 files, 1 changesets, 2 total revisions
72 $ cd ..
75 $ cd ..
73
76
74 clone remote via pull
77 clone remote via pull
75
78
76 $ hg clone -e "python ./dummyssh" ssh://user@dummy/remote local
79 $ hg clone -e "python ./dummyssh" ssh://user@dummy/remote local
77 requesting all changes
80 requesting all changes
78 adding changesets
81 adding changesets
79 adding manifests
82 adding manifests
80 adding file changes
83 adding file changes
81 added 1 changesets with 2 changes to 2 files
84 added 1 changesets with 2 changes to 2 files
82 updating to branch default
85 updating to branch default
83 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
86 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
84
87
85 verify
88 verify
86
89
87 $ cd local
90 $ cd local
88 $ hg verify
91 $ hg verify
89 checking changesets
92 checking changesets
90 checking manifests
93 checking manifests
91 crosschecking files in changesets and manifests
94 crosschecking files in changesets and manifests
92 checking files
95 checking files
93 2 files, 1 changesets, 2 total revisions
96 2 files, 1 changesets, 2 total revisions
94 $ echo '[hooks]' >> .hg/hgrc
97 $ echo '[hooks]' >> .hg/hgrc
95 $ echo 'changegroup = python ../printenv.py changegroup-in-local 0 ../dummylog' >> .hg/hgrc
98 $ echo 'changegroup = python ../printenv.py changegroup-in-local 0 ../dummylog' >> .hg/hgrc
96
99
97 empty default pull
100 empty default pull
98
101
99 $ hg paths
102 $ hg paths
100 default = ssh://user@dummy/remote
103 default = ssh://user@dummy/remote
101 $ hg pull -e "python ../dummyssh"
104 $ hg pull -e "python ../dummyssh"
102 pulling from ssh://user@dummy/remote
105 pulling from ssh://user@dummy/remote
103 searching for changes
106 searching for changes
104 no changes found
107 no changes found
105
108
106 local change
109 local change
107
110
108 $ echo bleah > foo
111 $ echo bleah > foo
109 $ hg ci -m "add"
112 $ hg ci -m "add"
110
113
111 updating rc
114 updating rc
112
115
113 $ echo "default-push = ssh://user@dummy/remote" >> .hg/hgrc
116 $ echo "default-push = ssh://user@dummy/remote" >> .hg/hgrc
114 $ echo "[ui]" >> .hg/hgrc
117 $ echo "[ui]" >> .hg/hgrc
115 $ echo "ssh = python ../dummyssh" >> .hg/hgrc
118 $ echo "ssh = python ../dummyssh" >> .hg/hgrc
116
119
117 find outgoing
120 find outgoing
118
121
119 $ hg out ssh://user@dummy/remote
122 $ hg out ssh://user@dummy/remote
120 comparing with ssh://user@dummy/remote
123 comparing with ssh://user@dummy/remote
121 searching for changes
124 searching for changes
122 changeset: 1:a28a9d1a809c
125 changeset: 1:a28a9d1a809c
123 tag: tip
126 tag: tip
124 user: test
127 user: test
125 date: Thu Jan 01 00:00:00 1970 +0000
128 date: Thu Jan 01 00:00:00 1970 +0000
126 summary: add
129 summary: add
127
130
128
131
129 find incoming on the remote side
132 find incoming on the remote side
130
133
131 $ hg incoming -R ../remote -e "python ../dummyssh" ssh://user@dummy/local
134 $ hg incoming -R ../remote -e "python ../dummyssh" ssh://user@dummy/local
132 comparing with ssh://user@dummy/local
135 comparing with ssh://user@dummy/local
133 searching for changes
136 searching for changes
134 changeset: 1:a28a9d1a809c
137 changeset: 1:a28a9d1a809c
135 tag: tip
138 tag: tip
136 user: test
139 user: test
137 date: Thu Jan 01 00:00:00 1970 +0000
140 date: Thu Jan 01 00:00:00 1970 +0000
138 summary: add
141 summary: add
139
142
140
143
141 push
144 push
142
145
143 $ hg push
146 $ hg push
144 pushing to ssh://user@dummy/remote
147 pushing to ssh://user@dummy/remote
145 searching for changes
148 searching for changes
146 remote: adding changesets
149 remote: adding changesets
147 remote: adding manifests
150 remote: adding manifests
148 remote: adding file changes
151 remote: adding file changes
149 remote: added 1 changesets with 1 changes to 1 files
152 remote: added 1 changesets with 1 changes to 1 files
150 $ cd ../remote
153 $ cd ../remote
151
154
152 check remote tip
155 check remote tip
153
156
154 $ hg tip
157 $ hg tip
155 changeset: 1:a28a9d1a809c
158 changeset: 1:a28a9d1a809c
156 tag: tip
159 tag: tip
157 user: test
160 user: test
158 date: Thu Jan 01 00:00:00 1970 +0000
161 date: Thu Jan 01 00:00:00 1970 +0000
159 summary: add
162 summary: add
160
163
161 $ hg verify
164 $ hg verify
162 checking changesets
165 checking changesets
163 checking manifests
166 checking manifests
164 crosschecking files in changesets and manifests
167 crosschecking files in changesets and manifests
165 checking files
168 checking files
166 2 files, 2 changesets, 3 total revisions
169 2 files, 2 changesets, 3 total revisions
167 $ hg cat -r tip foo
170 $ hg cat -r tip foo
168 bleah
171 bleah
169 $ echo z > z
172 $ echo z > z
170 $ hg ci -A -m z z
173 $ hg ci -A -m z z
171 created new head
174 created new head
172
175
173 a bad, evil hook that prints to stdout
176 a bad, evil hook that prints to stdout
174
177
175 $ echo 'changegroup.stdout = python ../badhook' >> .hg/hgrc
178 $ echo 'changegroup.stdout = python ../badhook' >> .hg/hgrc
176 $ cd ../local
179 $ cd ../local
177 $ echo r > r
180 $ echo r > r
178 $ hg ci -A -m z r
181 $ hg ci -A -m z r
179
182
180 push should succeed even though it has an unexpected response
183 push should succeed even though it has an unexpected response
181
184
182 $ hg push
185 $ hg push
183 pushing to ssh://user@dummy/remote
186 pushing to ssh://user@dummy/remote
184 searching for changes
187 searching for changes
185 note: unsynced remote changes!
188 note: unsynced remote changes!
186 remote: adding changesets
189 remote: adding changesets
187 remote: adding manifests
190 remote: adding manifests
188 remote: adding file changes
191 remote: adding file changes
189 remote: added 1 changesets with 1 changes to 1 files
192 remote: added 1 changesets with 1 changes to 1 files
190 remote: KABOOM
193 remote: KABOOM
191 $ hg -R ../remote heads
194 $ hg -R ../remote heads
192 changeset: 3:1383141674ec
195 changeset: 3:1383141674ec
193 tag: tip
196 tag: tip
194 parent: 1:a28a9d1a809c
197 parent: 1:a28a9d1a809c
195 user: test
198 user: test
196 date: Thu Jan 01 00:00:00 1970 +0000
199 date: Thu Jan 01 00:00:00 1970 +0000
197 summary: z
200 summary: z
198
201
199 changeset: 2:6c0482d977a3
202 changeset: 2:6c0482d977a3
200 parent: 0:1160648e36ce
203 parent: 0:1160648e36ce
201 user: test
204 user: test
202 date: Thu Jan 01 00:00:00 1970 +0000
205 date: Thu Jan 01 00:00:00 1970 +0000
203 summary: z
206 summary: z
204
207
205 $ cd ..
208 $ cd ..
206 $ cat dummylog
209 $ cat dummylog
207 Got arguments 1:user@dummy 2:hg -R nonexistent serve --stdio
210 Got arguments 1:user@dummy 2:hg -R nonexistent serve --stdio
208 Got arguments 1:user@dummy 2:hg -R */nonexistent serve --stdio (glob)
211 Got arguments 1:user@dummy 2:hg -R */nonexistent serve --stdio (glob)
209 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
212 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
210 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
213 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
211 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
214 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
212 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
215 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
213 Got arguments 1:user@dummy 2:hg -R local serve --stdio
216 Got arguments 1:user@dummy 2:hg -R local serve --stdio
214 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
217 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
215 changegroup-in-remote hook: HG_NODE=a28a9d1a809cab7d4e2fde4bee738a9ede948b60 HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1
218 changegroup-in-remote hook: HG_NODE=a28a9d1a809cab7d4e2fde4bee738a9ede948b60 HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1
216 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
219 Got arguments 1:user@dummy 2:hg -R remote serve --stdio
217 changegroup-in-remote hook: HG_NODE=1383141674ec756a6056f6a9097618482fe0f4a6 HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1
220 changegroup-in-remote hook: HG_NODE=1383141674ec756a6056f6a9097618482fe0f4a6 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