1 AT_BANNER([OVSDB -- ovsdb-server transactions (Unix sockets)])
3 m4_define([OVSDB_SERVER_SHUTDOWN],
4 [OVS_APP_EXIT_AND_WAIT_BY_TARGET([ovsdb-server], [ovsdb-server.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 --remote=punix:socket 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([uuidfilt 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 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 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 db --run="sh txnfile"], [0], [stdout], [])
84 AT_CHECK([uuidfilt 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 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 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 db --run="sh txnfile"], [0], [stdout], [])
132 AT_CHECK([uuidfilt 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 dnl CHECK_DBS([databases])
142 dnl Checks that ovsdb-server hosts the given 'databases', each of which
143 dnl needs to be followed by a newline.
144 m4_define([CHECK_DBS],
145 [AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
148 AT_CHECK([ovsdb-client --no-headings dump _Server Database name | sort], [0], [dnl
153 AT_SETUP([database multiplexing implementation])
154 AT_KEYWORDS([ovsdb server positive])
155 ordinal_schema > schema1
156 constraint_schema > schema2
157 AT_CHECK([ovsdb-tool create db1 schema1], [0], [ignore], [ignore])
158 AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore])
159 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:db.sock db1 db2], [0], [ignore], [ignore])
160 CHECK_DBS([constraints
164 [[ovstest test-jsonrpc request unix:db.sock get_schema [\"nonexistent\"]]], [0],
165 [[{"error":{"details":"get_schema request specifies unknown database nonexistent","error":"unknown database","syntax":"[\"nonexistent\"]"},"id":0,"result":null}
166 ]], [], [test ! -e pid || kill `cat pid`])
167 OVSDB_SERVER_SHUTDOWN
170 AT_SETUP([ovsdb-server/add-db and remove-db])
171 AT_KEYWORDS([ovsdb server positive])
172 on_exit 'kill `cat *.pid`'
173 ordinal_schema > schema1
174 constraint_schema > schema2
175 AT_CHECK([ovsdb-tool create db1 schema1], [0], [ignore], [ignore])
176 AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore])
178 # Start ovsdb-server with just a single database - db1.
179 AT_CHECK([ovsdb-server -vfile -vvlog:off --log-file --detach --no-chdir --pidfile --remote=punix:db.sock db1], [0])
183 # Remove the database.
184 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db ordinals], [0])
187 # Start monitoring processes.
188 AT_CHECK([ovsdb-client --detach --no-chdir --pidfile=ovsdb-client-1.pid --no-db-change-aware --no-headings monitor _Server Database name > db-change-unaware.stdout 2> db-change-unaware.stderr])
189 AT_CHECK([ovsdb-client --detach --no-chdir --pidfile=ovsdb-client-2.pid --db-change-aware --no-headings monitor _Server Database name > db-change-aware.stdout 2> db-change-aware.stderr])
190 AT_CAPTURE_FILE([db-change-unaware.stdout])
191 AT_CAPTURE_FILE([db-change-unaware.stderr])
192 AT_CAPTURE_FILE([db-change-aware.stdout])
193 AT_CAPTURE_FILE([db-change-aware.stderr])
195 # Add the first database back.
196 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db1], [0])
200 # Add the second database.
201 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], [0])
202 CHECK_DBS([constraints
206 # The databases are responsive.
207 AT_CHECK([ovsdb-client list-tables unix:db.sock constraints], [0], [ignore], [ignore])
208 AT_CHECK([ovsdb-client list-tables unix:db.sock ordinals], [0], [ignore], [ignore])
210 # Add an already added database.
211 if test $IS_WIN32 = "yes"; then
212 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], 2, [],
213 [I/O error: db2: failed to lock lockfile (Resource deadlock avoided)
214 ovs-appctl: ovsdb-server: server returned an error
217 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], 2, [],
218 [ovsdb error: db2: already open
219 ovs-appctl: ovsdb-server: server returned an error
223 # Add a non-existing database.
224 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db3], 2, [], [stderr])
225 AT_CHECK([sed 's/(.*)/(...)/' stderr], [0],
226 [I/O error: db3: open failed (...)
227 ovs-appctl: ovsdb-server: server returned an error
230 # Add a remote through a db path in db1.
231 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote db:ordinals,ordinals,name], [0])
232 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
233 [0], [db:ordinals,ordinals,name
237 # Removing db1 has no effect on its remote.
238 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db ordinals], [0])
239 CHECK_DBS([constraints
241 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
242 [0], [db:ordinals,ordinals,name
245 AT_CHECK([ovsdb-client list-tables unix:db.sock ordinals], [1], [ignore], [ignore])
248 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db constraints], [0])
250 AT_CHECK([ovsdb-client list-tables unix:db.sock constraints], [1], [ignore], [ignore])
252 # Remove a non-existent database.
253 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db ordinals], [2],
254 [], [Failed to find the database.
255 ovs-appctl: ovsdb-server: server returned an error
258 # Add a removed database.
259 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], [0])
260 CHECK_DBS([constraints
262 AT_CHECK([ovsdb-client list-tables unix:db.sock constraints], [0], [ignore], [ignore])
264 # Check the monitoring results.
265 AT_CHECK([uuidfilt db-change-aware.stdout], [0], [dnl
270 <2> insert constraints
274 <2> delete constraints
276 <3> insert constraints
278 AT_CHECK([uuidfilt db-change-unaware.stdout], [0], [dnl
282 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
285 AT_SETUP([ovsdb-server/add-db with --monitor])
286 AT_KEYWORDS([ovsdb server positive])
287 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
289 # This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it.
290 ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS
292 # Start ovsdb-server, initially with one db.
293 ordinal_schema > schema
294 AT_CHECK([ovsdb-tool create db1 schema], [0], [ignore], [ignore])
295 on_exit 'kill `cat *.pid`'
296 AT_CHECK([ovsdb-server -vfile -vvlog:off --monitor --detach --no-chdir --pidfile --log-file --remote=punix:db.sock db1])
298 # Add the second database.
299 constraint_schema > schema2
300 AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore])
301 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], [0])
302 CHECK_DBS([constraints
306 # Kill the daemon process, making it look like a segfault,
307 # and wait for a new daemon process to get spawned.
308 cp ovsdb-server.pid old.pid
309 AT_CHECK([kill -SEGV `cat ovsdb-server.pid`])
310 OVS_WAIT_WHILE([kill -0 `cat old.pid`])
312 [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`])
313 OVS_WAIT_UNTIL([ovs-appctl -t ovsdb-server version])
314 CHECK_DBS([constraints
317 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
320 AT_SETUP([ovsdb-server/add-db and remove-db with --monitor])
321 AT_KEYWORDS([ovsdb server positive])
322 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
324 # This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it.
325 ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS
327 # Start ovsdb-server, initially with one db.
328 ordinal_schema > schema
329 AT_CHECK([ovsdb-tool create db1 schema], [0], [ignore], [ignore])
330 constraint_schema > schema2
331 AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore])
332 on_exit 'kill `cat *.pid`'
333 AT_CHECK([ovsdb-server -vfile -vvlog:off --monitor --detach --no-chdir --pidfile --log-file --remote=punix:db.sock db1 db2])
335 # Remove the second database.
336 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db constraints])
340 # Kill the daemon process, making it look like a segfault,
341 # and wait for a new daemon process to get spawned.
342 cp ovsdb-server.pid old.pid
343 AT_CHECK([kill -SEGV `cat ovsdb-server.pid`])
344 OVS_WAIT_WHILE([kill -0 `cat old.pid`])
346 [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`])
347 OVS_WAIT_UNTIL([ovs-appctl -t ovsdb-server version])
350 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
353 AT_SETUP([--remote=db: implementation])
354 AT_KEYWORDS([ovsdb server positive])
364 "max": "unlimited"}},
367 "key": {"type": "uuid", "refTable": "Manager"},
369 "max": "unlimited"}}}},
380 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
382 [[ovsdb-tool transact db \
387 "managers": "punix:socket1",
388 "manager_options": ["set", [["named-uuid", "x"]]]}},
392 "row": {"target": "punix:socket2"}}]']], [0], [ignore], [ignore])
393 on_exit 'kill `cat ovsdb-server.pid`'
394 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])
395 ovs-appctl -t ovsdb-server time/warp 6000 1000
397 [[ovsdb-client transact unix:socket1 \
402 "columns": ["managers"]},
406 "columns": ["target", "is_connected"]}]']],
407 [0], [stdout], [ignore])
411 [[[{"rows":[{"managers":"punix:socket1"}]},{"rows":[{"is_connected":false,"target":"punix:socket2"}]}]
414 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
417 AT_SETUP([ovsdb-server/add-remote and remove-remote])
418 AT_KEYWORDS([ovsdb server positive])
419 ordinal_schema > schema
420 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
421 on_exit 'kill `cat *.pid`'
422 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile db])
424 AT_CHECK([test ! -e socket1])
425 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1])
426 if test "$IS_WIN32" = "yes"; then
427 OVS_WAIT_UNTIL([test -e socket1])
429 OVS_WAIT_UNTIL([test -S socket1])
431 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
435 AT_CHECK([test ! -e socket2])
436 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket2])
437 if test "$IS_WIN32" = "yes"; then
438 OVS_WAIT_UNTIL([test -e socket2])
440 OVS_WAIT_UNTIL([test -S socket2])
442 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
447 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote db:x,y,z], [2],
448 [], ["db:x,y,z": no database named x
449 ovs-appctl: ovsdb-server: server returned an error
452 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket1])
453 OVS_WAIT_UNTIL([test ! -e socket1])
454 if test "$IS_WIN32" = "yes"; then
455 AT_CHECK([test -e socket2])
457 AT_CHECK([test -S socket2])
459 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
463 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket2])
464 OVS_WAIT_UNTIL([test ! -e socket2])
465 AT_CHECK([test ! -e socket1])
466 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes])
467 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
470 AT_SETUP([ovsdb-server/add-remote with --monitor])
471 AT_KEYWORDS([ovsdb server positive])
472 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
474 # This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it.
475 ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS
477 # Start ovsdb-server, initially with no remotes.
478 ordinal_schema > schema
479 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
480 on_exit 'kill `cat *.pid`'
481 AT_CHECK([ovsdb-server -vfile -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db])
484 AT_CHECK([test ! -e socket1])
485 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1])
486 OVS_WAIT_UNTIL([test -S socket1])
487 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
491 # Kill the daemon process, making it look like a segfault,
492 # and wait for a new daemon process to get spawned and for it to
493 # start listening on 'socket1'.
494 cp ovsdb-server.pid old.pid
496 AT_CHECK([kill -SEGV `cat ovsdb-server.pid`])
497 OVS_WAIT_WHILE([kill -0 `cat old.pid`])
499 [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`])
500 OVS_WAIT_UNTIL([ovs-appctl -t ovsdb-server version])
501 OVS_WAIT_UNTIL([test -S socket1])
502 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
505 AT_SETUP([ovsdb-server/add-remote and remove-remote with --monitor])
506 AT_KEYWORDS([ovsdb server positive])
507 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
509 # This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it.
510 ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS
512 # Start ovsdb-server, initially with no remotes.
513 ordinal_schema > schema
514 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
515 on_exit 'kill `cat *.pid`'
516 AT_CHECK([ovsdb-server -vfile -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db])
519 AT_CHECK([test ! -e socket1])
520 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1])
521 OVS_WAIT_UNTIL([test -S socket1])
522 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
527 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket1])
528 OVS_WAIT_UNTIL([test ! -e socket1])
529 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes])
531 # Kill the daemon process, making it look like a segfault,
532 # and wait for a new daemon process to get spawned and make sure that it
533 # does not listen on 'socket1'.
534 cp ovsdb-server.pid old.pid
535 AT_CHECK([kill -SEGV `cat ovsdb-server.pid`])
536 OVS_WAIT_WHILE([kill -0 `cat old.pid`])
538 [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`])
539 OVS_WAIT_UNTIL([ovs-appctl -t ovsdb-server version])
540 AT_CHECK([test ! -e socket1])
541 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
544 AT_SETUP([SSL db: implementation])
545 AT_KEYWORDS([ovsdb server positive ssl $5])
546 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
547 # For this test, we pass PKIDIR through a ovsdb-tool transact and
548 # msys on Windows does not convert the path style automatically.
549 # So, do that forcefully with a 'pwd -W' (called through pwd() function).
550 PKIDIR="$(cd $abs_top_builddir/tests && pwd)"
551 AT_SKIP_IF([expr "$PKIDIR" : ".*[ '\"
558 "private_key": {"type": "string"},
559 "certificate": {"type": "string"},
560 "ca_cert": {"type": "string"},
561 "ssl_protocols" : {"type": "string"},
562 "ssl_ciphers" : {"type" : "string"}}}}}
564 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
565 # The !ECDHE-ECDSA-AES256-GCM-SHA384 in the ssl_ciphers is so that
566 # a cipher negotiation failure can be tested for later.
568 [[ovsdb-tool transact db \
572 "row": {"private_key": "'"$PKIDIR/testpki-privkey2.pem"'",
573 "certificate": "'"$PKIDIR/testpki-cert2.pem"'",
574 "ca_cert": "'"$PKIDIR/testpki-cacert.pem"'",
575 "ssl_protocols": "'"TLSv1.2,TLSv1.1"'",
576 "ssl_ciphers": "'"HIGH:!aNULL:!MD5:!ECDHE-ECDSA-AES256-GCM-SHA384"'"}}]']],
577 [0], [ignore], [ignore])
578 on_exit 'kill `cat *.pid`'
580 [ovsdb-server --log-file --detach --no-chdir --pidfile \
581 --private-key=db:mydb,SSL,private_key \
582 --certificate=db:mydb,SSL,certificate \
583 --ca-cert=db:mydb,SSL,ca_cert \
584 --ssl-protocols=db:mydb,SSL,ssl_protocols \
585 --ssl-ciphers=db:mydb,SSL,ssl_ciphers \
586 --remote=pssl:0:127.0.0.1 db],
587 [0], [ignore], [ignore])
588 PARSE_LISTENING_PORT([ovsdb-server.log], [SSL_PORT])
591 --private-key=$PKIDIR/testpki-privkey.pem \
592 --certificate=$PKIDIR/testpki-cert.pem \
593 --ca-cert=$PKIDIR/testpki-cacert.pem \
594 --ssl-protocols=TLSv1.2,TLSv1.1 \
595 --ssl-ciphers=HIGH:!aNULL:!MD5 \
596 transact ssl:127.0.0.1:$SSL_PORT \
601 "columns": ["private_key"]}]']],
602 [0], [stdout], [ignore])
606 [[@<:@{"rows":@<:@{"private_key":"$PKIDIR/testpki-privkey2.pem"}@:>@}@:>@
608 # Check that when the server has TLSv1.1+ and the client has
609 # TLSv1 that the connection fails.
612 --private-key=$PKIDIR/testpki-privkey.pem \
613 --certificate=$PKIDIR/testpki-cert.pem \
614 --ca-cert=$PKIDIR/testpki-cacert.pem \
615 --ssl-protocols=TLSv1 \
616 --ssl-ciphers=HIGH:!aNULL:!MD5 \
617 transact ssl:127.0.0.1:$SSL_PORT \
622 "columns": ["private_key"]}]']],
627 [sed -n "/failed to connect/s/ (.*)//p" output], [0],
628 [ovsdb-client: failed to connect to "ssl:127.0.0.1:$SSL_PORT"
631 # Check that when ciphers are not compatible, that a negotiation
635 --private-key=$PKIDIR/testpki-privkey.pem \
636 --certificate=$PKIDIR/testpki-cert.pem \
637 --ca-cert=$PKIDIR/testpki-cacert.pem \
638 --ssl-protocols=TLSv1.2,TLSv1.1 \
639 --ssl-ciphers=ECDHE-ECDSA-AES256-GCM-SHA384 \
640 transact ssl:127.0.0.1:$SSL_PORT \
645 "columns": ["private_key"]}]']],
650 [sed -n "/failed to connect/s/ (.*)//p" output], [0],
651 [ovsdb-client: failed to connect to "ssl:127.0.0.1:$SSL_PORT"
654 # The error message for being unable to negotiate a shared ciphersuite
655 # is 'sslv3 alert handshake failure'. This is not the clearest message.
657 [grep "sslv3 alert handshake failure" output], [0],
660 OVSDB_SERVER_SHUTDOWN
663 OVS_START_SHELL_HELPERS
664 # ovsdb_check_online_compaction MODEL
666 # where MODEL is "standalone" or "cluster"
667 ovsdb_check_online_compaction() {
670 ordinal_schema > schema
671 dnl Make sure that "ovsdb-tool create" works with a dangling symlink for
672 dnl the database and the lockfile, creating the target of each symlink rather
673 dnl than replacing the symlinks with regular files.
675 if test "$IS_WIN32" = "no"; then
677 ln -s dir/.db.~lock~ .db.~lock~
678 AT_SKIP_IF([test ! -h db || test ! -h .db.~lock~])
680 AT_CHECK([if test $model = standalone; then
681 ovsdb-tool create db schema
683 ovsdb-tool create-cluster db schema unix:s1.raft
685 dnl Start ovsdb-server.
686 AT_CHECK([ovsdb-server -vvlog:off -vconsole:off --detach --no-chdir --pidfile --remote=punix:socket --log-file db], [0])
687 AT_CHECK([ovsdb_client_wait unix:socket ordinals connected])
688 AT_CAPTURE_FILE([ovsdb-server.log])
689 dnl Do a bunch of random transactions that put crap in the database log.
691 [[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do
693 ovsdb-client transact unix:socket '
697 "row": {"name": "'$1'", "number": '$2'}},
699 "comment": "add row for '"$pair"'"}]'
700 ovsdb-client transact unix:socket '
704 "where": [["number", "==", '$2']]},
706 "comment": "delete row for '"$2"'"}]'
707 ovsdb-client transact unix:socket '
711 "row": {"name": "'$1'", "number": '$2'}},
713 "comment": "add back row for '"$pair"'"}]'
716 if test $model = standalone; then
717 dnl Check that all the crap is in fact in the database log.
718 AT_CHECK([[uuidfilt db | grep -v ^OVSDB | \
719 sed 's/"_date":[0-9]*/"_date":0/' | sed 's/"_is_diff":true,//' | \
720 ovstest test-json --multiple -]], [0],
721 [[{"cksum":"12345678 9","name":"ordinals","tables":{"ordinals":{"columns":{"name":{"type":"string"},"number":{"type":"integer"}},"indexes":[["number"]]}},"version":"5.1.3"}
722 {"_comment":"add row for zero 0","_date":0,"ordinals":{"<0>":{"name":"zero"}}}
723 {"_comment":"delete row for 0","_date":0,"ordinals":{"<0>":null}}
724 {"_comment":"add back row for zero 0","_date":0,"ordinals":{"<1>":{"name":"zero"}}}
725 {"_comment":"add row for one 1","_date":0,"ordinals":{"<2>":{"name":"one","number":1}}}
726 {"_comment":"delete row for 1","_date":0,"ordinals":{"<2>":null}}
727 {"_comment":"add back row for one 1","_date":0,"ordinals":{"<3>":{"name":"one","number":1}}}
728 {"_comment":"add row for two 2","_date":0,"ordinals":{"<4>":{"name":"two","number":2}}}
729 {"_comment":"delete row for 2","_date":0,"ordinals":{"<4>":null}}
730 {"_comment":"add back row for two 2","_date":0,"ordinals":{"<5>":{"name":"two","number":2}}}
731 {"_comment":"add row for three 3","_date":0,"ordinals":{"<6>":{"name":"three","number":3}}}
732 {"_comment":"delete row for 3","_date":0,"ordinals":{"<6>":null}}
733 {"_comment":"add back row for three 3","_date":0,"ordinals":{"<7>":{"name":"three","number":3}}}
734 {"_comment":"add row for four 4","_date":0,"ordinals":{"<8>":{"name":"four","number":4}}}
735 {"_comment":"delete row for 4","_date":0,"ordinals":{"<8>":null}}
736 {"_comment":"add back row for four 4","_date":0,"ordinals":{"<9>":{"name":"four","number":4}}}
737 {"_comment":"add row for five 5","_date":0,"ordinals":{"<10>":{"name":"five","number":5}}}
738 {"_comment":"delete row for 5","_date":0,"ordinals":{"<10>":null}}
739 {"_comment":"add back row for five 5","_date":0,"ordinals":{"<11>":{"name":"five","number":5}}}
742 dnl Check that at least there's a lot of transactions.
743 AT_CHECK([test `wc -l < db` -gt 50])
745 dnl Dump out and check the actual database contents.
746 AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout])
747 AT_CHECK([uuidfilt stdout], [0], [dnl
750 ------------------------------------ ----- ------
758 cp db db.pre-compaction
759 dnl Now compact the database in-place.
760 AT_CHECK([[ovs-appctl -t ovsdb-server ovsdb-server/compact]],
763 AT_CHECK([[ovs-appctl -t ovsdb-server ovsdb-server/compact _Server]],
764 [2], [], [cannot compact built-in databases
765 ovs-appctl: ovsdb-server: server returned an error
767 dnl Make sure that "db" is still a symlink to dir/db instead of getting
768 dnl replaced by a regular file, ditto for .db.~lock~.
769 if test "$IS_WIN32" = "no"; then
770 AT_CHECK([test -h db])
771 AT_CHECK([test -h .db.~lock~])
772 AT_CHECK([test -f dir/db])
773 AT_CHECK([test -f dir/.db.~lock~])
776 # We can't fully re-check the contents of the database log, because the
777 # order of the records is not predictable, but there should only be 4 lines
778 # in it now in the standalone case
779 AT_CAPTURE_FILE([db])
780 compacted_lines=`wc -l < db`
781 echo compacted_lines=$compacted_lines
782 if test $model = standalone; then
783 AT_CHECK([test $compacted_lines -eq 4])
786 dnl And check that the dumped data is the same too:
787 AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout])
788 AT_CHECK([uuidfilt stdout], [0], [dnl
791 ------------------------------------ ----- ------
799 dnl Now do some more transactions.
801 [[ovsdb-client transact unix:socket '
805 "where": [["number", "<", 3]]}]']],
809 dnl There should be 6 lines in the log now, for the standalone case,
810 dnl and for the clustered case the file should at least have grown.
811 updated_lines=`wc -l < db`
812 echo compacted_lines=$compacted_lines updated_lines=$updated_lines
813 if test $model = standalone; then
814 AT_CHECK([test $updated_lines -eq 6])
816 AT_CHECK([test $updated_lines -gt $compacted_lines])
819 dnl Then check that the dumped data is correct. This time first kill
820 dnl and restart the database server to ensure that the data is correct on
821 dnl disk as well as in memory.
822 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
823 AT_CHECK([ovsdb-server -vvlog:off -vconsole:off --detach --no-chdir --pidfile --remote=punix:socket --log-file db])
824 AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout])
825 AT_CHECK([uuidfilt stdout], [0], [dnl
828 ------------------------------------ ----- ------
832 ], [], [test ! -e pid || kill `cat pid`])
833 OVSDB_SERVER_SHUTDOWN
835 OVS_END_SHELL_HELPERS
837 AT_SETUP([compacting online - standalone])
838 AT_KEYWORDS([ovsdb server compact])
839 ovsdb_check_online_compaction standalone
842 AT_SETUP([compacting online - cluster])
843 AT_KEYWORDS([ovsdb server compact])
844 ovsdb_check_online_compaction cluster
847 OVS_START_SHELL_HELPERS
848 # ovsdb_check_online_conversion MODEL
850 # where MODEL is "standalone" or "cluster"
851 ovsdb_check_online_conversion() {
853 on_exit 'kill `cat *.pid`'
854 ordinal_schema > schema
855 AT_DATA([new-schema],
856 [[{"name": "ordinals",
860 "number": {"type": "integer"}}}}}
862 dnl Make sure that "ovsdb-tool create" works with a dangling symlink for
863 dnl the database and the lockfile, creating the target of each symlink
864 dnl rather than replacing the symlinks with regular files.
866 if test "$IS_WIN32" = "no"; then
868 ln -s dir/.db.~lock~ .db.~lock~
869 AT_SKIP_IF([test ! -h db || test ! -h .db.~lock~])
871 AT_CHECK([if test $model = standalone; then
872 ovsdb-tool create db schema
874 ovsdb-tool create-cluster db schema unix:s1.raft
877 dnl Start the database server.
878 AT_CHECK([ovsdb-server -vfile -vvlog:off -vconsole:off --detach --no-chdir --pidfile --log-file --remote=punix:db.sock db], [0])
879 AT_CAPTURE_FILE([ovsdb-server.log])
881 dnl Put some data in the database.
883 [[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do
885 ovsdb-client transact '
889 "row": {"name": "'$1'", "number": '$2'}},
891 "comment": "add row for '"$pair"'"}]'
892 done | uuidfilt]], [0],
893 [[[{"uuid":["uuid","<0>"]},{}]
894 [{"uuid":["uuid","<1>"]},{}]
895 [{"uuid":["uuid","<2>"]},{}]
896 [{"uuid":["uuid","<3>"]},{}]
897 [{"uuid":["uuid","<4>"]},{}]
898 [{"uuid":["uuid","<5>"]},{}]
901 dnl Try "needs-conversion".
902 AT_CHECK([ovsdb-client needs-conversion schema], [0], [no
904 AT_CHECK([ovsdb-client needs-conversion new-schema], [0], [yes
907 dnl Start two monitors on the 'ordinals' db, one that is database
908 dnl change aware and one that is not.
909 AT_CHECK([ovsdb-client -vfile -vvlog:off --detach --no-chdir --pidfile=monitor-ordinals-aware.pid --log-file=monitor-ordinals-aware.log --db-change-aware --no-headings monitor ordinals ordinals number name > monitor-ordinals-aware.stdout 2> monitor-ordinals-aware.stderr])
910 AT_CAPTURE_FILE([monitor-ordinals-aware.stdout])
911 AT_CAPTURE_FILE([monitor-ordinals-aware.log])
912 AT_CAPTURE_FILE([monitor-ordinals-aware.stderr])
914 AT_CHECK([ovsdb-client -vfile -vvlog:off --detach --no-chdir --pidfile=monitor-ordinals-unaware.pid --log-file=monitor-ordinals-unaware.log --no-db-change-aware --no-headings monitor ordinals ordinals number name > monitor-ordinals-unaware.stdout 2> monitor-ordinals-unaware.stderr])
915 AT_CAPTURE_FILE([monitor-ordinals-unaware.stdout])
916 AT_CAPTURE_FILE([monitor-ordinals-unaware.log])
917 AT_CAPTURE_FILE([monitor-ordinals-unaware.stderr])
919 dnl Start two monitors on the '_Server' db, one that is database
920 dnl change aware and one that is not.
921 AT_CHECK([ovsdb-client -vfile -vvlog:off --detach --no-chdir --pidfile=monitor-server-aware.pid --log-file=monitor-server-aware.log --db-change-aware --no-headings monitor _Server Database name > monitor-server-aware.stdout 2> monitor-server-aware.stderr])
922 AT_CAPTURE_FILE([monitor-server-aware.stdout])
923 AT_CAPTURE_FILE([monitor-server-aware.log])
924 AT_CAPTURE_FILE([monitor-server-aware.stderr])
926 AT_CHECK([ovsdb-client -vfile -vvlog:off --detach --no-chdir --pidfile=monitor-server-unaware.pid --log-file=monitor-server-unaware.log --no-db-change-aware --no-headings monitor _Server Database name > monitor-server-unaware.stdout 2> monitor-server-unaware.stderr])
927 AT_CAPTURE_FILE([monitor-server-unaware.stdout])
928 AT_CAPTURE_FILE([monitor-server-unaware.log])
929 AT_CAPTURE_FILE([monitor-server-unaware.stderr])
931 dnl Start two long-running transactions (triggers) on the 'ordinals' db,
932 dnl one that is database change aware and one that is not.
933 ordinals_txn='[["ordinals",
936 "where": [["name", "==", "seven"]],
937 "columns": ["name", "number"],
940 AT_CHECK([ovsdb-client -vfile -vvlog:off --detach --no-chdir --pidfile=trigger-ordinals-aware.pid --log-file=trigger-ordinals-aware.log --db-change-aware transact "$ordinals_txn" > trigger-ordinals-aware.stdout 2> trigger-ordinals-aware.stderr])
941 AT_CAPTURE_FILE([trigger-ordinals-aware.stdout])
942 AT_CAPTURE_FILE([trigger-ordinals-aware.log])
943 AT_CAPTURE_FILE([trigger-ordinals-aware.stderr])
945 AT_CHECK([ovsdb-client -vfile -vvlog:off --detach --no-chdir --pidfile=trigger-ordinals-unaware.pid --log-file=trigger-ordinals-unaware.log --no-db-change-aware transact "$ordinals_txn" > trigger-ordinals-unaware.stdout 2> trigger-ordinals-unaware.stderr])
946 AT_CAPTURE_FILE([trigger-ordinals-unaware.stdout])
947 AT_CAPTURE_FILE([trigger-ordinals-unaware.log])
948 AT_CAPTURE_FILE([trigger-ordinals-unaware.stderr])
950 dnl Start two long-running transactions (triggers) on the _Server db,
951 dnl one that is database change aware and one that is not.
952 server_txn='[["_Server",
955 "where": [["name", "==", "xyzzy"]],
959 AT_CHECK([ovsdb-client -vfile -vvlog:off --detach --no-chdir --pidfile=trigger-server-aware.pid --log-file=trigger-server-aware.log --db-change-aware transact "$server_txn" > trigger-server-aware.stdout 2> trigger-server-aware.stderr])
960 AT_CAPTURE_FILE([trigger-server-aware.stdout])
961 AT_CAPTURE_FILE([trigger-server-aware.log])
962 AT_CAPTURE_FILE([trigger-server-aware.stderr])
964 AT_CHECK([ovsdb-client -vfile -vvlog:off --detach --no-chdir --pidfile=trigger-server-unaware.pid --log-file=trigger-server-unaware.log --no-db-change-aware transact "$server_txn" > trigger-server-unaware.stdout 2> trigger-server-unaware.stderr])
965 AT_CAPTURE_FILE([trigger-server-unaware.stdout])
966 AT_CAPTURE_FILE([trigger-server-unaware.log])
967 AT_CAPTURE_FILE([trigger-server-unaware.stderr])
969 dnl Dump out and check the actual database contents.
970 AT_CHECK([ovsdb-client dump unix:db.sock ordinals], [0], [stdout])
971 AT_CHECK([uuidfilt stdout], [0], [dnl
974 ------------------------------------ ----- ------
983 dnl Convert the database.
984 AT_CHECK([ovsdb-client convert new-schema])
986 dnl Try "needs-conversion".
987 AT_CHECK([ovsdb-client needs-conversion schema], [0], [yes
989 AT_CHECK([ovsdb-client needs-conversion new-schema], [0], [no
992 dnl Verify that the "ordinals" monitors behaved as they should have.
993 dnl Both should have exited, for different reasons.
994 for x in aware unaware; do
996 OVS_WAIT_WHILE([test -e monitor-ordinals-$x.pid])
997 AT_CHECK([sort -k 3 monitor-ordinals-$x.stdout | uuidfilt], [0],
1006 AT_CHECK([sed 's/.*: //' monitor-ordinals-unaware.stderr], [0], [receive failed (End of file)
1008 AT_CHECK([sed 's/.*: //' monitor-ordinals-aware.stderr], [0], [ordinals database was removed
1011 dnl Verify that the _Server monitors behaved as they should have.
1012 dnl The db-aware monitor should still be running, but not the unaware one.
1013 for x in aware unaware; do
1014 AT_CHECK([sort -k 3 monitor-server-$x.stdout | uuidfilt], [0],
1015 [<0> initial _Server
1016 <1> initial ordinals
1019 OVS_WAIT_WHILE([test -e monitor-server-unaware.pid])
1020 AT_CHECK([sed 's/.*: //' monitor-ordinals-unaware.stderr], [0], [receive failed (End of file)
1022 AT_CHECK([test -e monitor-server-aware.pid])
1024 dnl Verify that the "ordinals" triggers behaved as they should have:
1025 dnl Both should have exited, for different reasons.
1026 for x in unaware aware; do
1027 OVS_WAIT_WHILE([test -e trigger-ordinals-$x.pid])
1028 AT_CHECK([cat trigger-ordinals-$x.stdout])
1030 AT_CHECK([cat trigger-ordinals-unaware.stderr], [0], [ovsdb-client: transaction failed (End of file)
1032 AT_CHECK([cat trigger-ordinals-aware.stderr], [0], [ovsdb-client: transaction returned error: "canceled"
1035 dnl Verify that the _Server triggers behaved as they should have:
1036 dnl The db-aware trigger should still be waiting, but not the unaware one.
1037 for x in aware unaware; do
1038 AT_CHECK([cat trigger-server-$x.stdout])
1040 OVS_WAIT_WHILE([test -e trigger-server-unaware.pid])
1041 AT_CHECK([sed 's/.*: //' trigger-ordinals-unaware.stderr], [0], [transaction failed (End of file)
1043 AT_CHECK([test -e trigger-server-aware.pid])
1045 AT_CAPTURE_FILE([db])
1046 if test $model = standalone; then
1047 dnl We can't fully re-check the contents of the database log, because the
1048 dnl order of the records is not predictable, but there should only be 4 lines
1050 AT_CHECK([test `wc -l < db` -eq 4])
1052 dnl Check that the dumped data is the same except for the removed column:
1053 AT_CHECK([ovsdb-client dump unix:db.sock ordinals | uuidfilt], [0], [dnl
1056 ------------------------------------ ------
1064 dnl Now check that the converted database is still online and can be modified,
1065 dnl then check that the database log has one more record and that the data
1068 [[ovsdb-client transact '
1071 "table": "ordinals",
1072 "row": {"number": 6}},
1074 "comment": "add row for 6"}]' | uuidfilt]], [0],
1075 [[[{"uuid":["uuid","<0>"]},{}]
1077 if test $model = standalone; then
1078 AT_CHECK([test `wc -l < db` -eq 6])
1080 AT_CHECK([ovsdb-client dump unix:db.sock ordinals | uuidfilt], [0], [dnl
1083 ------------------------------------ ------
1092 dnl Now kill and restart the database server to ensure that the data is
1093 dnl correct on disk as well as in memory.
1094 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
1095 AT_CHECK([[ovsdb-server -vfile -vvlog:off -vconsole:off --detach --no-chdir --pidfile --log-file --remote=punix:db.sock db]],
1097 AT_CHECK([ovsdb-client dump unix:db.sock ordinals | uuidfilt], [0], [dnl
1100 ------------------------------------ ------
1110 dnl Make sure that "db" is still a symlink to dir/db instead of getting
1111 dnl replaced by a regular file, ditto for .db.~lock~.
1112 if test "$IS_WIN32" = "no"; then
1113 AT_CHECK([test -h db])
1114 AT_CHECK([test -h .db.~lock~])
1115 AT_CHECK([test -f dir/db])
1116 AT_CHECK([test -f dir/.db.~lock~])
1119 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
1121 OVS_END_SHELL_HELPERS
1123 AT_SETUP([schema conversion online - standalone])
1124 AT_KEYWORDS([ovsdb server convert needs-conversion standalone])
1125 ovsdb_check_online_conversion standalone
1128 AT_SETUP([schema conversion online - clustered])
1129 AT_KEYWORDS([ovsdb server convert needs-conversion cluster])
1130 ovsdb_check_online_conversion cluster
1133 AT_SETUP([ovsdb-server combines updates on backlogged connections])
1134 on_exit 'kill `cat *.pid`'
1136 # The maximum socket receive buffer size is important for this test, which
1137 # tests behavior when the receive buffer overflows.
1138 if test -e /proc/sys/net/core/rmem_max; then
1140 rmem_max=`cat /proc/sys/net/core/rmem_max`
1141 elif rmem_max=`sysctl -n net.inet.tcp.recvbuf_max 2>/dev/null`; then
1144 # Don't know how to get maximum socket receive buffer on this OS
1148 # Calculate the number of iterations we need to queue. Each of the
1149 # iterations we execute, by itself, yields a monitor update of about
1150 # 25 kB, so fill up that much space plus a few for luck.
1151 n_iterations=`expr $rmem_max / 25000 + 5`
1152 echo rmem_max=$rmem_max n_iterations=$n_iterations
1154 # If there's too much queuing skip the test to avoid timing out.
1155 AT_SKIP_IF([test $rmem_max -gt 1048576])
1157 # Calculate the exact number of monitor updates expected for $n_iterations,
1158 # assuming no updates are combined. The "extra" update is for the initial
1159 # contents of the database.
1160 n_updates=`expr $n_iterations \* 3 + 1`
1162 # Start an ovsdb-server with the vswitchd schema.
1164 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:db.sock db],
1165 [0], [ignore], [ignore])
1167 # Executes a set of transactions that add a bridge with 100 ports, and
1168 # then deletes that bridge. This yields three monitor updates that
1169 # add up to about 25 kB in size.
1171 # The update also increments a counter held in the database so that we can
1172 # verify that the overall effect of the transactions took effect (e.g.
1173 # monitor updates at the end weren't just dropped). We add an arbitrary
1174 # string to the counter to make grepping for it more reliable.
1176 trigger_big_update () {
1177 counter=`expr $counter + 1`
1178 ovs-vsctl --no-wait -- set open_vswitch . system_version=xyzzy$counter
1179 ovs-vsctl --no-wait -- add-br br0 $add
1180 ovs-vsctl --no-wait -- del-br br0
1183 for j in `seq 1 100`; do
1184 printf " -- add-port br0 p%d" $j
1189 AT_CAPTURE_FILE([ovsdb-client.err])
1190 AT_CAPTURE_FILE([ovsdb-client-nonblock.err])
1193 # Start an ovsdb-client monitoring all changes to the database,
1194 # By default, it is non-blocking, and will get update message
1195 # for each ovsdb-server transaactions.
1196 AT_CHECK([ovsdb-client --detach --no-chdir --pidfile=nonblock.pid monitor ALL >ovsdb-client-nonblock.out 2>ovsdb-client-nonblock.err])
1198 # Start an ovsdb-client monitoring all changes to the database,
1199 # make it block to force the buffers to fill up, and then execute
1200 # enough iterations that ovsdb-server starts combining updates.
1201 AT_CHECK([ovsdb-client --detach --no-chdir --pidfile monitor ALL >ovsdb-client.out 2>ovsdb-client.err])
1202 AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/block])
1203 for i in `seq 1 $n_iterations`; do
1204 echo "blocked update ($i of $n_iterations)"
1205 trigger_big_update $i
1207 AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/unblock])
1208 OVS_WAIT_UNTIL([grep "xyzzy$counter" ovsdb-client.out])
1209 OVS_WAIT_UNTIL([grep "xyzzy$counter" ovsdb-client-nonblock.out])
1210 OVS_APP_EXIT_AND_WAIT([ovsdb-client])
1211 AT_CHECK([kill `cat nonblock.pid`])
1213 # Count the number of updates in the ovsdb-client output, by counting
1214 # the number of changes to the Open_vSwitch table. (All of our
1215 # transactions modify the Open_vSwitch table.) It should be less than
1216 # $n_updates updates.
1218 # Check that the counter is what we expect.
1219 logged_updates=`grep -c '^Open_vSwitch' ovsdb-client.out`
1220 logged_nonblock_updates=`grep -c '^Open_vSwitch' ovsdb-client-nonblock.out`
1221 echo "logged_nonblock_updates=$logged_nonblock_updates (expected less or equal to $n_updates)"
1222 echo "logged_updates=$logged_updates (expected less than $logged_nonblock_updates)"
1223 AT_CHECK([test $logged_nonblock_updates -le $n_updates])
1224 AT_CHECK([test $logged_updates -lt $logged_nonblock_updates])
1225 AT_CHECK_UNQUOTED([ovs-vsctl get open_vswitch . system_version], [0],
1228 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
1231 AT_BANNER([OVSDB -- ovsdb-server transactions (SSL IPv4 sockets)])
1233 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
1235 # Creates a database with the given SCHEMA, starts an ovsdb-server on
1236 # that database, and runs each of the TRANSACTIONS (which should be a
1237 # quoted list of quoted strings) against it with ovsdb-client one at a
1240 # Checks that the overall output is OUTPUT, but UUIDs in the output
1241 # are replaced by markers of the form <N> where N is a number. The
1242 # first unique UUID is replaced by <0>, the next by <1>, and so on.
1243 # If a given UUID appears more than once it is always replaced by the
1246 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
1247 m4_define([OVSDB_CHECK_EXECUTION],
1249 AT_KEYWORDS([ovsdb server positive ssl $5])
1250 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
1252 PKIDIR=$abs_top_builddir/tests
1253 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
1254 AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile --private-key=$PKIDIR/testpki-privkey2.pem --certificate=$PKIDIR/testpki-cert2.pem --ca-cert=$PKIDIR/testpki-cacert.pem --remote=pssl:0:127.0.0.1 db], [0], [ignore], [ignore])
1255 PARSE_LISTENING_PORT([ovsdb-server.log], [SSL_PORT])
1256 m4_foreach([txn], [$3],
1257 [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],
1258 [test ! -e pid || kill `cat pid`])
1259 cat stdout >> output
1261 AT_CHECK([uuidfilt output], [0], [$4], [ignore],
1262 [test ! -e pid || kill `cat pid`])
1263 OVSDB_SERVER_SHUTDOWN
1268 AT_BANNER([OVSDB -- ovsdb-server transactions (SSL IPv6 sockets)])
1270 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
1272 # Creates a database with the given SCHEMA, starts an ovsdb-server on
1273 # that database, and runs each of the TRANSACTIONS (which should be a
1274 # quoted list of quoted strings) against it with ovsdb-client one at a
1277 # Checks that the overall output is OUTPUT, but UUIDs in the output
1278 # are replaced by markers of the form <N> where N is a number. The
1279 # first unique UUID is replaced by <0>, the next by <1>, and so on.
1280 # If a given UUID appears more than once it is always replaced by the
1283 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
1284 m4_define([OVSDB_CHECK_EXECUTION],
1286 AT_KEYWORDS([ovsdb server positive ssl6 $5])
1287 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
1288 AT_SKIP_IF([test $HAVE_IPV6 = no])
1290 PKIDIR=$abs_top_builddir/tests
1291 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
1292 AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile --private-key=$PKIDIR/testpki-privkey2.pem --certificate=$PKIDIR/testpki-cert2.pem --ca-cert=$PKIDIR/testpki-cacert.pem --remote=pssl:0:[[::1]] db], [0], [ignore], [ignore])
1293 PARSE_LISTENING_PORT([ovsdb-server.log], [SSL_PORT])
1294 m4_foreach([txn], [$3],
1295 [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],
1296 [test ! -e pid || kill `cat pid`])
1297 cat stdout >> output
1299 AT_CHECK([uuidfilt output], [0], [$4], [ignore],
1300 [test ! -e pid || kill `cat pid`])
1301 OVSDB_SERVER_SHUTDOWN
1304 ONE_EXECUTION_EXAMPLE
1306 AT_BANNER([OVSDB -- ovsdb-server transactions (TCP IPv4 sockets)])
1308 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
1310 # Creates a database with the given SCHEMA, starts an ovsdb-server on
1311 # that database, and runs each of the TRANSACTIONS (which should be a
1312 # quoted list of quoted strings) against it with ovsdb-client one at a
1315 # Checks that the overall output is OUTPUT, but UUIDs in the output
1316 # are replaced by markers of the form <N> where N is a number. The
1317 # first unique UUID is replaced by <0>, the next by <1>, and so on.
1318 # If a given UUID appears more than once it is always replaced by the
1321 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
1322 m4_define([OVSDB_CHECK_EXECUTION],
1324 AT_KEYWORDS([ovsdb server positive tcp $5])
1326 PKIDIR=$abs_top_builddir/tests
1327 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
1328 AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile --remote=ptcp:0:127.0.0.1 db], [0], [ignore], [ignore])
1329 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
1330 m4_foreach([txn], [$3],
1331 [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT 'txn'], [0], [stdout], [ignore],
1332 [test ! -e pid || kill `cat pid`])
1333 cat stdout >> output
1335 AT_CHECK([uuidfilt output], [0], [$4], [ignore],
1336 [test ! -e pid || kill `cat pid`])
1337 OVSDB_SERVER_SHUTDOWN
1342 AT_BANNER([OVSDB -- ovsdb-server transactions (TCP IPv6 sockets)])
1344 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
1346 # Creates a database with the given SCHEMA, starts an ovsdb-server on
1347 # that database, and runs each of the TRANSACTIONS (which should be a
1348 # quoted list of quoted strings) against it with ovsdb-client one at a
1351 # Checks that the overall output is OUTPUT, but UUIDs in the output
1352 # are replaced by markers of the form <N> where N is a number. The
1353 # first unique UUID is replaced by <0>, the next by <1>, and so on.
1354 # If a given UUID appears more than once it is always replaced by the
1357 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
1358 m4_define([OVSDB_CHECK_EXECUTION],
1360 AT_KEYWORDS([ovsdb server positive tcp6 $5])
1361 AT_SKIP_IF([test $HAVE_IPV6 = no])
1363 PKIDIR=$abs_top_builddir/tests
1364 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
1365 AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile --remote=ptcp:0:[[::1]] db], [0], [ignore], [ignore])
1366 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
1367 m4_foreach([txn], [$3],
1368 [AT_CHECK([ovsdb-client transact tcp:[[::1]]:$TCP_PORT 'txn'], [0], [stdout], [ignore],
1369 [test ! -e pid || kill `cat pid`])
1370 cat stdout >> output
1372 AT_CHECK([uuidfilt output], [0], [$4], [ignore],
1373 [test ! -e pid || kill `cat pid`])
1374 OVSDB_SERVER_SHUTDOWN
1377 ONE_EXECUTION_EXAMPLE
1379 AT_BANNER([OVSDB -- transactions on transient ovsdb-server])
1381 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
1383 # Creates a database with the given SCHEMA and runs each of the
1384 # TRANSACTIONS (which should be a quoted list of quoted strings)
1385 # against it with ovsdb-client one at a time. Each ovsdb-client
1386 # is run against a separately started ovsdb-server that executes
1387 # only that single transaction. (The idea is that this should
1388 # help to ferret out any differences between what ovsdb-server has
1389 # in memory and what actually gets committed to disk.)
1391 # Checks that the overall output is OUTPUT, but UUIDs in the output
1392 # are replaced by markers of the form <N> where N is a number. The
1393 # first unique UUID is replaced by <0>, the next by <1>, and so on.
1394 # If a given UUID appears more than once it is always replaced by the
1397 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
1398 m4_define([OVSDB_CHECK_EXECUTION],
1400 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
1401 AT_KEYWORDS([ovsdb server positive transient $5])
1403 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
1404 m4_foreach([txn], [$3],
1405 [AT_DATA([txnfile], [ovsdb-client transact unix:socket 'txn'
1407 AT_CHECK([ovsdb-server --remote=punix:socket db --run="sh txnfile"], [0], [stdout], [ignore])
1408 cat stdout >> output
1410 AT_CHECK([uuidfilt output], [0], [$4], [ignore])
1415 AT_BANNER([OVSDB -- ovsdb-server replication])
1417 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
1419 # Creates two databases with the given SCHEMA, and starts an ovsdb-server on
1421 # Runs each of the TRANSACTIONS (which should be a quoted list of
1422 # quoted strings) against one of the servers with ovsdb-client one at a
1423 # time. The server replicates its database to the other ovsdb-server.
1425 # Checks that the dump of both databases are the same.
1427 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
1428 m4_define([OVSDB_CHECK_EXECUTION],
1430 AT_KEYWORDS([ovsdb server tcp replication $5])
1432 AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore])
1433 AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore])
1435 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile --remote=punix:db.sock db1], [0], [ignore], [ignore])
1437 on_exit 'test ! -e pid || kill `cat pid`'
1439 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile=pid2 --remote=punix:db2.sock --unixctl=unixctl2 --sync-from=unix:db.sock db2], [0], [ignore], [ignore])
1440 on_exit 'test ! -e pid2 || kill `cat pid2`'
1442 m4_foreach([txn], [$3],
1443 [AT_CHECK([ovsdb-client transact 'txn'], [0], [stdout], [ignore])
1446 AT_CHECK([ovsdb-client dump], [0], [stdout], [ignore])
1447 OVS_WAIT_UNTIL([ ovsdb-client dump unix:db2.sock > dump2; diff stdout dump2])
1449 OVSDB_SERVER_SHUTDOWN
1450 OVSDB_SERVER_SHUTDOWN2
1455 AT_BANNER([OVSDB -- ovsdb-server replication table-exclusion])
1457 # OVSDB_CHECK_REPLICATION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
1459 # Creates two databases with the given SCHEMA, and starts an
1460 # ovsdb-server on each database.
1461 # Runs each of the TRANSACTIONS (which should be a quoted list of
1462 # quoted strings) against one of the servers with ovsdb-client one at a
1463 # time. The server replicates its database to the other ovsdb-server.
1465 # Checks that the difference between the dump of the databases is
1466 # OUTPUT, but UUIDs in the output are replaced by markers of the form
1467 # <N> where N is a number. The first unique UUID is replaced by <0>,
1468 # the next by <1>, and so on.
1469 # If a given UUID appears more than once it is always replaced by the
1472 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
1473 m4_define([OVSDB_CHECK_REPLICATION],
1475 AT_KEYWORDS([ovsdb server tcp replication table-exclusion])
1476 AT_SKIP_IF([test $DIFF_SUPPORTS_NORMAL_FORMAT = no])
1478 AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore])
1479 AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore])
1481 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile --remote=punix:db.sock db1], [0], [ignore], [ignore])
1482 on_exit 'test ! -e pid || kill `cat pid`'
1484 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile=pid2 --remote=punix:db2.sock --unixctl=unixctl2 --sync-from=unix:db.sock --sync-exclude-tables=mydb:b db2], [0], [ignore], [ignore])
1485 on_exit 'test ! -e pid2 || kill `cat pid2`'
1487 m4_foreach([txn], [$3],
1488 [AT_CHECK([ ovsdb-client transact 'txn' ], [0], [stdout], [ignore])
1491 AT_CHECK([ovsdb-client dump], [0], [stdout], [ignore])
1494 OVS_WAIT_UNTIL([ ovsdb-client dump unix:db2.sock | grep one ])
1495 AT_CHECK([ovsdb-client dump unix:db2.sock], [0], [stdout], [ignore])
1498 AT_CHECK([diff dump1 dump2], [1], [stdout], [ignore])
1501 AT_CHECK([uuidfilt output], [0], [$4], [ignore])
1503 OVSDB_SERVER_SHUTDOWN
1504 OVSDB_SERVER_SHUTDOWN2
1507 REPLICATION_EXAMPLES
1509 AT_BANNER([OVSDB -- ovsdb-server replication runtime management commands])
1511 #ovsdb-server/get-active-ovsdb-server command
1512 AT_SETUP([ovsdb-server/get-active-ovsdb-server])
1513 AT_KEYWORDS([ovsdb server replication get-active])
1514 ordinal_schema > schema
1515 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
1516 on_exit 'kill `cat *.pid`'
1517 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --sync-from=tcp:127.0.0.1:9999 db])
1519 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/get-active-ovsdb-server],
1520 [0], [tcp:127.0.0.1:9999
1524 #*ovsdb-server/set-active-ovsdb-server command
1525 AT_SETUP([ovsdb-server/set-active-ovsdb-server])
1526 AT_KEYWORDS([ovsdb server replication set-active])
1527 ordinal_schema > schema
1528 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
1529 on_exit 'kill `cat *.pid`'
1530 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile db])
1532 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/set-active-ovsdb-server tcp:127.0.0.1:9999])
1533 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/get-active-ovsdb-server],
1534 [0], [tcp:127.0.0.1:9999
1538 #ovsdb-server/get-sync-exclude-tables command
1539 AT_SETUP([ovsdb-server/get-sync-exclude-tables])
1540 AT_KEYWORDS([ovsdb server replication get-exclude-tables])
1541 ordinal_schema > schema
1542 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
1543 on_exit 'kill `cat *.pid`'
1544 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --sync-exclude-tables=mydb:db1,mydb:db2 db])
1546 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/get-sync-exclude-tables],
1547 [0], [mydb:db1,mydb:db2
1551 #ovsdb-server/set-sync-exclude-tables command
1552 AT_SETUP([ovsdb-server/set-sync-exclude-tables])
1553 AT_KEYWORDS([ovsdb server replication set-exclude-tables])
1554 AT_SKIP_IF([test $DIFF_SUPPORTS_NORMAL_FORMAT = no])
1556 replication_schema > schema
1557 AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore])
1558 AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore])
1560 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile --remote=punix:db.sock db1], [0], [ignore], [ignore])
1561 on_exit 'test ! -e pid || kill `cat pid`'
1563 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile=pid2 --remote=punix:db2.sock --unixctl=unixctl2 --sync-from=unix:db.sock db2], [0], [ignore], [ignore])
1564 on_exit 'test ! -e pid2 || kill `cat pid2`'
1566 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/set-sync-exclude-tables mydb:b], [0], [ignore], [ignore], [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1568 AT_CHECK([ovsdb-client transact unix:db.sock \
1572 "row": {"number": 0, "name": "zero"}},
1575 "row": {"number": 1, "name": "one"}}]]'], [0], [stdout], [ignore],
1576 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1578 AT_CHECK([ovsdb-client dump unix:db.sock], [0], [stdout], [ignore],
1579 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1581 OVS_WAIT_UNTIL([ ovsdb-client dump unix:db2.sock | grep zero ])
1582 AT_CHECK([ovsdb-client dump unix:db2.sock], [0], [stdout], [ignore])
1585 AT_CHECK([diff dump1 dump2], [1], [stdout], [ignore])
1588 AT_CHECK([uuidfilt output], [0], [7,9c7,8
1590 < ------------------------------------ ---- ------
1597 OVSDB_SERVER_SHUTDOWN
1598 OVSDB_SERVER_SHUTDOWN2
1601 #ovsdb-server/connect-active-ovsdb-server
1602 AT_SETUP([ovsdb-server/connect-active-server])
1603 AT_KEYWORDS([ovsdb server replication connect-active-server])
1604 replication_schema > schema
1605 AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore])
1606 AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore])
1608 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile --remote=punix:db.sock db1], [0], [ignore], [ignore])
1609 on_exit 'test ! -e pid || kill `cat pid`'
1611 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile=pid2 --remote=punix:db2.sock --unixctl=unixctl2 db2], [0], [ignore], [ignore])
1612 on_exit 'test ! -e pid2 || kill `cat pid2`'
1614 dnl Try to connect without specifying the active server.
1615 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/connect-active-ovsdb-server], [0],
1616 [Unable to connect: active server is not specified.
1619 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/set-active-ovsdb-server unix:db.sock], [0], [stdout], [ignore])
1621 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/connect-active-ovsdb-server], [0], [stdout], [ignore])
1623 AT_CHECK([ovsdb-client transact unix:db.sock \
1627 "row": {"number": 0, "name": "zero"}}]]'], [0], [stdout], [ignore])
1629 AT_CHECK([ovsdb-client dump unix:db.sock], [0], [stdout], [ignore])
1631 OVS_WAIT_UNTIL([ ovsdb-client dump unix:db2.sock | grep zero ])
1632 AT_CHECK([ovsdb-client dump unix:db2.sock], [0], [stdout], [ignore])
1635 AT_CHECK([diff dump1 dump2], [0], [], [ignore])
1636 OVSDB_SERVER_SHUTDOWN
1637 OVSDB_SERVER_SHUTDOWN2
1640 #ovsdb-server/disconnect-active-server command
1641 AT_SETUP([ovsdb-server/disconnect-active-server])
1642 AT_KEYWORDS([ovsdb server replication disconnect-active-server])
1643 AT_SKIP_IF([test $DIFF_SUPPORTS_NORMAL_FORMAT = no])
1645 replication_schema > schema
1646 AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore])
1647 AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore])
1649 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile --remote=punix:db.sock db1], [0], [ignore], [ignore])
1650 on_exit 'test ! -e pid || kill `cat pid`'
1652 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile=pid2 --remote=punix:db2.sock --unixctl=unixctl2 --sync-from=unix:db.sock db2], [0], [ignore], [ignore])
1653 on_exit 'test ! -e pid2 || kill `cat pid2`'
1655 AT_CHECK([ovsdb-client transact unix:db.sock \
1659 "row": {"number": 0, "name": "zero"}}]]'], [0], [stdout], [ignore])
1661 dnl Make sure the transaction shows up in db2. This also tests the back up server
1663 OVS_WAIT_UNTIL([ovsdb-client dump unix:db2.sock | grep zero])
1665 dnl The backup server does not accept any write transaction
1666 AT_CHECK([ovsdb-client transact unix:db2.sock \
1670 "row": {"number": 1, "name": "one"}}]]'], [0],
1671 [[[{"details":"insert operation not allowed when database server is in read only mode","error":"not allowed"}]]
1674 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/disconnect-active-ovsdb-server], [0], [ignore], [ignore])
1676 AT_CHECK([ovsdb-client transact unix:db.sock \
1680 "row": {"number": 1, "name": "one"}}]]'], [0], [stdout], [ignore])
1682 AT_CHECK([ovsdb-client dump unix:db.sock], [0], [stdout], [ignore])
1686 AT_CHECK([ovsdb-client dump unix:db2.sock], [0], [stdout], [ignore])
1689 AT_CHECK([diff dump1 dump2], [1], [stdout], [ignore])
1692 AT_CHECK([uuidfilt output], [0], [7,9c7,8
1694 < ------------------------------------ ---- ------
1699 ], [ignore], [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1701 dnl The backup server now become active, and can accept write transactions.
1702 AT_CHECK([ovsdb-client transact unix:db2.sock \
1706 "row": {"number": 1, "name": "one"}}]]'], [0], [stdout], [ignore])
1708 AT_CHECK([ovsdb-client dump unix:db2.sock], [0], [stdout])
1711 AT_CHECK([uuidfilt output], [0], [a table
1713 ------------------------------------ ---- ------
1718 ------------------------------------ ---- ------
1722 OVSDB_SERVER_SHUTDOWN
1723 OVSDB_SERVER_SHUTDOWN2
1726 #ovsdb-server/active-backup-role-switching
1727 AT_SETUP([ovsdb-server/active-backup-role-switching])
1728 AT_KEYWORDS([ovsdb server replication active-backup-switching])
1729 replication_schema > schema
1730 AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore])
1731 AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore])
1733 dnl Add some data to both DBs
1734 AT_CHECK([ovsdb-tool transact db1 \
1738 "row": {"number": 9, "name": "nine"}}]]'], [0], [ignore], [ignore])
1740 AT_CHECK([ovsdb-tool transact db2 \
1744 "row": {"number": 9, "name": "nine"}}]]'], [0], [ignore], [ignore])
1746 dnl Start both 'db1' and 'db2' in backup mode. Let them backup from each
1747 dnl other. This is not an supported operation state, but to simulate a start
1748 dnl up condition where an HA manger can select which one to be an active
1749 dnl server soon after.
1750 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile="`pwd`"/pid --remote=punix:db.sock --unixctl="`pwd`"/unixctl db1 --sync-from=unix:db2.sock --active ], [0], [ignore], [ignore])
1751 on_exit 'test ! -e pid || kill `cat pid`'
1753 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/connect-active-ovsdb-server])
1755 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile="`pwd`"/pid2 --remote=punix:db2.sock --unixctl="`pwd`"/unixctl2 --sync-from=unix:db.sock db2], [0], [ignore], [ignore])
1756 on_exit 'test ! -e pid2 || kill `cat pid2`'
1759 dnl make sure both servers reached the replication state
1760 OVS_WAIT_UNTIL([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/sync-status |grep replicating])
1761 OVS_WAIT_UNTIL([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/sync-status |grep replicating])
1763 dnl Switch the 'db1' to active
1764 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/disconnect-active-ovsdb-server])
1765 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/sync-status], [0], [state: active
1768 dnl Issue a transaction to 'db1'
1769 AT_CHECK([ovsdb-client transact unix:db.sock \
1773 "row": {"number": 0, "name": "zero"}}]]'], [0], [ignore])
1775 dnl It should be replicated to 'db2'
1776 OVS_WAIT_UNTIL([ovsdb-client dump unix:db2.sock | grep zero])
1778 dnl Flip the role of 'db1' and 'db2'. 'db1' becomes backup, and db2 becomes active
1779 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/disconnect-active-ovsdb-server])
1780 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/connect-active-ovsdb-server])
1782 dnl Verify the change happend
1783 OVS_WAIT_UNTIL([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/sync-status |grep replicating])
1784 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/sync-status], [0], [state: active
1787 dnl Issue an transaction to 'db2' which is now active.
1788 AT_CHECK([ovsdb-client transact unix:db2.sock \
1792 "row": {"number": 1, "name": "one"}}]]'], [0], [ignore])
1794 dnl The transaction should be replicated to 'db1'
1795 OVS_WAIT_UNTIL([ovsdb-client dump unix:db.sock | grep one])
1797 dnl Both servers should have the same content.
1798 AT_CHECK([ovsdb-client dump unix:db.sock], [0], [stdout])
1801 AT_CHECK([ovsdb-client dump unix:db2.sock], [0], [stdout])
1804 AT_CHECK([diff dump1 dump2])
1806 dnl OVSDB_SERVER_SHUTDOWN
1807 dnl OVSDB_SERVER_SHUTDOWN2
1810 #ovsdb-server prevent self replicating
1811 AT_SETUP([ovsdb-server prevent self replicating])
1812 AT_KEYWORDS([ovsdb server replication])
1813 replication_schema > schema
1814 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
1816 dnl Add some data to both DBs
1817 AT_CHECK([ovsdb-tool transact db \
1821 "row": {"number": 9, "name": "nine"}}]]'], [0], [ignore], [ignore])
1823 dnl Start 'db', then try to be a back up server of itself.
1824 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server.log --pidfile="`pwd`"/pid --remote=punix:db.sock --unixctl="`pwd`"/unixctl db --sync-from=unix:db.sock --active ], [0], [ignore], [ignore])
1825 on_exit 'test ! -e pid || kill `cat pid`'
1827 dnl Save the current content
1828 AT_CHECK([ovsdb-client dump unix:db.sock], [0], [stdout])
1831 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/connect-active-ovsdb-server])
1832 dnl Check that self replicating is blocked.
1833 AT_CHECK([grep "Self replicating is not allowed" ovsdb-server.log], [0], [stdout])
1835 dnl Check current DB content is preserved.
1836 AT_CHECK([ovsdb-client dump unix:db.sock], [0], [stdout])
1839 AT_CHECK([diff dump1 dump2])
1842 AT_SETUP([ovsdb-server/read-only db:ptcp connection])
1843 AT_KEYWORDS([ovsdb server read-only])
1851 "key": {"type": "uuid", "refTable": "Manager"},
1853 "max": "unlimited"}}}},
1870 "number": {"type": "integer"},
1871 "name": {"type": "string"}},
1872 "indexes": [["number"]]}
1875 "cksum": "12345678 9"
1878 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
1880 [[ovsdb-tool transact db \
1885 "managers": ["set", [["named-uuid", "x"]]]}},
1889 "row": {"target": "ptcp:0:127.0.0.1",
1890 "read_only": true}}]']], [0], [ignore], [ignore])
1892 AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile --remote=db:mydb,Root,managers db], [0], [ignore], [ignore])
1893 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
1894 AT_CHECK([ovsdb-client get-schema-version tcp:127.0.0.1:$TCP_PORT mydb], [0], [5.1.3
1897 AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT \
1900 "table": "ordinals",
1901 "row": {"name": "two", "number": '2'}}
1902 ]']], [0], [stdout], [ignore])
1903 cat stdout >> output
1904 AT_CHECK([uuidfilt output], [0], [[[{"details":"insert operation not allowed when database server is in read only mode","error":"not allowed"}]]
1906 OVSDB_SERVER_SHUTDOWN
1909 AT_SETUP([ovsdb-server replication with schema mismatch])
1910 AT_KEYWORDS([ovsdb server replication])
1911 replication_schema > subset_schema
1912 replication_schema_v2 > superset_schema
1914 AT_CHECK([ovsdb-tool create db1 subset_schema], [0], [stdout], [ignore])
1915 AT_CHECK([ovsdb-tool create db2 superset_schema], [0], [stdout], [ignore])
1917 dnl Add some data to both DBs
1918 AT_CHECK([ovsdb-tool transact db1 \
1922 "row": {"number": 9, "name": "nine"}}]]'], [0], [ignore], [ignore])
1924 AT_CHECK([ovsdb-tool transact db2 \
1928 "row": {"number": 10, "name": "ten"}}]]'], [0], [ignore], [ignore])
1930 dnl Start both 'db1' and 'db2'.
1931 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile="`pwd`"/pid --remote=punix:db.sock --unixctl="`pwd`"/unixctl db1 --active ], [0], [ignore], [ignore])
1932 on_exit 'test ! -e pid || kill `cat pid`'
1935 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile="`pwd`"/pid2 --remote=punix:db2.sock --unixctl="`pwd`"/unixctl2 db2], [0], [ignore], [ignore])
1936 on_exit 'test ! -e pid2 || kill `cat pid2`'
1938 OVS_WAIT_UNTIL([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/sync-status |grep active])
1939 OVS_WAIT_UNTIL([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/sync-status |grep active])
1941 AT_CHECK([ovsdb-client dump unix:db.sock a number name], 0, [dnl
1948 AT_CHECK([ovsdb-client dump unix:db2.sock a number name], 0, [dnl
1955 # Replicate db1 from db2. It should fail since db2 schema
1956 # doesn't match with db1 and has additional tables/columns.
1957 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/set-active-ovsdb-server unix:db2.sock])
1958 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/connect-active-ovsdb-server])
1961 [test 1 = `cat ovsdb-server1.log | grep "Schema version mismatch, checking if mydb can still be replicated or not" | wc -l]`
1965 [test 1 = `cat ovsdb-server1.log | grep "mydb cannot be replicated" | wc -l]`
1968 OVS_WAIT_UNTIL([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/sync-status |grep active])
1970 # Replicate db2 from db1. This should be successful.
1971 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/disconnect-active-ovsdb-server])
1972 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/set-active-ovsdb-server unix:db.sock])
1973 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/connect-active-ovsdb-server])
1976 [test 1 = `cat ovsdb-server2.log | grep "Schema version mismatch, checking if mydb can still be replicated or not" | wc -l]`
1980 [test 1 = `cat ovsdb-server2.log | grep "mydb can be replicated" | wc -l]`
1983 OVS_WAIT_UNTIL([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/sync-status |grep replicating])
1985 AT_CHECK([ovsdb-client dump unix:db.sock a number name], 0, [dnl
1992 AT_CHECK([ovsdb-client dump unix:db2.sock a number name], 0, [dnl
1999 AT_CHECK([ovsdb-client transact unix:db.sock \
2003 "row": {"number": 6, "name": "six"}}]]'], [0], [ignore], [ignore])
2005 OVS_WAIT_UNTIL([test 1 = `ovsdb-client dump unix:db2.sock a number name | grep six | wc -l`])
2008 ovsdb-client dump unix:db2.sock a number name], 0, [dnl