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_BANNER([ovsdb-server miscellaneous features])
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 \
53 "row": {"number": 0, "name": "zero"}}]'
55 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [])
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.
60 AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
64 "row": {"number": 1, "name": "one"}}]'
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],
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 \
80 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [])
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}]}]
87 [test ! -e pid || kill `cat pid`])
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 \
100 "row": {"number": 0, "name": "zero"}}]'
102 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [])
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 \
112 "row": {"number": 1, "name": "one"}}]'
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],
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 \
126 "sort": ["number"]}]'
128 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [])
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}]}]
135 [test ! -e pid || kill `cat pid`])
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
146 OVSDB_SERVER_SHUTDOWN
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])
158 [[ovsdb-client list-dbs unix:socket]],
161 ], [ignore], [test ! -e pid || kill `cat pid`])
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
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])
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],
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],
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])
196 # Add an already added database.
197 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], 2, [],
199 ovs-appctl: ovsdb-server: server returned an error
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
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
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],
221 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
222 [0], [db:ordinals,ordinals,name
225 AT_CHECK([ovsdb-client list-tables unix:socket ordinals], [1], [ignore], [ignore])
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],
231 AT_CHECK([ovsdb-client list-tables unix:socket constraints], [1], [ignore], [ignore])
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
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],
244 AT_CHECK([ovsdb-client list-tables unix:socket constraints], [0], [ignore], [ignore])
247 AT_SETUP([ovsdb-server/add-db with --monitor])
248 AT_KEYWORDS([ovsdb server positive])
249 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
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])
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],
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`])
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],
280 AT_SETUP([ovsdb-server/add-db and remove-db with --monitor])
281 AT_KEYWORDS([ovsdb server positive])
282 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
283 # Start ovsdb-server, initially with one db.
284 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
285 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
286 ordinal_schema > schema
287 AT_CHECK([ovsdb-tool create db1 schema], [0], [ignore], [ignore])
288 constraint_schema > schema2
289 AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore])
290 ON_EXIT([kill `cat *.pid`])
291 AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db1 db2])
293 # Remove the second database.
294 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db constraints])
295 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
299 # Kill the daemon process, making it look like a segfault,
300 # and wait for a new daemon process to get spawned.
301 cp ovsdb-server.pid old.pid
302 AT_CHECK([kill -SEGV `cat ovsdb-server.pid`])
303 OVS_WAIT_WHILE([kill -0 `cat old.pid`])
305 [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`])
306 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
311 AT_SETUP([--remote=db: implementation])
312 AT_KEYWORDS([ovsdb server positive])
313 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
314 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
324 "max": "unlimited"}},
327 "key": {"type": "uuid", "refTable": "Manager"},
329 "max": "unlimited"}}}},
340 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
342 [[ovsdb-tool transact db \
347 "managers": "punix:socket1",
348 "manager_options": ["set", [["named-uuid", "x"]]]}},
352 "row": {"target": "punix:socket2"}}]']], [0], [ignore], [ignore])
353 ON_EXIT([kill `cat ovsdb-server.pid`])
354 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])
355 for i in 1 2 3 4 5 6; do ovs-appctl -t ovsdb-server time/warp 1000; done
357 [[ovsdb-client transact unix:socket1 \
362 "columns": ["managers"]},
366 "columns": ["target", "is_connected"]}]']],
367 [0], [stdout], [ignore])
369 [${PERL} $srcdir/uuidfilt.pl stdout],
371 [[[{"rows":[{"managers":"punix:socket1"}]},{"rows":[{"is_connected":false,"target":"punix:socket2"}]}]
376 AT_SETUP([ovsdb-server/add-remote and remove-remote])
377 AT_KEYWORDS([ovsdb server positive])
378 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
379 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
380 ordinal_schema > schema
381 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
382 ON_EXIT([kill `cat *.pid`])
383 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile db])
385 AT_CHECK([test ! -e socket1])
386 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1])
387 if test "$IS_WIN32" = "yes"; then
388 OVS_WAIT_UNTIL([test -s socket1])
390 OVS_WAIT_UNTIL([test -S socket1])
392 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
396 AT_CHECK([test ! -e socket2])
397 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket2])
398 if test "$IS_WIN32" = "yes"; then
399 OVS_WAIT_UNTIL([test -s socket2])
401 OVS_WAIT_UNTIL([test -S socket2])
403 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
408 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote db:x,y,z], [2],
409 [], ["db:x,y,z": no database named x
410 ovs-appctl: ovsdb-server: server returned an error
413 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket1])
414 OVS_WAIT_UNTIL([test ! -e socket1])
415 if test "$IS_WIN32" = "yes"; then
416 AT_CHECK([test -s socket2])
418 AT_CHECK([test -S socket2])
420 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
424 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket2])
425 OVS_WAIT_UNTIL([test ! -e socket2])
426 AT_CHECK([test ! -e socket1])
427 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes])
430 AT_SETUP([ovsdb-server/add-remote with --monitor])
431 AT_KEYWORDS([ovsdb server positive])
432 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
433 # Start ovsdb-server, initially with no remotes.
434 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
435 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
436 ordinal_schema > schema
437 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
438 ON_EXIT([kill `cat *.pid`])
439 AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db])
442 AT_CHECK([test ! -e socket1])
443 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1])
444 OVS_WAIT_UNTIL([test -S socket1])
445 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 for it to
451 # start listening on 'socket1'.
452 cp ovsdb-server.pid old.pid
454 AT_CHECK([kill -SEGV `cat ovsdb-server.pid`])
455 OVS_WAIT_WHILE([kill -0 `cat old.pid`])
457 [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`])
458 OVS_WAIT_UNTIL([test -S socket1])
461 AT_SETUP([ovsdb-server/add-remote and remove-remote with --monitor])
462 AT_KEYWORDS([ovsdb server positive])
463 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
464 # Start ovsdb-server, initially with no remotes.
465 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
466 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
467 ordinal_schema > schema
468 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
469 ON_EXIT([kill `cat *.pid`])
470 AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db])
473 AT_CHECK([test ! -e socket1])
474 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1])
475 OVS_WAIT_UNTIL([test -S socket1])
476 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
481 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket1])
482 OVS_WAIT_UNTIL([test ! -e socket1])
483 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes])
485 # Kill the daemon process, making it look like a segfault,
486 # and wait for a new daemon process to get spawned and make sure that it
487 # does not listen on 'socket1'.
488 cp ovsdb-server.pid old.pid
489 AT_CHECK([kill -SEGV `cat ovsdb-server.pid`])
490 OVS_WAIT_WHILE([kill -0 `cat old.pid`])
492 [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`])
493 AT_CHECK([test ! -e socket1])
496 AT_SETUP([SSL db: implementation])
497 AT_KEYWORDS([ovsdb server positive ssl $5])
498 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
499 PKIDIR=$abs_top_builddir/tests
500 AT_SKIP_IF([expr "$PKIDIR" : ".*[ '\"
507 "private_key": {"type": "string"},
508 "certificate": {"type": "string"},
509 "ca_cert": {"type": "string"}}}}}
511 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
513 [[ovsdb-tool transact db \
517 "row": {"private_key": "'"$PKIDIR/testpki-privkey2.pem"'",
518 "certificate": "'"$PKIDIR/testpki-cert2.pem"'",
519 "ca_cert": "'"$PKIDIR/testpki-cacert.pem"'"}}]']],
520 [0], [ignore], [ignore])
521 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
523 [ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid \
524 --private-key=db:mydb,SSL,private_key \
525 --certificate=db:mydb,SSL,certificate \
526 --ca-cert=db:mydb,SSL,ca_cert \
527 --remote=pssl:0:127.0.0.1 --unixctl="`pwd`"/unixctl db],
528 [0], [ignore], [ignore])
529 SSL_PORT=`parse_listening_port < ovsdb-server.log`
532 --private-key=$PKIDIR/testpki-privkey.pem \
533 --certificate=$PKIDIR/testpki-cert.pem \
534 --ca-cert=$PKIDIR/testpki-cacert.pem \
535 transact ssl:127.0.0.1:$SSL_PORT \
540 "columns": ["private_key"]}]']],
541 [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`])
545 [[[{"rows":[{"private_key":"$PKIDIR/testpki-privkey2.pem"}]}]
546 ]], [ignore], [test ! -e pid || kill `cat pid`])
547 OVSDB_SERVER_SHUTDOWN
550 AT_SETUP([compacting online])
551 AT_KEYWORDS([ovsdb server compact])
552 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
553 ordinal_schema > schema
554 dnl Make sure that "ovsdb-tool create" works with a dangling symlink for
555 dnl the database and the lockfile, creating the target of each symlink rather
556 dnl than replacing the symlinks with regular files.
559 ln -s dir/.db.~lock~ .db.~lock~
560 AT_SKIP_IF([test ! -h db || test ! -h .db.~lock~])
561 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
562 dnl Start ovsdb-server.
563 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])
564 AT_CAPTURE_FILE([ovsdb-server.log])
565 dnl Do a bunch of random transactions that put crap in the database log.
567 [[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do
569 ovsdb-client transact unix:socket '
573 "row": {"name": "'$1'", "number": '$2'}},
575 "comment": "add row for '"$pair"'"}]'
576 ovsdb-client transact unix:socket '
580 "where": [["number", "==", '$2']]},
582 "comment": "delete row for '"$2"'"}]'
583 ovsdb-client transact unix:socket '
587 "row": {"name": "'$1'", "number": '$2'}},
589 "comment": "add back row for '"$pair"'"}]'
591 [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`])
592 dnl Check that all the crap is in fact in the database log.
593 AT_CHECK([[${PERL} $srcdir/uuidfilt.pl db | grep -v ^OVSDB | sed 's/"_date":[0-9]*/"_date":0/' | ovstest test-json --multiple -]], [0],
594 [[{"cksum":"12345678 9","name":"ordinals","tables":{"ordinals":{"columns":{"name":{"type":"string"},"number":{"type":"integer"}},"indexes":[["number"]]}},"version":"5.1.3"}
595 {"_comment":"add row for zero 0","_date":0,"ordinals":{"<0>":{"name":"zero"}}}
596 {"_comment":"delete row for 0","_date":0,"ordinals":{"<0>":null}}
597 {"_comment":"add back row for zero 0","_date":0,"ordinals":{"<1>":{"name":"zero"}}}
598 {"_comment":"add row for one 1","_date":0,"ordinals":{"<2>":{"name":"one","number":1}}}
599 {"_comment":"delete row for 1","_date":0,"ordinals":{"<2>":null}}
600 {"_comment":"add back row for one 1","_date":0,"ordinals":{"<3>":{"name":"one","number":1}}}
601 {"_comment":"add row for two 2","_date":0,"ordinals":{"<4>":{"name":"two","number":2}}}
602 {"_comment":"delete row for 2","_date":0,"ordinals":{"<4>":null}}
603 {"_comment":"add back row for two 2","_date":0,"ordinals":{"<5>":{"name":"two","number":2}}}
604 {"_comment":"add row for three 3","_date":0,"ordinals":{"<6>":{"name":"three","number":3}}}
605 {"_comment":"delete row for 3","_date":0,"ordinals":{"<6>":null}}
606 {"_comment":"add back row for three 3","_date":0,"ordinals":{"<7>":{"name":"three","number":3}}}
607 {"_comment":"add row for four 4","_date":0,"ordinals":{"<8>":{"name":"four","number":4}}}
608 {"_comment":"delete row for 4","_date":0,"ordinals":{"<8>":null}}
609 {"_comment":"add back row for four 4","_date":0,"ordinals":{"<9>":{"name":"four","number":4}}}
610 {"_comment":"add row for five 5","_date":0,"ordinals":{"<10>":{"name":"five","number":5}}}
611 {"_comment":"delete row for 5","_date":0,"ordinals":{"<10>":null}}
612 {"_comment":"add back row for five 5","_date":0,"ordinals":{"<11>":{"name":"five","number":5}}}
613 ]], [], [test ! -e pid || kill `cat pid`])
614 dnl Dump out and check the actual database contents.
615 AT_CHECK([[ovsdb-client dump unix:socket ordinals]],
616 [0], [stdout], [ignore])
617 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl
620 ------------------------------------ ----- ------
627 ], [], [test ! -e pid || kill `cat pid`])
628 dnl Now compact the database in-place.
629 AT_CHECK([[ovs-appctl -t "`pwd`"/unixctl ovsdb-server/compact]],
630 [0], [], [ignore], [test ! -e pid || kill `cat pid`])
631 dnl Make sure that "db" is still a symlink to dir/db instead of getting
632 dnl replaced by a regular file, ditto for .db.~lock~.
633 AT_CHECK([test -h db])
634 AT_CHECK([test -h .db.~lock~])
635 AT_CHECK([test -f dir/db])
636 AT_CHECK([test -f dir/.db.~lock~])
637 dnl We can't fully re-check the contents of the database log, because the
638 dnl order of the records is not predictable, but there should only be 4 lines
640 AT_CAPTURE_FILE([db])
641 AT_CHECK([test `wc -l < db` -eq 4], [0], [], [],
642 [test ! -e pid || kill `cat pid`])
643 dnl And check that the dumped data is the same too:
644 AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore],
645 [test ! -e pid || kill `cat pid`])
646 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl
649 ------------------------------------ ----- ------
656 ], [], [test ! -e pid || kill `cat pid`])
657 dnl Now do some more transactions.
659 [[ovsdb-client transact unix:socket '
663 "where": [["number", "<", 3]]}]']],
665 ]], [ignore], [test ! -e pid || kill `cat pid`])
666 dnl There should be 6 lines in the log now.
667 AT_CHECK([test `wc -l < db` -eq 6], [0], [], [],
668 [test ! -e pid || kill `cat pid`])
669 dnl Then check that the dumped data is correct.
670 AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore],
671 [test ! -e pid || kill `cat pid`])
672 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl
675 ------------------------------------ ----- ------
679 ], [], [test ! -e pid || kill `cat pid`])
680 OVSDB_SERVER_SHUTDOWN
683 AT_SETUP([ovsdb-server combines updates on backlogged connections])
684 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
685 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
686 ON_EXIT([kill `cat *.pid`])
688 # The maximum socket receive buffer size is important for this test, which
689 # tests behavior when the receive buffer overflows.
690 if test -e /proc/sys/net/core/rmem_max; then
692 rmem_max=`cat /proc/sys/net/core/rmem_max`
693 elif rmem_max=`sysctl -n net.inet.tcp.recvbuf_max 2>/dev/null`; then
696 # Don't know how to get maximum socket receive buffer on this OS
700 # Calculate the number of iterations we need to queue. Each of the
701 # iterations we execute, by itself, yields a monitor update of about
702 # 25 kB, so fill up that much space plus a few for luck.
703 n_iterations=`expr $rmem_max / 25000 + 5`
704 echo rmem_max=$rmem_max n_iterations=$n_iterations
706 # If there's too much queuing skip the test to avoid timing out.
707 AT_SKIP_IF([test $rmem_max -gt 1048576])
709 # Calculate the exact number of monitor updates expected for $n_iterations,
710 # assuming no updates are combined. The "extra" update is for the initial
711 # contents of the database.
712 n_updates=`expr $n_iterations \* 3 + 1`
714 # Start an ovsdb-server with the vswitchd schema.
716 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:db.sock db],
717 [0], [ignore], [ignore])
719 # Executes a set of transactions that add a bridge with 100 ports, and
720 # then deletes that bridge. This yields three monitor updates that
721 # add up to about 25 kB in size.
723 # The update also increments a counter held in the database so that we can
724 # verify that the overall effect of the transactions took effect (e.g.
725 # monitor updates at the end weren't just dropped). We add an arbitrary
726 # string to the counter to make grepping for it more reliable.
728 trigger_big_update () {
729 counter=`expr $counter + 1`
730 ovs-vsctl --no-wait -- set open_vswitch . system_version=xyzzy$counter
731 ovs-vsctl --no-wait -- add-br br0 $add
732 ovs-vsctl --no-wait -- del-br br0
735 for j in `seq 1 100`; do
736 printf " -- add-port br0 p%d" $j
741 AT_CAPTURE_FILE([ovsdb-client.err])
743 # Start an ovsdb-client monitoring all changes to the database,
744 # make it block to force the buffers to fill up, and then execute
745 # enough iterations that ovsdb-server starts combining updates.
746 AT_CHECK([ovsdb-client --detach --no-chdir --pidfile monitor ALL >ovsdb-client.out 2>ovsdb-client.err])
747 AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/block])
748 for i in `seq 1 $n_iterations`; do
749 echo "blocked update ($i of $n_iterations)"
750 trigger_big_update $i
752 AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/unblock])
753 OVS_WAIT_UNTIL([grep "\"xyzzy$counter\"" ovsdb-client.out])
754 AT_CHECK([ovs-appctl -t ovsdb-client exit])
755 OVS_WAIT_WHILE([test -e ovsdb-client.pid])
757 # Count the number of updates in the ovsdb-client output, by counting
758 # the number of changes to the Open_vSwitch table. (All of our
759 # transactions modify the Open_vSwitch table.) It should be less than
760 # $n_updates updates.
762 # Check that the counter is what we expect.
763 logged_updates=`grep -c '^Open_vSwitch' ovsdb-client.out`
764 echo "logged_updates=$logged_updates (expected less than $n_updates)"
765 AT_CHECK([test $logged_updates -lt $n_updates])
766 AT_CHECK_UNQUOTED([ovs-vsctl get open_vswitch . system_version], [0],
771 AT_BANNER([OVSDB -- ovsdb-server transactions (SSL IPv4 sockets)])
773 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
775 # Creates a database with the given SCHEMA, starts an ovsdb-server on
776 # that database, and runs each of the TRANSACTIONS (which should be a
777 # quoted list of quoted strings) against it with ovsdb-client one at a
780 # Checks that the overall output is OUTPUT, but UUIDs in the output
781 # are replaced by markers of the form <N> where N is a number. The
782 # first unique UUID is replaced by <0>, the next by <1>, and so on.
783 # If a given UUID appears more than once it is always replaced by the
786 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
787 m4_define([OVSDB_CHECK_EXECUTION],
789 AT_KEYWORDS([ovsdb server positive ssl $5])
790 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
791 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
792 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
794 PKIDIR=$abs_top_builddir/tests
795 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
796 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])
797 SSL_PORT=`parse_listening_port < ovsdb-server.log`
798 m4_foreach([txn], [$3],
799 [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],
800 [test ! -e pid || kill `cat pid`])
803 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
804 [test ! -e pid || kill `cat pid`])
805 OVSDB_SERVER_SHUTDOWN
810 AT_BANNER([OVSDB -- ovsdb-server transactions (SSL IPv6 sockets)])
812 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
814 # Creates a database with the given SCHEMA, starts an ovsdb-server on
815 # that database, and runs each of the TRANSACTIONS (which should be a
816 # quoted list of quoted strings) against it with ovsdb-client one at a
819 # Checks that the overall output is OUTPUT, but UUIDs in the output
820 # are replaced by markers of the form <N> where N is a number. The
821 # first unique UUID is replaced by <0>, the next by <1>, and so on.
822 # If a given UUID appears more than once it is always replaced by the
825 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
826 m4_define([OVSDB_CHECK_EXECUTION],
828 AT_KEYWORDS([ovsdb server positive ssl6 $5])
829 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
830 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
831 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
833 PKIDIR=$abs_top_builddir/tests
834 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
835 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])
836 SSL_PORT=`parse_listening_port < ovsdb-server.log`
837 m4_foreach([txn], [$3],
838 [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],
839 [test ! -e pid || kill `cat pid`])
842 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
843 [test ! -e pid || kill `cat pid`])
844 OVSDB_SERVER_SHUTDOWN
847 ONE_EXECUTION_EXAMPLE
849 AT_BANNER([OVSDB -- ovsdb-server transactions (TCP IPv4 sockets)])
851 AT_SETUP([ovsdb-client get-schema-version - tcp socket])
852 AT_KEYWORDS([ovsdb server positive tcp])
853 ordinal_schema > schema
854 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
855 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
856 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])
857 TCP_PORT=`parse_listening_port < ovsdb-server.log`
858 AT_CHECK([ovsdb-client get-schema-version tcp:127.0.0.1:$TCP_PORT ordinals], [0], [5.1.3
860 OVSDB_SERVER_SHUTDOWN
863 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
865 # Creates a database with the given SCHEMA, starts an ovsdb-server on
866 # that database, and runs each of the TRANSACTIONS (which should be a
867 # quoted list of quoted strings) against it with ovsdb-client one at a
870 # Checks that the overall output is OUTPUT, but UUIDs in the output
871 # are replaced by markers of the form <N> where N is a number. The
872 # first unique UUID is replaced by <0>, the next by <1>, and so on.
873 # If a given UUID appears more than once it is always replaced by the
876 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
877 m4_define([OVSDB_CHECK_EXECUTION],
879 AT_KEYWORDS([ovsdb server positive tcp $5])
880 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
881 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
883 PKIDIR=$abs_top_builddir/tests
884 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
885 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])
886 TCP_PORT=`parse_listening_port < ovsdb-server.log`
887 m4_foreach([txn], [$3],
888 [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT 'txn'], [0], [stdout], [ignore],
889 [test ! -e pid || kill `cat pid`])
892 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
893 [test ! -e pid || kill `cat pid`])
894 OVSDB_SERVER_SHUTDOWN
899 AT_BANNER([OVSDB -- ovsdb-server transactions (TCP IPv6 sockets)])
901 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
903 # Creates a database with the given SCHEMA, starts an ovsdb-server on
904 # that database, and runs each of the TRANSACTIONS (which should be a
905 # quoted list of quoted strings) against it with ovsdb-client one at a
908 # Checks that the overall output is OUTPUT, but UUIDs in the output
909 # are replaced by markers of the form <N> where N is a number. The
910 # first unique UUID is replaced by <0>, the next by <1>, and so on.
911 # If a given UUID appears more than once it is always replaced by the
914 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
915 m4_define([OVSDB_CHECK_EXECUTION],
917 AT_KEYWORDS([ovsdb server positive tcp6 $5])
918 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
919 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
921 PKIDIR=$abs_top_builddir/tests
922 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
923 AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid --remote=ptcp:0:[[::1]] --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
924 TCP_PORT=`parse_listening_port < ovsdb-server.log`
925 m4_foreach([txn], [$3],
926 [AT_CHECK([ovsdb-client transact tcp:[[::1]]:$TCP_PORT 'txn'], [0], [stdout], [ignore],
927 [test ! -e pid || kill `cat pid`])
930 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
931 [test ! -e pid || kill `cat pid`])
932 OVSDB_SERVER_SHUTDOWN
935 ONE_EXECUTION_EXAMPLE
937 AT_BANNER([OVSDB -- transactions on transient ovsdb-server])
939 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
941 # Creates a database with the given SCHEMA and runs each of the
942 # TRANSACTIONS (which should be a quoted list of quoted strings)
943 # against it with ovsdb-client one at a time. Each ovsdb-client
944 # is run against a separately started ovsdb-server that executes
945 # only that single transaction. (The idea is that this should
946 # help to ferret out any differences between what ovsdb-server has
947 # in memory and what actually gets committed to disk.)
949 # Checks that the overall output is OUTPUT, but UUIDs in the output
950 # are replaced by markers of the form <N> where N is a number. The
951 # first unique UUID is replaced by <0>, the next by <1>, and so on.
952 # If a given UUID appears more than once it is always replaced by the
955 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
956 m4_define([OVSDB_CHECK_EXECUTION],
958 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
959 AT_KEYWORDS([ovsdb server positive transient $5])
960 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
962 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
963 m4_foreach([txn], [$3],
964 [AT_DATA([txnfile], [ovsdb-client transact unix:socket 'txn'
966 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [ignore])
969 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore])