tests: Fix typo in ovsdb-server test.
[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   [[ovstest 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/' | ovstest 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 combines updates on backlogged connections])
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, NetBSD
680 else
681     # Don't know how to get maximum socket receive buffer on this OS
682     AT_SKIP_IF([:])
683 fi
684
685 # Calculate the number of iterations we need to queue.  Each of the
686 # iterations we execute, by itself, yields a monitor update of about
687 # 25 kB, so fill up that much space plus a few for luck.
688 n_iterations=`expr $rmem_max / 25000 + 5`
689 echo rmem_max=$rmem_max n_iterations=$n_iterations
690
691 # Calculate the exact number of monitor updates expected for $n_iterations,
692 # assuming no updates are combined.  The "extra" update is for the initial
693 # contents of the database.
694 n_updates=`expr $n_iterations \* 3 + 1`
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:db.sock db],
699   [0], [ignore], [ignore])
700
701 # Executes a set of transactions that add a bridge with 100 ports, and
702 # then deletes that bridge.  This yields three monitor updates that
703 # add up to about 25 kB in size.
704 #
705 # The update also increments a counter held in the database so that we can
706 # verify that the overall effect of the transactions took effect (e.g.
707 # monitor updates at the end weren't just dropped).  We add an arbitrary
708 # string to the counter to make grepping for it more reliable.
709 counter=0
710 trigger_big_update () {
711     counter=`expr $counter + 1`
712     ovs-vsctl --no-wait -- set open_vswitch . system_version=xyzzy$counter
713     ovs-vsctl --no-wait -- add-br br0 $add
714     ovs-vsctl --no-wait -- del-br br0
715 }
716 add_ports () {
717     for j in `seq 1 100`; do
718         printf " -- add-port br0 p%d" $j
719     done
720 }
721 add=`add_ports`
722
723 AT_CAPTURE_FILE([ovsdb-client.err])
724
725 # Start an ovsdb-client monitoring all changes to the database,
726 # make it block to force the buffers to fill up, and then execute
727 # enough iterations that ovsdb-server starts combining updates.
728 AT_CHECK([ovsdb-client --detach --no-chdir --pidfile monitor ALL >ovsdb-client.out 2>ovsdb-client.err])
729 AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/block])
730 for i in `seq 1 $n_iterations`; do
731     echo "blocked update ($i of $n_iterations)"
732     trigger_big_update $i
733 done
734 AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/unblock])
735 OVS_WAIT_UNTIL([grep "\"xyzzy$counter\"" ovsdb-client.out])
736 AT_CHECK([ovs-appctl -t ovsdb-client exit])
737 OVS_WAIT_WHILE([test -e ovsdb-client.pid])
738
739 # Count the number of updates in the ovsdb-client output, by counting
740 # the number of changes to the Open_vSwitch table.  (All of our
741 # transactions modify the Open_vSwitch table.)  It should be less than
742 # $n_updates updates.
743 #
744 # Check that the counter is what we expect.
745 logged_updates=`grep -c '^Open_vSwitch' ovsdb-client.out`
746 echo "logged_updates=$logged_updates (expected less than $n_updates)"
747 AT_CHECK([test $logged_updates -lt $n_updates])
748 AT_CHECK_UNQUOTED([ovs-vsctl get open_vswitch . system_version], [0],
749   ["xyzzy$counter"
750 ])
751 AT_CLEANUP
752 \f
753 AT_BANNER([OVSDB -- ovsdb-server transactions (SSL IPv4 sockets)])
754
755 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
756 #
757 # Creates a database with the given SCHEMA, starts an ovsdb-server on
758 # that database, and runs each of the TRANSACTIONS (which should be a
759 # quoted list of quoted strings) against it with ovsdb-client one at a
760 # time.
761 #
762 # Checks that the overall output is OUTPUT, but UUIDs in the output
763 # are replaced by markers of the form <N> where N is a number.  The
764 # first unique UUID is replaced by <0>, the next by <1>, and so on.
765 # If a given UUID appears more than once it is always replaced by the
766 # same marker.
767 #
768 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
769 m4_define([OVSDB_CHECK_EXECUTION], 
770   [AT_SETUP([$1])
771    AT_KEYWORDS([ovsdb server positive ssl $5])
772    AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
773    OVS_RUNDIR=`pwd`; export OVS_RUNDIR
774    OVS_LOGDIR=`pwd`; export OVS_LOGDIR
775    $2 > schema
776    PKIDIR=$abs_top_builddir/tests
777    AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
778    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])
779    SSL_PORT=`parse_listening_port < ovsdb-server.log`
780    m4_foreach([txn], [$3], 
781      [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],
782      [test ! -e pid || kill `cat pid`])
783 cat stdout >> output
784 ])
785    AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
786             [test ! -e pid || kill `cat pid`])
787    OVSDB_SERVER_SHUTDOWN
788    AT_CLEANUP])
789
790 EXECUTION_EXAMPLES
791
792 AT_BANNER([OVSDB -- ovsdb-server transactions (SSL IPv6 sockets)])
793
794 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
795 #
796 # Creates a database with the given SCHEMA, starts an ovsdb-server on
797 # that database, and runs each of the TRANSACTIONS (which should be a
798 # quoted list of quoted strings) against it with ovsdb-client one at a
799 # time.
800 #
801 # Checks that the overall output is OUTPUT, but UUIDs in the output
802 # are replaced by markers of the form <N> where N is a number.  The
803 # first unique UUID is replaced by <0>, the next by <1>, and so on.
804 # If a given UUID appears more than once it is always replaced by the
805 # same marker.
806 #
807 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
808 m4_define([OVSDB_CHECK_EXECUTION],
809   [AT_SETUP([$1])
810    AT_KEYWORDS([ovsdb server positive ssl6 $5])
811    AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
812    OVS_RUNDIR=`pwd`; export OVS_RUNDIR
813    OVS_LOGDIR=`pwd`; export OVS_LOGDIR
814    $2 > schema
815    PKIDIR=$abs_top_builddir/tests
816    AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
817    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])
818    SSL_PORT=`parse_listening_port < ovsdb-server.log`
819    m4_foreach([txn], [$3],
820      [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],
821      [test ! -e pid || kill `cat pid`])
822 cat stdout >> output
823 ])
824    AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
825             [test ! -e pid || kill `cat pid`])
826    OVSDB_SERVER_SHUTDOWN
827    AT_CLEANUP])
828
829 ONE_EXECUTION_EXAMPLE
830
831 AT_BANNER([OVSDB -- ovsdb-server transactions (TCP IPv4 sockets)])
832
833 AT_SETUP([ovsdb-client get-schema-version - tcp socket])
834 AT_KEYWORDS([ovsdb server positive tcp])
835 ordinal_schema > schema
836 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
837 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
838 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])
839 TCP_PORT=`parse_listening_port < ovsdb-server.log`
840 AT_CHECK([ovsdb-client get-schema-version tcp:127.0.0.1:$TCP_PORT ordinals], [0], [5.1.3
841 ])
842 OVSDB_SERVER_SHUTDOWN
843 AT_CLEANUP])
844
845 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
846 #
847 # Creates a database with the given SCHEMA, starts an ovsdb-server on
848 # that database, and runs each of the TRANSACTIONS (which should be a
849 # quoted list of quoted strings) against it with ovsdb-client one at a
850 # time.
851 #
852 # Checks that the overall output is OUTPUT, but UUIDs in the output
853 # are replaced by markers of the form <N> where N is a number.  The
854 # first unique UUID is replaced by <0>, the next by <1>, and so on.
855 # If a given UUID appears more than once it is always replaced by the
856 # same marker.
857 #
858 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
859 m4_define([OVSDB_CHECK_EXECUTION],
860   [AT_SETUP([$1])
861    AT_KEYWORDS([ovsdb server positive tcp $5])
862    OVS_RUNDIR=`pwd`; export OVS_RUNDIR
863    OVS_LOGDIR=`pwd`; export OVS_LOGDIR
864    $2 > schema
865    PKIDIR=$abs_top_builddir/tests
866    AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
867    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])
868    TCP_PORT=`parse_listening_port < ovsdb-server.log`
869    m4_foreach([txn], [$3],
870      [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT 'txn'], [0], [stdout], [ignore],
871      [test ! -e pid || kill `cat pid`])
872 cat stdout >> output
873 ])
874    AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
875             [test ! -e pid || kill `cat pid`])
876    OVSDB_SERVER_SHUTDOWN
877    AT_CLEANUP])
878
879 EXECUTION_EXAMPLES
880
881 AT_BANNER([OVSDB -- ovsdb-server transactions (TCP IPv6 sockets)])
882
883 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
884 #
885 # Creates a database with the given SCHEMA, starts an ovsdb-server on
886 # that database, and runs each of the TRANSACTIONS (which should be a
887 # quoted list of quoted strings) against it with ovsdb-client one at a
888 # time.
889 #
890 # Checks that the overall output is OUTPUT, but UUIDs in the output
891 # are replaced by markers of the form <N> where N is a number.  The
892 # first unique UUID is replaced by <0>, the next by <1>, and so on.
893 # If a given UUID appears more than once it is always replaced by the
894 # same marker.
895 #
896 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
897 m4_define([OVSDB_CHECK_EXECUTION],
898   [AT_SETUP([$1])
899    AT_KEYWORDS([ovsdb server positive tcp6 $5])
900    OVS_RUNDIR=`pwd`; export OVS_RUNDIR
901    OVS_LOGDIR=`pwd`; export OVS_LOGDIR
902    $2 > schema
903    PKIDIR=$abs_top_builddir/tests
904    AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
905    AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid --remote=ptcp:0:[[::1]] --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
906    TCP_PORT=`parse_listening_port < ovsdb-server.log`
907    m4_foreach([txn], [$3],
908      [AT_CHECK([ovsdb-client transact tcp:[[::1]]:$TCP_PORT 'txn'], [0], [stdout], [ignore],
909      [test ! -e pid || kill `cat pid`])
910 cat stdout >> output
911 ])
912    AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
913             [test ! -e pid || kill `cat pid`])
914    OVSDB_SERVER_SHUTDOWN
915    AT_CLEANUP])
916
917 ONE_EXECUTION_EXAMPLE
918 \f
919 AT_BANNER([OVSDB -- transactions on transient ovsdb-server])
920
921 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
922 #
923 # Creates a database with the given SCHEMA and runs each of the
924 # TRANSACTIONS (which should be a quoted list of quoted strings)
925 # against it with ovsdb-client one at a time.  Each ovsdb-client
926 # is run against a separately started ovsdb-server that executes
927 # only that single transaction.  (The idea is that this should
928 # help to ferret out any differences between what ovsdb-server has
929 # in memory and what actually gets committed to disk.)
930 #
931 # Checks that the overall output is OUTPUT, but UUIDs in the output
932 # are replaced by markers of the form <N> where N is a number.  The
933 # first unique UUID is replaced by <0>, the next by <1>, and so on.
934 # If a given UUID appears more than once it is always replaced by the
935 # same marker.
936 #
937 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
938 m4_define([OVSDB_CHECK_EXECUTION], 
939   [AT_SETUP([$1])
940    AT_KEYWORDS([ovsdb server positive transient $5])
941    OVS_RUNDIR=`pwd`; export OVS_RUNDIR
942    $2 > schema
943    AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
944    m4_foreach([txn], [$3], 
945      [AT_DATA([txnfile], [ovsdb-client transact unix:socket 'txn'
946 ])
947       AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [ignore])
948       cat stdout >> output
949 ])
950    AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore])
951    AT_CLEANUP])
952
953 EXECUTION_EXAMPLES