tests: Remove daemon tests that have been skipped forever.
[openvswitch] / tests / daemon.at
1 AT_BANNER([daemon unit tests - C])
2
3 AT_SETUP([daemon])
4 AT_SKIP_IF([test "$CHECK_LCOV" = true]) # lcov wrapper make pids differ
5 OVSDB_INIT([db])
6 AT_CAPTURE_FILE([pid])
7 AT_CAPTURE_FILE([expected])
8 # Start the daemon and wait for the pidfile to get created
9 # and that its contents are the correct pid.
10 AT_CHECK([ovsdb-server --pidfile="`pwd`"/pid --remote=punix:socket --unixctl="`pwd`"/unixctl db& echo $! > expected], [0])
11 OVS_WAIT_UNTIL([test -s pid], [kill `cat expected`])
12 AT_CHECK(
13   [pid=`cat pid` && expected=`cat expected` && test "$pid" = "$expected"],
14   [0], [], [], [kill `cat expected`])
15 AT_CHECK([kill -0 `cat pid`], [0], [], [], [kill `cat expected`])
16 # Kill the daemon and make sure that the pidfile gets deleted.
17 kill `cat expected`
18 OVS_WAIT_WHILE([kill -0 `cat expected`])
19 AT_CHECK([test ! -e pid])
20 AT_CLEANUP
21
22 AT_SETUP([daemon --monitor])
23 AT_SKIP_IF([test "$CHECK_LCOV" = true]) # lcov wrapper make pids differ
24 OVSDB_INIT([db])
25 AT_CAPTURE_FILE([pid])
26 AT_CAPTURE_FILE([parent])
27 AT_CAPTURE_FILE([parentpid])
28 AT_CAPTURE_FILE([newpid])
29 # Start the daemon and wait for the pidfile to get created.
30 AT_CHECK([ovsdb-server --monitor --pidfile="`pwd`"/pid --remote=punix:socket --unixctl="`pwd`"/unixctl db& echo $! > parent], [0])
31 OVS_WAIT_UNTIL([test -s pid], [kill `cat parent`])
32 # Check that the pidfile names a running process,
33 # and that the parent process of that process is our child process.
34 AT_CHECK([kill -0 `cat pid`], [0], [], [], [kill `cat parent`])
35 AT_CHECK([ps -o ppid= -p `cat pid` > parentpid],
36   [0], [], [], [kill `cat parent`])
37 AT_CHECK(
38   [parentpid=`cat parentpid` && 
39    parent=`cat parent` && 
40    test $parentpid = $parent],
41   [0], [], [], [kill `cat parent`])
42 # Avoid a race between pidfile creation and notifying the parent,
43 # which can easily trigger if ovsdb-server is slow (e.g. due to valgrind).
44 OVS_WAIT_UNTIL(
45   [ovs-appctl --timeout=10 -t "`pwd`/unixctl" version],
46   [kill `cat pid`])
47 # Kill the daemon process, making it look like a segfault,
48 # and wait for a new child process to get spawned.
49 AT_CHECK([cp pid oldpid], [0], [], [], [kill `cat parent`])
50 AT_CHECK([kill -SEGV `cat pid`], [0], [], [ignore], [kill `cat parent`])
51 OVS_WAIT_WHILE([kill -0 `cat oldpid`], [kill `cat parent`])
52 OVS_WAIT_UNTIL([test -s pid && test `cat pid` != `cat oldpid`],
53   [kill `cat parent`])
54 AT_CHECK([cp pid newpid], [0], [], [], [kill `cat parent`])
55 # Check that the pidfile names a running process,
56 # and that the parent process of that process is our child process.
57 AT_CHECK([ps -o ppid= -p `cat pid` > parentpid],
58   [0], [], [], [kill `cat parent`])
59 AT_CHECK(
60   [parentpid=`cat parentpid` && 
61    parent=`cat parent` && 
62    test $parentpid = $parent],
63   [0], [], [], [kill `cat parent`])
64 # Kill the daemon process with SIGTERM, and wait for the daemon
65 # and the monitor processes to go away and the pidfile to get deleted.
66 AT_CHECK([kill `cat pid`], [0], [], [ignore], [kill `cat parent`])
67 OVS_WAIT_WHILE([kill -0 `cat parent` || kill -0 `cat newpid` || test -e pid],
68   [kill `cat parent`])
69 AT_CLEANUP
70
71 AT_SETUP([daemon --detach])
72 AT_SKIP_IF([test "$CHECK_LCOV" = true]) # lcov wrapper make pids differ
73 AT_CAPTURE_FILE([pid])
74 OVSDB_INIT([db])
75 # Start the daemon and make sure that the pidfile exists immediately.
76 # We don't wait for the pidfile to get created because the daemon is
77 # supposed to do so before the parent exits.
78 AT_CHECK([ovsdb-server --detach --pidfile="`pwd`"/pid --remote=punix:socket --unixctl="`pwd`"/unixctl db], [0])
79 AT_CHECK([test -s pid])
80 AT_CHECK([kill -0 `cat pid`])
81 # Kill the daemon and make sure that the pidfile gets deleted.
82 cp pid saved-pid
83 kill `cat pid`
84 OVS_WAIT_WHILE([kill -0 `cat saved-pid`])
85 AT_CHECK([test ! -e pid])
86 AT_CLEANUP
87
88 AT_SETUP([daemon --detach --monitor])
89 AT_SKIP_IF([test "$CHECK_LCOV" = true]) # lcov wrapper make pids differ
90 m4_define([CHECK], 
91   [AT_CHECK([$1], [$2], [$3], [$4], [kill `cat daemon monitor`])])
92 OVSDB_INIT([db])
93 AT_CAPTURE_FILE([daemon])
94 AT_CAPTURE_FILE([olddaemon])
95 AT_CAPTURE_FILE([newdaemon])
96 AT_CAPTURE_FILE([monitor])
97 AT_CAPTURE_FILE([newmonitor])
98 AT_CAPTURE_FILE([init])
99 # Start the daemon and make sure that the pidfile exists immediately.
100 # We don't wait for the pidfile to get created because the daemon is
101 # supposed to do so before the parent exits.
102 AT_CHECK([ovsdb-server --detach --pidfile="`pwd`"/daemon --monitor --remote=punix:socket --unixctl="`pwd`"/unixctl db], [0])
103 AT_CHECK([test -s daemon])
104 # Check that the pidfile names a running process,
105 # and that the parent process of that process is a running process,
106 # and that the parent process of that process is init.
107 CHECK([kill -0 `cat daemon`])
108 CHECK([ps -o ppid= -p `cat daemon` > monitor])
109 CHECK([kill -0 `cat monitor`])
110 CHECK([ps -o ppid= -p `cat monitor` > init])
111 CHECK([test `cat init` = 1])
112 # Kill the daemon process, making it look like a segfault,
113 # and wait for a new daemon process to get spawned.
114 CHECK([cp daemon olddaemon])
115 CHECK([kill -SEGV `cat daemon`], [0])
116 OVS_WAIT_WHILE([kill -0 `cat olddaemon`], [kill `cat olddaemon daemon`])
117 OVS_WAIT_UNTIL([test -s daemon && test `cat daemon` != `cat olddaemon`],
118   [kill `cat olddaemon daemon`])
119 CHECK([cp daemon newdaemon])
120 # Check that the pidfile names a running process,
121 # and that the parent process of that process is our child process.
122 CHECK([kill -0 `cat daemon`])
123 CHECK([diff olddaemon newdaemon], [1], [ignore])
124 CHECK([ps -o ppid= -p `cat daemon` > newmonitor])
125 CHECK([diff monitor newmonitor])
126 CHECK([kill -0 `cat newmonitor`])
127 CHECK([ps -o ppid= -p `cat newmonitor` > init])
128 CHECK([test `cat init` = 1])
129 # Kill the daemon process with SIGTERM, and wait for the daemon
130 # and the monitor processes to go away and the pidfile to get deleted.
131 CHECK([kill `cat daemon`], [0], [], [ignore])
132 OVS_WAIT_WHILE(
133   [kill -0 `cat monitor` || kill -0 `cat newdaemon` || test -e daemon],
134   [kill `cat monitor newdaemon`])
135 m4_undefine([CHECK])
136 AT_CLEANUP
137
138 AT_SETUP([daemon --detach startup errors])
139 AT_CAPTURE_FILE([pid])
140 OVSDB_INIT([db])
141 AT_CHECK([ovsdb-server --detach --pidfile="`pwd`"/pid --unixctl="`pwd`"/nonexistent/unixctl db], [1], [], [stderr])
142 AT_CHECK([grep 'ovsdb-server: could not initialize control socket' stderr],
143   [0], [ignore], [])
144 AT_CHECK([test ! -s pid])
145 AT_CLEANUP
146
147 AT_SETUP([daemon --detach --monitor startup errors])
148 AT_CAPTURE_FILE([pid])
149 OVSDB_INIT([db])
150 AT_CHECK([ovsdb-server --detach --pidfile="`pwd`"/pid --monitor --unixctl="`pwd`"/nonexistent/unixctl db], [1], [], [stderr])
151 AT_CHECK([grep 'ovsdb-server: could not initialize control socket' stderr],
152   [0], [ignore], [])
153 AT_CHECK([test ! -s pid])
154 AT_CLEANUP