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