##// END OF EJS Templates
tests: stabilize test-push-http.t for Windows...
Matt Harbison -
r37496:d815b973 default
parent child Browse files
Show More
@@ -1,382 +1,382
1 1 #require killdaemons
2 2
3 3 #testcases bundle1 bundle2
4 4
5 5 #if bundle1
6 6 $ cat << EOF >> $HGRCPATH
7 7 > [devel]
8 8 > # This test is dedicated to interaction through old bundle
9 9 > legacy.exchange = bundle1
10 10 > EOF
11 11 #endif
12 12
13 13 $ hg init test
14 14 $ cd test
15 15 $ echo a > a
16 16 $ hg ci -Ama
17 17 adding a
18 18 $ cd ..
19 19 $ hg clone test test2
20 20 updating to branch default
21 21 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
22 22 $ cd test2
23 23 $ echo a >> a
24 24 $ hg ci -mb
25 25 $ req() {
26 26 > hg $1 serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
27 27 > cat hg.pid >> $DAEMON_PIDS
28 28 > hg --cwd ../test2 push http://localhost:$HGPORT/
29 29 > exitstatus=$?
30 30 > killdaemons.py
31 31 > echo % serve errors
32 32 > cat errors.log
33 33 > return $exitstatus
34 34 > }
35 35 $ cd ../test
36 36
37 37 expect ssl error
38 38
39 39 $ req
40 40 pushing to http://localhost:$HGPORT/
41 41 searching for changes
42 42 abort: HTTP Error 403: ssl required
43 43 % serve errors
44 44 [255]
45 45
46 46 expect authorization error
47 47
48 48 $ echo '[web]' > .hg/hgrc
49 49 $ echo 'push_ssl = false' >> .hg/hgrc
50 50 $ req
51 51 pushing to http://localhost:$HGPORT/
52 52 searching for changes
53 53 abort: authorization failed
54 54 % serve errors
55 55 [255]
56 56
57 57 expect authorization error: must have authorized user
58 58
59 59 $ echo 'allow_push = unperson' >> .hg/hgrc
60 60 $ req
61 61 pushing to http://localhost:$HGPORT/
62 62 searching for changes
63 63 abort: authorization failed
64 64 % serve errors
65 65 [255]
66 66
67 67 expect success
68 68
69 69 $ cat > $TESTTMP/hook.sh <<'EOF'
70 70 > echo "phase-move: $HG_NODE: $HG_OLDPHASE -> $HG_PHASE"
71 71 > EOF
72 72
73 73 #if bundle1
74 74 $ cat >> .hg/hgrc <<EOF
75 75 > allow_push = *
76 76 > [hooks]
77 77 > changegroup = sh -c "printenv.py changegroup 0"
78 78 > pushkey = sh -c "printenv.py pushkey 0"
79 79 > txnclose-phase.test = sh $TESTTMP/hook.sh
80 80 > EOF
81 81 $ req "--debug --config extensions.blackbox="
82 listening at http://localhost:$HGPORT/ (bound to $LOCALIP:$HGPORT)
82 listening at http://localhost:$HGPORT/ (bound to $LOCALIP:$HGPORT) (?)
83 83 pushing to http://localhost:$HGPORT/
84 84 searching for changes
85 85 remote: redirecting incoming bundle to */hg-unbundle-* (glob)
86 86 remote: adding changesets
87 87 remote: add changeset ba677d0156c1
88 88 remote: adding manifests
89 89 remote: adding file changes
90 90 remote: adding a revisions
91 91 remote: added 1 changesets with 1 changes to 1 files
92 92 remote: updating the branch cache
93 93 remote: running hook txnclose-phase.test: sh $TESTTMP/hook.sh
94 94 remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b: draft -> public
95 95 remote: running hook txnclose-phase.test: sh $TESTTMP/hook.sh
96 96 remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872: -> public
97 97 remote: running hook changegroup: sh -c "printenv.py changegroup 0"
98 98 remote: changegroup hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
99 99 % serve errors
100 100 $ hg rollback
101 101 repository tip rolled back to revision 0 (undo serve)
102 102 $ req "--debug --config server.streamunbundle=True --config extensions.blackbox="
103 listening at http://localhost:$HGPORT/ (bound to $LOCALIP:$HGPORT)
103 listening at http://localhost:$HGPORT/ (bound to $LOCALIP:$HGPORT) (?)
104 104 pushing to http://localhost:$HGPORT/
105 105 searching for changes
106 106 remote: adding changesets
107 107 remote: add changeset ba677d0156c1
108 108 remote: adding manifests
109 109 remote: adding file changes
110 110 remote: adding a revisions
111 111 remote: added 1 changesets with 1 changes to 1 files
112 112 remote: updating the branch cache
113 113 remote: running hook txnclose-phase.test: sh $TESTTMP/hook.sh
114 114 remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b: draft -> public
115 115 remote: running hook txnclose-phase.test: sh $TESTTMP/hook.sh
116 116 remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872: -> public
117 117 remote: running hook changegroup: sh -c "printenv.py changegroup 0"
118 118 remote: changegroup hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
119 119 % serve errors
120 120 $ hg rollback
121 121 repository tip rolled back to revision 0 (undo serve)
122 122 #endif
123 123
124 124 #if bundle2
125 125 $ cat >> .hg/hgrc <<EOF
126 126 > allow_push = *
127 127 > [hooks]
128 128 > changegroup = sh -c "printenv.py changegroup 0"
129 129 > pushkey = sh -c "printenv.py pushkey 0"
130 130 > txnclose-phase.test = sh $TESTTMP/hook.sh
131 131 > EOF
132 132 $ req
133 133 pushing to http://localhost:$HGPORT/
134 134 searching for changes
135 135 remote: adding changesets
136 136 remote: adding manifests
137 137 remote: adding file changes
138 138 remote: added 1 changesets with 1 changes to 1 files
139 139 remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b: draft -> public
140 140 remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872: -> public
141 141 remote: changegroup hook: HG_BUNDLE2=1 HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
142 142 % serve errors
143 143 $ hg rollback
144 144 repository tip rolled back to revision 0 (undo serve)
145 145 #endif
146 146
147 147 expect success, server lacks the httpheader capability
148 148
149 149 $ CAP=httpheader
150 150 $ . "$TESTDIR/notcapable"
151 151 $ req
152 152 pushing to http://localhost:$HGPORT/
153 153 searching for changes
154 154 remote: adding changesets
155 155 remote: adding manifests
156 156 remote: adding file changes
157 157 remote: added 1 changesets with 1 changes to 1 files
158 158 remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b: draft -> public
159 159 remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872: -> public
160 160 remote: changegroup hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob) (bundle1 !)
161 161 remote: changegroup hook: HG_BUNDLE2=1 HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob) (bundle2 !)
162 162 % serve errors
163 163 $ hg rollback
164 164 repository tip rolled back to revision 0 (undo serve)
165 165
166 166 expect success, server lacks the unbundlehash capability
167 167
168 168 $ CAP=unbundlehash
169 169 $ . "$TESTDIR/notcapable"
170 170 $ req
171 171 pushing to http://localhost:$HGPORT/
172 172 searching for changes
173 173 remote: adding changesets
174 174 remote: adding manifests
175 175 remote: adding file changes
176 176 remote: added 1 changesets with 1 changes to 1 files
177 177 remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b: draft -> public
178 178 remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872: -> public
179 179 remote: changegroup hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob) (bundle1 !)
180 180 remote: changegroup hook: HG_BUNDLE2=1 HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob) (bundle2 !)
181 181 % serve errors
182 182 $ hg rollback
183 183 repository tip rolled back to revision 0 (undo serve)
184 184
185 185 expect success, pre-d1b16a746db6 server supports the unbundle capability, but
186 186 has no parameter
187 187
188 188 $ cat <<EOF > notcapable-unbundleparam.py
189 189 > from mercurial import extensions, httppeer
190 190 > def capable(orig, self, name):
191 191 > if name == 'unbundle':
192 192 > return True
193 193 > return orig(self, name)
194 194 > def uisetup(ui):
195 195 > extensions.wrapfunction(httppeer.httppeer, 'capable', capable)
196 196 > EOF
197 197 $ cp $HGRCPATH $HGRCPATH.orig
198 198 $ cat <<EOF >> $HGRCPATH
199 199 > [extensions]
200 200 > notcapable-unbundleparam = `pwd`/notcapable-unbundleparam.py
201 201 > EOF
202 202 $ req
203 203 pushing to http://localhost:$HGPORT/
204 204 searching for changes
205 205 remote: adding changesets
206 206 remote: adding manifests
207 207 remote: adding file changes
208 208 remote: added 1 changesets with 1 changes to 1 files
209 209 remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b: draft -> public
210 210 remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872: -> public
211 211 remote: changegroup hook: * (glob)
212 212 % serve errors
213 213 $ hg rollback
214 214 repository tip rolled back to revision 0 (undo serve)
215 215 $ mv $HGRCPATH.orig $HGRCPATH
216 216
217 217 Test pushing to a publishing repository with a failing prepushkey hook
218 218
219 219 $ cat > .hg/hgrc <<EOF
220 220 > [web]
221 221 > push_ssl = false
222 222 > allow_push = *
223 223 > [hooks]
224 224 > prepushkey = sh -c "printenv.py prepushkey 1"
225 225 > [devel]
226 226 > legacy.exchange=phases
227 227 > EOF
228 228
229 229 #if bundle1
230 230 Bundle1 works because a) phases are updated as part of changegroup application
231 231 and b) client checks phases after the "unbundle" command. Since it sees no
232 232 phase changes are necessary, it doesn't send the "pushkey" command and the
233 233 prepushkey hook never has to fire.
234 234
235 235 $ req
236 236 pushing to http://localhost:$HGPORT/
237 237 searching for changes
238 238 remote: adding changesets
239 239 remote: adding manifests
240 240 remote: adding file changes
241 241 remote: added 1 changesets with 1 changes to 1 files
242 242 % serve errors
243 243
244 244 #endif
245 245
246 246 #if bundle2
247 247 Bundle2 sends a "pushkey" bundle2 part. This runs as part of the transaction
248 248 and fails the entire push.
249 249 $ req
250 250 pushing to http://localhost:$HGPORT/
251 251 searching for changes
252 252 remote: adding changesets
253 253 remote: adding manifests
254 254 remote: adding file changes
255 255 remote: added 1 changesets with 1 changes to 1 files
256 256 remote: prepushkey hook: HG_BUNDLE2=1 HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_OLD=1 HG_PENDING=$TESTTMP/test HG_PHASES_MOVED=1 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
257 257 remote: pushkey-abort: prepushkey hook exited with status 1
258 258 remote: transaction abort!
259 259 remote: rollback completed
260 260 abort: updating ba677d0156c1 to public failed
261 261 % serve errors
262 262 [255]
263 263
264 264 #endif
265 265
266 266 Now remove the failing prepushkey hook.
267 267
268 268 $ cat >> .hg/hgrc <<EOF
269 269 > [hooks]
270 270 > prepushkey = sh -c "printenv.py prepushkey 0"
271 271 > EOF
272 272
273 273 We don't need to test bundle1 because it succeeded above.
274 274
275 275 #if bundle2
276 276 $ req
277 277 pushing to http://localhost:$HGPORT/
278 278 searching for changes
279 279 remote: adding changesets
280 280 remote: adding manifests
281 281 remote: adding file changes
282 282 remote: added 1 changesets with 1 changes to 1 files
283 283 remote: prepushkey hook: HG_BUNDLE2=1 HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_OLD=1 HG_PENDING=$TESTTMP/test HG_PHASES_MOVED=1 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
284 284 % serve errors
285 285 #endif
286 286
287 287 $ hg --config extensions.strip= strip -r 1:
288 288 saved backup bundle to $TESTTMP/test/.hg/strip-backup/ba677d0156c1-eea704d7-backup.hg
289 289
290 290 Now do a variant of the above, except on a non-publishing repository
291 291
292 292 $ cat >> .hg/hgrc <<EOF
293 293 > [phases]
294 294 > publish = false
295 295 > [hooks]
296 296 > prepushkey = sh -c "printenv.py prepushkey 1"
297 297 > EOF
298 298
299 299 #if bundle1
300 300 $ req
301 301 pushing to http://localhost:$HGPORT/
302 302 searching for changes
303 303 remote: adding changesets
304 304 remote: adding manifests
305 305 remote: adding file changes
306 306 remote: added 1 changesets with 1 changes to 1 files
307 307 remote: prepushkey hook: HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_OLD=1
308 308 remote: pushkey-abort: prepushkey hook exited with status 1
309 309 updating ba677d0156c1 to public failed!
310 310 % serve errors
311 311 #endif
312 312
313 313 #if bundle2
314 314 $ req
315 315 pushing to http://localhost:$HGPORT/
316 316 searching for changes
317 317 remote: adding changesets
318 318 remote: adding manifests
319 319 remote: adding file changes
320 320 remote: added 1 changesets with 1 changes to 1 files
321 321 remote: prepushkey hook: HG_BUNDLE2=1 HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_OLD=1 HG_PENDING=$TESTTMP/test HG_PHASES_MOVED=1 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
322 322 remote: pushkey-abort: prepushkey hook exited with status 1
323 323 remote: transaction abort!
324 324 remote: rollback completed
325 325 abort: updating ba677d0156c1 to public failed
326 326 % serve errors
327 327 [255]
328 328 #endif
329 329
330 330 Make phases updates work
331 331
332 332 $ cat >> .hg/hgrc <<EOF
333 333 > [hooks]
334 334 > prepushkey = sh -c "printenv.py prepushkey 0"
335 335 > EOF
336 336
337 337 #if bundle1
338 338 $ req
339 339 pushing to http://localhost:$HGPORT/
340 340 searching for changes
341 341 no changes found
342 342 remote: prepushkey hook: HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_OLD=1
343 343 % serve errors
344 344 [1]
345 345 #endif
346 346
347 347 #if bundle2
348 348 $ req
349 349 pushing to http://localhost:$HGPORT/
350 350 searching for changes
351 351 remote: adding changesets
352 352 remote: adding manifests
353 353 remote: adding file changes
354 354 remote: added 1 changesets with 1 changes to 1 files
355 355 remote: prepushkey hook: HG_BUNDLE2=1 HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NAMESPACE=phases HG_NEW=0 HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_OLD=1 HG_PENDING=$TESTTMP/test HG_PHASES_MOVED=1 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
356 356 % serve errors
357 357 #endif
358 358
359 359 $ hg --config extensions.strip= strip -r 1:
360 360 saved backup bundle to $TESTTMP/test/.hg/strip-backup/ba677d0156c1-eea704d7-backup.hg
361 361
362 362 #if bundle2
363 363
364 364 $ cat > .hg/hgrc <<EOF
365 365 > [web]
366 366 > push_ssl = false
367 367 > allow_push = *
368 368 > [experimental]
369 369 > httppostargs=true
370 370 > EOF
371 371 $ req
372 372 pushing to http://localhost:$HGPORT/
373 373 searching for changes
374 374 remote: adding changesets
375 375 remote: adding manifests
376 376 remote: adding file changes
377 377 remote: added 1 changesets with 1 changes to 1 files
378 378 % serve errors
379 379
380 380 #endif
381 381
382 382 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now