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