##// END OF EJS Templates
test-chg: add basic tests for server lifecycle...
Yuya Nishihara -
r29275:e53f961a default
parent child Browse files
Show More
@@ -1,34 +1,106 b''
1 1 #require chg
2 2
3 $ cp $HGRCPATH $HGRCPATH.orig
4
3 5 init repo
4 6
5 7 $ chg init foo
6 8 $ cd foo
7 9
8 10 ill-formed config
9 11
10 12 $ chg status
11 13 $ echo '=brokenconfig' >> $HGRCPATH
12 14 $ chg status
13 15 hg: parse error at * (glob)
14 16 [255]
15 17
16 18 alias having an environment variable and set to use pager
17 19
18 20 $ rm $HGRCPATH
19 21 $ cat >> $HGRCPATH <<'EOF'
20 22 > [ui]
21 23 > formatted = yes
22 24 > [extensions]
23 25 > pager =
24 26 > [pager]
25 27 > pager = sed -e 's/^/P/'
26 28 > attend = printa
27 29 > [alias]
28 30 > printa = log -T "$A\n" -r 0
29 31 > EOF
30 32
31 33 $ A=1 chg printa
32 34 P1
33 35 $ A=2 chg printa
34 36 P2
37
38 $ cp $HGRCPATH.orig $HGRCPATH
39 $ cd ..
40
41 server lifecycle
42 ----------------
43
44 chg server should be restarted on code change, and old server will shut down
45 automatically. In this test, we use the following time parameters:
46
47 - "sleep 1" to make mtime different
48 - "sleep 2" to notice mtime change (polling interval is 1 sec)
49
50 set up repository with an extension:
51
52 $ chg init extreload
53 $ cd extreload
54 $ touch dummyext.py
55 $ cat <<EOF >> .hg/hgrc
56 > [extensions]
57 > dummyext = dummyext.py
58 > EOF
59
60 isolate socket directory for stable result:
61
62 $ OLDCHGSOCKNAME=$CHGSOCKNAME
63 $ mkdir chgsock
64 $ CHGSOCKNAME=`pwd`/chgsock/server
65
66 warm up server:
67
68 $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start'
69 chg: debug: start cmdserver at $TESTTMP/extreload/chgsock/server
70
71 new server should be started if extension modified:
72
73 $ sleep 1
74 $ touch dummyext.py
75 $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start'
76 chg: debug: instruction: unlink $TESTTMP/extreload/chgsock/server-* (glob)
77 chg: debug: instruction: reconnect
78 chg: debug: start cmdserver at $TESTTMP/extreload/chgsock/server
79
80 old server will shut down, while new server should still be reachable:
81
82 $ sleep 2
83 $ CHGDEBUG= chg log 2>&1 | (egrep 'instruction|start' || true)
84
85 socket file should never be unlinked by old server:
86 (simulates unowned socket by updating mtime, which makes sure server exits
87 at polling cycle)
88
89 $ ls chgsock/server-*
90 chgsock/server-* (glob)
91 $ touch chgsock/server-*
92 $ sleep 2
93 $ ls chgsock/server-*
94 chgsock/server-* (glob)
95
96 since no server is reachable from socket file, new server should be started:
97 (this test makes sure that old server shut down automatically)
98
99 $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start'
100 chg: debug: start cmdserver at $TESTTMP/extreload/chgsock/server
101
102 shut down servers and restore environment:
103
104 $ rm -R chgsock
105 $ CHGSOCKNAME=$OLDCHGSOCKNAME
106 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now