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