Mercurial > hg
annotate tests/test-chg.t @ 40894:57e4150fb15b
test: enable sparse-revlog for test-init.t
We are about to enable sparse-revlog globally. To help with reviewing the
tests change, we isolate them in individual changesets.
Differential Revision: https://phab.mercurial-scm.org/D5321
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Mon, 12 Nov 2018 01:06:10 +0100 |
parents | 25e9089c7686 |
children | 042ed354b9eb |
rev | line source |
---|---|
29274
148a9a5379f0
test-chg: run only with chg
Yuya Nishihara <yuya@tcha.org>
parents:
29088
diff
changeset
|
1 #require chg |
148a9a5379f0
test-chg: run only with chg
Yuya Nishihara <yuya@tcha.org>
parents:
29088
diff
changeset
|
2 |
40827
d23fd01cc115
commandserver: add config knob for various logging options
Yuya Nishihara <yuya@tcha.org>
parents:
40826
diff
changeset
|
3 $ mkdir log |
40826
1617aa916d88
commandserver: expand log path for convenience
Yuya Nishihara <yuya@tcha.org>
parents:
40825
diff
changeset
|
4 $ cat <<'EOF' >> $HGRCPATH |
40825
eaabcb689747
commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents:
39707
diff
changeset
|
5 > [cmdserver] |
40827
d23fd01cc115
commandserver: add config knob for various logging options
Yuya Nishihara <yuya@tcha.org>
parents:
40826
diff
changeset
|
6 > log = $TESTTMP/log/server.log |
d23fd01cc115
commandserver: add config knob for various logging options
Yuya Nishihara <yuya@tcha.org>
parents:
40826
diff
changeset
|
7 > max-log-files = 1 |
d23fd01cc115
commandserver: add config knob for various logging options
Yuya Nishihara <yuya@tcha.org>
parents:
40826
diff
changeset
|
8 > max-log-size = 10 kB |
40825
eaabcb689747
commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents:
39707
diff
changeset
|
9 > EOF |
29275
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
10 $ cp $HGRCPATH $HGRCPATH.orig |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
11 |
40825
eaabcb689747
commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents:
39707
diff
changeset
|
12 $ filterlog () { |
eaabcb689747
commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents:
39707
diff
changeset
|
13 > sed -e 's!^[0-9/]* [0-9:]* ([0-9]*)>!YYYY/MM/DD HH:MM:SS (PID)>!' \ |
eaabcb689747
commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents:
39707
diff
changeset
|
14 > -e 's!\(setprocname\|received fds\|setenv\): .*!\1: ...!' \ |
eaabcb689747
commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents:
39707
diff
changeset
|
15 > -e 's!\(confighash\|mtimehash\) = [0-9a-f]*!\1 = ...!g' \ |
eaabcb689747
commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents:
39707
diff
changeset
|
16 > -e 's!\(pid\)=[0-9]*!\1=...!g' \ |
eaabcb689747
commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents:
39707
diff
changeset
|
17 > -e 's!\(/server-\)[0-9a-f]*!\1...!g' |
eaabcb689747
commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents:
39707
diff
changeset
|
18 > } |
eaabcb689747
commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents:
39707
diff
changeset
|
19 |
28516
3bf2892f685f
chgserver: handle ParseError during validate
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
20 init repo |
3bf2892f685f
chgserver: handle ParseError during validate
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
21 |
29274
148a9a5379f0
test-chg: run only with chg
Yuya Nishihara <yuya@tcha.org>
parents:
29088
diff
changeset
|
22 $ chg init foo |
28516
3bf2892f685f
chgserver: handle ParseError during validate
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
23 $ cd foo |
3bf2892f685f
chgserver: handle ParseError during validate
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
24 |
3bf2892f685f
chgserver: handle ParseError during validate
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
25 ill-formed config |
3bf2892f685f
chgserver: handle ParseError during validate
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
26 |
29274
148a9a5379f0
test-chg: run only with chg
Yuya Nishihara <yuya@tcha.org>
parents:
29088
diff
changeset
|
27 $ chg status |
28516
3bf2892f685f
chgserver: handle ParseError during validate
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
28 $ echo '=brokenconfig' >> $HGRCPATH |
29274
148a9a5379f0
test-chg: run only with chg
Yuya Nishihara <yuya@tcha.org>
parents:
29088
diff
changeset
|
29 $ chg status |
28516
3bf2892f685f
chgserver: handle ParseError during validate
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
30 hg: parse error at * (glob) |
3bf2892f685f
chgserver: handle ParseError during validate
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
31 [255] |
29088 | 32 |
29275
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
33 $ cp $HGRCPATH.orig $HGRCPATH |
30677 | 34 |
35 long socket path | |
36 | |
37 $ sockpath=$TESTTMP/this/path/should/be/longer/than/one-hundred-and-seven/characters/where/107/is/the/typical/size/limit/of/unix-domain-socket | |
38 $ mkdir -p $sockpath | |
39 $ bakchgsockname=$CHGSOCKNAME | |
40 $ CHGSOCKNAME=$sockpath/server | |
41 $ export CHGSOCKNAME | |
42 $ chg root | |
43 $TESTTMP/foo | |
44 $ rm -rf $sockpath | |
45 $ CHGSOCKNAME=$bakchgsockname | |
46 $ export CHGSOCKNAME | |
47 | |
29275
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
48 $ cd .. |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
49 |
31107
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
50 editor |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
51 ------ |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
52 |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
53 $ cat >> pushbuffer.py <<EOF |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
54 > def reposetup(ui, repo): |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
55 > repo.ui.pushbuffer(subproc=True) |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
56 > EOF |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
57 |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
58 $ chg init editor |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
59 $ cd editor |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
60 |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
61 by default, system() should be redirected to the client: |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
62 |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
63 $ touch foo |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
64 $ CHGDEBUG= HGEDITOR=cat chg ci -Am channeled --edit 2>&1 \ |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
65 > | egrep "HG:|run 'cat" |
34309
b94db1780365
chg: show timestamp with debug messages
Jun Wu <quark@fb.com>
parents:
33949
diff
changeset
|
66 chg: debug: * run 'cat "*"' at '$TESTTMP/editor' (glob) |
31107
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
67 HG: Enter commit message. Lines beginning with 'HG:' are removed. |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
68 HG: Leave message empty to abort commit. |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
69 HG: -- |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
70 HG: user: test |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
71 HG: branch 'default' |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
72 HG: added foo |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
73 |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
74 but no redirection should be made if output is captured: |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
75 |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
76 $ touch bar |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
77 $ CHGDEBUG= HGEDITOR=cat chg ci -Am bufferred --edit \ |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
78 > --config extensions.pushbuffer="$TESTTMP/pushbuffer.py" 2>&1 \ |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
79 > | egrep "HG:|run 'cat" |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
80 [1] |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
81 |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
82 check that commit commands succeeded: |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
83 |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
84 $ hg log -T '{rev}:{desc}\n' |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
85 1:bufferred |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
86 0:channeled |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
87 |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
88 $ cd .. |
fbce78c58f1e
chg: refactor ui.system() to be partly overridden
Yuya Nishihara <yuya@tcha.org>
parents:
30847
diff
changeset
|
89 |
30847
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
90 pager |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
91 ----- |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
92 |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
93 $ cat >> fakepager.py <<EOF |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
94 > import sys |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
95 > for line in sys.stdin: |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
96 > sys.stdout.write('paged! %r\n' % line) |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
97 > EOF |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
98 |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
99 enable pager extension globally, but spawns the master server with no tty: |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
100 |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
101 $ chg init pager |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
102 $ cd pager |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
103 $ cat >> $HGRCPATH <<EOF |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
104 > [extensions] |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
105 > pager = |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
106 > [pager] |
39707
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
34309
diff
changeset
|
107 > pager = "$PYTHON" $TESTTMP/fakepager.py |
30847
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
108 > EOF |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
109 $ chg version > /dev/null |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
110 $ touch foo |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
111 $ chg ci -qAm foo |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
112 |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
113 pager should be enabled if the attached client has a tty: |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
114 |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
115 $ chg log -l1 -q --config ui.formatted=True |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
116 paged! '0:1f7b0de80e11\n' |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
117 $ chg log -l1 -q --config ui.formatted=False |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
118 0:1f7b0de80e11 |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
119 |
31890 | 120 chg waits for pager if runcommand raises |
121 | |
122 $ cat > $TESTTMP/crash.py <<EOF | |
32337
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31890
diff
changeset
|
123 > from mercurial import registrar |
31890 | 124 > cmdtable = {} |
32337
46ba2cdda476
registrar: move cmdutil.command to registrar module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31890
diff
changeset
|
125 > command = registrar.command(cmdtable) |
33097
fce4ed2912bb
py3: make sure commands name are bytes in tests
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32940
diff
changeset
|
126 > @command(b'crash') |
31890 | 127 > def pagercrash(ui, repo, *pats, **opts): |
128 > ui.write('going to crash\n') | |
129 > raise Exception('.') | |
130 > EOF | |
131 | |
132 $ cat > $TESTTMP/fakepager.py <<EOF | |
33949
0d0cec9602c3
tests: update test-chg to pass our import checker
Augie Fackler <raf@durin42.com>
parents:
33097
diff
changeset
|
133 > from __future__ import absolute_import |
0d0cec9602c3
tests: update test-chg to pass our import checker
Augie Fackler <raf@durin42.com>
parents:
33097
diff
changeset
|
134 > import sys |
0d0cec9602c3
tests: update test-chg to pass our import checker
Augie Fackler <raf@durin42.com>
parents:
33097
diff
changeset
|
135 > import time |
31890 | 136 > for line in iter(sys.stdin.readline, ''): |
137 > if 'crash' in line: # only interested in lines containing 'crash' | |
138 > # if chg exits when pager is sleeping (incorrectly), the output | |
139 > # will be captured by the next test case | |
140 > time.sleep(1) | |
141 > sys.stdout.write('crash-pager: %s' % line) | |
142 > EOF | |
143 | |
144 $ cat >> .hg/hgrc <<EOF | |
145 > [extensions] | |
146 > crash = $TESTTMP/crash.py | |
147 > EOF | |
148 | |
149 $ chg crash --pager=on --config ui.formatted=True 2>/dev/null | |
150 crash-pager: going to crash | |
151 [255] | |
152 | |
30847
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
153 $ cd .. |
e12553cfd0a4
pager: wrap _runcommand() no matter if stdout is redirected
Yuya Nishihara <yuya@tcha.org>
parents:
30677
diff
changeset
|
154 |
29275
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
155 server lifecycle |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
156 ---------------- |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
157 |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
158 chg server should be restarted on code change, and old server will shut down |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
159 automatically. In this test, we use the following time parameters: |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
160 |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
161 - "sleep 1" to make mtime different |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
162 - "sleep 2" to notice mtime change (polling interval is 1 sec) |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
163 |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
164 set up repository with an extension: |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
165 |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
166 $ chg init extreload |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
167 $ cd extreload |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
168 $ touch dummyext.py |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
169 $ cat <<EOF >> .hg/hgrc |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
170 > [extensions] |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
171 > dummyext = dummyext.py |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
172 > EOF |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
173 |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
174 isolate socket directory for stable result: |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
175 |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
176 $ OLDCHGSOCKNAME=$CHGSOCKNAME |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
177 $ mkdir chgsock |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
178 $ CHGSOCKNAME=`pwd`/chgsock/server |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
179 |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
180 warm up server: |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
181 |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
182 $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start' |
34309
b94db1780365
chg: show timestamp with debug messages
Jun Wu <quark@fb.com>
parents:
33949
diff
changeset
|
183 chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob) |
29275
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
184 |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
185 new server should be started if extension modified: |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
186 |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
187 $ sleep 1 |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
188 $ touch dummyext.py |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
189 $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start' |
34309
b94db1780365
chg: show timestamp with debug messages
Jun Wu <quark@fb.com>
parents:
33949
diff
changeset
|
190 chg: debug: * instruction: unlink $TESTTMP/extreload/chgsock/server-* (glob) |
b94db1780365
chg: show timestamp with debug messages
Jun Wu <quark@fb.com>
parents:
33949
diff
changeset
|
191 chg: debug: * instruction: reconnect (glob) |
b94db1780365
chg: show timestamp with debug messages
Jun Wu <quark@fb.com>
parents:
33949
diff
changeset
|
192 chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob) |
29275
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
193 |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
194 old server will shut down, while new server should still be reachable: |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
195 |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
196 $ sleep 2 |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
197 $ CHGDEBUG= chg log 2>&1 | (egrep 'instruction|start' || true) |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
198 |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
199 socket file should never be unlinked by old server: |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
200 (simulates unowned socket by updating mtime, which makes sure server exits |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
201 at polling cycle) |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
202 |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
203 $ ls chgsock/server-* |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
204 chgsock/server-* (glob) |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
205 $ touch chgsock/server-* |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
206 $ sleep 2 |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
207 $ ls chgsock/server-* |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
208 chgsock/server-* (glob) |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
209 |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
210 since no server is reachable from socket file, new server should be started: |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
211 (this test makes sure that old server shut down automatically) |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
212 |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
213 $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start' |
34309
b94db1780365
chg: show timestamp with debug messages
Jun Wu <quark@fb.com>
parents:
33949
diff
changeset
|
214 chg: debug: * start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob) |
29275
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
215 |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
216 shut down servers and restore environment: |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
217 |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
218 $ rm -R chgsock |
40825
eaabcb689747
commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents:
39707
diff
changeset
|
219 $ sleep 2 |
29275
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
220 $ CHGSOCKNAME=$OLDCHGSOCKNAME |
e53f961ac75f
test-chg: add basic tests for server lifecycle
Yuya Nishihara <yuya@tcha.org>
parents:
29274
diff
changeset
|
221 $ cd .. |
40825
eaabcb689747
commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents:
39707
diff
changeset
|
222 |
eaabcb689747
commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents:
39707
diff
changeset
|
223 check that server events are recorded: |
eaabcb689747
commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents:
39707
diff
changeset
|
224 |
40827
d23fd01cc115
commandserver: add config knob for various logging options
Yuya Nishihara <yuya@tcha.org>
parents:
40826
diff
changeset
|
225 $ ls log |
d23fd01cc115
commandserver: add config knob for various logging options
Yuya Nishihara <yuya@tcha.org>
parents:
40826
diff
changeset
|
226 server.log |
d23fd01cc115
commandserver: add config knob for various logging options
Yuya Nishihara <yuya@tcha.org>
parents:
40826
diff
changeset
|
227 server.log.1 |
d23fd01cc115
commandserver: add config knob for various logging options
Yuya Nishihara <yuya@tcha.org>
parents:
40826
diff
changeset
|
228 |
d23fd01cc115
commandserver: add config knob for various logging options
Yuya Nishihara <yuya@tcha.org>
parents:
40826
diff
changeset
|
229 print only the last 10 lines, since we aren't sure how many records are |
d23fd01cc115
commandserver: add config knob for various logging options
Yuya Nishihara <yuya@tcha.org>
parents:
40826
diff
changeset
|
230 preserved: |
d23fd01cc115
commandserver: add config knob for various logging options
Yuya Nishihara <yuya@tcha.org>
parents:
40826
diff
changeset
|
231 |
d23fd01cc115
commandserver: add config knob for various logging options
Yuya Nishihara <yuya@tcha.org>
parents:
40826
diff
changeset
|
232 $ cat log/server.log.1 log/server.log | tail -10 | filterlog |
40828
25e9089c7686
commandserver: turn server debug messages into logs
Yuya Nishihara <yuya@tcha.org>
parents:
40827
diff
changeset
|
233 YYYY/MM/DD HH:MM:SS (PID)> forked worker process (pid=...) |
40825
eaabcb689747
commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents:
39707
diff
changeset
|
234 YYYY/MM/DD HH:MM:SS (PID)> setprocname: ... |
eaabcb689747
commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents:
39707
diff
changeset
|
235 YYYY/MM/DD HH:MM:SS (PID)> received fds: ... |
eaabcb689747
commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents:
39707
diff
changeset
|
236 YYYY/MM/DD HH:MM:SS (PID)> chdir to '$TESTTMP/extreload' |
eaabcb689747
commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents:
39707
diff
changeset
|
237 YYYY/MM/DD HH:MM:SS (PID)> setumask 18 |
eaabcb689747
commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents:
39707
diff
changeset
|
238 YYYY/MM/DD HH:MM:SS (PID)> setenv: ... |
eaabcb689747
commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents:
39707
diff
changeset
|
239 YYYY/MM/DD HH:MM:SS (PID)> confighash = ... mtimehash = ... |
eaabcb689747
commandserver: switch logging facility to ui.log() interface
Yuya Nishihara <yuya@tcha.org>
parents:
39707
diff
changeset
|
240 YYYY/MM/DD HH:MM:SS (PID)> validate: [] |
40828
25e9089c7686
commandserver: turn server debug messages into logs
Yuya Nishihara <yuya@tcha.org>
parents:
40827
diff
changeset
|
241 YYYY/MM/DD HH:MM:SS (PID)> worker process exited (pid=...) |
25e9089c7686
commandserver: turn server debug messages into logs
Yuya Nishihara <yuya@tcha.org>
parents:
40827
diff
changeset
|
242 YYYY/MM/DD HH:MM:SS (PID)> $TESTTMP/extreload/chgsock/server-... is not owned, exiting. |