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