##// END OF EJS Templates
test-chg: add basic tests for server lifecycle...
Yuya Nishihara -
r29275:e53f961a default
parent child Browse files
Show More
@@ -1,5 +1,7 b''
1 #require chg
1 #require chg
2
2
3 $ cp $HGRCPATH $HGRCPATH.orig
4
3 init repo
5 init repo
4
6
5 $ chg init foo
7 $ chg init foo
@@ -32,3 +34,73 b' alias having an environment variable and'
32 P1
34 P1
33 $ A=2 chg printa
35 $ A=2 chg printa
34 P2
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