1 AT_BANNER([OVSDB -- ovsdb-server transactions (Unix sockets)])
3 m4_define([OVSDB_SERVER_SHUTDOWN],
5 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl -e exit], [0], [ignore], [ignore])
6 OVS_WAIT_WHILE([kill -0 `cat savepid`], [kill `cat savepid`])])
8 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
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
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
21 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
22 m4_define([OVSDB_CHECK_EXECUTION],
24 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
25 AT_KEYWORDS([ovsdb server positive unix $5])
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`])
34 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
35 [test ! -e pid || kill `cat pid`])
41 AT_SETUP([truncating corrupted database log])
42 AT_KEYWORDS([ovsdb server positive unix])
43 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
44 ordinal_schema > schema
45 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
46 dnl Do one transaction and save the output.
47 AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
51 "row": {"number": 0, "name": "zero"}}]'
53 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [])
55 dnl Add some crap to the database log and run another transaction, which should
56 dnl ignore the crap and truncate it out of the log.
58 AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
62 "row": {"number": 1, "name": "one"}}]'
64 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [stderr])
65 AT_CHECK([grep 'syntax error: db: parse error.* in header line "xxx"' stderr],
68 dnl Run a final transaction to verify that both transactions succeeeded.
69 dnl The crap that we added should have been truncated by the previous run,
70 dnl so ovsdb-server shouldn't log a warning this time.
71 AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
78 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [])
80 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0],
81 [[[{"uuid":["uuid","<0>"]}]
82 [{"uuid":["uuid","<1>"]}]
83 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
85 [test ! -e pid || kill `cat pid`])
88 AT_SETUP([truncating database log with bad transaction])
89 AT_KEYWORDS([ovsdb server positive unix])
90 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
91 ordinal_schema > schema
92 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
93 dnl Do one transaction and save the output.
94 AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
98 "row": {"number": 0, "name": "zero"}}]'
100 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [])
102 dnl Add some crap to the database log and run another transaction, which should
103 dnl ignore the crap and truncate it out of the log.
104 echo 'OVSDB JSON 15 ffbcdae4b0386265f9ea3280dd7c8f0b72a20e56
105 {"invalid":{}}' >> db
106 AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
110 "row": {"number": 1, "name": "one"}}]'
112 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [stderr])
113 AT_CHECK([grep 'syntax "{"invalid":{}}": unknown table: No table named invalid.' stderr],
116 dnl Run a final transaction to verify that both transactions succeeeded.
117 dnl The crap that we added should have been truncated by the previous run,
118 dnl so ovsdb-server shouldn't log a warning this time.
119 AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
124 "sort": ["number"]}]'
126 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [])
128 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0],
129 [[[{"uuid":["uuid","<0>"]}]
130 [{"uuid":["uuid","<1>"]}]
131 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
133 [test ! -e pid || kill `cat pid`])
136 AT_SETUP([ovsdb-client get-schema-version])
137 AT_KEYWORDS([ovsdb server positive])
138 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
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
144 OVSDB_SERVER_SHUTDOWN
147 AT_SETUP([database multiplexing implementation])
148 AT_KEYWORDS([ovsdb server positive])
149 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
150 ordinal_schema > schema1
151 constraint_schema > schema2
152 AT_CHECK([ovsdb-tool create db1 schema1], [0], [ignore], [ignore])
153 AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore])
154 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/pid --unixctl="`pwd`"/unixctl --remote=punix:socket db1 db2], [0], [ignore], [ignore])
156 [[ovsdb-client list-dbs unix:socket]],
159 ], [ignore], [test ! -e pid || kill `cat pid`])
161 [[test-jsonrpc request unix:socket get_schema [\"nonexistent\"]]], [0],
162 [[{"error":null,"id":0,"result":{"details":"get_schema request specifies unknown database nonexistent","error":"unknown database","syntax":"[\"nonexistent\"]"}}
163 ]], [], [test ! -e pid || kill `cat pid`])
164 OVSDB_SERVER_SHUTDOWN
167 AT_SETUP([ovsdb-server/add-db and remove-db])
168 AT_KEYWORDS([ovsdb server positive])
169 ON_EXIT([kill `cat ovsdb-server.pid`])
170 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
171 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
172 ordinal_schema > schema1
173 constraint_schema > schema2
174 AT_CHECK([ovsdb-tool create db1 schema1], [0], [ignore], [ignore])
175 AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore])
177 # Start ovsdb-server with just a single database - db1.
178 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket db1], [0])
179 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
183 # Add the second database.
184 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], [0])
185 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
190 # The databases are responsive.
191 AT_CHECK([ovsdb-client list-tables unix:socket constraints], [0], [ignore], [ignore])
192 AT_CHECK([ovsdb-client list-tables unix:socket ordinals], [0], [ignore], [ignore])
194 # Add an already added database.
195 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], 2, [], [stderr])
196 AT_CHECK([sed 's/(.*)/(...)/' stderr], [0],
197 [I/O error: db2: failed to lock lockfile (...)
198 ovs-appctl: ovsdb-server: server returned an error
201 # Add a non-existing database.
202 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db3], 2, [], [stderr])
203 AT_CHECK([sed 's/(.*)/(...)/' stderr], [0],
204 [I/O error: open: db3 failed (...)
205 ovs-appctl: ovsdb-server: server returned an error
208 # Add a remote through a db path in db1.
209 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote db:ordinals,ordinals,name], [0])
210 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
211 [0], [db:ordinals,ordinals,name
215 # Removing db1 has no effect on its remote.
216 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db ordinals], [0])
217 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
220 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
221 [0], [db:ordinals,ordinals,name
224 AT_CHECK([ovsdb-client list-tables unix:socket ordinals], [1], [ignore], [ignore])
227 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db constraints], [0])
228 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
230 AT_CHECK([ovsdb-client list-tables unix:socket constraints], [1], [ignore], [ignore])
232 # Remove a non-existent database.
233 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db ordinals], [2],
234 [], [Failed to find the database.
235 ovs-appctl: ovsdb-server: server returned an error
238 # Add a removed database.
239 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], [0])
240 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
243 AT_CHECK([ovsdb-client list-tables unix:socket constraints], [0], [ignore], [ignore])
246 AT_SETUP([ovsdb-server/add-db with --monitor])
247 AT_KEYWORDS([ovsdb server positive])
248 # Start ovsdb-server, initially with one db.
249 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
250 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
251 ordinal_schema > schema
252 AT_CHECK([ovsdb-tool create db1 schema], [0], [ignore], [ignore])
253 ON_EXIT([kill `cat *.pid`])
254 AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db1])
256 # Add the second database.
257 constraint_schema > schema2
258 AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore])
259 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], [0])
260 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
265 # Kill the daemon process, making it look like a segfault,
266 # and wait for a new daemon process to get spawned.
267 cp ovsdb-server.pid old.pid
268 AT_CHECK([kill -SEGV `cat ovsdb-server.pid`])
269 OVS_WAIT_WHILE([kill -0 `cat old.pid`])
271 [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`])
272 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
278 AT_SETUP([ovsdb-server/add-db and remove-db with --monitor])
279 AT_KEYWORDS([ovsdb server positive])
280 # Start ovsdb-server, initially with one db.
281 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
282 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
283 ordinal_schema > schema
284 AT_CHECK([ovsdb-tool create db1 schema], [0], [ignore], [ignore])
285 constraint_schema > schema2
286 AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore])
287 ON_EXIT([kill `cat *.pid`])
288 AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db1 db2])
290 # Remove the second database.
291 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db constraints])
292 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
296 # Kill the daemon process, making it look like a segfault,
297 # and wait for a new daemon process to get spawned.
298 cp ovsdb-server.pid old.pid
299 AT_CHECK([kill -SEGV `cat ovsdb-server.pid`])
300 OVS_WAIT_WHILE([kill -0 `cat old.pid`])
302 [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`])
303 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
308 AT_SETUP([--remote=db: implementation])
309 AT_KEYWORDS([ovsdb server positive])
310 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
311 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
321 "max": "unlimited"}},
324 "key": {"type": "uuid", "refTable": "Manager"},
326 "max": "unlimited"}}}},
337 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
339 [[ovsdb-tool transact db \
344 "managers": "punix:socket1",
345 "manager_options": ["set", [["named-uuid", "x"]]]}},
349 "row": {"target": "punix:socket2"}}]']], [0], [ignore], [ignore])
350 ON_EXIT([kill `cat ovsdb-server.pid`])
351 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])
352 for i in 1 2 3 4 5 6; do ovs-appctl -t ovsdb-server time/warp 1000; done
354 [[ovsdb-client transact unix:socket1 \
359 "columns": ["managers"]},
363 "columns": ["target", "is_connected"]}]']],
364 [0], [stdout], [ignore])
366 [${PERL} $srcdir/uuidfilt.pl stdout],
368 [[[{"rows":[{"managers":"punix:socket1"}]},{"rows":[{"is_connected":false,"target":"punix:socket2"}]}]
373 AT_SETUP([ovsdb-server/add-remote and remove-remote])
374 AT_KEYWORDS([ovsdb server positive])
375 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
376 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
377 ordinal_schema > schema
378 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
379 ON_EXIT([kill `cat *.pid`])
380 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile db])
382 AT_CHECK([test ! -e socket1])
383 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1])
384 OVS_WAIT_UNTIL([test -S socket1])
385 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
389 AT_CHECK([test ! -e socket2])
390 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket2])
391 OVS_WAIT_UNTIL([test -S socket2])
392 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
397 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote db:x,y,z], [2],
398 [], ["db:x,y,z": no database named x
399 ovs-appctl: ovsdb-server: server returned an error
402 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket1])
403 OVS_WAIT_UNTIL([test ! -e socket1])
404 AT_CHECK([test -S socket2])
405 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
409 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket2])
410 OVS_WAIT_UNTIL([test ! -e socket2])
411 AT_CHECK([test ! -e socket1])
412 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes])
415 AT_SETUP([ovsdb-server/add-remote and remove-remote with --monitor])
416 AT_KEYWORDS([ovsdb server positive])
417 # Start ovsdb-server, initially with no remotes.
418 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
419 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
420 ordinal_schema > schema
421 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
422 ON_EXIT([kill `cat *.pid`])
423 AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db])
426 AT_CHECK([test ! -e socket1])
427 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1])
428 OVS_WAIT_UNTIL([test -S socket1])
429 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
433 # Kill the daemon process, making it look like a segfault,
434 # and wait for a new daemon process to get spawned and for it to
435 # start listening on 'socket1'.
436 cp ovsdb-server.pid old.pid
438 AT_CHECK([kill -SEGV `cat ovsdb-server.pid`])
439 OVS_WAIT_WHILE([kill -0 `cat old.pid`])
441 [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`])
442 OVS_WAIT_UNTIL([test -S socket1])
445 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket1])
446 OVS_WAIT_UNTIL([test ! -e socket1])
447 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes])
449 # Kill the daemon process, making it look like a segfault,
450 # and wait for a new daemon process to get spawned and make sure that it
451 # does not listen on 'socket1'.
452 cp ovsdb-server.pid old.pid
453 AT_CHECK([kill -SEGV `cat ovsdb-server.pid`])
454 OVS_WAIT_WHILE([kill -0 `cat old.pid`])
456 [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`])
457 AT_CHECK([test ! -e socket1])
460 AT_SETUP([SSL db: implementation])
461 AT_KEYWORDS([ovsdb server positive ssl $5])
462 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
463 PKIDIR=$abs_top_builddir/tests
464 AT_SKIP_IF([expr "$PKIDIR" : ".*[ '\"
471 "private_key": {"type": "string"},
472 "certificate": {"type": "string"},
473 "ca_cert": {"type": "string"}}}}}
475 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
477 [[ovsdb-tool transact db \
481 "row": {"private_key": "'"$PKIDIR/testpki-privkey2.pem"'",
482 "certificate": "'"$PKIDIR/testpki-cert2.pem"'",
483 "ca_cert": "'"$PKIDIR/testpki-cacert.pem"'"}}]']],
484 [0], [ignore], [ignore])
485 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
487 [ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid \
488 --private-key=db:mydb,SSL,private_key \
489 --certificate=db:mydb,SSL,certificate \
490 --ca-cert=db:mydb,SSL,ca_cert \
491 --remote=pssl:0:127.0.0.1 --unixctl="`pwd`"/unixctl db],
492 [0], [ignore], [ignore])
493 SSL_PORT=`parse_listening_port < ovsdb-server.log`
496 --private-key=$PKIDIR/testpki-privkey.pem \
497 --certificate=$PKIDIR/testpki-cert.pem \
498 --ca-cert=$PKIDIR/testpki-cacert.pem \
499 transact ssl:127.0.0.1:$SSL_PORT \
504 "columns": ["private_key"]}]']],
505 [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`])
508 [${PERL} $srcdir/uuidfilt.pl output], [0],
509 [[[{"rows":[{"private_key":"$PKIDIR/testpki-privkey2.pem"}]}]
510 ]], [ignore], [test ! -e pid || kill `cat pid`])
511 OVSDB_SERVER_SHUTDOWN
514 AT_SETUP([compacting online])
515 AT_KEYWORDS([ovsdb server compact])
516 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
517 ordinal_schema > schema
518 dnl Make sure that "ovsdb-tool create" works with a dangling symlink for
519 dnl the database and the lockfile, creating the target of each symlink rather
520 dnl than replacing the symlinks with regular files.
523 ln -s dir/.db.~lock~ .db.~lock~
524 AT_SKIP_IF([test ! -h db || test ! -h .db.~lock~])
525 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
526 dnl Start ovsdb-server.
527 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])
528 AT_CAPTURE_FILE([ovsdb-server.log])
529 dnl Do a bunch of random transactions that put crap in the database log.
531 [[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do
533 ovsdb-client transact unix:socket '
537 "row": {"name": "'$1'", "number": '$2'}},
539 "comment": "add row for '"$pair"'"}]'
540 ovsdb-client transact unix:socket '
544 "where": [["number", "==", '$2']]},
546 "comment": "delete row for '"$2"'"}]'
547 ovsdb-client transact unix:socket '
551 "row": {"name": "'$1'", "number": '$2'}},
553 "comment": "add back row for '"$pair"'"}]'
555 [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`])
556 dnl Check that all the crap is in fact in the database log.
557 AT_CHECK([[${PERL} $srcdir/uuidfilt.pl db | grep -v ^OVSDB | sed 's/"_date":[0-9]*/"_date":0/' | test-json --multiple -]], [0],
558 [[{"cksum":"12345678 9","name":"ordinals","tables":{"ordinals":{"columns":{"name":{"type":"string"},"number":{"type":"integer"}},"indexes":[["number"]]}},"version":"5.1.3"}
559 {"_comment":"add row for zero 0","_date":0,"ordinals":{"<0>":{"name":"zero"}}}
560 {"_comment":"delete row for 0","_date":0,"ordinals":{"<0>":null}}
561 {"_comment":"add back row for zero 0","_date":0,"ordinals":{"<1>":{"name":"zero"}}}
562 {"_comment":"add row for one 1","_date":0,"ordinals":{"<2>":{"name":"one","number":1}}}
563 {"_comment":"delete row for 1","_date":0,"ordinals":{"<2>":null}}
564 {"_comment":"add back row for one 1","_date":0,"ordinals":{"<3>":{"name":"one","number":1}}}
565 {"_comment":"add row for two 2","_date":0,"ordinals":{"<4>":{"name":"two","number":2}}}
566 {"_comment":"delete row for 2","_date":0,"ordinals":{"<4>":null}}
567 {"_comment":"add back row for two 2","_date":0,"ordinals":{"<5>":{"name":"two","number":2}}}
568 {"_comment":"add row for three 3","_date":0,"ordinals":{"<6>":{"name":"three","number":3}}}
569 {"_comment":"delete row for 3","_date":0,"ordinals":{"<6>":null}}
570 {"_comment":"add back row for three 3","_date":0,"ordinals":{"<7>":{"name":"three","number":3}}}
571 {"_comment":"add row for four 4","_date":0,"ordinals":{"<8>":{"name":"four","number":4}}}
572 {"_comment":"delete row for 4","_date":0,"ordinals":{"<8>":null}}
573 {"_comment":"add back row for four 4","_date":0,"ordinals":{"<9>":{"name":"four","number":4}}}
574 {"_comment":"add row for five 5","_date":0,"ordinals":{"<10>":{"name":"five","number":5}}}
575 {"_comment":"delete row for 5","_date":0,"ordinals":{"<10>":null}}
576 {"_comment":"add back row for five 5","_date":0,"ordinals":{"<11>":{"name":"five","number":5}}}
577 ]], [], [test ! -e pid || kill `cat pid`])
578 dnl Dump out and check the actual database contents.
579 AT_CHECK([[ovsdb-client dump unix:socket ordinals]],
580 [0], [stdout], [ignore])
581 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl
584 ------------------------------------ ----- ------
591 ], [], [test ! -e pid || kill `cat pid`])
592 dnl Now compact the database in-place.
593 AT_CHECK([[ovs-appctl -t "`pwd`"/unixctl ovsdb-server/compact]],
594 [0], [], [ignore], [test ! -e pid || kill `cat pid`])
595 dnl Make sure that "db" is still a symlink to dir/db instead of getting
596 dnl replaced by a regular file, ditto for .db.~lock~.
597 AT_CHECK([test -h db])
598 AT_CHECK([test -h .db.~lock~])
599 AT_CHECK([test -f dir/db])
600 AT_CHECK([test -f dir/.db.~lock~])
601 dnl We can't fully re-check the contents of the database log, because the
602 dnl order of the records is not predictable, but there should only be 4 lines
604 AT_CAPTURE_FILE([db])
605 AT_CHECK([test `wc -l < db` -eq 4], [0], [], [],
606 [test ! -e pid || kill `cat pid`])
607 dnl And check that the dumped data is the same too:
608 AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore],
609 [test ! -e pid || kill `cat pid`])
610 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl
613 ------------------------------------ ----- ------
620 ], [], [test ! -e pid || kill `cat pid`])
621 dnl Now do some more transactions.
623 [[ovsdb-client transact unix:socket '
627 "where": [["number", "<", 3]]}]']],
629 ]], [ignore], [test ! -e pid || kill `cat pid`])
630 dnl There should be 6 lines in the log now.
631 AT_CHECK([test `wc -l < db` -eq 6], [0], [], [],
632 [test ! -e pid || kill `cat pid`])
633 dnl Then check that the dumped data is correct.
634 AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore],
635 [test ! -e pid || kill `cat pid`])
636 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl
639 ------------------------------------ ----- ------
643 ], [], [test ! -e pid || kill `cat pid`])
644 OVSDB_SERVER_SHUTDOWN
647 AT_BANNER([OVSDB -- ovsdb-server transactions (SSL sockets)])
649 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
651 # Creates a database with the given SCHEMA, starts an ovsdb-server on
652 # that database, and runs each of the TRANSACTIONS (which should be a
653 # quoted list of quoted strings) against it with ovsdb-client one at a
656 # Checks that the overall output is OUTPUT, but UUIDs in the output
657 # are replaced by markers of the form <N> where N is a number. The
658 # first unique UUID is replaced by <0>, the next by <1>, and so on.
659 # If a given UUID appears more than once it is always replaced by the
662 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
663 m4_define([OVSDB_CHECK_EXECUTION],
665 AT_KEYWORDS([ovsdb server positive ssl $5])
666 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
667 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
668 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
670 PKIDIR=$abs_top_builddir/tests
671 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
672 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])
673 SSL_PORT=`parse_listening_port < ovsdb-server.log`
674 m4_foreach([txn], [$3],
675 [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],
676 [test ! -e pid || kill `cat pid`])
679 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
680 [test ! -e pid || kill `cat pid`])
681 OVSDB_SERVER_SHUTDOWN
686 AT_BANNER([OVSDB -- ovsdb-server transactions (TCP sockets)])
688 AT_SETUP([ovsdb-client get-schema-version - tcp socket])
689 AT_KEYWORDS([ovsdb server positive tcp])
690 ordinal_schema > schema
691 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
692 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
693 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])
694 TCP_PORT=`parse_listening_port < ovsdb-server.log`
695 AT_CHECK([ovsdb-client get-schema-version tcp:127.0.0.1:$TCP_PORT ordinals], [0], [5.1.3
697 OVSDB_SERVER_SHUTDOWN
700 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
702 # Creates a database with the given SCHEMA, starts an ovsdb-server on
703 # that database, and runs each of the TRANSACTIONS (which should be a
704 # quoted list of quoted strings) against it with ovsdb-client one at a
707 # Checks that the overall output is OUTPUT, but UUIDs in the output
708 # are replaced by markers of the form <N> where N is a number. The
709 # first unique UUID is replaced by <0>, the next by <1>, and so on.
710 # If a given UUID appears more than once it is always replaced by the
713 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
714 m4_define([OVSDB_CHECK_EXECUTION],
716 AT_KEYWORDS([ovsdb server positive tcp $5])
717 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
718 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
720 PKIDIR=$abs_top_builddir/tests
721 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
722 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])
723 TCP_PORT=`parse_listening_port < ovsdb-server.log`
724 m4_foreach([txn], [$3],
725 [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT 'txn'], [0], [stdout], [ignore],
726 [test ! -e pid || kill `cat pid`])
729 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
730 [test ! -e pid || kill `cat pid`])
731 OVSDB_SERVER_SHUTDOWN
736 AT_BANNER([OVSDB -- transactions on transient ovsdb-server])
738 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
740 # Creates a database with the given SCHEMA and runs each of the
741 # TRANSACTIONS (which should be a quoted list of quoted strings)
742 # against it with ovsdb-client one at a time. Each ovsdb-client
743 # is run against a separately started ovsdb-server that executes
744 # only that single transaction. (The idea is that this should
745 # help to ferret out any differences between what ovsdb-server has
746 # in memory and what actually gets committed to disk.)
748 # Checks that the overall output is OUTPUT, but UUIDs in the output
749 # are replaced by markers of the form <N> where N is a number. The
750 # first unique UUID is replaced by <0>, the next by <1>, and so on.
751 # If a given UUID appears more than once it is always replaced by the
754 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
755 m4_define([OVSDB_CHECK_EXECUTION],
757 AT_KEYWORDS([ovsdb server positive transient $5])
758 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
760 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
761 m4_foreach([txn], [$3],
762 [AT_DATA([txnfile], [ovsdb-client transact unix:socket 'txn'
764 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [ignore])
767 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore])