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