Show More
@@ -1,331 +1,333 b'' | |||
|
1 | 1 | #require chg |
|
2 | 2 | |
|
3 | 3 | $ mkdir log |
|
4 | 4 | $ cp $HGRCPATH $HGRCPATH.unconfigured |
|
5 | 5 | $ cat <<'EOF' >> $HGRCPATH |
|
6 | 6 | > [cmdserver] |
|
7 | 7 | > log = $TESTTMP/log/server.log |
|
8 | 8 | > max-log-files = 1 |
|
9 | 9 | > max-log-size = 10 kB |
|
10 | 10 | > EOF |
|
11 | 11 | $ cp $HGRCPATH $HGRCPATH.orig |
|
12 | 12 | |
|
13 | 13 | $ filterlog () { |
|
14 | 14 | > sed -e 's!^[0-9/]* [0-9:]* ([0-9]*)>!YYYY/MM/DD HH:MM:SS (PID)>!' \ |
|
15 | 15 | > -e 's!\(setprocname\|received fds\|setenv\): .*!\1: ...!' \ |
|
16 | 16 | > -e 's!\(confighash\|mtimehash\) = [0-9a-f]*!\1 = ...!g' \ |
|
17 | 17 | > -e 's!\(in \)[0-9.]*s\b!\1 ...s!g' \ |
|
18 | 18 | > -e 's!\(pid\)=[0-9]*!\1=...!g' \ |
|
19 | 19 | > -e 's!\(/server-\)[0-9a-f]*!\1...!g' |
|
20 | 20 | > } |
|
21 | 21 | |
|
22 | 22 | init repo |
|
23 | 23 | |
|
24 | 24 | $ chg init foo |
|
25 | 25 | $ cd foo |
|
26 | 26 | |
|
27 | 27 | ill-formed config |
|
28 | 28 | |
|
29 | 29 | $ chg status |
|
30 | 30 | $ echo '=brokenconfig' >> $HGRCPATH |
|
31 | 31 | $ chg status |
|
32 | 32 | hg: parse error at * (glob) |
|
33 | 33 | [255] |
|
34 | 34 | |
|
35 | 35 | $ cp $HGRCPATH.orig $HGRCPATH |
|
36 | 36 | |
|
37 | 37 | long socket path |
|
38 | 38 | |
|
39 | 39 | $ sockpath=$TESTTMP/this/path/should/be/longer/than/one-hundred-and-seven/characters/where/107/is/the/typical/size/limit/of/unix-domain-socket |
|
40 | 40 | $ mkdir -p $sockpath |
|
41 | 41 | $ bakchgsockname=$CHGSOCKNAME |
|
42 | 42 | $ CHGSOCKNAME=$sockpath/server |
|
43 | 43 | $ export CHGSOCKNAME |
|
44 | 44 | $ chg root |
|
45 | 45 | $TESTTMP/foo |
|
46 | 46 | $ rm -rf $sockpath |
|
47 | 47 | $ CHGSOCKNAME=$bakchgsockname |
|
48 | 48 | $ export CHGSOCKNAME |
|
49 | 49 | |
|
50 | 50 | $ cd .. |
|
51 | 51 | |
|
52 | 52 | editor |
|
53 | 53 | ------ |
|
54 | 54 | |
|
55 | 55 | $ cat >> pushbuffer.py <<EOF |
|
56 | 56 | > def reposetup(ui, repo): |
|
57 | 57 | > repo.ui.pushbuffer(subproc=True) |
|
58 | 58 | > EOF |
|
59 | 59 | |
|
60 | 60 | $ chg init editor |
|
61 | 61 | $ cd editor |
|
62 | 62 | |
|
63 | 63 | by default, system() should be redirected to the client: |
|
64 | 64 | |
|
65 | 65 | $ touch foo |
|
66 | 66 | $ CHGDEBUG= HGEDITOR=cat chg ci -Am channeled --edit 2>&1 \ |
|
67 | 67 | > | egrep "HG:|run 'cat" |
|
68 | 68 | chg: debug: * run 'cat "*"' at '$TESTTMP/editor' (glob) |
|
69 | 69 | HG: Enter commit message. Lines beginning with 'HG:' are removed. |
|
70 | 70 | HG: Leave message empty to abort commit. |
|
71 | 71 | HG: -- |
|
72 | 72 | HG: user: test |
|
73 | 73 | HG: branch 'default' |
|
74 | 74 | HG: added foo |
|
75 | 75 | |
|
76 | 76 | but no redirection should be made if output is captured: |
|
77 | 77 | |
|
78 | 78 | $ touch bar |
|
79 | 79 | $ CHGDEBUG= HGEDITOR=cat chg ci -Am bufferred --edit \ |
|
80 | 80 | > --config extensions.pushbuffer="$TESTTMP/pushbuffer.py" 2>&1 \ |
|
81 | 81 | > | egrep "HG:|run 'cat" |
|
82 | 82 | [1] |
|
83 | 83 | |
|
84 | 84 | check that commit commands succeeded: |
|
85 | 85 | |
|
86 | 86 | $ hg log -T '{rev}:{desc}\n' |
|
87 | 87 | 1:bufferred |
|
88 | 88 | 0:channeled |
|
89 | 89 | |
|
90 | 90 | $ cd .. |
|
91 | 91 | |
|
92 | 92 | pager |
|
93 | 93 | ----- |
|
94 | 94 | |
|
95 | 95 | $ cat >> fakepager.py <<EOF |
|
96 | 96 | > import sys |
|
97 | 97 | > for line in sys.stdin: |
|
98 | 98 | > sys.stdout.write('paged! %r\n' % line) |
|
99 | 99 | > EOF |
|
100 | 100 | |
|
101 | 101 | enable pager extension globally, but spawns the master server with no tty: |
|
102 | 102 | |
|
103 | 103 | $ chg init pager |
|
104 | 104 | $ cd pager |
|
105 | 105 | $ cat >> $HGRCPATH <<EOF |
|
106 | 106 | > [extensions] |
|
107 | 107 | > pager = |
|
108 | 108 | > [pager] |
|
109 | 109 | > pager = "$PYTHON" $TESTTMP/fakepager.py |
|
110 | 110 | > EOF |
|
111 | 111 | $ chg version > /dev/null |
|
112 | 112 | $ touch foo |
|
113 | 113 | $ chg ci -qAm foo |
|
114 | 114 | |
|
115 | 115 | pager should be enabled if the attached client has a tty: |
|
116 | 116 | |
|
117 | 117 | $ chg log -l1 -q --config ui.formatted=True |
|
118 | 118 | paged! '0:1f7b0de80e11\n' |
|
119 | 119 | $ chg log -l1 -q --config ui.formatted=False |
|
120 | 120 | 0:1f7b0de80e11 |
|
121 | 121 | |
|
122 | 122 | chg waits for pager if runcommand raises |
|
123 | 123 | |
|
124 | 124 | $ cat > $TESTTMP/crash.py <<EOF |
|
125 | 125 | > from mercurial import registrar |
|
126 | 126 | > cmdtable = {} |
|
127 | 127 | > command = registrar.command(cmdtable) |
|
128 | 128 | > @command(b'crash') |
|
129 | 129 | > def pagercrash(ui, repo, *pats, **opts): |
|
130 | 130 | > ui.write(b'going to crash\n') |
|
131 | 131 | > raise Exception('.') |
|
132 | 132 | > EOF |
|
133 | 133 | |
|
134 | 134 | $ cat > $TESTTMP/fakepager.py <<EOF |
|
135 | 135 | > from __future__ import absolute_import |
|
136 | 136 | > import sys |
|
137 | 137 | > import time |
|
138 | 138 | > for line in iter(sys.stdin.readline, ''): |
|
139 | 139 | > if 'crash' in line: # only interested in lines containing 'crash' |
|
140 | 140 | > # if chg exits when pager is sleeping (incorrectly), the output |
|
141 | 141 | > # will be captured by the next test case |
|
142 | 142 | > time.sleep(1) |
|
143 | 143 | > sys.stdout.write('crash-pager: %s' % line) |
|
144 | 144 | > EOF |
|
145 | 145 | |
|
146 | 146 | $ cat >> .hg/hgrc <<EOF |
|
147 | 147 | > [extensions] |
|
148 | 148 | > crash = $TESTTMP/crash.py |
|
149 | 149 | > EOF |
|
150 | 150 | |
|
151 | 151 | $ chg crash --pager=on --config ui.formatted=True 2>/dev/null |
|
152 | 152 | crash-pager: going to crash |
|
153 | 153 | [255] |
|
154 | 154 | |
|
155 | 155 | $ cd .. |
|
156 | 156 | |
|
157 | 157 | server lifecycle |
|
158 | 158 | ---------------- |
|
159 | 159 | |
|
160 | 160 | chg server should be restarted on code change, and old server will shut down |
|
161 | 161 | automatically. In this test, we use the following time parameters: |
|
162 | 162 | |
|
163 | 163 | - "sleep 1" to make mtime different |
|
164 | 164 | - "sleep 2" to notice mtime change (polling interval is 1 sec) |
|
165 | 165 | |
|
166 | 166 | set up repository with an extension: |
|
167 | 167 | |
|
168 | 168 | $ chg init extreload |
|
169 | 169 | $ cd extreload |
|
170 | 170 | $ touch dummyext.py |
|
171 | 171 | $ cat <<EOF >> .hg/hgrc |
|
172 | 172 | > [extensions] |
|
173 | 173 | > dummyext = dummyext.py |
|
174 | 174 | > EOF |
|
175 | 175 | |
|
176 | 176 | isolate socket directory for stable result: |
|
177 | 177 | |
|
178 | 178 | $ OLDCHGSOCKNAME=$CHGSOCKNAME |
|
179 | 179 | $ mkdir chgsock |
|
180 | 180 | $ CHGSOCKNAME=`pwd`/chgsock/server |
|
181 | 181 | |
|
182 | 182 | warm up server: |
|
183 | 183 | |
|
184 | 184 | $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start' |
|
185 | 185 | chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob) |
|
186 | 186 | |
|
187 | 187 | new server should be started if extension modified: |
|
188 | 188 | |
|
189 | 189 | $ sleep 1 |
|
190 | 190 | $ touch dummyext.py |
|
191 | 191 | $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start' |
|
192 | 192 | chg: debug: * instruction: unlink $TESTTMP/extreload/chgsock/server-* (glob) |
|
193 | 193 | chg: debug: * instruction: reconnect (glob) |
|
194 | 194 | chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob) |
|
195 | 195 | |
|
196 | 196 | old server will shut down, while new server should still be reachable: |
|
197 | 197 | |
|
198 | 198 | $ sleep 2 |
|
199 | 199 | $ CHGDEBUG= chg log 2>&1 | (egrep 'instruction|start' || true) |
|
200 | 200 | |
|
201 | 201 | socket file should never be unlinked by old server: |
|
202 | 202 | (simulates unowned socket by updating mtime, which makes sure server exits |
|
203 | 203 | at polling cycle) |
|
204 | 204 | |
|
205 | 205 | $ ls chgsock/server-* |
|
206 | 206 | chgsock/server-* (glob) |
|
207 | 207 | $ touch chgsock/server-* |
|
208 | 208 | $ sleep 2 |
|
209 | 209 | $ ls chgsock/server-* |
|
210 | 210 | chgsock/server-* (glob) |
|
211 | 211 | |
|
212 | 212 | since no server is reachable from socket file, new server should be started: |
|
213 | 213 | (this test makes sure that old server shut down automatically) |
|
214 | 214 | |
|
215 | 215 | $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start' |
|
216 | 216 | chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob) |
|
217 | 217 | |
|
218 | 218 | shut down servers and restore environment: |
|
219 | 219 | |
|
220 | 220 | $ rm -R chgsock |
|
221 | 221 | $ sleep 2 |
|
222 | 222 | $ CHGSOCKNAME=$OLDCHGSOCKNAME |
|
223 | 223 | $ cd .. |
|
224 | 224 | |
|
225 | 225 | check that server events are recorded: |
|
226 | 226 | |
|
227 | 227 | $ ls log |
|
228 | 228 | server.log |
|
229 | 229 | server.log.1 |
|
230 | 230 | |
|
231 | 231 | print only the last 10 lines, since we aren't sure how many records are |
|
232 | preserved: | |
|
232 | preserved (since setprocname isn't available on py3, the 10th-most-recent line | |
|
233 | is different when using py3): | |
|
233 | 234 | |
|
234 | 235 | $ cat log/server.log.1 log/server.log | tail -10 | filterlog |
|
236 | YYYY/MM/DD HH:MM:SS (PID)> confighash = ... mtimehash = ... (py3 !) | |
|
235 | 237 | YYYY/MM/DD HH:MM:SS (PID)> forked worker process (pid=...) |
|
236 | YYYY/MM/DD HH:MM:SS (PID)> setprocname: ... | |
|
238 | YYYY/MM/DD HH:MM:SS (PID)> setprocname: ... (no-py3 !) | |
|
237 | 239 | YYYY/MM/DD HH:MM:SS (PID)> received fds: ... |
|
238 | 240 |
|
|
239 | 241 | YYYY/MM/DD HH:MM:SS (PID)> setumask 18 |
|
240 | 242 | YYYY/MM/DD HH:MM:SS (PID)> setenv: ... |
|
241 | 243 | YYYY/MM/DD HH:MM:SS (PID)> confighash = ... mtimehash = ... |
|
242 | 244 | YYYY/MM/DD HH:MM:SS (PID)> validate: [] |
|
243 | 245 | YYYY/MM/DD HH:MM:SS (PID)> worker process exited (pid=...) |
|
244 | 246 | YYYY/MM/DD HH:MM:SS (PID)> $TESTTMP/extreload/chgsock/server-... is not owned, exiting. |
|
245 | 247 | |
|
246 | 248 | repository cache |
|
247 | 249 | ---------------- |
|
248 | 250 | |
|
249 | 251 | $ rm log/server.log* |
|
250 | 252 | $ cp $HGRCPATH.unconfigured $HGRCPATH |
|
251 | 253 | $ cat <<'EOF' >> $HGRCPATH |
|
252 | 254 | > [cmdserver] |
|
253 | 255 | > log = $TESTTMP/log/server.log |
|
254 | 256 | > max-repo-cache = 1 |
|
255 | 257 | > track-log = command, repocache |
|
256 | 258 | > EOF |
|
257 | 259 | |
|
258 | 260 | isolate socket directory for stable result: |
|
259 | 261 | |
|
260 | 262 | $ OLDCHGSOCKNAME=$CHGSOCKNAME |
|
261 | 263 | $ mkdir chgsock |
|
262 | 264 | $ CHGSOCKNAME=`pwd`/chgsock/server |
|
263 | 265 | |
|
264 | 266 | create empty repo and cache it: |
|
265 | 267 | |
|
266 | 268 | $ hg init cached |
|
267 | 269 | $ hg id -R cached |
|
268 | 270 | 000000000000 tip |
|
269 | 271 | $ sleep 1 |
|
270 | 272 | |
|
271 | 273 | modify repo (and cache will be invalidated): |
|
272 | 274 | |
|
273 | 275 | $ touch cached/a |
|
274 | 276 |
$ hg ci -R cached -Am ' |
|
275 | 277 | adding a |
|
276 | 278 | $ sleep 1 |
|
277 | 279 | |
|
278 | 280 | read cached repo: |
|
279 | 281 | |
|
280 | 282 | $ hg log -R cached |
|
281 | 283 | changeset: 0:ac82d8b1f7c4 |
|
282 | 284 | tag: tip |
|
283 | 285 | user: test |
|
284 | 286 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
285 | 287 | summary: add a |
|
286 | 288 | |
|
287 | 289 | $ sleep 1 |
|
288 | 290 | |
|
289 | 291 | discard cached from LRU cache: |
|
290 | 292 | |
|
291 | 293 | $ hg clone cached cached2 |
|
292 | 294 | updating to branch default |
|
293 | 295 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
294 | 296 | $ hg id -R cached2 |
|
295 | 297 | ac82d8b1f7c4 tip |
|
296 | 298 | $ sleep 1 |
|
297 | 299 | |
|
298 | 300 | read uncached repo: |
|
299 | 301 | |
|
300 | 302 | $ hg log -R cached |
|
301 | 303 | changeset: 0:ac82d8b1f7c4 |
|
302 | 304 | tag: tip |
|
303 | 305 | user: test |
|
304 | 306 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
305 | 307 | summary: add a |
|
306 | 308 | |
|
307 | 309 | $ sleep 1 |
|
308 | 310 | |
|
309 | 311 | shut down servers and restore environment: |
|
310 | 312 | |
|
311 | 313 | $ rm -R chgsock |
|
312 | 314 | $ sleep 2 |
|
313 | 315 | $ CHGSOCKNAME=$OLDCHGSOCKNAME |
|
314 | 316 | |
|
315 | 317 | check server log: |
|
316 | 318 | |
|
317 | 319 | $ cat log/server.log | filterlog |
|
318 | 320 | YYYY/MM/DD HH:MM:SS (PID)> init cached |
|
319 | 321 | YYYY/MM/DD HH:MM:SS (PID)> id -R cached |
|
320 | 322 | YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s) |
|
321 | 323 | YYYY/MM/DD HH:MM:SS (PID)> repo from cache: $TESTTMP/cached |
|
322 | 324 |
YYYY/MM/DD HH:MM:SS (PID)> ci -R cached -Am ' |
|
323 | 325 | YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s) |
|
324 | 326 | YYYY/MM/DD HH:MM:SS (PID)> repo from cache: $TESTTMP/cached |
|
325 | 327 | YYYY/MM/DD HH:MM:SS (PID)> log -R cached |
|
326 | 328 | YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s) |
|
327 | 329 | YYYY/MM/DD HH:MM:SS (PID)> clone cached cached2 |
|
328 | 330 | YYYY/MM/DD HH:MM:SS (PID)> id -R cached2 |
|
329 | 331 | YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached2 (in ...s) |
|
330 | 332 | YYYY/MM/DD HH:MM:SS (PID)> log -R cached |
|
331 | 333 | YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s) |
General Comments 0
You need to be logged in to leave comments.
Login now