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