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