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