]> git.proxmox.com Git - mirror_ovs.git/blame - tests/ovsdb-server.at
tests/ovs-monitor-ipsec: Remove --no-wait -vreconnect:emer from ovs-vsctl.
[mirror_ovs.git] / tests / ovsdb-server.at
CommitLineData
80d326ad 1AT_BANNER([OVSDB -- ovsdb-server transactions (Unix sockets)])
21ff1aee 2
028cbd99 3m4_define([OVSDB_SERVER_SHUTDOWN],
8a16ab90 4 [OVS_APP_EXIT_AND_WAIT_BY_TARGET([`pwd`/unixctl], [`pwd`/pid])])
028cbd99 5
ae671c5f
MC
6m4_define([OVSDB_SERVER_SHUTDOWN2],
7 [cp pid2 savepid2
8 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 -e exit], [0], [ignore], [ignore])
9 OVS_WAIT_WHILE([kill -0 `cat savepid2`], [kill `cat savepid2`])])
10
21ff1aee
BP
11# OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
12#
13# Creates a database with the given SCHEMA, starts an ovsdb-server on
14# that database, and runs each of the TRANSACTIONS (which should be a
15# quoted list of quoted strings) against it with ovsdb-client one at a
16# time.
17#
18# Checks that the overall output is OUTPUT, but UUIDs in the output
19# are replaced by markers of the form <N> where N is a number. The
20# first unique UUID is replaced by <0>, the next by <1>, and so on.
21# If a given UUID appears more than once it is always replaced by the
22# same marker.
23#
24# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
25m4_define([OVSDB_CHECK_EXECUTION],
26 [AT_SETUP([$1])
9ff373db 27 AT_KEYWORDS([ovsdb server positive unix $5])
39ab07af 28 $2 > schema
7c126fbb 29 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
77a922c7 30 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/pid --remote=punix:socket --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
21ff1aee 31 m4_foreach([txn], [$3],
7c126fbb 32 [AT_CHECK([ovsdb-client transact unix:socket 'txn'], [0], [stdout], [ignore],
21ff1aee
BP
33 [test ! -e pid || kill `cat pid`])
34cat stdout >> output
35])
5c6d0628 36 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
21ff1aee 37 [test ! -e pid || kill `cat pid`])
028cbd99 38 OVSDB_SERVER_SHUTDOWN
21ff1aee
BP
39 AT_CLEANUP])
40
41EXECUTION_EXAMPLES
80d326ad 42\f
48f6e410
BP
43AT_BANNER([ovsdb-server miscellaneous features])
44
db90b374
BP
45AT_SETUP([truncating corrupted database log])
46AT_KEYWORDS([ovsdb server positive unix])
bdb2e73b 47AT_SKIP_IF([test "$IS_WIN32" = "yes"])
39ab07af 48ordinal_schema > schema
db90b374
BP
49AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
50dnl Do one transaction and save the output.
51AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
52'["ordinals",
53 {"op": "insert",
54 "table": "ordinals",
55 "row": {"number": 0, "name": "zero"}}]'
56]])
37d03458 57AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [])
db90b374
BP
58cat stdout >> output
59dnl Add some crap to the database log and run another transaction, which should
60dnl ignore the crap and truncate it out of the log.
61echo 'xxx' >> db
62AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
63'["ordinals",
64 {"op": "insert",
65 "table": "ordinals",
66 "row": {"number": 1, "name": "one"}}]'
67]])
37d03458 68AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [stderr])
db90b374
BP
69AT_CHECK([grep 'syntax error: db: parse error.* in header line "xxx"' stderr],
70 [0], [ignore])
71cat stdout >> output
72dnl Run a final transaction to verify that both transactions succeeeded.
73dnl The crap that we added should have been truncated by the previous run,
74dnl so ovsdb-server shouldn't log a warning this time.
75AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
76'["ordinals",
77 {"op": "select",
78 "table": "ordinals",
79 "where": [],
80 "sort": ["number"]}]'
81]])
37d03458 82AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [])
43675e26 83cat stdout >> output
5c6d0628 84AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0],
43675e26
BP
85 [[[{"uuid":["uuid","<0>"]}]
86[{"uuid":["uuid","<1>"]}]
87[{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
88]], [],
89 [test ! -e pid || kill `cat pid`])
90AT_CLEANUP
91
92AT_SETUP([truncating database log with bad transaction])
93AT_KEYWORDS([ovsdb server positive unix])
bdb2e73b 94AT_SKIP_IF([test "$IS_WIN32" = "yes"])
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])
39ab07af 142ordinal_schema > schema
8159b984 143AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
77a922c7 144AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/pid --unixctl="`pwd`"/unixctl --remote=punix:socket db], [0], [ignore], [ignore])
8159b984
BP
145AT_CHECK([ovsdb-client get-schema-version unix:socket ordinals], [0], [5.1.3
146])
147OVSDB_SERVER_SHUTDOWN
148AT_CLEANUP
149
9cb53f26
BP
150AT_SETUP([database multiplexing implementation])
151AT_KEYWORDS([ovsdb server positive])
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],
508624b6 164 [[{"error":{"details":"get_schema request specifies unknown database nonexistent","error":"unknown database","syntax":"[\"nonexistent\"]"},"id":0,"result":null}
53ffefe9 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])
53eb8cb8 171on_exit 'kill `cat ovsdb-server.pid`'
0a3b723b
BP
172ordinal_schema > schema1
173constraint_schema > schema2
174AT_CHECK([ovsdb-tool create db1 schema1], [0], [ignore], [ignore])
175AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore])
176
177# Start ovsdb-server with just a single database - db1.
178AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket db1], [0])
179AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
180 [0], [ordinals
181])
182
183# Add the second database.
184AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], [0])
185AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
186 [0], [constraints
187ordinals
188])
189
190# The databases are responsive.
191AT_CHECK([ovsdb-client list-tables unix:socket constraints], [0], [ignore], [ignore])
192AT_CHECK([ovsdb-client list-tables unix:socket ordinals], [0], [ignore], [ignore])
193
194# Add an already added database.
bd270dc3
GS
195if test $IS_WIN32 = "yes"; then
196 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], 2, [],
197 [I/O error: db2: failed to lock lockfile (Resource deadlock avoided)
198ovs-appctl: ovsdb-server: server returned an error
199])
200else
201 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], 2, [],
ebed9f78 202 [db2: already open
0a3b723b
BP
203ovs-appctl: ovsdb-server: server returned an error
204])
bd270dc3 205fi
0a3b723b
BP
206
207# Add a non-existing database.
208AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db3], 2, [], [stderr])
209AT_CHECK([sed 's/(.*)/(...)/' stderr], [0],
a6be657b 210 [I/O error: db3: open failed (...)
0a3b723b
BP
211ovs-appctl: ovsdb-server: server returned an error
212])
213
214# Add a remote through a db path in db1.
215AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote db:ordinals,ordinals,name], [0])
216AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
217 [0], [db:ordinals,ordinals,name
218punix:socket
219])
220
221# Removing db1 has no effect on its remote.
222AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db ordinals], [0])
223AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
224 [0], [constraints
225])
226AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
227 [0], [db:ordinals,ordinals,name
228punix:socket
229])
230AT_CHECK([ovsdb-client list-tables unix:socket ordinals], [1], [ignore], [ignore])
231
232# Remove db2.
233AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db constraints], [0])
234AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
235 [0], [])
236AT_CHECK([ovsdb-client list-tables unix:socket constraints], [1], [ignore], [ignore])
237
238# Remove a non-existent database.
239AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db ordinals], [2],
240 [], [Failed to find the database.
241ovs-appctl: ovsdb-server: server returned an error
242])
3fc53787
GS
243
244# Add a removed database.
245AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], [0])
246AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
247 [0], [constraints
248])
249AT_CHECK([ovsdb-client list-tables unix:socket constraints], [0], [ignore], [ignore])
d9c8c57c 250OVS_APP_EXIT_AND_WAIT([ovsdb-server])
0a3b723b
BP
251AT_CLEANUP
252
d7ae8d6b 253AT_SETUP([ovsdb-server/add-db with --monitor])
0a3b723b 254AT_KEYWORDS([ovsdb server positive])
36373c1a 255AT_SKIP_IF([test "$IS_WIN32" = "yes"])
0a3b723b 256# Start ovsdb-server, initially with one db.
0a3b723b
BP
257ordinal_schema > schema
258AT_CHECK([ovsdb-tool create db1 schema], [0], [ignore], [ignore])
53eb8cb8 259on_exit 'kill `cat *.pid`'
0a3b723b
BP
260AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db1])
261
262# Add the second database.
263constraint_schema > schema2
264AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore])
265AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], [0])
266AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
267 [0], [constraints
268ordinals
269])
270
271# Kill the daemon process, making it look like a segfault,
272# and wait for a new daemon process to get spawned.
273cp ovsdb-server.pid old.pid
274AT_CHECK([kill -SEGV `cat ovsdb-server.pid`])
275OVS_WAIT_WHILE([kill -0 `cat old.pid`])
276OVS_WAIT_UNTIL(
277 [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`])
857570c4 278OVS_WAIT_UNTIL([ovs-appctl -t ovsdb-server version])
0a3b723b
BP
279AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
280 [0], [constraints
281ordinals
282])
d9c8c57c 283OVS_APP_EXIT_AND_WAIT([ovsdb-server])
d7ae8d6b
BP
284AT_CLEANUP
285
286AT_SETUP([ovsdb-server/add-db and remove-db with --monitor])
287AT_KEYWORDS([ovsdb server positive])
36373c1a 288AT_SKIP_IF([test "$IS_WIN32" = "yes"])
d7ae8d6b 289# Start ovsdb-server, initially with one db.
d7ae8d6b
BP
290ordinal_schema > schema
291AT_CHECK([ovsdb-tool create db1 schema], [0], [ignore], [ignore])
292constraint_schema > schema2
293AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore])
53eb8cb8 294on_exit 'kill `cat *.pid`'
d7ae8d6b 295AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db1 db2])
0a3b723b 296
d7ae8d6b 297# Remove the second database.
0a3b723b
BP
298AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db constraints])
299AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
300 [0], [ordinals
301])
302
303# Kill the daemon process, making it look like a segfault,
304# and wait for a new daemon process to get spawned.
305cp ovsdb-server.pid old.pid
306AT_CHECK([kill -SEGV `cat ovsdb-server.pid`])
307OVS_WAIT_WHILE([kill -0 `cat old.pid`])
308OVS_WAIT_UNTIL(
309 [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`])
857570c4 310OVS_WAIT_UNTIL([ovs-appctl -t ovsdb-server version])
0a3b723b
BP
311AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs],
312 [0], [ordinals
313])
d9c8c57c 314OVS_APP_EXIT_AND_WAIT([ovsdb-server])
0a3b723b
BP
315AT_CLEANUP
316
0b1fae1b
BP
317AT_SETUP([--remote=db: implementation])
318AT_KEYWORDS([ovsdb server positive])
319AT_DATA([schema],
320 [[{"name": "mydb",
321 "tables": {
b4e8d170
BP
322 "Root": {
323 "columns": {
324 "managers": {
325 "type": {
326 "key": "string",
327 "min": 0,
328 "max": "unlimited"}},
329 "manager_options": {
330 "type": {
331 "key": {"type": "uuid", "refTable": "Manager"},
332 "min": 0,
333 "max": "unlimited"}}}},
0b1fae1b
BP
334 "Manager": {
335 "columns": {
b4e8d170
BP
336 "target": {
337 "type": "string"},
338 "is_connected": {
339 "type": {
340 "key": "boolean",
341 "min": 0,
342 "max": 1}}}}}}
0b1fae1b 343]])
7c126fbb
BP
344AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
345AT_CHECK(
0b1fae1b 346 [[ovsdb-tool transact db \
9cb53f26 347 '["mydb",
b4e8d170
BP
348 {"op": "insert",
349 "table": "Root",
350 "row": {
351 "managers": "punix:socket1",
352 "manager_options": ["set", [["named-uuid", "x"]]]}},
9cb53f26 353 {"op": "insert",
0b1fae1b 354 "table": "Manager",
b4e8d170
BP
355 "uuid-name": "x",
356 "row": {"target": "punix:socket2"}}]']], [0], [ignore], [ignore])
53eb8cb8 357on_exit 'kill `cat ovsdb-server.pid`'
8ad822c9 358AT_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 359ovs-appctl -t ovsdb-server time/warp 6000 1000
7c126fbb 360AT_CHECK(
b4e8d170 361 [[ovsdb-client transact unix:socket1 \
9cb53f26 362 '["mydb",
b4e8d170
BP
363 {"op": "select",
364 "table": "Root",
365 "where": [],
366 "columns": ["managers"]},
9cb53f26 367 {"op": "select",
0b1fae1b
BP
368 "table": "Manager",
369 "where": [],
b4e8d170
BP
370 "columns": ["target", "is_connected"]}]']],
371 [0], [stdout], [ignore])
0b1fae1b 372AT_CHECK(
5c6d0628 373 [${PERL} $srcdir/uuidfilt.pl stdout],
0b1fae1b 374 [0],
b4e8d170 375 [[[{"rows":[{"managers":"punix:socket1"}]},{"rows":[{"is_connected":false,"target":"punix:socket2"}]}]
0b1fae1b 376]],
b4e8d170 377 [ignore])
d9c8c57c 378OVS_APP_EXIT_AND_WAIT([ovsdb-server])
0b1fae1b 379AT_CLEANUP
ada496b5 380
b421d2af
BP
381AT_SETUP([ovsdb-server/add-remote and remove-remote])
382AT_KEYWORDS([ovsdb server positive])
b421d2af
BP
383ordinal_schema > schema
384AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
53eb8cb8 385on_exit 'kill `cat *.pid`'
b421d2af
BP
386AT_CHECK([ovsdb-server --detach --no-chdir --pidfile db])
387
388AT_CHECK([test ! -e socket1])
389AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1])
91fc9298
GS
390if test "$IS_WIN32" = "yes"; then
391 OVS_WAIT_UNTIL([test -s socket1])
392else
393 OVS_WAIT_UNTIL([test -S socket1])
394fi
b421d2af
BP
395AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
396 [0], [punix:socket1
397])
398
399AT_CHECK([test ! -e socket2])
400AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket2])
91fc9298
GS
401if test "$IS_WIN32" = "yes"; then
402 OVS_WAIT_UNTIL([test -s socket2])
403else
404 OVS_WAIT_UNTIL([test -S socket2])
405fi
b421d2af
BP
406AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
407 [0], [punix:socket1
408punix:socket2
409])
410
411AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote db:x,y,z], [2],
412 [], ["db:x,y,z": no database named x
413ovs-appctl: ovsdb-server: server returned an error
414])
415
416AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket1])
417OVS_WAIT_UNTIL([test ! -e socket1])
91fc9298
GS
418if test "$IS_WIN32" = "yes"; then
419 AT_CHECK([test -s socket2])
420else
421 AT_CHECK([test -S socket2])
422fi
b421d2af
BP
423AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
424 [0], [punix:socket2
425])
426
427AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket2])
428OVS_WAIT_UNTIL([test ! -e socket2])
429AT_CHECK([test ! -e socket1])
430AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes])
d9c8c57c 431OVS_APP_EXIT_AND_WAIT([ovsdb-server])
b421d2af
BP
432AT_CLEANUP
433
09993217 434AT_SETUP([ovsdb-server/add-remote with --monitor])
5f36127e 435AT_KEYWORDS([ovsdb server positive])
36373c1a 436AT_SKIP_IF([test "$IS_WIN32" = "yes"])
5f36127e 437# Start ovsdb-server, initially with no remotes.
5f36127e
BP
438ordinal_schema > schema
439AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
53eb8cb8 440on_exit 'kill `cat *.pid`'
5f36127e
BP
441AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db])
442
443# Add a remote.
444AT_CHECK([test ! -e socket1])
445AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1])
446OVS_WAIT_UNTIL([test -S socket1])
447AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
448 [0], [punix:socket1
449])
450
451# Kill the daemon process, making it look like a segfault,
452# and wait for a new daemon process to get spawned and for it to
453# start listening on 'socket1'.
454cp ovsdb-server.pid old.pid
455rm socket1
456AT_CHECK([kill -SEGV `cat ovsdb-server.pid`])
457OVS_WAIT_WHILE([kill -0 `cat old.pid`])
458OVS_WAIT_UNTIL(
459 [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`])
857570c4 460OVS_WAIT_UNTIL([ovs-appctl -t ovsdb-server version])
5f36127e 461OVS_WAIT_UNTIL([test -S socket1])
d9c8c57c 462OVS_APP_EXIT_AND_WAIT([ovsdb-server])
09993217
AW
463AT_CLEANUP
464
465AT_SETUP([ovsdb-server/add-remote and remove-remote with --monitor])
466AT_KEYWORDS([ovsdb server positive])
36373c1a 467AT_SKIP_IF([test "$IS_WIN32" = "yes"])
09993217 468# Start ovsdb-server, initially with no remotes.
09993217
AW
469ordinal_schema > schema
470AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
53eb8cb8 471on_exit 'kill `cat *.pid`'
09993217
AW
472AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db])
473
474# Add a remote.
475AT_CHECK([test ! -e socket1])
476AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1])
477OVS_WAIT_UNTIL([test -S socket1])
478AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
479 [0], [punix:socket1
480])
5f36127e
BP
481
482# Remove the remote.
483AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket1])
484OVS_WAIT_UNTIL([test ! -e socket1])
485AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes])
486
487# Kill the daemon process, making it look like a segfault,
488# and wait for a new daemon process to get spawned and make sure that it
489# does not listen on 'socket1'.
490cp ovsdb-server.pid old.pid
491AT_CHECK([kill -SEGV `cat ovsdb-server.pid`])
492OVS_WAIT_WHILE([kill -0 `cat old.pid`])
493OVS_WAIT_UNTIL(
494 [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`])
857570c4 495OVS_WAIT_UNTIL([ovs-appctl -t ovsdb-server version])
5f36127e 496AT_CHECK([test ! -e socket1])
d9c8c57c 497OVS_APP_EXIT_AND_WAIT([ovsdb-server])
5f36127e
BP
498AT_CLEANUP
499
78876719
BP
500AT_SETUP([SSL db: implementation])
501AT_KEYWORDS([ovsdb server positive ssl $5])
502AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
b028245a
GS
503# For this test, we pass PKIDIR through a ovsdb-tool transact and
504# msys on Windows does not convert the path style automatically.
505# So, do that forcefully with a 'pwd -W' (called through pwd() function).
506PKIDIR="$(cd $abs_top_builddir/tests && pwd)"
78876719 507AT_SKIP_IF([expr "$PKIDIR" : ".*[ '\"
0bcff889 508\\]"])
78876719
BP
509AT_DATA([schema],
510 [[{"name": "mydb",
511 "tables": {
512 "SSL": {
513 "columns": {
514 "private_key": {"type": "string"},
515 "certificate": {"type": "string"},
516 "ca_cert": {"type": "string"}}}}}
517]])
518AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
519AT_CHECK(
520 [[ovsdb-tool transact db \
521 '["mydb",
522 {"op": "insert",
523 "table": "SSL",
524 "row": {"private_key": "'"$PKIDIR/testpki-privkey2.pem"'",
525 "certificate": "'"$PKIDIR/testpki-cert2.pem"'",
526 "ca_cert": "'"$PKIDIR/testpki-cacert.pem"'"}}]']],
527 [0], [ignore], [ignore])
528AT_CHECK(
1e04fcc8 529 [ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid \
fb6de52c
GS
530 --private-key=db:mydb,SSL,private_key \
531 --certificate=db:mydb,SSL,certificate \
532 --ca-cert=db:mydb,SSL,ca_cert \
1e04fcc8 533 --remote=pssl:0:127.0.0.1 --unixctl="`pwd`"/unixctl db],
78876719 534 [0], [ignore], [ignore])
fb28ef2d 535PARSE_LISTENING_PORT([ovsdb-server.log], [SSL_PORT])
78876719
BP
536AT_CHECK(
537 [[ovsdb-client \
538 --private-key=$PKIDIR/testpki-privkey.pem \
539 --certificate=$PKIDIR/testpki-cert.pem \
540 --ca-cert=$PKIDIR/testpki-cacert.pem \
541 transact ssl:127.0.0.1:$SSL_PORT \
542 '["mydb",
543 {"op": "select",
544 "table": "SSL",
545 "where": [],
546 "columns": ["private_key"]}]']],
547 [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`])
548cat stdout >> output
549AT_CHECK_UNQUOTED(
b33bff0f 550 [cat output], [0],
0877a018 551 [[@<:@{"rows":@<:@{"private_key":"$PKIDIR/testpki-privkey2.pem"}@:>@}@:>@
78876719
BP
552]], [ignore], [test ! -e pid || kill `cat pid`])
553OVSDB_SERVER_SHUTDOWN
554AT_CLEANUP
555
ada496b5
BP
556AT_SETUP([compacting online])
557AT_KEYWORDS([ovsdb server compact])
39ab07af 558ordinal_schema > schema
a35ae81c
BP
559dnl Make sure that "ovsdb-tool create" works with a dangling symlink for
560dnl the database and the lockfile, creating the target of each symlink rather
561dnl than replacing the symlinks with regular files.
562mkdir dir
563ln -s dir/db db
564ln -s dir/.db.~lock~ .db.~lock~
565AT_SKIP_IF([test ! -h db || test ! -h .db.~lock~])
ada496b5 566AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
a35ae81c 567dnl Start ovsdb-server.
77a922c7 568AT_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
569AT_CAPTURE_FILE([ovsdb-server.log])
570dnl Do a bunch of random transactions that put crap in the database log.
571AT_CHECK(
572 [[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do
573 set -- $pair
574 ovsdb-client transact unix:socket '
575 ["ordinals",
576 {"op": "insert",
577 "table": "ordinals",
578 "row": {"name": "'$1'", "number": '$2'}},
579 {"op": "comment",
580 "comment": "add row for '"$pair"'"}]'
581 ovsdb-client transact unix:socket '
582 ["ordinals",
583 {"op": "delete",
584 "table": "ordinals",
585 "where": [["number", "==", '$2']]},
586 {"op": "comment",
587 "comment": "delete row for '"$2"'"}]'
588 ovsdb-client transact unix:socket '
589 ["ordinals",
590 {"op": "insert",
591 "table": "ordinals",
592 "row": {"name": "'$1'", "number": '$2'}},
593 {"op": "comment",
594 "comment": "add back row for '"$pair"'"}]'
595 done]],
596 [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`])
597dnl Check that all the crap is in fact in the database log.
eadd1644 598AT_CHECK([[${PERL} $srcdir/uuidfilt.pl db | grep -v ^OVSDB | sed 's/"_date":[0-9]*/"_date":0/' | ovstest test-json --multiple -]], [0],
6910a6e6 599 [[{"cksum":"12345678 9","name":"ordinals","tables":{"ordinals":{"columns":{"name":{"type":"string"},"number":{"type":"integer"}},"indexes":[["number"]]}},"version":"5.1.3"}
62c87d4a
BP
600{"_comment":"add row for zero 0","_date":0,"ordinals":{"<0>":{"name":"zero"}}}
601{"_comment":"delete row for 0","_date":0,"ordinals":{"<0>":null}}
602{"_comment":"add back row for zero 0","_date":0,"ordinals":{"<1>":{"name":"zero"}}}
603{"_comment":"add row for one 1","_date":0,"ordinals":{"<2>":{"name":"one","number":1}}}
604{"_comment":"delete row for 1","_date":0,"ordinals":{"<2>":null}}
605{"_comment":"add back row for one 1","_date":0,"ordinals":{"<3>":{"name":"one","number":1}}}
606{"_comment":"add row for two 2","_date":0,"ordinals":{"<4>":{"name":"two","number":2}}}
607{"_comment":"delete row for 2","_date":0,"ordinals":{"<4>":null}}
608{"_comment":"add back row for two 2","_date":0,"ordinals":{"<5>":{"name":"two","number":2}}}
609{"_comment":"add row for three 3","_date":0,"ordinals":{"<6>":{"name":"three","number":3}}}
610{"_comment":"delete row for 3","_date":0,"ordinals":{"<6>":null}}
611{"_comment":"add back row for three 3","_date":0,"ordinals":{"<7>":{"name":"three","number":3}}}
612{"_comment":"add row for four 4","_date":0,"ordinals":{"<8>":{"name":"four","number":4}}}
613{"_comment":"delete row for 4","_date":0,"ordinals":{"<8>":null}}
614{"_comment":"add back row for four 4","_date":0,"ordinals":{"<9>":{"name":"four","number":4}}}
615{"_comment":"add row for five 5","_date":0,"ordinals":{"<10>":{"name":"five","number":5}}}
616{"_comment":"delete row for 5","_date":0,"ordinals":{"<10>":null}}
617{"_comment":"add back row for five 5","_date":0,"ordinals":{"<11>":{"name":"five","number":5}}}
ada496b5
BP
618]], [], [test ! -e pid || kill `cat pid`])
619dnl Dump out and check the actual database contents.
620AT_CHECK([[ovsdb-client dump unix:socket ordinals]],
621 [0], [stdout], [ignore])
5c6d0628 622AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl
370a11b9
BP
623ordinals table
624_uuid name number
ada496b5
BP
625------------------------------------ ----- ------
626<0> five 5 @&t@
627<1> four 4 @&t@
628<2> one 1 @&t@
629<3> three 3 @&t@
630<4> two 2 @&t@
631<5> zero 0 @&t@
632], [], [test ! -e pid || kill `cat pid`])
633dnl Now compact the database in-place.
37d03458 634AT_CHECK([[ovs-appctl -t "`pwd`"/unixctl ovsdb-server/compact]],
ada496b5 635 [0], [], [ignore], [test ! -e pid || kill `cat pid`])
a35ae81c
BP
636dnl Make sure that "db" is still a symlink to dir/db instead of getting
637dnl replaced by a regular file, ditto for .db.~lock~.
638AT_CHECK([test -h db])
639AT_CHECK([test -h .db.~lock~])
640AT_CHECK([test -f dir/db])
641AT_CHECK([test -f dir/.db.~lock~])
ada496b5
BP
642dnl We can't fully re-check the contents of the database log, because the
643dnl order of the records is not predictable, but there should only be 4 lines
644dnl in it now.
645AT_CAPTURE_FILE([db])
e0c7697c
EM
646AT_CHECK([test `wc -l < db` -eq 4], [0], [], [],
647 [test ! -e pid || kill `cat pid`])
ada496b5
BP
648dnl And check that the dumped data is the same too:
649AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore],
650 [test ! -e pid || kill `cat pid`])
5c6d0628 651AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl
370a11b9
BP
652ordinals table
653_uuid name number
ada496b5
BP
654------------------------------------ ----- ------
655<0> five 5 @&t@
656<1> four 4 @&t@
657<2> one 1 @&t@
658<3> three 3 @&t@
659<4> two 2 @&t@
660<5> zero 0 @&t@
661], [], [test ! -e pid || kill `cat pid`])
662dnl Now do some more transactions.
663AT_CHECK(
664 [[ovsdb-client transact unix:socket '
665 ["ordinals",
666 {"op": "delete",
667 "table": "ordinals",
668 "where": [["number", "<", 3]]}]']],
669 [0], [[[{"count":3}]
670]], [ignore], [test ! -e pid || kill `cat pid`])
671dnl There should be 6 lines in the log now.
e0c7697c
EM
672AT_CHECK([test `wc -l < db` -eq 6], [0], [], [],
673 [test ! -e pid || kill `cat pid`])
ada496b5
BP
674dnl Then check that the dumped data is correct.
675AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore],
676 [test ! -e pid || kill `cat pid`])
5c6d0628 677AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl
370a11b9
BP
678ordinals table
679_uuid name number
ada496b5
BP
680------------------------------------ ----- ------
681<0> five 5 @&t@
682<1> four 4 @&t@
683<2> three 3 @&t@
684], [], [test ! -e pid || kill `cat pid`])
685OVSDB_SERVER_SHUTDOWN
686AT_CLEANUP
48f6e410
BP
687
688AT_SETUP([ovsdb-server combines updates on backlogged connections])
53eb8cb8 689on_exit 'kill `cat *.pid`'
48f6e410
BP
690
691# The maximum socket receive buffer size is important for this test, which
692# tests behavior when the receive buffer overflows.
693if test -e /proc/sys/net/core/rmem_max; then
694 # Linux
695 rmem_max=`cat /proc/sys/net/core/rmem_max`
696elif rmem_max=`sysctl -n net.inet.tcp.recvbuf_max 2>/dev/null`; then
81b9d305 697 : # FreeBSD, NetBSD
48f6e410
BP
698else
699 # Don't know how to get maximum socket receive buffer on this OS
700 AT_SKIP_IF([:])
701fi
702
703# Calculate the number of iterations we need to queue. Each of the
704# iterations we execute, by itself, yields a monitor update of about
705# 25 kB, so fill up that much space plus a few for luck.
f5ca49d8 706n_iterations=`expr $rmem_max / 25000 + 5`
48f6e410
BP
707echo rmem_max=$rmem_max n_iterations=$n_iterations
708
21aa35c3
BP
709# If there's too much queuing skip the test to avoid timing out.
710AT_SKIP_IF([test $rmem_max -gt 1048576])
711
48f6e410
BP
712# Calculate the exact number of monitor updates expected for $n_iterations,
713# assuming no updates are combined. The "extra" update is for the initial
714# contents of the database.
715n_updates=`expr $n_iterations \* 3 + 1`
716
717# Start an ovsdb-server with the vswitchd schema.
718OVSDB_INIT([db])
719AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:db.sock db],
720 [0], [ignore], [ignore])
721
722# Executes a set of transactions that add a bridge with 100 ports, and
723# then deletes that bridge. This yields three monitor updates that
724# add up to about 25 kB in size.
725#
726# The update also increments a counter held in the database so that we can
727# verify that the overall effect of the transactions took effect (e.g.
728# monitor updates at the end weren't just dropped). We add an arbitrary
729# string to the counter to make grepping for it more reliable.
730counter=0
731trigger_big_update () {
732 counter=`expr $counter + 1`
733 ovs-vsctl --no-wait -- set open_vswitch . system_version=xyzzy$counter
734 ovs-vsctl --no-wait -- add-br br0 $add
735 ovs-vsctl --no-wait -- del-br br0
736}
737add_ports () {
738 for j in `seq 1 100`; do
739 printf " -- add-port br0 p%d" $j
740 done
741}
742add=`add_ports`
743
744AT_CAPTURE_FILE([ovsdb-client.err])
c005fd61
AZ
745AT_CAPTURE_FILE([ovsdb-client-nonblock.err])
746
747
748# Start an ovsdb-client monitoring all changes to the database,
749# By default, it is non-blocking, and will get update message
750# for each ovsdb-server transaactions.
751AT_CHECK([ovsdb-client --detach --no-chdir --pidfile=nonblock.pid monitor ALL >ovsdb-client-nonblock.out 2>ovsdb-client-nonblock.err])
48f6e410
BP
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])
c005fd61 764OVS_WAIT_UNTIL([grep "\"xyzzy$counter\"" ovsdb-client-nonblock.out])
d9c8c57c 765OVS_APP_EXIT_AND_WAIT([ovsdb-client])
c005fd61 766AT_CHECK([kill `cat nonblock.pid`])
48f6e410
BP
767
768# Count the number of updates in the ovsdb-client output, by counting
769# the number of changes to the Open_vSwitch table. (All of our
770# transactions modify the Open_vSwitch table.) It should be less than
771# $n_updates updates.
772#
773# Check that the counter is what we expect.
774logged_updates=`grep -c '^Open_vSwitch' ovsdb-client.out`
c005fd61
AZ
775logged_nonblock_updates=`grep -c '^Open_vSwitch' ovsdb-client-nonblock.out`
776echo "logged_nonblock_updates=$logged_nonblock_updates (expected less or equal to $n_updates)"
777echo "logged_updates=$logged_updates (expected less than $logged_nonblock_updates)"
778AT_CHECK([test $logged_nonblock_updates -le $n_updates])
779AT_CHECK([test $logged_updates -lt $logged_nonblock_updates])
48f6e410
BP
780AT_CHECK_UNQUOTED([ovs-vsctl get open_vswitch . system_version], [0],
781 ["xyzzy$counter"
782])
d9c8c57c 783OVS_APP_EXIT_AND_WAIT([ovsdb-server])
48f6e410 784AT_CLEANUP
80d326ad 785\f
e731d71b 786AT_BANNER([OVSDB -- ovsdb-server transactions (SSL IPv4 sockets)])
80d326ad
BP
787
788# OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
789#
790# Creates a database with the given SCHEMA, starts an ovsdb-server on
791# that database, and runs each of the TRANSACTIONS (which should be a
792# quoted list of quoted strings) against it with ovsdb-client one at a
793# time.
794#
795# Checks that the overall output is OUTPUT, but UUIDs in the output
796# are replaced by markers of the form <N> where N is a number. The
797# first unique UUID is replaced by <0>, the next by <1>, and so on.
798# If a given UUID appears more than once it is always replaced by the
799# same marker.
800#
801# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
802m4_define([OVSDB_CHECK_EXECUTION],
803 [AT_SETUP([$1])
804 AT_KEYWORDS([ovsdb server positive ssl $5])
805 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
39ab07af 806 $2 > schema
15b619e2 807 PKIDIR=$abs_top_builddir/tests
7c126fbb 808 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
1e04fcc8 809 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])
fb28ef2d 810 PARSE_LISTENING_PORT([ovsdb-server.log], [SSL_PORT])
80d326ad 811 m4_foreach([txn], [$3],
7c126fbb 812 [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
813 [test ! -e pid || kill `cat pid`])
814cat stdout >> output
815])
5c6d0628 816 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
80d326ad 817 [test ! -e pid || kill `cat pid`])
028cbd99 818 OVSDB_SERVER_SHUTDOWN
80d326ad
BP
819 AT_CLEANUP])
820
e879d33e
MM
821EXECUTION_EXAMPLES
822
e731d71b
AS
823AT_BANNER([OVSDB -- ovsdb-server transactions (SSL IPv6 sockets)])
824
825# OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
826#
827# Creates a database with the given SCHEMA, starts an ovsdb-server on
828# that database, and runs each of the TRANSACTIONS (which should be a
829# quoted list of quoted strings) against it with ovsdb-client one at a
830# time.
831#
832# Checks that the overall output is OUTPUT, but UUIDs in the output
833# are replaced by markers of the form <N> where N is a number. The
834# first unique UUID is replaced by <0>, the next by <1>, and so on.
835# If a given UUID appears more than once it is always replaced by the
836# same marker.
837#
838# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
839m4_define([OVSDB_CHECK_EXECUTION],
840 [AT_SETUP([$1])
841 AT_KEYWORDS([ovsdb server positive ssl6 $5])
842 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
4819b3a5 843 AT_SKIP_IF([test $HAVE_IPV6 = no])
e731d71b
AS
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])
fb28ef2d 848 PARSE_LISTENING_PORT([ovsdb-server.log], [SSL_PORT])
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 867AT_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])
fb28ef2d 868PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
e879d33e
MM
869AT_CHECK([ovsdb-client get-schema-version tcp:127.0.0.1:$TCP_PORT ordinals], [0], [5.1.3
870])
871OVSDB_SERVER_SHUTDOWN
872AT_CLEANUP])
873
874# OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
875#
876# Creates a database with the given SCHEMA, starts an ovsdb-server on
877# that database, and runs each of the TRANSACTIONS (which should be a
878# quoted list of quoted strings) against it with ovsdb-client one at a
879# time.
880#
881# Checks that the overall output is OUTPUT, but UUIDs in the output
882# are replaced by markers of the form <N> where N is a number. The
883# first unique UUID is replaced by <0>, the next by <1>, and so on.
884# If a given UUID appears more than once it is always replaced by the
885# same marker.
886#
887# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
888m4_define([OVSDB_CHECK_EXECUTION],
889 [AT_SETUP([$1])
890 AT_KEYWORDS([ovsdb server positive tcp $5])
891 $2 > schema
e879d33e
MM
892 PKIDIR=$abs_top_builddir/tests
893 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
1e04fcc8 894 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])
fb28ef2d 895 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
e879d33e
MM
896 m4_foreach([txn], [$3],
897 [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT 'txn'], [0], [stdout], [ignore],
898 [test ! -e pid || kill `cat pid`])
899cat stdout >> output
900])
5c6d0628 901 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
e879d33e
MM
902 [test ! -e pid || kill `cat pid`])
903 OVSDB_SERVER_SHUTDOWN
904 AT_CLEANUP])
905
80d326ad 906EXECUTION_EXAMPLES
e731d71b 907
7daaec4e
BP
908AT_BANNER([OVSDB -- ovsdb-server transactions (TCP IPv6 sockets)])
909
e731d71b
AS
910# OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
911#
912# Creates a database with the given SCHEMA, starts an ovsdb-server on
913# that database, and runs each of the TRANSACTIONS (which should be a
914# quoted list of quoted strings) against it with ovsdb-client one at a
915# time.
916#
917# Checks that the overall output is OUTPUT, but UUIDs in the output
918# are replaced by markers of the form <N> where N is a number. The
919# first unique UUID is replaced by <0>, the next by <1>, and so on.
920# If a given UUID appears more than once it is always replaced by the
921# same marker.
922#
923# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
924m4_define([OVSDB_CHECK_EXECUTION],
925 [AT_SETUP([$1])
926 AT_KEYWORDS([ovsdb server positive tcp6 $5])
4819b3a5 927 AT_SKIP_IF([test $HAVE_IPV6 = no])
e731d71b
AS
928 $2 > schema
929 PKIDIR=$abs_top_builddir/tests
930 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
931 AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid --remote=ptcp:0:[[::1]] --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
fb28ef2d 932 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
e731d71b
AS
933 m4_foreach([txn], [$3],
934 [AT_CHECK([ovsdb-client transact tcp:[[::1]]:$TCP_PORT 'txn'], [0], [stdout], [ignore],
935 [test ! -e pid || kill `cat pid`])
936cat stdout >> output
937])
938 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
939 [test ! -e pid || kill `cat pid`])
940 OVSDB_SERVER_SHUTDOWN
941 AT_CLEANUP])
942
943ONE_EXECUTION_EXAMPLE
9ff373db
BP
944\f
945AT_BANNER([OVSDB -- transactions on transient ovsdb-server])
946
947# OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
948#
949# Creates a database with the given SCHEMA and runs each of the
950# TRANSACTIONS (which should be a quoted list of quoted strings)
951# against it with ovsdb-client one at a time. Each ovsdb-client
952# is run against a separately started ovsdb-server that executes
953# only that single transaction. (The idea is that this should
954# help to ferret out any differences between what ovsdb-server has
955# in memory and what actually gets committed to disk.)
956#
957# Checks that the overall output is OUTPUT, but UUIDs in the output
958# are replaced by markers of the form <N> where N is a number. The
959# first unique UUID is replaced by <0>, the next by <1>, and so on.
960# If a given UUID appears more than once it is always replaced by the
961# same marker.
962#
963# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
964m4_define([OVSDB_CHECK_EXECUTION],
965 [AT_SETUP([$1])
c17b52e8 966 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
9ff373db 967 AT_KEYWORDS([ovsdb server positive transient $5])
39ab07af 968 $2 > schema
9ff373db
BP
969 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
970 m4_foreach([txn], [$3],
971 [AT_DATA([txnfile], [ovsdb-client transact unix:socket 'txn'
972])
37d03458 973 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [ignore])
9ff373db
BP
974 cat stdout >> output
975])
5c6d0628 976 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore])
9ff373db
BP
977 AT_CLEANUP])
978
979EXECUTION_EXAMPLES
ae671c5f
MC
980\f
981AT_BANNER([OVSDB -- ovsdb-server replication (TCP IPv4 sockets)])
982
983# OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
984#
985# Creates two databases with the given SCHEMA, and starts an ovsdb-server on
986# each database.
987# Runs each of the TRANSACTIONS (which should be a quoted list of
988# quoted strings) against one of the servers with ovsdb-client one at a
989# time. The server replicates its database to the other ovsdb-server.
990#
991# Checks that the dump of both databases are the same.
992#
993# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
994m4_define([OVSDB_CHECK_EXECUTION],
995 [AT_SETUP([$1])
996 AT_KEYWORDS([ovsdb server tcp replication $5])
997 $2 > schema
998 AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore])
999 AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore])
1000
1001 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile="`pwd`"/pid --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl db1], [0], [ignore], [ignore])
1002 PARSE_LISTENING_PORT([ovsdb-server1.log], [TCP_PORT1])
1003
1004 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile="`pwd`"/pid2 --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl2 --sync-from=tcp:127.0.0.1:$TCP_PORT1 db2], [0], [ignore], [ignore])
1005 PARSE_LISTENING_PORT([ovsdb-server2.log], [TCP_PORT2])
1006
1007 m4_foreach([txn], [$3],
1008 [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT1 'txn'; sleep 2], [0], [stdout], [ignore],
1009 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1010 ])
1011
1012 AT_CHECK([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT1], [0], [stdout], [ignore],
1013 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1014 cat stdout >> dump1
1015 AT_CHECK([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT2], [0], [stdout], [ignore],
1016 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1017 cat stdout >> dump2
1018
1019 AT_CHECK([diff dump1 dump2], [0], [], [ignore],
1020 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1021 OVSDB_SERVER_SHUTDOWN
1022 OVSDB_SERVER_SHUTDOWN2
1023 AT_CLEANUP])
1024
1025EXECUTION_EXAMPLES
7a9d65d2
MC
1026
1027AT_BANNER([OVSDB -- ovsdb-server replication table-exclusion (TCP IPv4 sockets)])
1028
1029# OVSDB_CHECK_REPLICATION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
1030#
1031# Creates two databases with the given SCHEMA, and starts an
1032# ovsdb-server on each database.
1033# Runs each of the TRANSACTIONS (which should be a quoted list of
1034# quoted strings) against one of the servers with ovsdb-client one at a
1035# time. The server replicates its database to the other ovsdb-server.
1036#
1037# Checks that the difference between the dump of the databases is
1038# OUTPUT, but UUIDs in the output are replaced by markers of the form
1039# <N> where N is a number. The first unique UUID is replaced by <0>,
1040# the next by <1>, and so on.
1041# If a given UUID appears more than once it is always replaced by the
1042# same marker.
1043#
1044# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
1045m4_define([OVSDB_CHECK_REPLICATION],
1046 [AT_SETUP([$1])
1047 AT_KEYWORDS([ovsdb server tcp replication table-exclusion])
1048 $2 > schema
1049 AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore])
1050 AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore])
1051
1052 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile="`pwd`"/pid --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl db1], [0], [ignore], [ignore])
1053 PARSE_LISTENING_PORT([ovsdb-server1.log], [TCP_PORT1])
1054
1055 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile="`pwd`"/pid2 --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl2 --sync-from=tcp:127.0.0.1:$TCP_PORT1 --sync-exclude-tables=mydb:b db2], [0], [ignore], [ignore])
1056 PARSE_LISTENING_PORT([ovsdb-server2.log], [TCP_PORT2])
1057
1058 m4_foreach([txn], [$3],
1059 [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT1 'txn'; sleep 2], [0], [stdout], [ignore],
1060 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1061 ])
1062
1063 AT_CHECK([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT1], [0], [stdout], [ignore],
1064 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1065 cat stdout >> dump1
1066 AT_CHECK([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT2], [0], [stdout], [ignore],
1067 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1068 cat stdout >> dump2
1069
1070 AT_CHECK([diff dump1 dump2], [1], [stdout], [ignore],
1071 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1072 cat stdout >> output
1073
1074 AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
1075 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1076
1077 OVSDB_SERVER_SHUTDOWN
1078 OVSDB_SERVER_SHUTDOWN2
1079 AT_CLEANUP])
1080
1081REPLICATION_EXAMPLES
9dc05cdc
MC
1082
1083AT_BANNER([OVSDB -- ovsdb-server replication runtime management commands])
1084
1085#ovsdb-server/get-remote-ovsdb-server command
1086AT_SETUP([ovsdb-server/get-remote-ovsdb-server])
1087AT_KEYWORDS([ovsdb server replication get-remote])
1088ordinal_schema > schema
1089AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
1090on_exit 'kill `cat *.pid`'
1091AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --sync-from=tcp:127.0.0.1:9999 db])
1092
1093AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/get-remote-ovsdb-server],
1094 [0], [tcp:127.0.0.1:9999
1095])
1096AT_CLEANUP
1097
1098#*ovsdb-server/set-remote-ovsdb-server command
1099AT_SETUP([ovsdb-server/set-remote-ovsdb-server])
1100AT_KEYWORDS([ovsdb server replication set-remote])
1101ordinal_schema > schema
1102AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
1103on_exit 'kill `cat *.pid`'
1104AT_CHECK([ovsdb-server --detach --no-chdir --pidfile db])
1105
1106AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/set-remote-ovsdb-server tcp:127.0.0.1:9999])
1107AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/get-remote-ovsdb-server],
1108 [0], [tcp:127.0.0.1:9999
1109])
1110AT_CLEANUP
1111
1112#ovsdb-server/get-sync-excluded-tables command
1113AT_SETUP([ovsdb-server/get-sync-excluded-tables])
1114AT_KEYWORDS([ovsdb server replication get-excluded-tables])
1115ordinal_schema > schema
1116AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
1117on_exit 'kill `cat *.pid`'
1118AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --sync-exclude-tables=mydb:db1,mydb:db2 db])
1119
1120AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/get-sync-excluded-tables],
1121 [0], [mydb:db2
1122mydb:db1
1123])
1124AT_CLEANUP
1125
1126#ovsdb-server/set-sync-excluded-tables command
1127AT_SETUP([ovsdb-server/set-sync-excluded-tables])
1128AT_KEYWORDS([ovsdb server replication set-excluded-tables])
1129replication_schema > schema
1130AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore])
1131AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore])
1132
1133AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile="`pwd`"/pid --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl db1], [0], [ignore], [ignore])
1134PARSE_LISTENING_PORT([ovsdb-server1.log], [TCP_PORT1])
1135
1136AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile="`pwd`"/pid2 --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl2 --sync-from=tcp:127.0.0.1:$TCP_PORT1 db2], [0], [ignore], [ignore])
1137PARSE_LISTENING_PORT([ovsdb-server2.log], [TCP_PORT2])
1138
1139AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/set-sync-excluded-tables mydb:b], [0], [ignore], [ignore], [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1140
1141AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT1 \
1142 '[["mydb",
1143 {"op": "insert",
1144 "table": "a",
1145 "row": {"number": 0, "name": "zero"}},
1146 {"op": "insert",
1147 "table": "b",
1148 "row": {"number": 1, "name": "one"}}]]'], [0], [stdout], [ignore],
1149 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1150sleep 2
1151
1152AT_CHECK([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT1], [0], [stdout], [ignore],
1153 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1154cat stdout >> dump1
1155AT_CHECK([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT2], [0], [stdout], [ignore],
1156 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1157cat stdout >> dump2
1158
1159AT_CHECK([diff dump1 dump2], [1], [stdout], [ignore],
1160 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1161cat stdout >> output
1162
1163AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [7,9c7,8
1164< _uuid name number
1165< ------------------------------------ ---- ------
1166< <0> one 1 @&t@
1167---
1168> _uuid name number
1169> ----- ---- ------
1170], [ignore], [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1171
1172OVSDB_SERVER_SHUTDOWN
1173OVSDB_SERVER_SHUTDOWN2
1174AT_CLEANUP
1175
1176#ovsdb-server/connect-remote-ovsdb-server
1177AT_SETUP([ovsdb-server/connect-remote-server])
1178AT_KEYWORDS([ovsdb server replication connect-remote-server])
1179replication_schema > schema
1180AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore])
1181AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore])
1182
1183AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile="`pwd`"/pid --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl db1], [0], [ignore], [ignore])
1184PARSE_LISTENING_PORT([ovsdb-server1.log], [TCP_PORT1])
1185
1186AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile="`pwd`"/pid2 --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl2 db2], [0], [ignore], [ignore])
1187PARSE_LISTENING_PORT([ovsdb-server2.log], [TCP_PORT2])
1188
1189AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/set-remote-ovsdb-server tcp:127.0.0.1:$TCP_PORT1], [0], [ignore], [ignore], [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1190
1191AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/connect-remote-ovsdb-server], [0], [ignore], [ignore],
1192 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1193
1194AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT1 \
1195 '[["mydb",
1196 {"op": "insert",
1197 "table": "a",
1198 "row": {},
1199 "uuid-name": "0"}]]'], [0], [stdout], [ignore],
1200 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1201sleep 2
1202
1203AT_CHECK([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT1], [0], [stdout], [ignore],
1204 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1205cat stdout >> dump1
1206AT_CHECK([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT2], [0], [stdout], [ignore],
1207 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1208cat stdout >> dump2
1209
1210AT_CHECK([diff dump1 dump2], [0], [], [ignore], [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1211OVSDB_SERVER_SHUTDOWN
1212OVSDB_SERVER_SHUTDOWN2
1213AT_CLEANUP
1214
1215#ovsdb-server/disconnect-remote-server command
1216AT_SETUP([ovsbd-server/disconnect-remote-server])
1217AT_KEYWORDS([ovsdb server replication disconnect-remote-server])
1218replication_schema > schema
1219AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore])
1220AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore])
1221
1222AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile="`pwd`"/pid --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl db1], [0], [ignore], [ignore])
1223PARSE_LISTENING_PORT([ovsdb-server1.log], [TCP_PORT1])
1224
1225AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile="`pwd`"/pid2 --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl2 --sync-from=tcp:127.0.0.1:$TCP_PORT1 db2], [0], [ignore], [ignore])
1226PARSE_LISTENING_PORT([ovsdb-server2.log], [TCP_PORT2])
1227
1228AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT1 \
1229'[["mydb",
1230 {"op": "insert",
1231 "table": "a",
1232 "row": {"number": 0, "name": "zero"}}]]'], [0], [stdout], [ignore],
1233[test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1234sleep 2
1235
1236AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/disconnect-remote-ovsdb-server], [0], [ignore], [ignore],
1237 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1238
1239AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT1 \
1240'[["mydb",
1241 {"op": "insert",
1242 "table": "b",
1243 "row": {"number": 1, "name": "one"}}]]'], [0], [stdout], [ignore],
1244[test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1245sleep 2
1246
1247AT_CHECK([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT1], [0], [stdout], [ignore],
1248 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1249cat stdout >> dump1
1250
1251AT_CHECK([ovsdb-client dump tcp:127.0.0.1:$TCP_PORT2], [0], [stdout], [ignore],
1252 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1253cat stdout >> dump2
1254
1255AT_CHECK([diff dump1 dump2], [1], [stdout], [ignore],
1256 [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1257cat stdout >> output
1258
1259AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [7,9c7,8
1260< _uuid name number
1261< ------------------------------------ ---- ------
1262< <0> one 1 @&t@
1263---
1264> _uuid name number
1265> ----- ---- ------
1266], [ignore], [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
1267
1268OVSDB_SERVER_SHUTDOWN
1269OVSDB_SERVER_SHUTDOWN2
1270AT_CLEANUP