Setting tag sliver-openvswitch-2.2.90-1
[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, [],
198   [db2: already open
199 ovs-appctl: ovsdb-server: server returned an error
200 ])
201
202 # Add a non-existing database.
203 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db3], 2, [], [stderr])
204 AT_CHECK([sed 's/(.*)/(...)/' stderr], [0],
205   [I/O error: open: db3 failed (...)
206 ovs-appctl: ovsdb-server: server returned an error
207 ])
208
209 # Add a remote through a db path in db1.
210 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote db:ordinals,ordinals,name], [0])
211 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
212   [0], [db:ordinals,ordinals,name
213 punix:socket
214 ])
215
216 # Removing db1 has no effect on its remote.
217 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db ordinals], [0])
218 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
219   [0], [constraints
220 ])
221 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
222   [0], [db:ordinals,ordinals,name
223 punix:socket
224 ])
225 AT_CHECK([ovsdb-client list-tables unix:socket ordinals], [1], [ignore], [ignore])
226
227 # Remove db2.
228 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db constraints], [0])
229 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
230   [0], [])
231 AT_CHECK([ovsdb-client list-tables unix:socket constraints], [1], [ignore], [ignore])
232
233 # Remove a non-existent database.
234 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db ordinals], [2],
235   [], [Failed to find the database.
236 ovs-appctl: ovsdb-server: server returned an error
237 ])
238
239 # Add a removed database.
240 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], [0])
241 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
242   [0], [constraints
243 ])
244 AT_CHECK([ovsdb-client list-tables unix:socket constraints], [0], [ignore], [ignore])
245 AT_CLEANUP
246
247 AT_SETUP([ovsdb-server/add-db with --monitor])
248 AT_KEYWORDS([ovsdb server positive])
249 # Start ovsdb-server, initially with one db.
250 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
251 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
252 ordinal_schema > schema
253 AT_CHECK([ovsdb-tool create db1 schema], [0], [ignore], [ignore])
254 ON_EXIT([kill `cat *.pid`])
255 AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db1])
256
257 # Add the second database.
258 constraint_schema > schema2
259 AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore])
260 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], [0])
261 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
262   [0], [constraints
263 ordinals
264 ])
265
266 # Kill the daemon process, making it look like a segfault,
267 # and wait for a new daemon process to get spawned.
268 cp ovsdb-server.pid old.pid
269 AT_CHECK([kill -SEGV `cat ovsdb-server.pid`])
270 OVS_WAIT_WHILE([kill -0 `cat old.pid`])
271 OVS_WAIT_UNTIL(
272   [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`])
273 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
274   [0], [constraints
275 ordinals
276 ])
277 AT_CLEANUP
278
279 AT_SETUP([ovsdb-server/add-db and remove-db with --monitor])
280 AT_KEYWORDS([ovsdb server positive])
281 # Start ovsdb-server, initially with one db.
282 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
283 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
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 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
312 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
313 AT_DATA([schema],
314   [[{"name": "mydb",
315      "tables": {
316        "Root": {
317          "columns": {
318            "managers": {
319              "type": {
320                "key": "string",
321                "min": 0,
322                "max": "unlimited"}},
323            "manager_options": {
324              "type": {
325                "key": {"type": "uuid", "refTable": "Manager"},
326                "min": 0,
327                "max": "unlimited"}}}},
328        "Manager": {
329          "columns": {
330            "target": {
331              "type": "string"},
332            "is_connected": {
333              "type": {
334                "key": "boolean",
335                "min": 0,
336                "max": 1}}}}}}
337 ]])
338 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
339 AT_CHECK(
340   [[ovsdb-tool transact db \
341      '["mydb",
342        {"op": "insert",
343         "table": "Root",
344         "row": {
345           "managers": "punix:socket1",
346           "manager_options": ["set", [["named-uuid", "x"]]]}},
347        {"op": "insert",
348         "table": "Manager",
349         "uuid-name": "x",
350         "row": {"target": "punix:socket2"}}]']], [0], [ignore], [ignore])
351 ON_EXIT([kill `cat ovsdb-server.pid`])
352 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])
353 for i in 1 2 3 4 5 6; do ovs-appctl -t ovsdb-server time/warp 1000; done
354 AT_CHECK(
355   [[ovsdb-client transact unix:socket1 \
356      '["mydb",
357        {"op": "select",
358         "table": "Root",
359         "where": [],
360         "columns": ["managers"]},
361        {"op": "select",
362         "table": "Manager",
363         "where": [],
364         "columns": ["target", "is_connected"]}]']],
365   [0], [stdout], [ignore])
366 AT_CHECK(
367   [${PERL} $srcdir/uuidfilt.pl stdout], 
368   [0], 
369   [[[{"rows":[{"managers":"punix:socket1"}]},{"rows":[{"is_connected":false,"target":"punix:socket2"}]}]
370 ]], 
371   [ignore])
372 AT_CLEANUP
373
374 AT_SETUP([ovsdb-server/add-remote and remove-remote])
375 AT_KEYWORDS([ovsdb server positive])
376 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
377 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
378 ordinal_schema > schema
379 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
380 ON_EXIT([kill `cat *.pid`])
381 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile db])
382
383 AT_CHECK([test ! -e socket1])
384 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1])
385 OVS_WAIT_UNTIL([test -S socket1])
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 OVS_WAIT_UNTIL([test -S socket2])
393 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
394   [0], [punix:socket1
395 punix:socket2
396 ])
397
398 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote db:x,y,z], [2],
399   [], ["db:x,y,z": no database named x
400 ovs-appctl: ovsdb-server: server returned an error
401 ])
402
403 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket1])
404 OVS_WAIT_UNTIL([test ! -e socket1])
405 AT_CHECK([test -S socket2])
406 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
407   [0], [punix:socket2
408 ])
409
410 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket2])
411 OVS_WAIT_UNTIL([test ! -e socket2])
412 AT_CHECK([test ! -e socket1])
413 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes])
414 AT_CLEANUP
415
416 AT_SETUP([ovsdb-server/add-remote with --monitor])
417 AT_KEYWORDS([ovsdb server positive])
418 # Start ovsdb-server, initially with no remotes.
419 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
420 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
421 ordinal_schema > schema
422 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
423 ON_EXIT([kill `cat *.pid`])
424 AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db])
425
426 # Add a remote.
427 AT_CHECK([test ! -e socket1])
428 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1])
429 OVS_WAIT_UNTIL([test -S socket1])
430 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
431   [0], [punix:socket1
432 ])
433
434 # Kill the daemon process, making it look like a segfault,
435 # and wait for a new daemon process to get spawned and for it to
436 # start listening on 'socket1'.
437 cp ovsdb-server.pid old.pid
438 rm socket1
439 AT_CHECK([kill -SEGV `cat ovsdb-server.pid`])
440 OVS_WAIT_WHILE([kill -0 `cat old.pid`])
441 OVS_WAIT_UNTIL(
442   [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`])
443 OVS_WAIT_UNTIL([test -S socket1])
444 AT_CLEANUP
445
446 AT_SETUP([ovsdb-server/add-remote and remove-remote with --monitor])
447 AT_KEYWORDS([ovsdb server positive])
448 # Start ovsdb-server, initially with no remotes.
449 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
450 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
451 ordinal_schema > schema
452 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
453 ON_EXIT([kill `cat *.pid`])
454 AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db])
455
456 # Add a remote.
457 AT_CHECK([test ! -e socket1])
458 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1])
459 OVS_WAIT_UNTIL([test -S socket1])
460 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
461   [0], [punix:socket1
462 ])
463
464 # Remove the remote.
465 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket1])
466 OVS_WAIT_UNTIL([test ! -e socket1])
467 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes])
468
469 # Kill the daemon process, making it look like a segfault,
470 # and wait for a new daemon process to get spawned and make sure that it
471 # does not listen on 'socket1'.
472 cp ovsdb-server.pid old.pid
473 AT_CHECK([kill -SEGV `cat ovsdb-server.pid`])
474 OVS_WAIT_WHILE([kill -0 `cat old.pid`])
475 OVS_WAIT_UNTIL(
476   [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`])
477 AT_CHECK([test ! -e socket1])
478 AT_CLEANUP
479
480 AT_SETUP([SSL db: implementation])
481 AT_KEYWORDS([ovsdb server positive ssl $5])
482 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
483 PKIDIR=$abs_top_builddir/tests
484 AT_SKIP_IF([expr "$PKIDIR" : ".*[       '\"
485 \\]"])
486 AT_DATA([schema],
487   [[{"name": "mydb",
488      "tables": {
489        "SSL": {
490          "columns": {
491            "private_key": {"type": "string"},
492            "certificate": {"type": "string"},
493            "ca_cert": {"type": "string"}}}}}
494 ]])
495 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
496 AT_CHECK(
497   [[ovsdb-tool transact db \
498      '["mydb",
499        {"op": "insert",
500         "table": "SSL",
501         "row": {"private_key": "'"$PKIDIR/testpki-privkey2.pem"'",
502                 "certificate": "'"$PKIDIR/testpki-cert2.pem"'",
503                 "ca_cert": "'"$PKIDIR/testpki-cacert.pem"'"}}]']],
504   [0], [ignore], [ignore])
505 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
506 AT_CHECK(
507   [ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid \
508         --private-key=db:mydb,SSL,private_key \
509         --certificate=db:mydb,SSL,certificate \
510         --ca-cert=db:mydb,SSL,ca_cert \
511         --remote=pssl:0:127.0.0.1 --unixctl="`pwd`"/unixctl db],
512   [0], [ignore], [ignore])
513 SSL_PORT=`parse_listening_port < ovsdb-server.log`
514 AT_CHECK(
515   [[ovsdb-client \
516         --private-key=$PKIDIR/testpki-privkey.pem \
517         --certificate=$PKIDIR/testpki-cert.pem \
518         --ca-cert=$PKIDIR/testpki-cacert.pem \
519         transact ssl:127.0.0.1:$SSL_PORT \
520         '["mydb",
521           {"op": "select",
522            "table": "SSL",
523            "where": [],
524            "columns": ["private_key"]}]']], 
525   [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`])
526 cat stdout >> output
527 AT_CHECK_UNQUOTED(
528   [cat output], [0],
529   [[[{"rows":[{"private_key":"$PKIDIR/testpki-privkey2.pem"}]}]
530 ]], [ignore], [test ! -e pid || kill `cat pid`])
531 OVSDB_SERVER_SHUTDOWN
532 AT_CLEANUP
533
534 AT_SETUP([compacting online])
535 AT_KEYWORDS([ovsdb server compact])
536 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
537 ordinal_schema > schema
538 dnl Make sure that "ovsdb-tool create" works with a dangling symlink for
539 dnl the database and the lockfile, creating the target of each symlink rather
540 dnl than replacing the symlinks with regular files.
541 mkdir dir
542 ln -s dir/db db
543 ln -s dir/.db.~lock~ .db.~lock~
544 AT_SKIP_IF([test ! -h db || test ! -h .db.~lock~])
545 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
546 dnl Start ovsdb-server.
547 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])
548 AT_CAPTURE_FILE([ovsdb-server.log])
549 dnl Do a bunch of random transactions that put crap in the database log.
550 AT_CHECK(
551   [[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do
552       set -- $pair
553       ovsdb-client transact unix:socket '
554         ["ordinals",
555          {"op": "insert",
556           "table": "ordinals",
557           "row": {"name": "'$1'", "number": '$2'}},
558          {"op": "comment",
559           "comment": "add row for '"$pair"'"}]'
560       ovsdb-client transact unix:socket '
561         ["ordinals",
562          {"op": "delete",
563           "table": "ordinals",
564           "where": [["number", "==", '$2']]},
565          {"op": "comment",
566           "comment": "delete row for '"$2"'"}]'
567       ovsdb-client transact unix:socket '
568         ["ordinals",
569          {"op": "insert",
570           "table": "ordinals",
571           "row": {"name": "'$1'", "number": '$2'}},
572          {"op": "comment",
573           "comment": "add back row for '"$pair"'"}]'
574     done]],
575   [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`])
576 dnl Check that all the crap is in fact in the database log.
577 AT_CHECK([[${PERL} $srcdir/uuidfilt.pl db | grep -v ^OVSDB | sed 's/"_date":[0-9]*/"_date":0/' | ovstest test-json --multiple -]], [0],
578   [[{"cksum":"12345678 9","name":"ordinals","tables":{"ordinals":{"columns":{"name":{"type":"string"},"number":{"type":"integer"}},"indexes":[["number"]]}},"version":"5.1.3"}
579 {"_comment":"add row for zero 0","_date":0,"ordinals":{"<0>":{"name":"zero"}}}
580 {"_comment":"delete row for 0","_date":0,"ordinals":{"<0>":null}}
581 {"_comment":"add back row for zero 0","_date":0,"ordinals":{"<1>":{"name":"zero"}}}
582 {"_comment":"add row for one 1","_date":0,"ordinals":{"<2>":{"name":"one","number":1}}}
583 {"_comment":"delete row for 1","_date":0,"ordinals":{"<2>":null}}
584 {"_comment":"add back row for one 1","_date":0,"ordinals":{"<3>":{"name":"one","number":1}}}
585 {"_comment":"add row for two 2","_date":0,"ordinals":{"<4>":{"name":"two","number":2}}}
586 {"_comment":"delete row for 2","_date":0,"ordinals":{"<4>":null}}
587 {"_comment":"add back row for two 2","_date":0,"ordinals":{"<5>":{"name":"two","number":2}}}
588 {"_comment":"add row for three 3","_date":0,"ordinals":{"<6>":{"name":"three","number":3}}}
589 {"_comment":"delete row for 3","_date":0,"ordinals":{"<6>":null}}
590 {"_comment":"add back row for three 3","_date":0,"ordinals":{"<7>":{"name":"three","number":3}}}
591 {"_comment":"add row for four 4","_date":0,"ordinals":{"<8>":{"name":"four","number":4}}}
592 {"_comment":"delete row for 4","_date":0,"ordinals":{"<8>":null}}
593 {"_comment":"add back row for four 4","_date":0,"ordinals":{"<9>":{"name":"four","number":4}}}
594 {"_comment":"add row for five 5","_date":0,"ordinals":{"<10>":{"name":"five","number":5}}}
595 {"_comment":"delete row for 5","_date":0,"ordinals":{"<10>":null}}
596 {"_comment":"add back row for five 5","_date":0,"ordinals":{"<11>":{"name":"five","number":5}}}
597 ]], [], [test ! -e pid || kill `cat pid`])
598 dnl Dump out and check the actual database contents.
599 AT_CHECK([[ovsdb-client dump unix:socket ordinals]],
600   [0], [stdout], [ignore])
601 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl
602 ordinals table
603 _uuid                                name  number
604 ------------------------------------ ----- ------
605 <0> five  5     @&t@
606 <1> four  4     @&t@
607 <2> one   1     @&t@
608 <3> three 3     @&t@
609 <4> two   2     @&t@
610 <5> zero  0     @&t@
611 ], [], [test ! -e pid || kill `cat pid`])
612 dnl Now compact the database in-place.
613 AT_CHECK([[ovs-appctl -t "`pwd`"/unixctl ovsdb-server/compact]],
614   [0], [], [ignore], [test ! -e pid || kill `cat pid`])
615 dnl Make sure that "db" is still a symlink to dir/db instead of getting
616 dnl replaced by a regular file, ditto for .db.~lock~.
617 AT_CHECK([test -h db])
618 AT_CHECK([test -h .db.~lock~])
619 AT_CHECK([test -f dir/db])
620 AT_CHECK([test -f dir/.db.~lock~])
621 dnl We can't fully re-check the contents of the database log, because the
622 dnl order of the records is not predictable, but there should only be 4 lines
623 dnl in it now.
624 AT_CAPTURE_FILE([db])
625 AT_CHECK([test `wc -l < db` -eq 4], [0], [], [],
626   [test ! -e pid || kill `cat pid`])
627 dnl And check that the dumped data is the same too:
628 AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore],
629   [test ! -e pid || kill `cat pid`])
630 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl
631 ordinals table
632 _uuid                                name  number
633 ------------------------------------ ----- ------
634 <0> five  5     @&t@
635 <1> four  4     @&t@
636 <2> one   1     @&t@
637 <3> three 3     @&t@
638 <4> two   2     @&t@
639 <5> zero  0     @&t@
640 ], [], [test ! -e pid || kill `cat pid`])
641 dnl Now do some more transactions.
642 AT_CHECK(
643   [[ovsdb-client transact unix:socket '
644      ["ordinals",
645       {"op": "delete",
646        "table": "ordinals",
647        "where": [["number", "<", 3]]}]']],
648   [0], [[[{"count":3}]
649 ]], [ignore], [test ! -e pid || kill `cat pid`])
650 dnl There should be 6 lines in the log now.
651 AT_CHECK([test `wc -l < db` -eq 6], [0], [], [],
652   [test ! -e pid || kill `cat pid`])
653 dnl Then check that the dumped data is correct.
654 AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore],
655   [test ! -e pid || kill `cat pid`])
656 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl
657 ordinals table
658 _uuid                                name  number
659 ------------------------------------ ----- ------
660 <0> five  5     @&t@
661 <1> four  4     @&t@
662 <2> three 3     @&t@
663 ], [], [test ! -e pid || kill `cat pid`])
664 OVSDB_SERVER_SHUTDOWN
665 AT_CLEANUP
666
667 AT_SETUP([ovsdb-server combines updates on backlogged connections])
668 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
669 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
670 ON_EXIT([kill `cat *.pid`])
671
672 # The maximum socket receive buffer size is important for this test, which
673 # tests behavior when the receive buffer overflows.
674 if test -e /proc/sys/net/core/rmem_max; then
675     # Linux
676     rmem_max=`cat /proc/sys/net/core/rmem_max`
677 elif rmem_max=`sysctl -n net.inet.tcp.recvbuf_max 2>/dev/null`; then
678     : # FreeBSD, NetBSD
679 else
680     # Don't know how to get maximum socket receive buffer on this OS
681     AT_SKIP_IF([:])
682 fi
683
684 # Calculate the number of iterations we need to queue.  Each of the
685 # iterations we execute, by itself, yields a monitor update of about
686 # 25 kB, so fill up that much space plus a few for luck.
687 n_iterations=`expr $rmem_max / 25000 + 5`
688 echo rmem_max=$rmem_max n_iterations=$n_iterations
689
690 # If there's too much queuing skip the test to avoid timing out.
691 AT_SKIP_IF([test $rmem_max -gt 1048576])
692
693 # Calculate the exact number of monitor updates expected for $n_iterations,
694 # assuming no updates are combined.  The "extra" update is for the initial
695 # contents of the database.
696 n_updates=`expr $n_iterations \* 3 + 1`
697
698 # Start an ovsdb-server with the vswitchd schema.
699 OVSDB_INIT([db])
700 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:db.sock db],
701   [0], [ignore], [ignore])
702
703 # Executes a set of transactions that add a bridge with 100 ports, and
704 # then deletes that bridge.  This yields three monitor updates that
705 # add up to about 25 kB in size.
706 #
707 # The update also increments a counter held in the database so that we can
708 # verify that the overall effect of the transactions took effect (e.g.
709 # monitor updates at the end weren't just dropped).  We add an arbitrary
710 # string to the counter to make grepping for it more reliable.
711 counter=0
712 trigger_big_update () {
713     counter=`expr $counter + 1`
714     ovs-vsctl --no-wait -- set open_vswitch . system_version=xyzzy$counter
715     ovs-vsctl --no-wait -- add-br br0 $add
716     ovs-vsctl --no-wait -- del-br br0
717 }
718 add_ports () {
719     for j in `seq 1 100`; do
720         printf " -- add-port br0 p%d" $j
721     done
722 }
723 add=`add_ports`
724
725 AT_CAPTURE_FILE([ovsdb-client.err])
726
727 # Start an ovsdb-client monitoring all changes to the database,
728 # make it block to force the buffers to fill up, and then execute
729 # enough iterations that ovsdb-server starts combining updates.
730 AT_CHECK([ovsdb-client --detach --no-chdir --pidfile monitor ALL >ovsdb-client.out 2>ovsdb-client.err])
731 AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/block])
732 for i in `seq 1 $n_iterations`; do
733     echo "blocked update ($i of $n_iterations)"
734     trigger_big_update $i
735 done
736 AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/unblock])
737 OVS_WAIT_UNTIL([grep "\"xyzzy$counter\"" ovsdb-client.out])
738 AT_CHECK([ovs-appctl -t ovsdb-client exit])
739 OVS_WAIT_WHILE([test -e ovsdb-client.pid])
740
741 # Count the number of updates in the ovsdb-client output, by counting
742 # the number of changes to the Open_vSwitch table.  (All of our
743 # transactions modify the Open_vSwitch table.)  It should be less than
744 # $n_updates updates.
745 #
746 # Check that the counter is what we expect.
747 logged_updates=`grep -c '^Open_vSwitch' ovsdb-client.out`
748 echo "logged_updates=$logged_updates (expected less than $n_updates)"
749 AT_CHECK([test $logged_updates -lt $n_updates])
750 AT_CHECK_UNQUOTED([ovs-vsctl get open_vswitch . system_version], [0],
751   ["xyzzy$counter"
752 ])
753 AT_CLEANUP
754 \f
755 AT_BANNER([OVSDB -- ovsdb-server transactions (SSL IPv4 sockets)])
756
757 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
758 #
759 # Creates a database with the given SCHEMA, starts an ovsdb-server on
760 # that database, and runs each of the TRANSACTIONS (which should be a
761 # quoted list of quoted strings) against it with ovsdb-client one at a
762 # time.
763 #
764 # Checks that the overall output is OUTPUT, but UUIDs in the output
765 # are replaced by markers of the form <N> where N is a number.  The
766 # first unique UUID is replaced by <0>, the next by <1>, and so on.
767 # If a given UUID appears more than once it is always replaced by the
768 # same marker.
769 #
770 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
771 m4_define([OVSDB_CHECK_EXECUTION], 
772   [AT_SETUP([$1])
773    AT_KEYWORDS([ovsdb server positive ssl $5])
774    AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
775    OVS_RUNDIR=`pwd`; export OVS_RUNDIR
776    OVS_LOGDIR=`pwd`; export OVS_LOGDIR
777    $2 > schema
778    PKIDIR=$abs_top_builddir/tests
779    AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
780    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])
781    SSL_PORT=`parse_listening_port < ovsdb-server.log`
782    m4_foreach([txn], [$3], 
783      [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],
784      [test ! -e pid || kill `cat pid`])
785 cat stdout >> output
786 ])
787    AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
788             [test ! -e pid || kill `cat pid`])
789    OVSDB_SERVER_SHUTDOWN
790    AT_CLEANUP])
791
792 EXECUTION_EXAMPLES
793
794 AT_BANNER([OVSDB -- ovsdb-server transactions (SSL IPv6 sockets)])
795
796 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
797 #
798 # Creates a database with the given SCHEMA, starts an ovsdb-server on
799 # that database, and runs each of the TRANSACTIONS (which should be a
800 # quoted list of quoted strings) against it with ovsdb-client one at a
801 # time.
802 #
803 # Checks that the overall output is OUTPUT, but UUIDs in the output
804 # are replaced by markers of the form <N> where N is a number.  The
805 # first unique UUID is replaced by <0>, the next by <1>, and so on.
806 # If a given UUID appears more than once it is always replaced by the
807 # same marker.
808 #
809 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
810 m4_define([OVSDB_CHECK_EXECUTION],
811   [AT_SETUP([$1])
812    AT_KEYWORDS([ovsdb server positive ssl6 $5])
813    AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
814    OVS_RUNDIR=`pwd`; export OVS_RUNDIR
815    OVS_LOGDIR=`pwd`; export OVS_LOGDIR
816    $2 > schema
817    PKIDIR=$abs_top_builddir/tests
818    AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
819    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])
820    SSL_PORT=`parse_listening_port < ovsdb-server.log`
821    m4_foreach([txn], [$3],
822      [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],
823      [test ! -e pid || kill `cat pid`])
824 cat stdout >> output
825 ])
826    AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
827             [test ! -e pid || kill `cat pid`])
828    OVSDB_SERVER_SHUTDOWN
829    AT_CLEANUP])
830
831 ONE_EXECUTION_EXAMPLE
832
833 AT_BANNER([OVSDB -- ovsdb-server transactions (TCP IPv4 sockets)])
834
835 AT_SETUP([ovsdb-client get-schema-version - tcp socket])
836 AT_KEYWORDS([ovsdb server positive tcp])
837 ordinal_schema > schema
838 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
839 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
840 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])
841 TCP_PORT=`parse_listening_port < ovsdb-server.log`
842 AT_CHECK([ovsdb-client get-schema-version tcp:127.0.0.1:$TCP_PORT ordinals], [0], [5.1.3
843 ])
844 OVSDB_SERVER_SHUTDOWN
845 AT_CLEANUP])
846
847 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
848 #
849 # Creates a database with the given SCHEMA, starts an ovsdb-server on
850 # that database, and runs each of the TRANSACTIONS (which should be a
851 # quoted list of quoted strings) against it with ovsdb-client one at a
852 # time.
853 #
854 # Checks that the overall output is OUTPUT, but UUIDs in the output
855 # are replaced by markers of the form <N> where N is a number.  The
856 # first unique UUID is replaced by <0>, the next by <1>, and so on.
857 # If a given UUID appears more than once it is always replaced by the
858 # same marker.
859 #
860 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
861 m4_define([OVSDB_CHECK_EXECUTION],
862   [AT_SETUP([$1])
863    AT_KEYWORDS([ovsdb server positive tcp $5])
864    OVS_RUNDIR=`pwd`; export OVS_RUNDIR
865    OVS_LOGDIR=`pwd`; export OVS_LOGDIR
866    $2 > schema
867    PKIDIR=$abs_top_builddir/tests
868    AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
869    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])
870    TCP_PORT=`parse_listening_port < ovsdb-server.log`
871    m4_foreach([txn], [$3],
872      [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT 'txn'], [0], [stdout], [ignore],
873      [test ! -e pid || kill `cat pid`])
874 cat stdout >> output
875 ])
876    AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
877             [test ! -e pid || kill `cat pid`])
878    OVSDB_SERVER_SHUTDOWN
879    AT_CLEANUP])
880
881 EXECUTION_EXAMPLES
882
883 AT_BANNER([OVSDB -- ovsdb-server transactions (TCP IPv6 sockets)])
884
885 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
886 #
887 # Creates a database with the given SCHEMA, starts an ovsdb-server on
888 # that database, and runs each of the TRANSACTIONS (which should be a
889 # quoted list of quoted strings) against it with ovsdb-client one at a
890 # time.
891 #
892 # Checks that the overall output is OUTPUT, but UUIDs in the output
893 # are replaced by markers of the form <N> where N is a number.  The
894 # first unique UUID is replaced by <0>, the next by <1>, and so on.
895 # If a given UUID appears more than once it is always replaced by the
896 # same marker.
897 #
898 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
899 m4_define([OVSDB_CHECK_EXECUTION],
900   [AT_SETUP([$1])
901    AT_KEYWORDS([ovsdb server positive tcp6 $5])
902    OVS_RUNDIR=`pwd`; export OVS_RUNDIR
903    OVS_LOGDIR=`pwd`; export OVS_LOGDIR
904    $2 > schema
905    PKIDIR=$abs_top_builddir/tests
906    AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
907    AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid --remote=ptcp:0:[[::1]] --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
908    TCP_PORT=`parse_listening_port < ovsdb-server.log`
909    m4_foreach([txn], [$3],
910      [AT_CHECK([ovsdb-client transact tcp:[[::1]]:$TCP_PORT 'txn'], [0], [stdout], [ignore],
911      [test ! -e pid || kill `cat pid`])
912 cat stdout >> output
913 ])
914    AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
915             [test ! -e pid || kill `cat pid`])
916    OVSDB_SERVER_SHUTDOWN
917    AT_CLEANUP])
918
919 ONE_EXECUTION_EXAMPLE
920 \f
921 AT_BANNER([OVSDB -- transactions on transient ovsdb-server])
922
923 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
924 #
925 # Creates a database with the given SCHEMA and runs each of the
926 # TRANSACTIONS (which should be a quoted list of quoted strings)
927 # against it with ovsdb-client one at a time.  Each ovsdb-client
928 # is run against a separately started ovsdb-server that executes
929 # only that single transaction.  (The idea is that this should
930 # help to ferret out any differences between what ovsdb-server has
931 # in memory and what actually gets committed to disk.)
932 #
933 # Checks that the overall output is OUTPUT, but UUIDs in the output
934 # are replaced by markers of the form <N> where N is a number.  The
935 # first unique UUID is replaced by <0>, the next by <1>, and so on.
936 # If a given UUID appears more than once it is always replaced by the
937 # same marker.
938 #
939 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
940 m4_define([OVSDB_CHECK_EXECUTION], 
941   [AT_SETUP([$1])
942    AT_KEYWORDS([ovsdb server positive transient $5])
943    OVS_RUNDIR=`pwd`; export OVS_RUNDIR
944    $2 > schema
945    AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
946    m4_foreach([txn], [$3], 
947      [AT_DATA([txnfile], [ovsdb-client transact unix:socket 'txn'
948 ])
949       AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [ignore])
950       cat stdout >> output
951 ])
952    AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore])
953    AT_CLEANUP])
954
955 EXECUTION_EXAMPLES