##// END OF EJS Templates
test-chg: use a different log to avoid flakyness...
marmoute -
r50993:889d2a2e stable
parent child Browse files
Show More
@@ -1,558 +1,555 b''
1 #require chg
1 #require chg
2
2
3 Scale the timeout for the chg-server to the test timeout scaling.
3 Scale the timeout for the chg-server to the test timeout scaling.
4 This is done to reduce the flakiness of this test on heavy load.
4 This is done to reduce the flakiness of this test on heavy load.
5
5
6 $ CHGTIMEOUT=`expr $HGTEST_TIMEOUT / 6`
6 $ CHGTIMEOUT=`expr $HGTEST_TIMEOUT / 6`
7 $ export CHGTIMEOUT
7 $ export CHGTIMEOUT
8
8
9 $ mkdir log
9 $ mkdir log
10 $ cp $HGRCPATH $HGRCPATH.unconfigured
10 $ cp $HGRCPATH $HGRCPATH.unconfigured
11 $ cat <<'EOF' >> $HGRCPATH
11 $ cat <<'EOF' >> $HGRCPATH
12 > [cmdserver]
12 > [cmdserver]
13 > log = $TESTTMP/log/server.log
13 > log = $TESTTMP/log/server.log
14 > max-log-files = 1
14 > max-log-files = 1
15 > max-log-size = 10 kB
15 > max-log-size = 10 kB
16 > EOF
16 > EOF
17 $ cp $HGRCPATH $HGRCPATH.orig
17 $ cp $HGRCPATH $HGRCPATH.orig
18
18
19 $ filterlog () {
19 $ filterlog () {
20 > sed -e 's!^[0-9/]* [0-9:]* ([0-9]*)>!YYYY/MM/DD HH:MM:SS (PID)>!' \
20 > sed -e 's!^[0-9/]* [0-9:]* ([0-9]*)>!YYYY/MM/DD HH:MM:SS (PID)>!' \
21 > -e 's!\(setprocname\|received fds\|setenv\): .*!\1: ...!' \
21 > -e 's!\(setprocname\|received fds\|setenv\): .*!\1: ...!' \
22 > -e 's!\(confighash\|mtimehash\) = [0-9a-f]*!\1 = ...!g' \
22 > -e 's!\(confighash\|mtimehash\) = [0-9a-f]*!\1 = ...!g' \
23 > -e 's!\(in \)[0-9.]*s\b!\1 ...s!g' \
23 > -e 's!\(in \)[0-9.]*s\b!\1 ...s!g' \
24 > -e 's!\(pid\)=[0-9]*!\1=...!g' \
24 > -e 's!\(pid\)=[0-9]*!\1=...!g' \
25 > -e 's!\(/server-\)[0-9a-f]*!\1...!g'
25 > -e 's!\(/server-\)[0-9a-f]*!\1...!g'
26 > }
26 > }
27
27
28 init repo
28 init repo
29
29
30 $ chg init foo
30 $ chg init foo
31 $ cd foo
31 $ cd foo
32
32
33 ill-formed config
33 ill-formed config
34
34
35 $ chg status
35 $ chg status
36 $ echo '=brokenconfig' >> $HGRCPATH
36 $ echo '=brokenconfig' >> $HGRCPATH
37 $ chg status
37 $ chg status
38 config error at * =brokenconfig (glob)
38 config error at * =brokenconfig (glob)
39 [30]
39 [30]
40
40
41 $ cp $HGRCPATH.orig $HGRCPATH
41 $ cp $HGRCPATH.orig $HGRCPATH
42
42
43 long socket path
43 long socket path
44
44
45 $ sockpath=$TESTTMP/this/path/should/be/longer/than/one-hundred-and-seven/characters/where/107/is/the/typical/size/limit/of/unix-domain-socket
45 $ sockpath=$TESTTMP/this/path/should/be/longer/than/one-hundred-and-seven/characters/where/107/is/the/typical/size/limit/of/unix-domain-socket
46 $ mkdir -p $sockpath
46 $ mkdir -p $sockpath
47 $ bakchgsockname=$CHGSOCKNAME
47 $ bakchgsockname=$CHGSOCKNAME
48 $ CHGSOCKNAME=$sockpath/server
48 $ CHGSOCKNAME=$sockpath/server
49 $ export CHGSOCKNAME
49 $ export CHGSOCKNAME
50 $ chg root
50 $ chg root
51 $TESTTMP/foo
51 $TESTTMP/foo
52 $ rm -rf $sockpath
52 $ rm -rf $sockpath
53 $ CHGSOCKNAME=$bakchgsockname
53 $ CHGSOCKNAME=$bakchgsockname
54 $ export CHGSOCKNAME
54 $ export CHGSOCKNAME
55
55
56 $ cd ..
56 $ cd ..
57
57
58 editor
58 editor
59 ------
59 ------
60
60
61 $ cat >> pushbuffer.py <<EOF
61 $ cat >> pushbuffer.py <<EOF
62 > def reposetup(ui, repo):
62 > def reposetup(ui, repo):
63 > repo.ui.pushbuffer(subproc=True)
63 > repo.ui.pushbuffer(subproc=True)
64 > EOF
64 > EOF
65
65
66 $ chg init editor
66 $ chg init editor
67 $ cd editor
67 $ cd editor
68
68
69 by default, system() should be redirected to the client:
69 by default, system() should be redirected to the client:
70
70
71 $ touch foo
71 $ touch foo
72 $ CHGDEBUG= HGEDITOR=cat chg ci -Am channeled --edit 2>&1 \
72 $ CHGDEBUG= HGEDITOR=cat chg ci -Am channeled --edit 2>&1 \
73 > | egrep "HG:|run 'cat"
73 > | egrep "HG:|run 'cat"
74 chg: debug: * run 'cat "*"' at '$TESTTMP/editor' (glob)
74 chg: debug: * run 'cat "*"' at '$TESTTMP/editor' (glob)
75 HG: Enter commit message. Lines beginning with 'HG:' are removed.
75 HG: Enter commit message. Lines beginning with 'HG:' are removed.
76 HG: Leave message empty to abort commit.
76 HG: Leave message empty to abort commit.
77 HG: --
77 HG: --
78 HG: user: test
78 HG: user: test
79 HG: branch 'default'
79 HG: branch 'default'
80 HG: added foo
80 HG: added foo
81
81
82 but no redirection should be made if output is captured:
82 but no redirection should be made if output is captured:
83
83
84 $ touch bar
84 $ touch bar
85 $ CHGDEBUG= HGEDITOR=cat chg ci -Am bufferred --edit \
85 $ CHGDEBUG= HGEDITOR=cat chg ci -Am bufferred --edit \
86 > --config extensions.pushbuffer="$TESTTMP/pushbuffer.py" 2>&1 \
86 > --config extensions.pushbuffer="$TESTTMP/pushbuffer.py" 2>&1 \
87 > | egrep "HG:|run 'cat"
87 > | egrep "HG:|run 'cat"
88 [1]
88 [1]
89
89
90 check that commit commands succeeded:
90 check that commit commands succeeded:
91
91
92 $ hg log -T '{rev}:{desc}\n'
92 $ hg log -T '{rev}:{desc}\n'
93 1:bufferred
93 1:bufferred
94 0:channeled
94 0:channeled
95
95
96 $ cd ..
96 $ cd ..
97
97
98 pager
98 pager
99 -----
99 -----
100
100
101 $ cat >> fakepager.py <<EOF
101 $ cat >> fakepager.py <<EOF
102 > import sys
102 > import sys
103 > for line in sys.stdin:
103 > for line in sys.stdin:
104 > sys.stdout.write('paged! %r\n' % line)
104 > sys.stdout.write('paged! %r\n' % line)
105 > EOF
105 > EOF
106
106
107 enable pager extension globally, but spawns the master server with no tty:
107 enable pager extension globally, but spawns the master server with no tty:
108
108
109 $ chg init pager
109 $ chg init pager
110 $ cd pager
110 $ cd pager
111 $ cat >> $HGRCPATH <<EOF
111 $ cat >> $HGRCPATH <<EOF
112 > [extensions]
112 > [extensions]
113 > pager =
113 > pager =
114 > [pager]
114 > [pager]
115 > pager = "$PYTHON" $TESTTMP/fakepager.py
115 > pager = "$PYTHON" $TESTTMP/fakepager.py
116 > EOF
116 > EOF
117 $ chg version > /dev/null
117 $ chg version > /dev/null
118 $ touch foo
118 $ touch foo
119 $ chg ci -qAm foo
119 $ chg ci -qAm foo
120
120
121 pager should be enabled if the attached client has a tty:
121 pager should be enabled if the attached client has a tty:
122
122
123 $ chg log -l1 -q --config ui.formatted=True
123 $ chg log -l1 -q --config ui.formatted=True
124 paged! '0:1f7b0de80e11\n'
124 paged! '0:1f7b0de80e11\n'
125 $ chg log -l1 -q --config ui.formatted=False
125 $ chg log -l1 -q --config ui.formatted=False
126 0:1f7b0de80e11
126 0:1f7b0de80e11
127
127
128 chg waits for pager if runcommand raises
128 chg waits for pager if runcommand raises
129
129
130 $ cat > $TESTTMP/crash.py <<EOF
130 $ cat > $TESTTMP/crash.py <<EOF
131 > from mercurial import registrar
131 > from mercurial import registrar
132 > cmdtable = {}
132 > cmdtable = {}
133 > command = registrar.command(cmdtable)
133 > command = registrar.command(cmdtable)
134 > @command(b'crash')
134 > @command(b'crash')
135 > def pagercrash(ui, repo, *pats, **opts):
135 > def pagercrash(ui, repo, *pats, **opts):
136 > ui.write(b'going to crash\n')
136 > ui.write(b'going to crash\n')
137 > raise Exception('.')
137 > raise Exception('.')
138 > EOF
138 > EOF
139
139
140 $ cat > $TESTTMP/fakepager.py <<EOF
140 $ cat > $TESTTMP/fakepager.py <<EOF
141 > import sys
141 > import sys
142 > import time
142 > import time
143 > for line in iter(sys.stdin.readline, ''):
143 > for line in iter(sys.stdin.readline, ''):
144 > if 'crash' in line: # only interested in lines containing 'crash'
144 > if 'crash' in line: # only interested in lines containing 'crash'
145 > # if chg exits when pager is sleeping (incorrectly), the output
145 > # if chg exits when pager is sleeping (incorrectly), the output
146 > # will be captured by the next test case
146 > # will be captured by the next test case
147 > time.sleep(1)
147 > time.sleep(1)
148 > sys.stdout.write('crash-pager: %s' % line)
148 > sys.stdout.write('crash-pager: %s' % line)
149 > EOF
149 > EOF
150
150
151 $ cat >> .hg/hgrc <<EOF
151 $ cat >> .hg/hgrc <<EOF
152 > [extensions]
152 > [extensions]
153 > crash = $TESTTMP/crash.py
153 > crash = $TESTTMP/crash.py
154 > EOF
154 > EOF
155
155
156 $ chg crash --pager=on --config ui.formatted=True 2>/dev/null
156 $ chg crash --pager=on --config ui.formatted=True 2>/dev/null
157 crash-pager: going to crash
157 crash-pager: going to crash
158 [255]
158 [255]
159
159
160 no stdout data should be printed after pager quits, and the buffered data
160 no stdout data should be printed after pager quits, and the buffered data
161 should never persist (issue6207)
161 should never persist (issue6207)
162
162
163 "killed!" may be printed if terminated by SIGPIPE, which isn't important
163 "killed!" may be printed if terminated by SIGPIPE, which isn't important
164 in this test.
164 in this test.
165
165
166 $ cat > $TESTTMP/bulkwrite.py <<'EOF'
166 $ cat > $TESTTMP/bulkwrite.py <<'EOF'
167 > import time
167 > import time
168 > from mercurial import error, registrar
168 > from mercurial import error, registrar
169 > cmdtable = {}
169 > cmdtable = {}
170 > command = registrar.command(cmdtable)
170 > command = registrar.command(cmdtable)
171 > @command(b'bulkwrite')
171 > @command(b'bulkwrite')
172 > def bulkwrite(ui, repo, *pats, **opts):
172 > def bulkwrite(ui, repo, *pats, **opts):
173 > ui.write(b'going to write massive data\n')
173 > ui.write(b'going to write massive data\n')
174 > ui.flush()
174 > ui.flush()
175 > t = time.time()
175 > t = time.time()
176 > while time.time() - t < 2:
176 > while time.time() - t < 2:
177 > ui.write(b'x' * 1023 + b'\n') # will be interrupted by SIGPIPE
177 > ui.write(b'x' * 1023 + b'\n') # will be interrupted by SIGPIPE
178 > raise error.Abort(b"write() doesn't block")
178 > raise error.Abort(b"write() doesn't block")
179 > EOF
179 > EOF
180
180
181 $ cat > $TESTTMP/fakepager.py <<'EOF'
181 $ cat > $TESTTMP/fakepager.py <<'EOF'
182 > import sys
182 > import sys
183 > import time
183 > import time
184 > sys.stdout.write('paged! %r\n' % sys.stdin.readline())
184 > sys.stdout.write('paged! %r\n' % sys.stdin.readline())
185 > time.sleep(1) # new data will be written
185 > time.sleep(1) # new data will be written
186 > EOF
186 > EOF
187
187
188 $ cat >> .hg/hgrc <<EOF
188 $ cat >> .hg/hgrc <<EOF
189 > [extensions]
189 > [extensions]
190 > bulkwrite = $TESTTMP/bulkwrite.py
190 > bulkwrite = $TESTTMP/bulkwrite.py
191 > EOF
191 > EOF
192
192
193 $ chg bulkwrite --pager=on --color no --config ui.formatted=True
193 $ chg bulkwrite --pager=on --color no --config ui.formatted=True
194 paged! 'going to write massive data\n'
194 paged! 'going to write massive data\n'
195 killed! (?)
195 killed! (?)
196 [255]
196 [255]
197
197
198 $ chg bulkwrite --pager=on --color no --config ui.formatted=True
198 $ chg bulkwrite --pager=on --color no --config ui.formatted=True
199 paged! 'going to write massive data\n'
199 paged! 'going to write massive data\n'
200 killed! (?)
200 killed! (?)
201 [255]
201 [255]
202
202
203 $ cd ..
203 $ cd ..
204
204
205 missing stdio
205 missing stdio
206 -------------
206 -------------
207
207
208 $ CHGDEBUG=1 chg version -q 0<&-
208 $ CHGDEBUG=1 chg version -q 0<&-
209 chg: debug: * stdio fds are missing (glob)
209 chg: debug: * stdio fds are missing (glob)
210 chg: debug: * execute original hg (glob)
210 chg: debug: * execute original hg (glob)
211 Mercurial Distributed SCM * (glob)
211 Mercurial Distributed SCM * (glob)
212
212
213 server lifecycle
213 server lifecycle
214 ----------------
214 ----------------
215
215
216 chg server should be restarted on code change, and old server will shut down
216 chg server should be restarted on code change, and old server will shut down
217 automatically. In this test, we use the following time parameters:
217 automatically. In this test, we use the following time parameters:
218
218
219 - "sleep 1" to make mtime different
219 - "sleep 1" to make mtime different
220 - "sleep 2" to notice mtime change (polling interval is 1 sec)
220 - "sleep 2" to notice mtime change (polling interval is 1 sec)
221
221
222 set up repository with an extension:
222 set up repository with an extension:
223
223
224 $ chg init extreload
224 $ chg init extreload
225 $ cd extreload
225 $ cd extreload
226 $ touch dummyext.py
226 $ touch dummyext.py
227 $ cat <<EOF >> .hg/hgrc
227 $ cat <<EOF >> .hg/hgrc
228 > [extensions]
228 > [extensions]
229 > dummyext = dummyext.py
229 > dummyext = dummyext.py
230 > EOF
230 > EOF
231
231
232 isolate socket directory for stable result:
232 isolate socket directory for stable result:
233
233
234 $ OLDCHGSOCKNAME=$CHGSOCKNAME
234 $ OLDCHGSOCKNAME=$CHGSOCKNAME
235 $ mkdir chgsock
235 $ mkdir chgsock
236 $ CHGSOCKNAME=`pwd`/chgsock/server
236 $ CHGSOCKNAME=`pwd`/chgsock/server
237
237
238 warm up server:
238 warm up server:
239
239
240 $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start'
240 $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start'
241 chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob)
241 chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob)
242
242
243 new server should be started if extension modified:
243 new server should be started if extension modified:
244
244
245 $ sleep 1
245 $ sleep 1
246 $ touch dummyext.py
246 $ touch dummyext.py
247 $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start'
247 $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start'
248 chg: debug: * instruction: unlink $TESTTMP/extreload/chgsock/server-* (glob)
248 chg: debug: * instruction: unlink $TESTTMP/extreload/chgsock/server-* (glob)
249 chg: debug: * instruction: reconnect (glob)
249 chg: debug: * instruction: reconnect (glob)
250 chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob)
250 chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob)
251
251
252 old server will shut down, while new server should still be reachable:
252 old server will shut down, while new server should still be reachable:
253
253
254 $ sleep 2
254 $ sleep 2
255 $ CHGDEBUG= chg log 2>&1 | (egrep 'instruction|start' || true)
255 $ CHGDEBUG= chg log 2>&1 | (egrep 'instruction|start' || true)
256
256
257 socket file should never be unlinked by old server:
257 socket file should never be unlinked by old server:
258 (simulates unowned socket by updating mtime, which makes sure server exits
258 (simulates unowned socket by updating mtime, which makes sure server exits
259 at polling cycle)
259 at polling cycle)
260
260
261 $ ls chgsock/server-*
261 $ ls chgsock/server-*
262 chgsock/server-* (glob)
262 chgsock/server-* (glob)
263 $ touch chgsock/server-*
263 $ touch chgsock/server-*
264 $ sleep 2
264 $ sleep 2
265 $ ls chgsock/server-*
265 $ ls chgsock/server-*
266 chgsock/server-* (glob)
266 chgsock/server-* (glob)
267
267
268 since no server is reachable from socket file, new server should be started:
268 since no server is reachable from socket file, new server should be started:
269 (this test makes sure that old server shut down automatically)
269 (this test makes sure that old server shut down automatically)
270
270
271 $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start'
271 $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start'
272 chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob)
272 chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob)
273
273
274 shut down servers and restore environment:
274 shut down servers and restore environment:
275
275
276 $ rm -R chgsock
276 $ rm -R chgsock
277 $ sleep 2
277 $ sleep 2
278 $ CHGSOCKNAME=$OLDCHGSOCKNAME
278 $ CHGSOCKNAME=$OLDCHGSOCKNAME
279 $ cd ..
279 $ cd ..
280
280
281 check that server events are recorded:
281 check that server events are recorded:
282
282
283 $ ls log
283 $ ls log
284 server.log
284 server.log
285 server.log.1
285 server.log.1
286
286
287 print only the last 10 lines, since we aren't sure how many records are
287 print only the last 10 lines, since we aren't sure how many records are
288 preserved (since setprocname isn't available on py3 and pure version,
288 preserved (since setprocname isn't available on py3 and pure version,
289 the 10th-most-recent line is different when using py3):
289 the 10th-most-recent line is different when using py3):
290
290
291 $ cat log/server.log.1 log/server.log | tail -10 | filterlog
291 $ cat log/server.log.1 log/server.log | tail -10 | filterlog
292 YYYY/MM/DD HH:MM:SS (PID)> confighash = ... mtimehash = ... (no-setprocname !)
292 YYYY/MM/DD HH:MM:SS (PID)> confighash = ... mtimehash = ... (no-setprocname !)
293 YYYY/MM/DD HH:MM:SS (PID)> forked worker process (pid=...)
293 YYYY/MM/DD HH:MM:SS (PID)> forked worker process (pid=...)
294 YYYY/MM/DD HH:MM:SS (PID)> setprocname: ... (setprocname !)
294 YYYY/MM/DD HH:MM:SS (PID)> setprocname: ... (setprocname !)
295 YYYY/MM/DD HH:MM:SS (PID)> received fds: ...
295 YYYY/MM/DD HH:MM:SS (PID)> received fds: ...
296 YYYY/MM/DD HH:MM:SS (PID)> chdir to '$TESTTMP/extreload'
296 YYYY/MM/DD HH:MM:SS (PID)> chdir to '$TESTTMP/extreload'
297 YYYY/MM/DD HH:MM:SS (PID)> setumask 18
297 YYYY/MM/DD HH:MM:SS (PID)> setumask 18
298 YYYY/MM/DD HH:MM:SS (PID)> setenv: ...
298 YYYY/MM/DD HH:MM:SS (PID)> setenv: ...
299 YYYY/MM/DD HH:MM:SS (PID)> confighash = ... mtimehash = ...
299 YYYY/MM/DD HH:MM:SS (PID)> confighash = ... mtimehash = ...
300 YYYY/MM/DD HH:MM:SS (PID)> validate: []
300 YYYY/MM/DD HH:MM:SS (PID)> validate: []
301 YYYY/MM/DD HH:MM:SS (PID)> worker process exited (pid=...)
301 YYYY/MM/DD HH:MM:SS (PID)> worker process exited (pid=...)
302 YYYY/MM/DD HH:MM:SS (PID)> $TESTTMP/extreload/chgsock/server-... is not owned, exiting.
302 YYYY/MM/DD HH:MM:SS (PID)> $TESTTMP/extreload/chgsock/server-... is not owned, exiting.
303
303
304 global data mutated by schems
304 global data mutated by schems
305 -----------------------------
305 -----------------------------
306
306
307 $ hg init schemes
307 $ hg init schemes
308 $ cd schemes
308 $ cd schemes
309
309
310 initial state
310 initial state
311
311
312 $ cat > .hg/hgrc <<'EOF'
312 $ cat > .hg/hgrc <<'EOF'
313 > [extensions]
313 > [extensions]
314 > schemes =
314 > schemes =
315 > [schemes]
315 > [schemes]
316 > foo = https://foo.example.org/
316 > foo = https://foo.example.org/
317 > EOF
317 > EOF
318 $ hg debugexpandscheme foo://expanded
318 $ hg debugexpandscheme foo://expanded
319 https://foo.example.org/expanded
319 https://foo.example.org/expanded
320 $ hg debugexpandscheme bar://unexpanded
320 $ hg debugexpandscheme bar://unexpanded
321 bar://unexpanded
321 bar://unexpanded
322
322
323 add bar
323 add bar
324
324
325 $ cat > .hg/hgrc <<'EOF'
325 $ cat > .hg/hgrc <<'EOF'
326 > [extensions]
326 > [extensions]
327 > schemes =
327 > schemes =
328 > [schemes]
328 > [schemes]
329 > foo = https://foo.example.org/
329 > foo = https://foo.example.org/
330 > bar = https://bar.example.org/
330 > bar = https://bar.example.org/
331 > EOF
331 > EOF
332 $ hg debugexpandscheme foo://expanded
332 $ hg debugexpandscheme foo://expanded
333 https://foo.example.org/expanded
333 https://foo.example.org/expanded
334 $ hg debugexpandscheme bar://expanded
334 $ hg debugexpandscheme bar://expanded
335 https://bar.example.org/expanded
335 https://bar.example.org/expanded
336
336
337 remove foo
337 remove foo
338
338
339 $ cat > .hg/hgrc <<'EOF'
339 $ cat > .hg/hgrc <<'EOF'
340 > [extensions]
340 > [extensions]
341 > schemes =
341 > schemes =
342 > [schemes]
342 > [schemes]
343 > bar = https://bar.example.org/
343 > bar = https://bar.example.org/
344 > EOF
344 > EOF
345 $ hg debugexpandscheme foo://unexpanded
345 $ hg debugexpandscheme foo://unexpanded
346 foo://unexpanded
346 foo://unexpanded
347 $ hg debugexpandscheme bar://expanded
347 $ hg debugexpandscheme bar://expanded
348 https://bar.example.org/expanded
348 https://bar.example.org/expanded
349
349
350 $ cd ..
350 $ cd ..
351
351
352 repository cache
352 repository cache
353 ----------------
353 ----------------
354
354
355 $ rm log/server.log*
356 $ cp $HGRCPATH.unconfigured $HGRCPATH
355 $ cp $HGRCPATH.unconfigured $HGRCPATH
357 $ cat <<'EOF' >> $HGRCPATH
356 $ cat <<'EOF' >> $HGRCPATH
358 > [cmdserver]
357 > [cmdserver]
359 > log = $TESTTMP/log/server.log
358 > log = $TESTTMP/log/server-cached.log
360 > max-repo-cache = 1
359 > max-repo-cache = 1
361 > track-log = command, repocache
360 > track-log = command, repocache
362 > EOF
361 > EOF
363
362
364 isolate socket directory for stable result:
363 isolate socket directory for stable result:
365
364
366 $ OLDCHGSOCKNAME=$CHGSOCKNAME
365 $ OLDCHGSOCKNAME=$CHGSOCKNAME
367 $ mkdir chgsock
366 $ mkdir chgsock
368 $ CHGSOCKNAME=`pwd`/chgsock/server
367 $ CHGSOCKNAME=`pwd`/chgsock/server
369
368
370 create empty repo and cache it:
369 create empty repo and cache it:
371
370
372 $ hg init cached
371 $ hg init cached
373 $ hg id -R cached
372 $ hg id -R cached
374 000000000000 tip
373 000000000000 tip
375 $ sleep 1
374 $ sleep 1
376
375
377 modify repo (and cache will be invalidated):
376 modify repo (and cache will be invalidated):
378
377
379 $ touch cached/a
378 $ touch cached/a
380 $ hg ci -R cached -Am 'add a'
379 $ hg ci -R cached -Am 'add a'
381 adding a
380 adding a
382 $ sleep 1
381 $ sleep 1
383
382
384 read cached repo:
383 read cached repo:
385
384
386 $ hg log -R cached
385 $ hg log -R cached
387 changeset: 0:ac82d8b1f7c4
386 changeset: 0:ac82d8b1f7c4
388 tag: tip
387 tag: tip
389 user: test
388 user: test
390 date: Thu Jan 01 00:00:00 1970 +0000
389 date: Thu Jan 01 00:00:00 1970 +0000
391 summary: add a
390 summary: add a
392
391
393 $ sleep 1
392 $ sleep 1
394
393
395 discard cached from LRU cache:
394 discard cached from LRU cache:
396
395
397 $ hg clone cached cached2
396 $ hg clone cached cached2
398 updating to branch default
397 updating to branch default
399 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
398 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
400 $ hg id -R cached2
399 $ hg id -R cached2
401 ac82d8b1f7c4 tip
400 ac82d8b1f7c4 tip
402 $ sleep 1
401 $ sleep 1
403
402
404 read uncached repo:
403 read uncached repo:
405
404
406 $ hg log -R cached
405 $ hg log -R cached
407 changeset: 0:ac82d8b1f7c4
406 changeset: 0:ac82d8b1f7c4
408 tag: tip
407 tag: tip
409 user: test
408 user: test
410 date: Thu Jan 01 00:00:00 1970 +0000
409 date: Thu Jan 01 00:00:00 1970 +0000
411 summary: add a
410 summary: add a
412
411
413 $ sleep 1
412 $ sleep 1
414
413
415 shut down servers and restore environment:
414 shut down servers and restore environment:
416
415
417 $ rm -R chgsock
416 $ rm -R chgsock
418 $ sleep 2
417 $ sleep 2
419 $ CHGSOCKNAME=$OLDCHGSOCKNAME
418 $ CHGSOCKNAME=$OLDCHGSOCKNAME
420
419
421 check server log:
420 check server log:
422
421
423 $ cat log/server.log | filterlog
422 $ cat log/server-cached.log | filterlog
424 YYYY/MM/DD HH:MM:SS (PID)> worker process exited (pid=...)
425 YYYY/MM/DD HH:MM:SS (PID)> worker process exited (pid=...) (?)
426 YYYY/MM/DD HH:MM:SS (PID)> init cached
423 YYYY/MM/DD HH:MM:SS (PID)> init cached
427 YYYY/MM/DD HH:MM:SS (PID)> id -R cached
424 YYYY/MM/DD HH:MM:SS (PID)> id -R cached
428 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
425 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
429 YYYY/MM/DD HH:MM:SS (PID)> repo from cache: $TESTTMP/cached
426 YYYY/MM/DD HH:MM:SS (PID)> repo from cache: $TESTTMP/cached
430 YYYY/MM/DD HH:MM:SS (PID)> ci -R cached -Am 'add a'
427 YYYY/MM/DD HH:MM:SS (PID)> ci -R cached -Am 'add a'
431 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
428 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
432 YYYY/MM/DD HH:MM:SS (PID)> repo from cache: $TESTTMP/cached
429 YYYY/MM/DD HH:MM:SS (PID)> repo from cache: $TESTTMP/cached
433 YYYY/MM/DD HH:MM:SS (PID)> log -R cached
430 YYYY/MM/DD HH:MM:SS (PID)> log -R cached
434 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
431 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
435 YYYY/MM/DD HH:MM:SS (PID)> clone cached cached2
432 YYYY/MM/DD HH:MM:SS (PID)> clone cached cached2
436 YYYY/MM/DD HH:MM:SS (PID)> id -R cached2
433 YYYY/MM/DD HH:MM:SS (PID)> id -R cached2
437 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached2 (in ...s)
434 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached2 (in ...s)
438 YYYY/MM/DD HH:MM:SS (PID)> log -R cached
435 YYYY/MM/DD HH:MM:SS (PID)> log -R cached
439 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
436 YYYY/MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in ...s)
440
437
441 Test that -R is interpreted relative to --cwd.
438 Test that -R is interpreted relative to --cwd.
442
439
443 $ hg init repo1
440 $ hg init repo1
444 $ mkdir -p a/b
441 $ mkdir -p a/b
445 $ hg init a/b/repo2
442 $ hg init a/b/repo2
446 $ printf "[alias]\ntest=repo1\n" >> repo1/.hg/hgrc
443 $ printf "[alias]\ntest=repo1\n" >> repo1/.hg/hgrc
447 $ printf "[alias]\ntest=repo2\n" >> a/b/repo2/.hg/hgrc
444 $ printf "[alias]\ntest=repo2\n" >> a/b/repo2/.hg/hgrc
448 $ cd a
445 $ cd a
449 $ chg --cwd .. -R repo1 show alias.test
446 $ chg --cwd .. -R repo1 show alias.test
450 repo1
447 repo1
451 $ chg --cwd . -R b/repo2 show alias.test
448 $ chg --cwd . -R b/repo2 show alias.test
452 repo2
449 repo2
453 $ cd ..
450 $ cd ..
454
451
455 Test that chg works (sets to the user's actual LC_CTYPE) even when python
452 Test that chg works (sets to the user's actual LC_CTYPE) even when python
456 "coerces" the locale (py3.7+)
453 "coerces" the locale (py3.7+)
457
454
458 $ cat > $TESTTMP/debugenv.py <<EOF
455 $ cat > $TESTTMP/debugenv.py <<EOF
459 > from mercurial import encoding
456 > from mercurial import encoding
460 > from mercurial import registrar
457 > from mercurial import registrar
461 > cmdtable = {}
458 > cmdtable = {}
462 > command = registrar.command(cmdtable)
459 > command = registrar.command(cmdtable)
463 > @command(b'debugenv', [], b'', norepo=True)
460 > @command(b'debugenv', [], b'', norepo=True)
464 > def debugenv(ui):
461 > def debugenv(ui):
465 > for k in [b'LC_ALL', b'LC_CTYPE', b'LANG']:
462 > for k in [b'LC_ALL', b'LC_CTYPE', b'LANG']:
466 > v = encoding.environ.get(k)
463 > v = encoding.environ.get(k)
467 > if v is not None:
464 > if v is not None:
468 > ui.write(b'%s=%s\n' % (k, encoding.environ[k]))
465 > ui.write(b'%s=%s\n' % (k, encoding.environ[k]))
469 > EOF
466 > EOF
470 (hg keeps python's modified LC_CTYPE, chg doesn't)
467 (hg keeps python's modified LC_CTYPE, chg doesn't)
471 $ (unset LC_ALL; unset LANG; LC_CTYPE= "$CHGHG" \
468 $ (unset LC_ALL; unset LANG; LC_CTYPE= "$CHGHG" \
472 > --config extensions.debugenv=$TESTTMP/debugenv.py debugenv)
469 > --config extensions.debugenv=$TESTTMP/debugenv.py debugenv)
473 LC_CTYPE=C.UTF-8 (py37 !)
470 LC_CTYPE=C.UTF-8 (py37 !)
474 LC_CTYPE= (no-py37 !)
471 LC_CTYPE= (no-py37 !)
475 $ (unset LC_ALL; unset LANG; LC_CTYPE= chg \
472 $ (unset LC_ALL; unset LANG; LC_CTYPE= chg \
476 > --config extensions.debugenv=$TESTTMP/debugenv.py debugenv)
473 > --config extensions.debugenv=$TESTTMP/debugenv.py debugenv)
477 LC_CTYPE=
474 LC_CTYPE=
478 $ (unset LC_ALL; unset LANG; LC_CTYPE=unsupported_value chg \
475 $ (unset LC_ALL; unset LANG; LC_CTYPE=unsupported_value chg \
479 > --config extensions.debugenv=$TESTTMP/debugenv.py debugenv)
476 > --config extensions.debugenv=$TESTTMP/debugenv.py debugenv)
480 *cannot change locale* (glob) (?)
477 *cannot change locale* (glob) (?)
481 LC_CTYPE=unsupported_value
478 LC_CTYPE=unsupported_value
482 $ (unset LC_ALL; unset LANG; LC_CTYPE= chg \
479 $ (unset LC_ALL; unset LANG; LC_CTYPE= chg \
483 > --config extensions.debugenv=$TESTTMP/debugenv.py debugenv)
480 > --config extensions.debugenv=$TESTTMP/debugenv.py debugenv)
484 LC_CTYPE=
481 LC_CTYPE=
485 $ LANG= LC_ALL= LC_CTYPE= chg \
482 $ LANG= LC_ALL= LC_CTYPE= chg \
486 > --config extensions.debugenv=$TESTTMP/debugenv.py debugenv
483 > --config extensions.debugenv=$TESTTMP/debugenv.py debugenv
487 LC_ALL=
484 LC_ALL=
488 LC_CTYPE=
485 LC_CTYPE=
489 LANG=
486 LANG=
490
487
491 Profiling isn't permanently enabled or carried over between chg invocations that
488 Profiling isn't permanently enabled or carried over between chg invocations that
492 share the same server
489 share the same server
493 $ cp $HGRCPATH.orig $HGRCPATH
490 $ cp $HGRCPATH.orig $HGRCPATH
494 $ hg init $TESTTMP/profiling
491 $ hg init $TESTTMP/profiling
495 $ cd $TESTTMP/profiling
492 $ cd $TESTTMP/profiling
496 $ filteredchg() {
493 $ filteredchg() {
497 > CHGDEBUG=1 chg "$@" 2>&1 | sed -rn 's_^No samples recorded.*$_Sample count: 0_; /Sample count/p; /start cmdserver/p'
494 > CHGDEBUG=1 chg "$@" 2>&1 | sed -rn 's_^No samples recorded.*$_Sample count: 0_; /Sample count/p; /start cmdserver/p'
498 > }
495 > }
499 $ newchg() {
496 $ newchg() {
500 > chg --kill-chg-daemon
497 > chg --kill-chg-daemon
501 > filteredchg "$@" | egrep -v 'start cmdserver' || true
498 > filteredchg "$@" | egrep -v 'start cmdserver' || true
502 > }
499 > }
503 (--profile isn't permanently on just because it was specified when chg was
500 (--profile isn't permanently on just because it was specified when chg was
504 started)
501 started)
505 $ newchg log -r . --profile
502 $ newchg log -r . --profile
506 Sample count: * (glob)
503 Sample count: * (glob)
507 $ filteredchg log -r .
504 $ filteredchg log -r .
508 (enabling profiling via config works, even on the first chg command that starts
505 (enabling profiling via config works, even on the first chg command that starts
509 a cmdserver)
506 a cmdserver)
510 $ cat >> $HGRCPATH <<EOF
507 $ cat >> $HGRCPATH <<EOF
511 > [profiling]
508 > [profiling]
512 > type=stat
509 > type=stat
513 > enabled=1
510 > enabled=1
514 > EOF
511 > EOF
515 $ newchg log -r .
512 $ newchg log -r .
516 Sample count: * (glob)
513 Sample count: * (glob)
517 $ filteredchg log -r .
514 $ filteredchg log -r .
518 Sample count: * (glob)
515 Sample count: * (glob)
519 (test that we aren't accumulating more and more samples each run)
516 (test that we aren't accumulating more and more samples each run)
520 $ cat > $TESTTMP/debugsleep.py <<EOF
517 $ cat > $TESTTMP/debugsleep.py <<EOF
521 > import time
518 > import time
522 > from mercurial import registrar
519 > from mercurial import registrar
523 > cmdtable = {}
520 > cmdtable = {}
524 > command = registrar.command(cmdtable)
521 > command = registrar.command(cmdtable)
525 > @command(b'debugsleep', [], b'', norepo=True)
522 > @command(b'debugsleep', [], b'', norepo=True)
526 > def debugsleep(ui):
523 > def debugsleep(ui):
527 > start = time.time()
524 > start = time.time()
528 > x = 0
525 > x = 0
529 > while time.time() < start + 0.5:
526 > while time.time() < start + 0.5:
530 > time.sleep(.1)
527 > time.sleep(.1)
531 > x += 1
528 > x += 1
532 > ui.status(b'%d debugsleep iterations in %.03fs\n' % (x, time.time() - start))
529 > ui.status(b'%d debugsleep iterations in %.03fs\n' % (x, time.time() - start))
533 > EOF
530 > EOF
534 $ cat >> $HGRCPATH <<EOF
531 $ cat >> $HGRCPATH <<EOF
535 > [extensions]
532 > [extensions]
536 > debugsleep = $TESTTMP/debugsleep.py
533 > debugsleep = $TESTTMP/debugsleep.py
537 > EOF
534 > EOF
538 $ newchg debugsleep > run_1
535 $ newchg debugsleep > run_1
539 $ filteredchg debugsleep > run_2
536 $ filteredchg debugsleep > run_2
540 $ filteredchg debugsleep > run_3
537 $ filteredchg debugsleep > run_3
541 $ filteredchg debugsleep > run_4
538 $ filteredchg debugsleep > run_4
542 FIXME: Run 4 should not be >3x Run 1's number of samples.
539 FIXME: Run 4 should not be >3x Run 1's number of samples.
543 $ "$PYTHON" <<EOF
540 $ "$PYTHON" <<EOF
544 > r1 = int(open("run_1", "r").read().split()[-1])
541 > r1 = int(open("run_1", "r").read().split()[-1])
545 > r4 = int(open("run_4", "r").read().split()[-1])
542 > r4 = int(open("run_4", "r").read().split()[-1])
546 > print("Run 1: %d samples\nRun 4: %d samples\nRun 4 > 3 * Run 1: %s" %
543 > print("Run 1: %d samples\nRun 4: %d samples\nRun 4 > 3 * Run 1: %s" %
547 > (r1, r4, r4 > (r1 * 3)))
544 > (r1, r4, r4 > (r1 * 3)))
548 > EOF
545 > EOF
549 Run 1: * samples (glob)
546 Run 1: * samples (glob)
550 Run 4: * samples (glob)
547 Run 4: * samples (glob)
551 Run 4 > 3 * Run 1: False
548 Run 4 > 3 * Run 1: False
552 (Disabling with --no-profile on the commandline still works, but isn't permanent)
549 (Disabling with --no-profile on the commandline still works, but isn't permanent)
553 $ newchg log -r . --no-profile
550 $ newchg log -r . --no-profile
554 $ filteredchg log -r .
551 $ filteredchg log -r .
555 Sample count: * (glob)
552 Sample count: * (glob)
556 $ filteredchg log -r . --no-profile
553 $ filteredchg log -r . --no-profile
557 $ filteredchg log -r .
554 $ filteredchg log -r .
558 Sample count: * (glob)
555 Sample count: * (glob)
General Comments 0
You need to be logged in to leave comments. Login now