tests: Add missing banner.
[sliver-openvswitch.git] / tests / ovsdb-server.at
1 AT_BANNER([OVSDB -- ovsdb-server transactions (Unix sockets)])
2
3 m4_define([OVSDB_SERVER_SHUTDOWN], 
4   [cp pid savepid
5    AT_CHECK([ovs-appctl -t "`pwd`"/unixctl -e exit], [0], [ignore], [ignore])
6    OVS_WAIT_WHILE([kill -0 `cat savepid`], [kill `cat savepid`])])
7
8 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
9 #
10 # Creates a database with the given SCHEMA, starts an ovsdb-server on
11 # that database, and runs each of the TRANSACTIONS (which should be a
12 # quoted list of quoted strings) against it with ovsdb-client one at a
13 # time.
14 #
15 # Checks that the overall output is OUTPUT, but UUIDs in the output
16 # are replaced by markers of the form <N> where N is a number.  The
17 # first unique UUID is replaced by <0>, the next by <1>, and so on.
18 # If a given UUID appears more than once it is always replaced by the
19 # same marker.
20 #
21 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
22 m4_define([OVSDB_CHECK_EXECUTION], 
23   [AT_SETUP([$1])
24   OVS_RUNDIR=`pwd`; export OVS_RUNDIR
25    AT_KEYWORDS([ovsdb server positive unix $5])
26    $2 > schema
27    AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
28    AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/pid --remote=punix:socket --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
29    m4_foreach([txn], [$3], 
30      [AT_CHECK([ovsdb-client transact unix:socket 'txn'], [0], [stdout], [ignore],
31      [test ! -e pid || kill `cat pid`])
32 cat stdout >> output
33 ])
34    AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
35             [test ! -e pid || kill `cat pid`])
36    OVSDB_SERVER_SHUTDOWN
37    AT_CLEANUP])
38
39 EXECUTION_EXAMPLES
40 \f
41 AT_BANNER([ovsdb-server miscellaneous features])
42
43 AT_SETUP([truncating corrupted database log])
44 AT_KEYWORDS([ovsdb server positive unix])
45 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
46 ordinal_schema > schema
47 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
48 dnl Do one transaction and save the output.
49 AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
50 '["ordinals",
51   {"op": "insert",
52    "table": "ordinals",
53    "row": {"number": 0, "name": "zero"}}]'
54 ]])
55 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [])
56 cat stdout >> output
57 dnl Add some crap to the database log and run another transaction, which should
58 dnl ignore the crap and truncate it out of the log.
59 echo 'xxx' >> db
60 AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
61 '["ordinals",
62   {"op": "insert",
63    "table": "ordinals",
64    "row": {"number": 1, "name": "one"}}]'
65 ]])
66 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [stderr])
67 AT_CHECK([grep 'syntax error: db: parse error.* in header line "xxx"' stderr],
68   [0], [ignore])
69 cat stdout >> output
70 dnl Run a final transaction to verify that both transactions succeeeded.
71 dnl The crap that we added should have been truncated by the previous run,
72 dnl so ovsdb-server shouldn't log a warning this time.
73 AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
74 '["ordinals",
75   {"op": "select",
76    "table": "ordinals",
77    "where": [],
78    "sort": ["number"]}]'
79 ]])
80 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [])
81 cat stdout >> output
82 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0],
83   [[[{"uuid":["uuid","<0>"]}]
84 [{"uuid":["uuid","<1>"]}]
85 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
86 ]], [],
87          [test ! -e pid || kill `cat pid`])
88 AT_CLEANUP
89
90 AT_SETUP([truncating database log with bad transaction])
91 AT_KEYWORDS([ovsdb server positive unix])
92 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
93 ordinal_schema > schema
94 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
95 dnl Do one transaction and save the output.
96 AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
97 '["ordinals",
98   {"op": "insert",
99    "table": "ordinals",
100    "row": {"number": 0, "name": "zero"}}]'
101 ]])
102 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [])
103 cat stdout >> output
104 dnl Add some crap to the database log and run another transaction, which should
105 dnl ignore the crap and truncate it out of the log.
106 echo 'OVSDB JSON 15 ffbcdae4b0386265f9ea3280dd7c8f0b72a20e56
107 {"invalid":{}}' >> db
108 AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
109 '["ordinals",
110   {"op": "insert",
111    "table": "ordinals",
112    "row": {"number": 1, "name": "one"}}]'
113 ]])
114 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [stderr])
115 AT_CHECK([grep 'syntax "{"invalid":{}}": unknown table: No table named invalid.' stderr],
116   [0], [ignore])
117 cat stdout >> output
118 dnl Run a final transaction to verify that both transactions succeeeded.
119 dnl The crap that we added should have been truncated by the previous run,
120 dnl so ovsdb-server shouldn't log a warning this time.
121 AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
122 '["ordinals",
123   {"op": "select",
124    "table": "ordinals",
125    "where": [],
126    "sort": ["number"]}]'
127 ]])
128 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [])
129 cat stdout >> output
130 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0],
131   [[[{"uuid":["uuid","<0>"]}]
132 [{"uuid":["uuid","<1>"]}]
133 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
134 ]], [],
135          [test ! -e pid || kill `cat pid`])
136 AT_CLEANUP
137
138 AT_SETUP([ovsdb-client get-schema-version])
139 AT_KEYWORDS([ovsdb server positive])
140 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
141 ordinal_schema > schema
142 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
143 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/pid --unixctl="`pwd`"/unixctl --remote=punix:socket db], [0], [ignore], [ignore])
144 AT_CHECK([ovsdb-client get-schema-version unix:socket ordinals], [0], [5.1.3
145 ])
146 OVSDB_SERVER_SHUTDOWN
147 AT_CLEANUP
148
149 AT_SETUP([database multiplexing implementation])
150 AT_KEYWORDS([ovsdb server positive])
151 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
152 ordinal_schema > schema1
153 constraint_schema > schema2
154 AT_CHECK([ovsdb-tool create db1 schema1], [0], [ignore], [ignore])
155 AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore])
156 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/pid --unixctl="`pwd`"/unixctl --remote=punix:socket db1 db2], [0], [ignore], [ignore])
157 AT_CHECK(
158   [[ovsdb-client list-dbs unix:socket]], 
159   [0], [constraints
160 ordinals
161 ], [ignore], [test ! -e pid || kill `cat pid`])
162 AT_CHECK(
163   [[test-jsonrpc request unix:socket get_schema [\"nonexistent\"]]], [0],
164   [[{"error":null,"id":0,"result":{"details":"get_schema request specifies unknown database nonexistent","error":"unknown database","syntax":"[\"nonexistent\"]"}}
165 ]], [], [test ! -e pid || kill `cat pid`])
166 OVSDB_SERVER_SHUTDOWN
167 AT_CLEANUP
168
169 AT_SETUP([ovsdb-server/add-db and remove-db])
170 AT_KEYWORDS([ovsdb server positive])
171 ON_EXIT([kill `cat ovsdb-server.pid`])
172 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
173 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
174 ordinal_schema > schema1
175 constraint_schema > schema2
176 AT_CHECK([ovsdb-tool create db1 schema1], [0], [ignore], [ignore])
177 AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore])
178
179 # Start ovsdb-server with just a single database - db1.
180 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket db1], [0])
181 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
182   [0], [ordinals
183 ])
184
185 # Add the second database.
186 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], [0])
187 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
188   [0], [constraints
189 ordinals
190 ])
191
192 # The databases are responsive.
193 AT_CHECK([ovsdb-client list-tables unix:socket constraints], [0], [ignore], [ignore])
194 AT_CHECK([ovsdb-client list-tables unix:socket ordinals], [0], [ignore], [ignore])
195
196 # Add an already added database.
197 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], 2, [], [stderr])
198 AT_CHECK([sed 's/(.*)/(...)/' stderr], [0],
199   [I/O error: db2: failed to lock lockfile (...)
200 ovs-appctl: ovsdb-server: server returned an error
201 ])
202
203 # Add a non-existing database.
204 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db3], 2, [], [stderr])
205 AT_CHECK([sed 's/(.*)/(...)/' stderr], [0],
206   [I/O error: open: db3 failed (...)
207 ovs-appctl: ovsdb-server: server returned an error
208 ])
209
210 # Add a remote through a db path in db1.
211 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote db:ordinals,ordinals,name], [0])
212 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
213   [0], [db:ordinals,ordinals,name
214 punix:socket
215 ])
216
217 # Removing db1 has no effect on its remote.
218 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db ordinals], [0])
219 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
220   [0], [constraints
221 ])
222 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
223   [0], [db:ordinals,ordinals,name
224 punix:socket
225 ])
226 AT_CHECK([ovsdb-client list-tables unix:socket ordinals], [1], [ignore], [ignore])
227
228 # Remove db2.
229 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db constraints], [0])
230 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
231   [0], [])
232 AT_CHECK([ovsdb-client list-tables unix:socket constraints], [1], [ignore], [ignore])
233
234 # Remove a non-existent database.
235 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db ordinals], [2],
236   [], [Failed to find the database.
237 ovs-appctl: ovsdb-server: server returned an error
238 ])
239
240 # Add a removed database.
241 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], [0])
242 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
243   [0], [constraints
244 ])
245 AT_CHECK([ovsdb-client list-tables unix:socket constraints], [0], [ignore], [ignore])
246 AT_CLEANUP
247
248 AT_SETUP([ovsdb-server/add-db with --monitor])
249 AT_KEYWORDS([ovsdb server positive])
250 # Start ovsdb-server, initially with one db.
251 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
252 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
253 ordinal_schema > schema
254 AT_CHECK([ovsdb-tool create db1 schema], [0], [ignore], [ignore])
255 ON_EXIT([kill `cat *.pid`])
256 AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db1])
257
258 # Add the second database.
259 constraint_schema > schema2
260 AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore])
261 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], [0])
262 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
263   [0], [constraints
264 ordinals
265 ])
266
267 # Kill the daemon process, making it look like a segfault,
268 # and wait for a new daemon process to get spawned.
269 cp ovsdb-server.pid old.pid
270 AT_CHECK([kill -SEGV `cat ovsdb-server.pid`])
271 OVS_WAIT_WHILE([kill -0 `cat old.pid`])
272 OVS_WAIT_UNTIL(
273   [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`])
274 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
275   [0], [constraints
276 ordinals
277 ])
278 AT_CLEANUP
279
280 AT_SETUP([ovsdb-server/add-db and remove-db with --monitor])
281 AT_KEYWORDS([ovsdb server positive])
282 # Start ovsdb-server, initially with one db.
283 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
284 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
285 ordinal_schema > schema
286 AT_CHECK([ovsdb-tool create db1 schema], [0], [ignore], [ignore])
287 constraint_schema > schema2
288 AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore])
289 ON_EXIT([kill `cat *.pid`])
290 AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db1 db2])
291
292 # Remove the second database.
293 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db constraints])
294 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
295   [0], [ordinals
296 ])
297
298 # Kill the daemon process, making it look like a segfault,
299 # and wait for a new daemon process to get spawned.
300 cp ovsdb-server.pid old.pid
301 AT_CHECK([kill -SEGV `cat ovsdb-server.pid`])
302 OVS_WAIT_WHILE([kill -0 `cat old.pid`])
303 OVS_WAIT_UNTIL(
304   [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`])
305 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
306   [0], [ordinals
307 ])
308 AT_CLEANUP
309
310 AT_SETUP([--remote=db: implementation])
311 AT_KEYWORDS([ovsdb server positive])
312 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
313 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
314 AT_DATA([schema],
315   [[{"name": "mydb",
316      "tables": {
317        "Root": {
318          "columns": {
319            "managers": {
320              "type": {
321                "key": "string",
322                "min": 0,
323                "max": "unlimited"}},
324            "manager_options": {
325              "type": {
326                "key": {"type": "uuid", "refTable": "Manager"},
327                "min": 0,
328                "max": "unlimited"}}}},
329        "Manager": {
330          "columns": {
331            "target": {
332              "type": "string"},
333            "is_connected": {
334              "type": {
335                "key": "boolean",
336                "min": 0,
337                "max": 1}}}}}}
338 ]])
339 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
340 AT_CHECK(
341   [[ovsdb-tool transact db \
342      '["mydb",
343        {"op": "insert",
344         "table": "Root",
345         "row": {
346           "managers": "punix:socket1",
347           "manager_options": ["set", [["named-uuid", "x"]]]}},
348        {"op": "insert",
349         "table": "Manager",
350         "uuid-name": "x",
351         "row": {"target": "punix:socket2"}}]']], [0], [ignore], [ignore])
352 ON_EXIT([kill `cat ovsdb-server.pid`])
353 AT_CHECK([ovsdb-server --enable-dummy --detach --no-chdir --pidfile --remote=db:mydb,Root,managers --remote=db:mydb,Root,manager_options --log-file db], [0], [ignore], [ignore])
354 for i in 1 2 3 4 5 6; do ovs-appctl -t ovsdb-server time/warp 1000; done
355 AT_CHECK(
356   [[ovsdb-client transact unix:socket1 \
357      '["mydb",
358        {"op": "select",
359         "table": "Root",
360         "where": [],
361         "columns": ["managers"]},
362        {"op": "select",
363         "table": "Manager",
364         "where": [],
365         "columns": ["target", "is_connected"]}]']],
366   [0], [stdout], [ignore])
367 AT_CHECK(
368   [${PERL} $srcdir/uuidfilt.pl stdout], 
369   [0], 
370   [[[{"rows":[{"managers":"punix:socket1"}]},{"rows":[{"is_connected":false,"target":"punix:socket2"}]}]
371 ]], 
372   [ignore])
373 AT_CLEANUP
374
375 AT_SETUP([ovsdb-server/add-remote and remove-remote])
376 AT_KEYWORDS([ovsdb server positive])
377 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
378 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
379 ordinal_schema > schema
380 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
381 ON_EXIT([kill `cat *.pid`])
382 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile db])
383
384 AT_CHECK([test ! -e socket1])
385 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1])
386 OVS_WAIT_UNTIL([test -S socket1])
387 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
388   [0], [punix:socket1
389 ])
390
391 AT_CHECK([test ! -e socket2])
392 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket2])
393 OVS_WAIT_UNTIL([test -S socket2])
394 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
395   [0], [punix:socket1
396 punix:socket2
397 ])
398
399 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote db:x,y,z], [2],
400   [], ["db:x,y,z": no database named x
401 ovs-appctl: ovsdb-server: server returned an error
402 ])
403
404 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket1])
405 OVS_WAIT_UNTIL([test ! -e socket1])
406 AT_CHECK([test -S socket2])
407 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
408   [0], [punix:socket2
409 ])
410
411 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket2])
412 OVS_WAIT_UNTIL([test ! -e socket2])
413 AT_CHECK([test ! -e socket1])
414 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes])
415 AT_CLEANUP
416
417 AT_SETUP([ovsdb-server/add-remote with --monitor])
418 AT_KEYWORDS([ovsdb server positive])
419 # Start ovsdb-server, initially with no remotes.
420 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
421 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
422 ordinal_schema > schema
423 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
424 ON_EXIT([kill `cat *.pid`])
425 AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db])
426
427 # Add a remote.
428 AT_CHECK([test ! -e socket1])
429 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1])
430 OVS_WAIT_UNTIL([test -S socket1])
431 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
432   [0], [punix:socket1
433 ])
434
435 # Kill the daemon process, making it look like a segfault,
436 # and wait for a new daemon process to get spawned and for it to
437 # start listening on 'socket1'.
438 cp ovsdb-server.pid old.pid
439 rm socket1
440 AT_CHECK([kill -SEGV `cat ovsdb-server.pid`])
441 OVS_WAIT_WHILE([kill -0 `cat old.pid`])
442 OVS_WAIT_UNTIL(
443   [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`])
444 OVS_WAIT_UNTIL([test -S socket1])
445 AT_CLEANUP
446
447 AT_SETUP([ovsdb-server/add-remote and remove-remote with --monitor])
448 AT_KEYWORDS([ovsdb server positive])
449 # Start ovsdb-server, initially with no remotes.
450 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
451 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
452 ordinal_schema > schema
453 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
454 ON_EXIT([kill `cat *.pid`])
455 AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db])
456
457 # Add a remote.
458 AT_CHECK([test ! -e socket1])
459 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1])
460 OVS_WAIT_UNTIL([test -S socket1])
461 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
462   [0], [punix:socket1
463 ])
464
465 # Remove the remote.
466 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket1])
467 OVS_WAIT_UNTIL([test ! -e socket1])
468 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes])
469
470 # Kill the daemon process, making it look like a segfault,
471 # and wait for a new daemon process to get spawned and make sure that it
472 # does not listen on 'socket1'.
473 cp ovsdb-server.pid old.pid
474 AT_CHECK([kill -SEGV `cat ovsdb-server.pid`])
475 OVS_WAIT_WHILE([kill -0 `cat old.pid`])
476 OVS_WAIT_UNTIL(
477   [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`])
478 AT_CHECK([test ! -e socket1])
479 AT_CLEANUP
480
481 AT_SETUP([SSL db: implementation])
482 AT_KEYWORDS([ovsdb server positive ssl $5])
483 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
484 PKIDIR=$abs_top_builddir/tests
485 AT_SKIP_IF([expr "$PKIDIR" : ".*[       '\"
486 \\]"])
487 AT_DATA([schema],
488   [[{"name": "mydb",
489      "tables": {
490        "SSL": {
491          "columns": {
492            "private_key": {"type": "string"},
493            "certificate": {"type": "string"},
494            "ca_cert": {"type": "string"}}}}}
495 ]])
496 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
497 AT_CHECK(
498   [[ovsdb-tool transact db \
499      '["mydb",
500        {"op": "insert",
501         "table": "SSL",
502         "row": {"private_key": "'"$PKIDIR/testpki-privkey2.pem"'",
503                 "certificate": "'"$PKIDIR/testpki-cert2.pem"'",
504                 "ca_cert": "'"$PKIDIR/testpki-cacert.pem"'"}}]']],
505   [0], [ignore], [ignore])
506 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
507 AT_CHECK(
508   [ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid \
509         --private-key=db:mydb,SSL,private_key \
510         --certificate=db:mydb,SSL,certificate \
511         --ca-cert=db:mydb,SSL,ca_cert \
512         --remote=pssl:0:127.0.0.1 --unixctl="`pwd`"/unixctl db],
513   [0], [ignore], [ignore])
514 SSL_PORT=`parse_listening_port < ovsdb-server.log`
515 AT_CHECK(
516   [[ovsdb-client \
517         --private-key=$PKIDIR/testpki-privkey.pem \
518         --certificate=$PKIDIR/testpki-cert.pem \
519         --ca-cert=$PKIDIR/testpki-cacert.pem \
520         transact ssl:127.0.0.1:$SSL_PORT \
521         '["mydb",
522           {"op": "select",
523            "table": "SSL",
524            "where": [],
525            "columns": ["private_key"]}]']], 
526   [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`])
527 cat stdout >> output
528 AT_CHECK_UNQUOTED(
529   [cat output], [0],
530   [[[{"rows":[{"private_key":"$PKIDIR/testpki-privkey2.pem"}]}]
531 ]], [ignore], [test ! -e pid || kill `cat pid`])
532 OVSDB_SERVER_SHUTDOWN
533 AT_CLEANUP
534
535 AT_SETUP([compacting online])
536 AT_KEYWORDS([ovsdb server compact])
537 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
538 ordinal_schema > schema
539 dnl Make sure that "ovsdb-tool create" works with a dangling symlink for
540 dnl the database and the lockfile, creating the target of each symlink rather
541 dnl than replacing the symlinks with regular files.
542 mkdir dir
543 ln -s dir/db db
544 ln -s dir/.db.~lock~ .db.~lock~
545 AT_SKIP_IF([test ! -h db || test ! -h .db.~lock~])
546 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
547 dnl Start ovsdb-server.
548 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/pid --unixctl="`pwd`"/unixctl --remote=punix:socket --log-file="`pwd`"/ovsdb-server.log db], [0], [ignore], [ignore])
549 AT_CAPTURE_FILE([ovsdb-server.log])
550 dnl Do a bunch of random transactions that put crap in the database log.
551 AT_CHECK(
552   [[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do
553       set -- $pair
554       ovsdb-client transact unix:socket '
555         ["ordinals",
556          {"op": "insert",
557           "table": "ordinals",
558           "row": {"name": "'$1'", "number": '$2'}},
559          {"op": "comment",
560           "comment": "add row for '"$pair"'"}]'
561       ovsdb-client transact unix:socket '
562         ["ordinals",
563          {"op": "delete",
564           "table": "ordinals",
565           "where": [["number", "==", '$2']]},
566          {"op": "comment",
567           "comment": "delete row for '"$2"'"}]'
568       ovsdb-client transact unix:socket '
569         ["ordinals",
570          {"op": "insert",
571           "table": "ordinals",
572           "row": {"name": "'$1'", "number": '$2'}},
573          {"op": "comment",
574           "comment": "add back row for '"$pair"'"}]'
575     done]],
576   [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`])
577 dnl Check that all the crap is in fact in the database log.
578 AT_CHECK([[${PERL} $srcdir/uuidfilt.pl db | grep -v ^OVSDB | sed 's/"_date":[0-9]*/"_date":0/' | test-json --multiple -]], [0],
579   [[{"cksum":"12345678 9","name":"ordinals","tables":{"ordinals":{"columns":{"name":{"type":"string"},"number":{"type":"integer"}},"indexes":[["number"]]}},"version":"5.1.3"}
580 {"_comment":"add row for zero 0","_date":0,"ordinals":{"<0>":{"name":"zero"}}}
581 {"_comment":"delete row for 0","_date":0,"ordinals":{"<0>":null}}
582 {"_comment":"add back row for zero 0","_date":0,"ordinals":{"<1>":{"name":"zero"}}}
583 {"_comment":"add row for one 1","_date":0,"ordinals":{"<2>":{"name":"one","number":1}}}
584 {"_comment":"delete row for 1","_date":0,"ordinals":{"<2>":null}}
585 {"_comment":"add back row for one 1","_date":0,"ordinals":{"<3>":{"name":"one","number":1}}}
586 {"_comment":"add row for two 2","_date":0,"ordinals":{"<4>":{"name":"two","number":2}}}
587 {"_comment":"delete row for 2","_date":0,"ordinals":{"<4>":null}}
588 {"_comment":"add back row for two 2","_date":0,"ordinals":{"<5>":{"name":"two","number":2}}}
589 {"_comment":"add row for three 3","_date":0,"ordinals":{"<6>":{"name":"three","number":3}}}
590 {"_comment":"delete row for 3","_date":0,"ordinals":{"<6>":null}}
591 {"_comment":"add back row for three 3","_date":0,"ordinals":{"<7>":{"name":"three","number":3}}}
592 {"_comment":"add row for four 4","_date":0,"ordinals":{"<8>":{"name":"four","number":4}}}
593 {"_comment":"delete row for 4","_date":0,"ordinals":{"<8>":null}}
594 {"_comment":"add back row for four 4","_date":0,"ordinals":{"<9>":{"name":"four","number":4}}}
595 {"_comment":"add row for five 5","_date":0,"ordinals":{"<10>":{"name":"five","number":5}}}
596 {"_comment":"delete row for 5","_date":0,"ordinals":{"<10>":null}}
597 {"_comment":"add back row for five 5","_date":0,"ordinals":{"<11>":{"name":"five","number":5}}}
598 ]], [], [test ! -e pid || kill `cat pid`])
599 dnl Dump out and check the actual database contents.
600 AT_CHECK([[ovsdb-client dump unix:socket ordinals]],
601   [0], [stdout], [ignore])
602 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl
603 ordinals table
604 _uuid                                name  number
605 ------------------------------------ ----- ------
606 <0> five  5     @&t@
607 <1> four  4     @&t@
608 <2> one   1     @&t@
609 <3> three 3     @&t@
610 <4> two   2     @&t@
611 <5> zero  0     @&t@
612 ], [], [test ! -e pid || kill `cat pid`])
613 dnl Now compact the database in-place.
614 AT_CHECK([[ovs-appctl -t "`pwd`"/unixctl ovsdb-server/compact]],
615   [0], [], [ignore], [test ! -e pid || kill `cat pid`])
616 dnl Make sure that "db" is still a symlink to dir/db instead of getting
617 dnl replaced by a regular file, ditto for .db.~lock~.
618 AT_CHECK([test -h db])
619 AT_CHECK([test -h .db.~lock~])
620 AT_CHECK([test -f dir/db])
621 AT_CHECK([test -f dir/.db.~lock~])
622 dnl We can't fully re-check the contents of the database log, because the
623 dnl order of the records is not predictable, but there should only be 4 lines
624 dnl in it now.
625 AT_CAPTURE_FILE([db])
626 AT_CHECK([test `wc -l < db` -eq 4], [0], [], [],
627   [test ! -e pid || kill `cat pid`])
628 dnl And check that the dumped data is the same too:
629 AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore],
630   [test ! -e pid || kill `cat pid`])
631 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl
632 ordinals table
633 _uuid                                name  number
634 ------------------------------------ ----- ------
635 <0> five  5     @&t@
636 <1> four  4     @&t@
637 <2> one   1     @&t@
638 <3> three 3     @&t@
639 <4> two   2     @&t@
640 <5> zero  0     @&t@
641 ], [], [test ! -e pid || kill `cat pid`])
642 dnl Now do some more transactions.
643 AT_CHECK(
644   [[ovsdb-client transact unix:socket '
645      ["ordinals",
646       {"op": "delete",
647        "table": "ordinals",
648        "where": [["number", "<", 3]]}]']],
649   [0], [[[{"count":3}]
650 ]], [ignore], [test ! -e pid || kill `cat pid`])
651 dnl There should be 6 lines in the log now.
652 AT_CHECK([test `wc -l < db` -eq 6], [0], [], [],
653   [test ! -e pid || kill `cat pid`])
654 dnl Then check that the dumped data is correct.
655 AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore],
656   [test ! -e pid || kill `cat pid`])
657 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl
658 ordinals table
659 _uuid                                name  number
660 ------------------------------------ ----- ------
661 <0> five  5     @&t@
662 <1> four  4     @&t@
663 <2> three 3     @&t@
664 ], [], [test ! -e pid || kill `cat pid`])
665 OVSDB_SERVER_SHUTDOWN
666 AT_CLEANUP
667
668 AT_SETUP([ovsdb-server connection queue limits])
669 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
670 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
671 ON_EXIT([kill `cat *.pid`])
672
673 # The maximum socket receive buffer size is important for this test, which
674 # tests behavior when the receive buffer overflows.
675 if test -e /proc/sys/net/core/rmem_max; then
676     # Linux
677     rmem_max=`cat /proc/sys/net/core/rmem_max`
678 elif rmem_max=`sysctl -n net.inet.tcp.recvbuf_max 2>/dev/null`; then
679     : # FreeBSD
680 else
681     # Don't know how to get maximum socket receive buffer on this OS
682     AT_SKIP_IF([:])
683 fi
684 # Calculate the total amount of data we need to queue: rmem_max in the
685 # kernel plus 1024 kB in jsonrpc-server sending userspace (see default
686 # backlog_threshold in ovsdb_jsonrpc_session_create() in
687 # jsonrpc-server.c).
688 queue_size=`expr $rmem_max + 1024 \* 1024`
689 echo rmem_max=$rmem_max queue_size=$queue_size
690
691 # Each flow update message takes up at least 48 bytes of space in queues
692 # and in practice more than that.
693 n_msgs=`expr $queue_size / 48`
694 echo n_msgs=$n_msgs
695
696 # Start an ovsdb-server with the vswitchd schema.
697 OVSDB_INIT([db])
698 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:socket db],
699   [0], [ignore], [ignore])
700
701 # Executes a pair of transactions that add a bridge with 100 ports,
702 # and then deletes that bridge.  Each of these transactions yields
703 # a monitor update about 25 kB in size.
704 trigger_big_update () {
705     ovs-vsctl --db=unix:socket --no-wait -- add-br br0 $add
706     ovs-vsctl --db=unix:socket --no-wait -- del-br br0
707 }
708 add_ports () {
709     for j in `seq 1 100`; do
710         printf " -- add-port br0 p%d" $j
711     done
712 }
713 add=`add_ports`
714
715 AT_CAPTURE_FILE([ovsdb-client.out])
716 AT_CAPTURE_FILE([ovsdb-client.err])
717
718 # Start an ovsdb-client monitoring all changes to the database,
719 # make it block to force the buffers to fill up, and then execute
720 # enough transactions that ovsdb-server disconnects it.
721 AT_CHECK([ovsdb-client --detach --no-chdir --pidfile monitor unix:socket ALL >ovsdb-client.out 2>ovsdb-client.err])
722 AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/block])
723 for i in `seq 1 100`; do
724     echo "blocked update ($i of 100)"
725     trigger_big_update
726 done
727 AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/unblock])
728
729 # Make sure that ovsdb-server disconnected the client and
730 # that the client exited as a result.
731 if grep "bytes backlogged but a complete replica would only take [[0-9]]* bytes, disconnecting" ovsdb-server.log; then
732     :
733 else
734     AT_FAIL_IF([:])
735 fi
736 OVS_WAIT_WHILE([test -e ovsdb-client.pid])
737
738 # Start an ovsdb-client monitoring all changes to the database,
739 # without making it block, and then execute the same transactions that
740 # we did before.  This time the client should not get disconnected.
741 AT_CHECK([ovsdb-client --detach --no-chdir --pidfile monitor unix:socket ALL >ovsdb-client.out 2>ovsdb-client.err])
742 for i in `seq 1 100`; do
743     echo "unblocked update ($i of 100)"
744     trigger_big_update
745
746     # Make sure that ovsdb-client gets enough CPU time to process the updates.
747     ovs-appctl -t ovsdb-client version > /dev/null
748 done
749 AT_CLEANUP
750 \f
751 AT_BANNER([OVSDB -- ovsdb-server transactions (SSL IPv4 sockets)])
752
753 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
754 #
755 # Creates a database with the given SCHEMA, starts an ovsdb-server on
756 # that database, and runs each of the TRANSACTIONS (which should be a
757 # quoted list of quoted strings) against it with ovsdb-client one at a
758 # time.
759 #
760 # Checks that the overall output is OUTPUT, but UUIDs in the output
761 # are replaced by markers of the form <N> where N is a number.  The
762 # first unique UUID is replaced by <0>, the next by <1>, and so on.
763 # If a given UUID appears more than once it is always replaced by the
764 # same marker.
765 #
766 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
767 m4_define([OVSDB_CHECK_EXECUTION], 
768   [AT_SETUP([$1])
769    AT_KEYWORDS([ovsdb server positive ssl $5])
770    AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
771    OVS_RUNDIR=`pwd`; export OVS_RUNDIR
772    OVS_LOGDIR=`pwd`; export OVS_LOGDIR
773    $2 > schema
774    PKIDIR=$abs_top_builddir/tests
775    AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
776    AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid --private-key=$PKIDIR/testpki-privkey2.pem --certificate=$PKIDIR/testpki-cert2.pem --ca-cert=$PKIDIR/testpki-cacert.pem --remote=pssl:0:127.0.0.1 --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
777    SSL_PORT=`parse_listening_port < ovsdb-server.log`
778    m4_foreach([txn], [$3], 
779      [AT_CHECK([ovsdb-client --private-key=$PKIDIR/testpki-privkey.pem --certificate=$PKIDIR/testpki-cert.pem --ca-cert=$PKIDIR/testpki-cacert.pem transact ssl:127.0.0.1:$SSL_PORT 'txn'], [0], [stdout], [ignore],
780      [test ! -e pid || kill `cat pid`])
781 cat stdout >> output
782 ])
783    AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
784             [test ! -e pid || kill `cat pid`])
785    OVSDB_SERVER_SHUTDOWN
786    AT_CLEANUP])
787
788 EXECUTION_EXAMPLES
789
790 AT_BANNER([OVSDB -- ovsdb-server transactions (SSL IPv6 sockets)])
791
792 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
793 #
794 # Creates a database with the given SCHEMA, starts an ovsdb-server on
795 # that database, and runs each of the TRANSACTIONS (which should be a
796 # quoted list of quoted strings) against it with ovsdb-client one at a
797 # time.
798 #
799 # Checks that the overall output is OUTPUT, but UUIDs in the output
800 # are replaced by markers of the form <N> where N is a number.  The
801 # first unique UUID is replaced by <0>, the next by <1>, and so on.
802 # If a given UUID appears more than once it is always replaced by the
803 # same marker.
804 #
805 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
806 m4_define([OVSDB_CHECK_EXECUTION],
807   [AT_SETUP([$1])
808    AT_KEYWORDS([ovsdb server positive ssl6 $5])
809    AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
810    OVS_RUNDIR=`pwd`; export OVS_RUNDIR
811    OVS_LOGDIR=`pwd`; export OVS_LOGDIR
812    $2 > schema
813    PKIDIR=$abs_top_builddir/tests
814    AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
815    AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid --private-key=$PKIDIR/testpki-privkey2.pem --certificate=$PKIDIR/testpki-cert2.pem --ca-cert=$PKIDIR/testpki-cacert.pem --remote=pssl:0:[[::1]] --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
816    SSL_PORT=`parse_listening_port < ovsdb-server.log`
817    m4_foreach([txn], [$3],
818      [AT_CHECK([ovsdb-client --private-key=$PKIDIR/testpki-privkey.pem --certificate=$PKIDIR/testpki-cert.pem --ca-cert=$PKIDIR/testpki-cacert.pem transact ssl:[[::1]]:$SSL_PORT 'txn'], [0], [stdout], [ignore],
819      [test ! -e pid || kill `cat pid`])
820 cat stdout >> output
821 ])
822    AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
823             [test ! -e pid || kill `cat pid`])
824    OVSDB_SERVER_SHUTDOWN
825    AT_CLEANUP])
826
827 ONE_EXECUTION_EXAMPLE
828
829 AT_BANNER([OVSDB -- ovsdb-server transactions (TCP IPv4 sockets)])
830
831 AT_SETUP([ovsdb-client get-schema-version - tcp socket])
832 AT_KEYWORDS([ovsdb server positive tcp])
833 ordinal_schema > schema
834 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
835 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
836 AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid --unixctl="`pwd`"/unixctl --remote=ptcp:0:127.0.0.1 db], [0], [ignore], [ignore])
837 TCP_PORT=`parse_listening_port < ovsdb-server.log`
838 AT_CHECK([ovsdb-client get-schema-version tcp:127.0.0.1:$TCP_PORT ordinals], [0], [5.1.3
839 ])
840 OVSDB_SERVER_SHUTDOWN
841 AT_CLEANUP])
842
843 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
844 #
845 # Creates a database with the given SCHEMA, starts an ovsdb-server on
846 # that database, and runs each of the TRANSACTIONS (which should be a
847 # quoted list of quoted strings) against it with ovsdb-client one at a
848 # time.
849 #
850 # Checks that the overall output is OUTPUT, but UUIDs in the output
851 # are replaced by markers of the form <N> where N is a number.  The
852 # first unique UUID is replaced by <0>, the next by <1>, and so on.
853 # If a given UUID appears more than once it is always replaced by the
854 # same marker.
855 #
856 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
857 m4_define([OVSDB_CHECK_EXECUTION],
858   [AT_SETUP([$1])
859    AT_KEYWORDS([ovsdb server positive tcp $5])
860    OVS_RUNDIR=`pwd`; export OVS_RUNDIR
861    OVS_LOGDIR=`pwd`; export OVS_LOGDIR
862    $2 > schema
863    PKIDIR=$abs_top_builddir/tests
864    AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
865    AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
866    TCP_PORT=`parse_listening_port < ovsdb-server.log`
867    m4_foreach([txn], [$3],
868      [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT 'txn'], [0], [stdout], [ignore],
869      [test ! -e pid || kill `cat pid`])
870 cat stdout >> output
871 ])
872    AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
873             [test ! -e pid || kill `cat pid`])
874    OVSDB_SERVER_SHUTDOWN
875    AT_CLEANUP])
876
877 EXECUTION_EXAMPLES
878
879 AT_BANNER([OVSDB -- ovsdb-server transactions (TCP IPv6 sockets)])
880
881 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
882 #
883 # Creates a database with the given SCHEMA, starts an ovsdb-server on
884 # that database, and runs each of the TRANSACTIONS (which should be a
885 # quoted list of quoted strings) against it with ovsdb-client one at a
886 # time.
887 #
888 # Checks that the overall output is OUTPUT, but UUIDs in the output
889 # are replaced by markers of the form <N> where N is a number.  The
890 # first unique UUID is replaced by <0>, the next by <1>, and so on.
891 # If a given UUID appears more than once it is always replaced by the
892 # same marker.
893 #
894 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
895 m4_define([OVSDB_CHECK_EXECUTION],
896   [AT_SETUP([$1])
897    AT_KEYWORDS([ovsdb server positive tcp6 $5])
898    OVS_RUNDIR=`pwd`; export OVS_RUNDIR
899    OVS_LOGDIR=`pwd`; export OVS_LOGDIR
900    $2 > schema
901    PKIDIR=$abs_top_builddir/tests
902    AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
903    AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid --remote=ptcp:0:[[::1]] --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
904    TCP_PORT=`parse_listening_port < ovsdb-server.log`
905    m4_foreach([txn], [$3],
906      [AT_CHECK([ovsdb-client transact tcp:[[::1]]:$TCP_PORT 'txn'], [0], [stdout], [ignore],
907      [test ! -e pid || kill `cat pid`])
908 cat stdout >> output
909 ])
910    AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
911             [test ! -e pid || kill `cat pid`])
912    OVSDB_SERVER_SHUTDOWN
913    AT_CLEANUP])
914
915 ONE_EXECUTION_EXAMPLE
916 \f
917 AT_BANNER([OVSDB -- transactions on transient ovsdb-server])
918
919 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
920 #
921 # Creates a database with the given SCHEMA and runs each of the
922 # TRANSACTIONS (which should be a quoted list of quoted strings)
923 # against it with ovsdb-client one at a time.  Each ovsdb-client
924 # is run against a separately started ovsdb-server that executes
925 # only that single transaction.  (The idea is that this should
926 # help to ferret out any differences between what ovsdb-server has
927 # in memory and what actually gets committed to disk.)
928 #
929 # Checks that the overall output is OUTPUT, but UUIDs in the output
930 # are replaced by markers of the form <N> where N is a number.  The
931 # first unique UUID is replaced by <0>, the next by <1>, and so on.
932 # If a given UUID appears more than once it is always replaced by the
933 # same marker.
934 #
935 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
936 m4_define([OVSDB_CHECK_EXECUTION], 
937   [AT_SETUP([$1])
938    AT_KEYWORDS([ovsdb server positive transient $5])
939    OVS_RUNDIR=`pwd`; export OVS_RUNDIR
940    $2 > schema
941    AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
942    m4_foreach([txn], [$3], 
943      [AT_DATA([txnfile], [ovsdb-client transact unix:socket 'txn'
944 ])
945       AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [ignore])
946       cat stdout >> output
947 ])
948    AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore])
949    AT_CLEANUP])
950
951 EXECUTION_EXAMPLES