1 AT_BANNER([OVSDB -- ovsdb-server transactions (Unix sockets)])
3 m4_define([OVSDB_SERVER_SHUTDOWN],
4 [OVS_APP_EXIT_AND_WAIT_BY_TARGET([`pwd`/unixctl], [`pwd`/pid])])
6 m4_define([OVSDB_SERVER_SHUTDOWN2],
8 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 -e exit], [0], [ignore], [ignore])
9 OVS_WAIT_WHILE([kill -0 `cat savepid2`], [kill `cat savepid2`])])
11 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
13 # Creates a database with the given SCHEMA, starts an ovsdb-server on
14 # that database, and runs each of the TRANSACTIONS (which should be a
15 # quoted list of quoted strings) against it with ovsdb-client one at a
18 # Checks that the overall output is OUTPUT, but UUIDs in the output
19 # are replaced by markers of the form <N> where N is a number. The
20 # first unique UUID is replaced by <0>, the next by <1>, and so on.
21 # If a given UUID appears more than once it is always replaced by the
24 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
25 m4_define([OVSDB_CHECK_EXECUTION],
27 AT_KEYWORDS([ovsdb server positive unix $5])
29 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
30 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/pid --remote=punix:socket --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
31 m4_foreach([txn], [$3],
32 [AT_CHECK([ovsdb-client transact unix:socket 'txn'], [0], [stdout], [ignore],
33 [test ! -e pid || kill `cat pid`])
36 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
37 [test ! -e pid || kill `cat pid`])
43 AT_BANNER([ovsdb-server miscellaneous features])
45 AT_SETUP([truncating corrupted database log])
46 AT_KEYWORDS([ovsdb server positive unix])
47 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
48 ordinal_schema > schema
49 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
50 dnl Do one transaction and save the output.
51 AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
55 "row": {"number": 0, "name": "zero"}}]'
57 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [])
59 dnl Add some crap to the database log and run another transaction, which should
60 dnl ignore the crap and truncate it out of the log.
62 AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
66 "row": {"number": 1, "name": "one"}}]'
68 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [stderr])
69 AT_CHECK([grep 'syntax error: db: parse error.* in header line "xxx"' stderr],
72 dnl Run a final transaction to verify that both transactions succeeeded.
73 dnl The crap that we added should have been truncated by the previous run,
74 dnl so ovsdb-server shouldn't log a warning this time.
75 AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
82 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [])
84 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0],
85 [[[{"uuid":["uuid","<0>"]}]
86 [{"uuid":["uuid","<1>"]}]
87 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
89 [test ! -e pid || kill `cat pid`])
92 AT_SETUP([truncating database log with bad transaction])
93 AT_KEYWORDS([ovsdb server positive unix])
94 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
95 ordinal_schema > schema
96 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
97 dnl Do one transaction and save the output.
98 AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
102 "row": {"number": 0, "name": "zero"}}]'
104 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [])
106 dnl Add some crap to the database log and run another transaction, which should
107 dnl ignore the crap and truncate it out of the log.
108 echo 'OVSDB JSON 15 ffbcdae4b0386265f9ea3280dd7c8f0b72a20e56
109 {"invalid":{}}' >> db
110 AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
114 "row": {"number": 1, "name": "one"}}]'
116 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [stderr])
117 AT_CHECK([grep 'syntax "{"invalid":{}}": unknown table: No table named invalid.' stderr],
120 dnl Run a final transaction to verify that both transactions succeeeded.
121 dnl The crap that we added should have been truncated by the previous run,
122 dnl so ovsdb-server shouldn't log a warning this time.
123 AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
128 "sort": ["number"]}]'
130 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [])
132 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0],
133 [[[{"uuid":["uuid","<0>"]}]
134 [{"uuid":["uuid","<1>"]}]
135 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
137 [test ! -e pid || kill `cat pid`])
140 AT_SETUP([ovsdb-client get-schema-version])
141 AT_KEYWORDS([ovsdb server positive])
142 ordinal_schema > schema
143 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
144 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/pid --unixctl="`pwd`"/unixctl --remote=punix:socket db], [0], [ignore], [ignore])
145 AT_CHECK([ovsdb-client get-schema-version unix:socket ordinals], [0], [5.1.3
147 OVSDB_SERVER_SHUTDOWN
150 AT_SETUP([database multiplexing implementation])
151 AT_KEYWORDS([ovsdb server positive])
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":{"details":"get_schema request specifies unknown database nonexistent","error":"unknown database","syntax":"[\"nonexistent\"]"},"id":0,"result":null}
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 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 if test $IS_WIN32 = "yes"; then
196 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], 2, [],
197 [I/O error: db2: failed to lock lockfile (Resource deadlock avoided)
198 ovs-appctl: ovsdb-server: server returned an error
201 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], 2, [],
203 ovs-appctl: ovsdb-server: server returned an error
207 # Add a non-existing database.
208 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db3], 2, [], [stderr])
209 AT_CHECK([sed 's/(.*)/(...)/' stderr], [0],
210 [I/O error: db3: open failed (...)
211 ovs-appctl: ovsdb-server: server returned an error
214 # Add a remote through a db path in db1.
215 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote db:ordinals,ordinals,name], [0])
216 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
217 [0], [db:ordinals,ordinals,name
221 # Removing db1 has no effect on its remote.
222 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db ordinals], [0])
223 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
226 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
227 [0], [db:ordinals,ordinals,name
230 AT_CHECK([ovsdb-client list-tables unix:socket ordinals], [1], [ignore], [ignore])
233 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db constraints], [0])
234 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
236 AT_CHECK([ovsdb-client list-tables unix:socket constraints], [1], [ignore], [ignore])
238 # Remove a non-existent database.
239 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db ordinals], [2],
240 [], [Failed to find the database.
241 ovs-appctl: ovsdb-server: server returned an error
244 # Add a removed database.
245 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], [0])
246 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
249 AT_CHECK([ovsdb-client list-tables unix:socket constraints], [0], [ignore], [ignore])
250 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
253 AT_SETUP([ovsdb-server/add-db with --monitor])
254 AT_KEYWORDS([ovsdb server positive])
255 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
256 # Start ovsdb-server, initially with one db.
257 ordinal_schema > schema
258 AT_CHECK([ovsdb-tool create db1 schema], [0], [ignore], [ignore])
259 on_exit 'kill `cat *.pid`'
260 AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db1])
262 # Add the second database.
263 constraint_schema > schema2
264 AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore])
265 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], [0])
266 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
271 # Kill the daemon process, making it look like a segfault,
272 # and wait for a new daemon process to get spawned.
273 cp ovsdb-server.pid old.pid
274 AT_CHECK([kill -SEGV `cat ovsdb-server.pid`])
275 OVS_WAIT_WHILE([kill -0 `cat old.pid`])
277 [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`])
278 OVS_WAIT_UNTIL([ovs-appctl -t ovsdb-server version])
279 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
283 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
286 AT_SETUP([ovsdb-server/add-db and remove-db with --monitor])
287 AT_KEYWORDS([ovsdb server positive])
288 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
289 # Start ovsdb-server, initially with one db.
290 ordinal_schema > schema
291 AT_CHECK([ovsdb-tool create db1 schema], [0], [ignore], [ignore])
292 constraint_schema > schema2
293 AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore])
294 on_exit 'kill `cat *.pid`'
295 AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db1 db2])
297 # Remove the second database.
298 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db constraints])
299 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
303 # Kill the daemon process, making it look like a segfault,
304 # and wait for a new daemon process to get spawned.
305 cp ovsdb-server.pid old.pid
306 AT_CHECK([kill -SEGV `cat ovsdb-server.pid`])
307 OVS_WAIT_WHILE([kill -0 `cat old.pid`])
309 [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`])
310 OVS_WAIT_UNTIL([ovs-appctl -t ovsdb-server version])
311 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
314 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
317 AT_SETUP([--remote=db: implementation])
318 AT_KEYWORDS([ovsdb server positive])
328 "max": "unlimited"}},
331 "key": {"type": "uuid", "refTable": "Manager"},
333 "max": "unlimited"}}}},
344 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
346 [[ovsdb-tool transact db \
351 "managers": "punix:socket1",
352 "manager_options": ["set", [["named-uuid", "x"]]]}},
356 "row": {"target": "punix:socket2"}}]']], [0], [ignore], [ignore])
357 on_exit 'kill `cat ovsdb-server.pid`'
358 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=db:mydb,Root,managers --remote=db:mydb,Root,manager_options --log-file db], [0], [ignore], [ignore])
359 ovs-appctl -t ovsdb-server time/warp 6000 1000
361 [[ovsdb-client transact unix:socket1 \
366 "columns": ["managers"]},
370 "columns": ["target", "is_connected"]}]']],
371 [0], [stdout], [ignore])
373 [${PERL} $srcdir/uuidfilt.pl stdout],
375 [[[{"rows":[{"managers":"punix:socket1"}]},{"rows":[{"is_connected":false,"target":"punix:socket2"}]}]
378 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
381 AT_SETUP([ovsdb-server/add-remote and remove-remote])
382 AT_KEYWORDS([ovsdb server positive])
383 ordinal_schema > schema
384 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
385 on_exit 'kill `cat *.pid`'
386 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile db])
388 AT_CHECK([test ! -e socket1])
389 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1])
390 if test "$IS_WIN32" = "yes"; then
391 OVS_WAIT_UNTIL([test -s socket1])
393 OVS_WAIT_UNTIL([test -S socket1])
395 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
399 AT_CHECK([test ! -e socket2])
400 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket2])
401 if test "$IS_WIN32" = "yes"; then
402 OVS_WAIT_UNTIL([test -s socket2])
404 OVS_WAIT_UNTIL([test -S socket2])
406 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
411 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote db:x,y,z], [2],
412 [], ["db:x,y,z": no database named x
413 ovs-appctl: ovsdb-server: server returned an error
416 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket1])
417 OVS_WAIT_UNTIL([test ! -e socket1])
418 if test "$IS_WIN32" = "yes"; then
419 AT_CHECK([test -s socket2])
421 AT_CHECK([test -S socket2])
423 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
427 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket2])
428 OVS_WAIT_UNTIL([test ! -e socket2])
429 AT_CHECK([test ! -e socket1])
430 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes])
431 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
434 AT_SETUP([ovsdb-server/add-remote with --monitor])
435 AT_KEYWORDS([ovsdb server positive])
436 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
437 # Start ovsdb-server, initially with no remotes.
438 ordinal_schema > schema
439 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
440 on_exit 'kill `cat *.pid`'
441 AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db])
444 AT_CHECK([test ! -e socket1])
445 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1])
446 OVS_WAIT_UNTIL([test -S socket1])
447 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
451 # Kill the daemon process, making it look like a segfault,
452 # and wait for a new daemon process to get spawned and for it to
453 # start listening on 'socket1'.
454 cp ovsdb-server.pid old.pid
456 AT_CHECK([kill -SEGV `cat ovsdb-server.pid`])
457 OVS_WAIT_WHILE([kill -0 `cat old.pid`])
459 [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`])
460 OVS_WAIT_UNTIL([ovs-appctl -t ovsdb-server version])
461 OVS_WAIT_UNTIL([test -S socket1])
462 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
465 AT_SETUP([ovsdb-server/add-remote and remove-remote with --monitor])
466 AT_KEYWORDS([ovsdb server positive])
467 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
468 # Start ovsdb-server, initially with no remotes.
469 ordinal_schema > schema
470 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
471 on_exit 'kill `cat *.pid`'
472 AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db])
475 AT_CHECK([test ! -e socket1])
476 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1])
477 OVS_WAIT_UNTIL([test -S socket1])
478 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
483 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket1])
484 OVS_WAIT_UNTIL([test ! -e socket1])
485 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes])
487 # Kill the daemon process, making it look like a segfault,
488 # and wait for a new daemon process to get spawned and make sure that it
489 # does not listen on 'socket1'.
490 cp ovsdb-server.pid old.pid
491 AT_CHECK([kill -SEGV `cat ovsdb-server.pid`])
492 OVS_WAIT_WHILE([kill -0 `cat old.pid`])
494 [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`])
495 OVS_WAIT_UNTIL([ovs-appctl -t ovsdb-server version])
496 AT_CHECK([test ! -e socket1])
497 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
500 AT_SETUP([SSL db: implementation])
501 AT_KEYWORDS([ovsdb server positive ssl $5])
502 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
503 # For this test, we pass PKIDIR through a ovsdb-tool transact and
504 # msys on Windows does not convert the path style automatically.
505 # So, do that forcefully with a 'pwd -W' (called through pwd() function).
506 PKIDIR="$(cd $abs_top_builddir/tests && pwd)"
507 AT_SKIP_IF([expr "$PKIDIR" : ".*[ '\"
514 "private_key": {"type": "string"},
515 "certificate": {"type": "string"},
516 "ca_cert": {"type": "string"}}}}}
518 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
520 [[ovsdb-tool transact db \
524 "row": {"private_key": "'"$PKIDIR/testpki-privkey2.pem"'",
525 "certificate": "'"$PKIDIR/testpki-cert2.pem"'",
526 "ca_cert": "'"$PKIDIR/testpki-cacert.pem"'"}}]']],
527 [0], [ignore], [ignore])
529 [ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid \
530 --private-key=db:mydb,SSL,private_key \
531 --certificate=db:mydb,SSL,certificate \
532 --ca-cert=db:mydb,SSL,ca_cert \
533 --remote=pssl:0:127.0.0.1 --unixctl="`pwd`"/unixctl db],
534 [0], [ignore], [ignore])
535 PARSE_LISTENING_PORT([ovsdb-server.log], [SSL_PORT])
538 --private-key=$PKIDIR/testpki-privkey.pem \
539 --certificate=$PKIDIR/testpki-cert.pem \
540 --ca-cert=$PKIDIR/testpki-cacert.pem \
541 transact ssl:127.0.0.1:$SSL_PORT \
546 "columns": ["private_key"]}]']],
547 [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`])
551 [[@<:@{"rows":@<:@{"private_key":"$PKIDIR/testpki-privkey2.pem"}@:>@}@:>@
552 ]], [ignore], [test ! -e pid || kill `cat pid`])
553 OVSDB_SERVER_SHUTDOWN
556 AT_SETUP([compacting online])
557 AT_KEYWORDS([ovsdb server compact])
558 ordinal_schema > schema
559 dnl Make sure that "ovsdb-tool create" works with a dangling symlink for
560 dnl the database and the lockfile, creating the target of each symlink rather
561 dnl than replacing the symlinks with regular files.
564 ln -s dir/.db.~lock~ .db.~lock~
565 AT_SKIP_IF([test ! -h db || test ! -h .db.~lock~])
566 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
567 dnl Start ovsdb-server.
568 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])
569 AT_CAPTURE_FILE([ovsdb-server.log])
570 dnl Do a bunch of random transactions that put crap in the database log.
572 [[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do
574 ovsdb-client transact unix:socket '
578 "row": {"name": "'$1'", "number": '$2'}},
580 "comment": "add row for '"$pair"'"}]'
581 ovsdb-client transact unix:socket '
585 "where": [["number", "==", '$2']]},
587 "comment": "delete row for '"$2"'"}]'
588 ovsdb-client transact unix:socket '
592 "row": {"name": "'$1'", "number": '$2'}},
594 "comment": "add back row for '"$pair"'"}]'
596 [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`])
597 dnl Check that all the crap is in fact in the database log.
598 AT_CHECK([[${PERL} $srcdir/uuidfilt.pl db | grep -v ^OVSDB | sed 's/"_date":[0-9]*/"_date":0/' | ovstest test-json --multiple -]], [0],
599 [[{"cksum":"12345678 9","name":"ordinals","tables":{"ordinals":{"columns":{"name":{"type":"string"},"number":{"type":"integer"}},"indexes":[["number"]]}},"version":"5.1.3"}
600 {"_comment":"add row for zero 0","_date":0,"ordinals":{"<0>":{"name":"zero"}}}
601 {"_comment":"delete row for 0","_date":0,"ordinals":{"<0>":null}}
602 {"_comment":"add back row for zero 0","_date":0,"ordinals":{"<1>":{"name":"zero"}}}
603 {"_comment":"add row for one 1","_date":0,"ordinals":{"<2>":{"name":"one","number":1}}}
604 {"_comment":"delete row for 1","_date":0,"ordinals":{"<2>":null}}
605 {"_comment":"add back row for one 1","_date":0,"ordinals":{"<3>":{"name":"one","number":1}}}
606 {"_comment":"add row for two 2","_date":0,"ordinals":{"<4>":{"name":"two","number":2}}}
607 {"_comment":"delete row for 2","_date":0,"ordinals":{"<4>":null}}
608 {"_comment":"add back row for two 2","_date":0,"ordinals":{"<5>":{"name":"two","number":2}}}
609 {"_comment":"add row for three 3","_date":0,"ordinals":{"<6>":{"name":"three","number":3}}}
610 {"_comment":"delete row for 3","_date":0,"ordinals":{"<6>":null}}
611 {"_comment":"add back row for three 3","_date":0,"ordinals":{"<7>":{"name":"three","number":3}}}
612 {"_comment":"add row for four 4","_date":0,"ordinals":{"<8>":{"name":"four","number":4}}}
613 {"_comment":"delete row for 4","_date":0,"ordinals":{"<8>":null}}
614 {"_comment":"add back row for four 4","_date":0,"ordinals":{"<9>":{"name":"four","number":4}}}
615 {"_comment":"add row for five 5","_date":0,"ordinals":{"<10>":{"name":"five","number":5}}}
616 {"_comment":"delete row for 5","_date":0,"ordinals":{"<10>":null}}
617 {"_comment":"add back row for five 5","_date":0,"ordinals":{"<11>":{"name":"five","number":5}}}
618 ]], [], [test ! -e pid || kill `cat pid`])
619 dnl Dump out and check the actual database contents.
620 AT_CHECK([[ovsdb-client dump unix:socket ordinals]],
621 [0], [stdout], [ignore])
622 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl
625 ------------------------------------ ----- ------
632 ], [], [test ! -e pid || kill `cat pid`])
633 dnl Now compact the database in-place.
634 AT_CHECK([[ovs-appctl -t "`pwd`"/unixctl ovsdb-server/compact]],
635 [0], [], [ignore], [test ! -e pid || kill `cat pid`])
636 dnl Make sure that "db" is still a symlink to dir/db instead of getting
637 dnl replaced by a regular file, ditto for .db.~lock~.
638 AT_CHECK([test -h db])
639 AT_CHECK([test -h .db.~lock~])
640 AT_CHECK([test -f dir/db])
641 AT_CHECK([test -f dir/.db.~lock~])
642 dnl We can't fully re-check the contents of the database log, because the
643 dnl order of the records is not predictable, but there should only be 4 lines
645 AT_CAPTURE_FILE([db])
646 AT_CHECK([test `wc -l < db` -eq 4], [0], [], [],
647 [test ! -e pid || kill `cat pid`])
648 dnl And check that the dumped data is the same too:
649 AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore],
650 [test ! -e pid || kill `cat pid`])
651 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl
654 ------------------------------------ ----- ------
661 ], [], [test ! -e pid || kill `cat pid`])
662 dnl Now do some more transactions.
664 [[ovsdb-client transact unix:socket '
668 "where": [["number", "<", 3]]}]']],
670 ]], [ignore], [test ! -e pid || kill `cat pid`])
671 dnl There should be 6 lines in the log now.
672 AT_CHECK([test `wc -l < db` -eq 6], [0], [], [],
673 [test ! -e pid || kill `cat pid`])
674 dnl Then check that the dumped data is correct.
675 AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore],
676 [test ! -e pid || kill `cat pid`])
677 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl
680 ------------------------------------ ----- ------
684 ], [], [test ! -e pid || kill `cat pid`])
685 OVSDB_SERVER_SHUTDOWN
688 AT_SETUP([ovsdb-server combines updates on backlogged connections])
689 on_exit 'kill `cat *.pid`'
691 # The maximum socket receive buffer size is important for this test, which
692 # tests behavior when the receive buffer overflows.
693 if test -e /proc/sys/net/core/rmem_max; then
695 rmem_max=`cat /proc/sys/net/core/rmem_max`
696 elif rmem_max=`sysctl -n net.inet.tcp.recvbuf_max 2>/dev/null`; then
699 # Don't know how to get maximum socket receive buffer on this OS
703 # Calculate the number of iterations we need to queue. Each of the
704 # iterations we execute, by itself, yields a monitor update of about
705 # 25 kB, so fill up that much space plus a few for luck.
706 n_iterations=`expr $rmem_max / 25000 + 5`
707 echo rmem_max=$rmem_max n_iterations=$n_iterations
709 # If there's too much queuing skip the test to avoid timing out.
710 AT_SKIP_IF([test $rmem_max -gt 1048576])
712 # Calculate the exact number of monitor updates expected for $n_iterations,
713 # assuming no updates are combined. The "extra" update is for the initial
714 # contents of the database.
715 n_updates=`expr $n_iterations \* 3 + 1`
717 # Start an ovsdb-server with the vswitchd schema.
719 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:db.sock db],
720 [0], [ignore], [ignore])
722 # Executes a set of transactions that add a bridge with 100 ports, and
723 # then deletes that bridge. This yields three monitor updates that
724 # add up to about 25 kB in size.
726 # The update also increments a counter held in the database so that we can
727 # verify that the overall effect of the transactions took effect (e.g.
728 # monitor updates at the end weren't just dropped). We add an arbitrary
729 # string to the counter to make grepping for it more reliable.
731 trigger_big_update () {
732 counter=`expr $counter + 1`
733 ovs-vsctl --no-wait -- set open_vswitch . system_version=xyzzy$counter
734 ovs-vsctl --no-wait -- add-br br0 $add
735 ovs-vsctl --no-wait -- del-br br0
738 for j in `seq 1 100`; do
739 printf " -- add-port br0 p%d" $j
744 AT_CAPTURE_FILE([ovsdb-client.err])
745 AT_CAPTURE_FILE([ovsdb-client-nonblock.err])
748 # Start an ovsdb-client monitoring all changes to the database,
749 # By default, it is non-blocking, and will get update message
750 # for each ovsdb-server transaactions.
751 AT_CHECK([ovsdb-client --detach --no-chdir --pidfile=nonblock.pid monitor ALL >ovsdb-client-nonblock.out 2>ovsdb-client-nonblock.err])
753 # Start an ovsdb-client monitoring all changes to the database,
754 # make it block to force the buffers to fill up, and then execute
755 # enough iterations that ovsdb-server starts combining updates.
756 AT_CHECK([ovsdb-client --detach --no-chdir --pidfile monitor ALL >ovsdb-client.out 2>ovsdb-client.err])
757 AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/block])
758 for i in `seq 1 $n_iterations`; do
759 echo "blocked update ($i of $n_iterations)"
760 trigger_big_update $i
762 AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/unblock])
763 OVS_WAIT_UNTIL([grep "\"xyzzy$counter\"" ovsdb-client.out])
764 OVS_WAIT_UNTIL([grep "\"xyzzy$counter\"" ovsdb-client-nonblock.out])
765 OVS_APP_EXIT_AND_WAIT([ovsdb-client])
766 AT_CHECK([kill `cat nonblock.pid`])
768 # Count the number of updates in the ovsdb-client output, by counting
769 # the number of changes to the Open_vSwitch table. (All of our
770 # transactions modify the Open_vSwitch table.) It should be less than
771 # $n_updates updates.
773 # Check that the counter is what we expect.
774 logged_updates=`grep -c '^Open_vSwitch' ovsdb-client.out`
775 logged_nonblock_updates=`grep -c '^Open_vSwitch' ovsdb-client-nonblock.out`
776 echo "logged_nonblock_updates=$logged_nonblock_updates (expected less or equal to $n_updates)"
777 echo "logged_updates=$logged_updates (expected less than $logged_nonblock_updates)"
778 AT_CHECK([test $logged_nonblock_updates -le $n_updates])
779 AT_CHECK([test $logged_updates -lt $logged_nonblock_updates])
780 AT_CHECK_UNQUOTED([ovs-vsctl get open_vswitch . system_version], [0],
783 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
786 AT_BANNER([OVSDB -- ovsdb-server transactions (SSL IPv4 sockets)])
788 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
790 # Creates a database with the given SCHEMA, starts an ovsdb-server on
791 # that database, and runs each of the TRANSACTIONS (which should be a
792 # quoted list of quoted strings) against it with ovsdb-client one at a
795 # Checks that the overall output is OUTPUT, but UUIDs in the output
796 # are replaced by markers of the form <N> where N is a number. The
797 # first unique UUID is replaced by <0>, the next by <1>, and so on.
798 # If a given UUID appears more than once it is always replaced by the
801 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
802 m4_define([OVSDB_CHECK_EXECUTION],
804 AT_KEYWORDS([ovsdb server positive ssl $5])
805 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
807 PKIDIR=$abs_top_builddir/tests
808 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
809 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])
810 PARSE_LISTENING_PORT([ovsdb-server.log], [SSL_PORT])
811 m4_foreach([txn], [$3],
812 [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],
813 [test ! -e pid || kill `cat pid`])
816 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
817 [test ! -e pid || kill `cat pid`])
818 OVSDB_SERVER_SHUTDOWN
823 AT_BANNER([OVSDB -- ovsdb-server transactions (SSL IPv6 sockets)])
825 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
827 # Creates a database with the given SCHEMA, starts an ovsdb-server on
828 # that database, and runs each of the TRANSACTIONS (which should be a
829 # quoted list of quoted strings) against it with ovsdb-client one at a
832 # Checks that the overall output is OUTPUT, but UUIDs in the output
833 # are replaced by markers of the form <N> where N is a number. The
834 # first unique UUID is replaced by <0>, the next by <1>, and so on.
835 # If a given UUID appears more than once it is always replaced by the
838 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
839 m4_define([OVSDB_CHECK_EXECUTION],
841 AT_KEYWORDS([ovsdb server positive ssl6 $5])
842 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
843 AT_SKIP_IF([test $HAVE_IPV6 = no])
845 PKIDIR=$abs_top_builddir/tests
846 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
847 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])
848 PARSE_LISTENING_PORT([ovsdb-server.log], [SSL_PORT])
849 m4_foreach([txn], [$3],
850 [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],
851 [test ! -e pid || kill `cat pid`])
854 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
855 [test ! -e pid || kill `cat pid`])
856 OVSDB_SERVER_SHUTDOWN
859 ONE_EXECUTION_EXAMPLE
861 AT_BANNER([OVSDB -- ovsdb-server transactions (TCP IPv4 sockets)])
863 AT_SETUP([ovsdb-client get-schema-version - tcp socket])
864 AT_KEYWORDS([ovsdb server positive tcp])
865 ordinal_schema > schema
866 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
867 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])
868 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
869 AT_CHECK([ovsdb-client get-schema-version tcp:127.0.0.1:$TCP_PORT ordinals], [0], [5.1.3
871 OVSDB_SERVER_SHUTDOWN
874 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
876 # Creates a database with the given SCHEMA, starts an ovsdb-server on
877 # that database, and runs each of the TRANSACTIONS (which should be a
878 # quoted list of quoted strings) against it with ovsdb-client one at a
881 # Checks that the overall output is OUTPUT, but UUIDs in the output
882 # are replaced by markers of the form <N> where N is a number. The
883 # first unique UUID is replaced by <0>, the next by <1>, and so on.
884 # If a given UUID appears more than once it is always replaced by the
887 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
888 m4_define([OVSDB_CHECK_EXECUTION],
890 AT_KEYWORDS([ovsdb server positive tcp $5])
892 PKIDIR=$abs_top_builddir/tests
893 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
894 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])
895 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
896 m4_foreach([txn], [$3],
897 [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT 'txn'], [0], [stdout], [ignore],
898 [test ! -e pid || kill `cat pid`])
901 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
902 [test ! -e pid || kill `cat pid`])
903 OVSDB_SERVER_SHUTDOWN
908 AT_BANNER([OVSDB -- ovsdb-server transactions (TCP IPv6 sockets)])
910 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
912 # Creates a database with the given SCHEMA, starts an ovsdb-server on
913 # that database, and runs each of the TRANSACTIONS (which should be a
914 # quoted list of quoted strings) against it with ovsdb-client one at a
917 # Checks that the overall output is OUTPUT, but UUIDs in the output
918 # are replaced by markers of the form <N> where N is a number. The
919 # first unique UUID is replaced by <0>, the next by <1>, and so on.
920 # If a given UUID appears more than once it is always replaced by the
923 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
924 m4_define([OVSDB_CHECK_EXECUTION],
926 AT_KEYWORDS([ovsdb server positive tcp6 $5])
927 AT_SKIP_IF([test $HAVE_IPV6 = no])
929 PKIDIR=$abs_top_builddir/tests
930 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
931 AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid --remote=ptcp:0:[[::1]] --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
932 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
933 m4_foreach([txn], [$3],
934 [AT_CHECK([ovsdb-client transact tcp:[[::1]]:$TCP_PORT 'txn'], [0], [stdout], [ignore],
935 [test ! -e pid || kill `cat pid`])
938 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
939 [test ! -e pid || kill `cat pid`])
940 OVSDB_SERVER_SHUTDOWN
943 ONE_EXECUTION_EXAMPLE
945 AT_BANNER([OVSDB -- transactions on transient ovsdb-server])
947 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
949 # Creates a database with the given SCHEMA and runs each of the
950 # TRANSACTIONS (which should be a quoted list of quoted strings)
951 # against it with ovsdb-client one at a time. Each ovsdb-client
952 # is run against a separately started ovsdb-server that executes
953 # only that single transaction. (The idea is that this should
954 # help to ferret out any differences between what ovsdb-server has
955 # in memory and what actually gets committed to disk.)
957 # Checks that the overall output is OUTPUT, but UUIDs in the output
958 # are replaced by markers of the form <N> where N is a number. The
959 # first unique UUID is replaced by <0>, the next by <1>, and so on.
960 # If a given UUID appears more than once it is always replaced by the
963 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
964 m4_define([OVSDB_CHECK_EXECUTION],
966 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
967 AT_KEYWORDS([ovsdb server positive transient $5])
969 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
970 m4_foreach([txn], [$3],
971 [AT_DATA([txnfile], [ovsdb-client transact unix:socket 'txn'
973 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [ignore])
976 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore])
981 AT_BANNER([OVSDB -- ovsdb-server replication (TCP IPv4 sockets)])
983 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
985 # Creates two databases with the given SCHEMA, and starts an ovsdb-server on
987 # Runs each of the TRANSACTIONS (which should be a quoted list of
988 # quoted strings) against one of the servers with ovsdb-client one at a
989 # time. The server replicates its database to the other ovsdb-server.
991 # Checks that the dump of both databases are the same.
993 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
994 m4_define([OVSDB_CHECK_EXECUTION],
996 AT_KEYWORDS([ovsdb server tcp replication $5])
998 AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore])
999 AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore])
1001 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile="`pwd`"/pid --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl db1], [0], [ignore], [ignore])
1002 PARSE_LISTENING_PORT([ovsdb-server1.log], [TCP_PORT1])
1004 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile="`pwd`"/pid2 --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl2 --sync-from=tcp:127.0.0.1:$TCP_PORT1 db2], [0], [ignore], [ignore])
1005 PARSE_LISTENING_PORT([ovsdb-server2.log], [TCP_PORT2])
1007 m4_foreach([txn], [$3],
1008 [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT1 'txn'; sleep 2], [0], [stdout], [ignore],
1009 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1012 AT_CHECK([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT1], [0], [stdout], [ignore],
1013 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1015 AT_CHECK([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT2], [0], [stdout], [ignore],
1016 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1019 AT_CHECK([diff dump1 dump2], [0], [], [ignore],
1020 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1021 OVSDB_SERVER_SHUTDOWN
1022 OVSDB_SERVER_SHUTDOWN2
1027 AT_BANNER([OVSDB -- ovsdb-server replication table-exclusion (TCP IPv4 sockets)])
1029 # OVSDB_CHECK_REPLICATION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
1031 # Creates two databases with the given SCHEMA, and starts an
1032 # ovsdb-server on each database.
1033 # Runs each of the TRANSACTIONS (which should be a quoted list of
1034 # quoted strings) against one of the servers with ovsdb-client one at a
1035 # time. The server replicates its database to the other ovsdb-server.
1037 # Checks that the difference between the dump of the databases is
1038 # OUTPUT, but UUIDs in the output are replaced by markers of the form
1039 # <N> where N is a number. The first unique UUID is replaced by <0>,
1040 # the next by <1>, and so on.
1041 # If a given UUID appears more than once it is always replaced by the
1044 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
1045 m4_define([OVSDB_CHECK_REPLICATION],
1047 AT_KEYWORDS([ovsdb server tcp replication table-exclusion])
1049 AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore])
1050 AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore])
1052 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile="`pwd`"/pid --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl db1], [0], [ignore], [ignore])
1053 PARSE_LISTENING_PORT([ovsdb-server1.log], [TCP_PORT1])
1055 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile="`pwd`"/pid2 --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl2 --sync-from=tcp:127.0.0.1:$TCP_PORT1 --sync-exclude-tables=mydb:b db2], [0], [ignore], [ignore])
1056 PARSE_LISTENING_PORT([ovsdb-server2.log], [TCP_PORT2])
1058 m4_foreach([txn], [$3],
1059 [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT1 'txn'; sleep 2], [0], [stdout], [ignore],
1060 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1063 AT_CHECK([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT1], [0], [stdout], [ignore],
1064 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1066 AT_CHECK([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT2], [0], [stdout], [ignore],
1067 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1070 AT_CHECK([diff dump1 dump2], [1], [stdout], [ignore],
1071 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1072 cat stdout >> output
1074 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
1075 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1077 OVSDB_SERVER_SHUTDOWN
1078 OVSDB_SERVER_SHUTDOWN2
1081 REPLICATION_EXAMPLES
1083 AT_BANNER([OVSDB -- ovsdb-server replication runtime management commands])
1085 #ovsdb-server/get-remote-ovsdb-server command
1086 AT_SETUP([ovsdb-server/get-remote-ovsdb-server])
1087 AT_KEYWORDS([ovsdb server replication get-remote])
1088 ordinal_schema > schema
1089 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
1090 on_exit 'kill `cat *.pid`'
1091 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --sync-from=tcp:127.0.0.1:9999 db])
1093 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/get-remote-ovsdb-server],
1094 [0], [tcp:127.0.0.1:9999
1098 #*ovsdb-server/set-remote-ovsdb-server command
1099 AT_SETUP([ovsdb-server/set-remote-ovsdb-server])
1100 AT_KEYWORDS([ovsdb server replication set-remote])
1101 ordinal_schema > schema
1102 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
1103 on_exit 'kill `cat *.pid`'
1104 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile db])
1106 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/set-remote-ovsdb-server tcp:127.0.0.1:9999])
1107 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/get-remote-ovsdb-server],
1108 [0], [tcp:127.0.0.1:9999
1112 #ovsdb-server/get-sync-excluded-tables command
1113 AT_SETUP([ovsdb-server/get-sync-excluded-tables])
1114 AT_KEYWORDS([ovsdb server replication get-excluded-tables])
1115 ordinal_schema > schema
1116 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
1117 on_exit 'kill `cat *.pid`'
1118 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --sync-exclude-tables=mydb:db1,mydb:db2 db])
1120 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/get-sync-excluded-tables],
1126 #ovsdb-server/set-sync-excluded-tables command
1127 AT_SETUP([ovsdb-server/set-sync-excluded-tables])
1128 AT_KEYWORDS([ovsdb server replication set-excluded-tables])
1129 replication_schema > schema
1130 AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore])
1131 AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore])
1133 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile="`pwd`"/pid --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl db1], [0], [ignore], [ignore])
1134 PARSE_LISTENING_PORT([ovsdb-server1.log], [TCP_PORT1])
1136 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile="`pwd`"/pid2 --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl2 --sync-from=tcp:127.0.0.1:$TCP_PORT1 db2], [0], [ignore], [ignore])
1137 PARSE_LISTENING_PORT([ovsdb-server2.log], [TCP_PORT2])
1139 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/set-sync-excluded-tables mydb:b], [0], [ignore], [ignore], [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1141 AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT1 \
1145 "row": {"number": 0, "name": "zero"}},
1148 "row": {"number": 1, "name": "one"}}]]'], [0], [stdout], [ignore],
1149 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1152 AT_CHECK([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT1], [0], [stdout], [ignore],
1153 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1155 AT_CHECK([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT2], [0], [stdout], [ignore],
1156 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1159 AT_CHECK([diff dump1 dump2], [1], [stdout], [ignore],
1160 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1161 cat stdout >> output
1163 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [7,9c7,8
1165 < ------------------------------------ ---- ------
1170 ], [ignore], [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1172 OVSDB_SERVER_SHUTDOWN
1173 OVSDB_SERVER_SHUTDOWN2
1176 #ovsdb-server/connect-remote-ovsdb-server
1177 AT_SETUP([ovsdb-server/connect-remote-server])
1178 AT_KEYWORDS([ovsdb server replication connect-remote-server])
1179 replication_schema > schema
1180 AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore])
1181 AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore])
1183 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile="`pwd`"/pid --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl db1], [0], [ignore], [ignore])
1184 PARSE_LISTENING_PORT([ovsdb-server1.log], [TCP_PORT1])
1186 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile="`pwd`"/pid2 --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl2 db2], [0], [ignore], [ignore])
1187 PARSE_LISTENING_PORT([ovsdb-server2.log], [TCP_PORT2])
1189 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/set-remote-ovsdb-server tcp:127.0.0.1:$TCP_PORT1], [0], [ignore], [ignore], [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1191 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/connect-remote-ovsdb-server], [0], [ignore], [ignore],
1192 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1194 AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT1 \
1199 "uuid-name": "0"}]]'], [0], [stdout], [ignore],
1200 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1203 AT_CHECK([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT1], [0], [stdout], [ignore],
1204 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1206 AT_CHECK([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT2], [0], [stdout], [ignore],
1207 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1210 AT_CHECK([diff dump1 dump2], [0], [], [ignore], [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1211 OVSDB_SERVER_SHUTDOWN
1212 OVSDB_SERVER_SHUTDOWN2
1215 #ovsdb-server/disconnect-remote-server command
1216 AT_SETUP([ovsdb-server/disconnect-remote-server])
1217 AT_KEYWORDS([ovsdb server replication disconnect-remote-server])
1218 replication_schema > schema
1219 AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore])
1220 AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore])
1222 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile="`pwd`"/pid --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl db1], [0], [ignore], [ignore])
1223 PARSE_LISTENING_PORT([ovsdb-server1.log], [TCP_PORT1])
1225 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile="`pwd`"/pid2 --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl2 --sync-from=tcp:127.0.0.1:$TCP_PORT1 db2], [0], [ignore], [ignore])
1226 PARSE_LISTENING_PORT([ovsdb-server2.log], [TCP_PORT2])
1228 AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT1 \
1232 "row": {"number": 0, "name": "zero"}}]]'], [0], [stdout], [ignore],
1233 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1235 OVS_WAIT_UNTIL([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT2 | grep zero])
1237 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/disconnect-remote-ovsdb-server], [0], [ignore], [ignore],
1238 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1240 AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT1 \
1244 "row": {"number": 1, "name": "one"}}]]'], [0], [stdout], [ignore],
1245 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1247 AT_CHECK([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT1], [0], [stdout], [ignore],
1248 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1251 AT_CHECK([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT2], [0], [stdout], [ignore],
1252 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1255 AT_CHECK([diff dump1 dump2], [1], [stdout], [ignore],
1256 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1257 cat stdout >> output
1259 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [7,9c7,8
1261 < ------------------------------------ ---- ------
1266 ], [ignore], [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1268 OVSDB_SERVER_SHUTDOWN
1269 OVSDB_SERVER_SHUTDOWN2