stream-unix: Use rundir as root for relative paths.
[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_SETUP([truncating corrupted database log])
42 AT_KEYWORDS([ovsdb server positive unix])
43 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
44 ordinal_schema > schema
45 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
46 dnl Do one transaction and save the output.
47 AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
48 '["ordinals",
49   {"op": "insert",
50    "table": "ordinals",
51    "row": {"number": 0, "name": "zero"}}]'
52 ]])
53 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [])
54 cat stdout >> output
55 dnl Add some crap to the database log and run another transaction, which should
56 dnl ignore the crap and truncate it out of the log.
57 echo 'xxx' >> db
58 AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
59 '["ordinals",
60   {"op": "insert",
61    "table": "ordinals",
62    "row": {"number": 1, "name": "one"}}]'
63 ]])
64 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [stderr])
65 AT_CHECK([grep 'syntax error: db: parse error.* in header line "xxx"' stderr],
66   [0], [ignore])
67 cat stdout >> output
68 dnl Run a final transaction to verify that both transactions succeeeded.
69 dnl The crap that we added should have been truncated by the previous run,
70 dnl so ovsdb-server shouldn't log a warning this time.
71 AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
72 '["ordinals",
73   {"op": "select",
74    "table": "ordinals",
75    "where": [],
76    "sort": ["number"]}]'
77 ]])
78 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [])
79 cat stdout >> output
80 AT_CHECK([perl $srcdir/uuidfilt.pl output], [0],
81   [[[{"uuid":["uuid","<0>"]}]
82 [{"uuid":["uuid","<1>"]}]
83 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
84 ]], [],
85          [test ! -e pid || kill `cat pid`])
86 AT_CLEANUP
87
88 AT_SETUP([truncating database log with bad transaction])
89 AT_KEYWORDS([ovsdb server positive unix])
90 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
91 ordinal_schema > schema
92 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
93 dnl Do one transaction and save the output.
94 AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
95 '["ordinals",
96   {"op": "insert",
97    "table": "ordinals",
98    "row": {"number": 0, "name": "zero"}}]'
99 ]])
100 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [])
101 cat stdout >> output
102 dnl Add some crap to the database log and run another transaction, which should
103 dnl ignore the crap and truncate it out of the log.
104 echo 'OVSDB JSON 15 ffbcdae4b0386265f9ea3280dd7c8f0b72a20e56
105 {"invalid":{}}' >> db
106 AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
107 '["ordinals",
108   {"op": "insert",
109    "table": "ordinals",
110    "row": {"number": 1, "name": "one"}}]'
111 ]])
112 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [stderr])
113 AT_CHECK([grep 'syntax "{"invalid":{}}": unknown table: No table named invalid.' stderr],
114   [0], [ignore])
115 cat stdout >> output
116 dnl Run a final transaction to verify that both transactions succeeeded.
117 dnl The crap that we added should have been truncated by the previous run,
118 dnl so ovsdb-server shouldn't log a warning this time.
119 AT_DATA([txnfile], [[ovsdb-client transact unix:socket \
120 '["ordinals",
121   {"op": "select",
122    "table": "ordinals",
123    "where": [],
124    "sort": ["number"]}]'
125 ]])
126 AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [])
127 cat stdout >> output
128 AT_CHECK([perl $srcdir/uuidfilt.pl output], [0],
129   [[[{"uuid":["uuid","<0>"]}]
130 [{"uuid":["uuid","<1>"]}]
131 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
132 ]], [],
133          [test ! -e pid || kill `cat pid`])
134 AT_CLEANUP
135
136 AT_SETUP([ovsdb-client get-schema-version])
137 AT_KEYWORDS([ovsdb server positive])
138 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
139 ordinal_schema > schema
140 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
141 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/pid --unixctl="`pwd`"/unixctl --remote=punix:socket db], [0], [ignore], [ignore])
142 AT_CHECK([ovsdb-client get-schema-version unix:socket ordinals], [0], [5.1.3
143 ])
144 OVSDB_SERVER_SHUTDOWN
145 AT_CLEANUP
146
147 AT_SETUP([database multiplexing implementation])
148 AT_KEYWORDS([ovsdb server positive])
149 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
150 ordinal_schema > schema1
151 constraint_schema > schema2
152 AT_CHECK([ovsdb-tool create db1 schema1], [0], [ignore], [ignore])
153 AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore])
154 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/pid --unixctl="`pwd`"/unixctl --remote=punix:socket db1 db2], [0], [ignore], [ignore])
155 AT_CHECK(
156   [[ovsdb-client list-dbs unix:socket]], 
157   [0], [constraints
158 ordinals
159 ], [ignore], [test ! -e pid || kill `cat pid`])
160 AT_CHECK(
161   [[test-jsonrpc request unix:socket get_schema [\"nonexistent\"]]], [0],
162   [[{"error":null,"id":0,"result":{"details":"get_schema request specifies unknown database nonexistent","error":"unknown database","syntax":"[\"nonexistent\"]"}}
163 ]], [], [test ! -e pid || kill `cat pid`])
164 OVSDB_SERVER_SHUTDOWN
165 AT_CLEANUP
166
167 AT_SETUP([--remote=db: implementation])
168 AT_KEYWORDS([ovsdb server positive])
169 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
170 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
171 AT_DATA([schema],
172   [[{"name": "mydb",
173      "tables": {
174        "Root": {
175          "columns": {
176            "managers": {
177              "type": {
178                "key": "string",
179                "min": 0,
180                "max": "unlimited"}},
181            "manager_options": {
182              "type": {
183                "key": {"type": "uuid", "refTable": "Manager"},
184                "min": 0,
185                "max": "unlimited"}}}},
186        "Manager": {
187          "columns": {
188            "target": {
189              "type": "string"},
190            "is_connected": {
191              "type": {
192                "key": "boolean",
193                "min": 0,
194                "max": 1}}}}}}
195 ]])
196 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
197 AT_CHECK(
198   [[ovsdb-tool transact db \
199      '["mydb",
200        {"op": "insert",
201         "table": "Root",
202         "row": {
203           "managers": "punix:socket1",
204           "manager_options": ["set", [["named-uuid", "x"]]]}},
205        {"op": "insert",
206         "table": "Manager",
207         "uuid-name": "x",
208         "row": {"target": "punix:socket2"}}]']], [0], [ignore], [ignore])
209 ON_EXIT([kill `cat ovsdb-server.pid`])
210 AT_CHECK([ovsdb-server --enable-dummy --detach --no-chdir --pidfile --remote=db:Root,managers --remote=db:Root,manager_options --log-file db], [0], [ignore], [ignore])
211 for i in 1 2 3 4 5 6; do ovs-appctl -t ovsdb-server time/warp 1000; done
212 AT_CHECK(
213   [[ovsdb-client transact unix:socket1 \
214      '["mydb",
215        {"op": "select",
216         "table": "Root",
217         "where": [],
218         "columns": ["managers"]},
219        {"op": "select",
220         "table": "Manager",
221         "where": [],
222         "columns": ["target", "is_connected"]}]']],
223   [0], [stdout], [ignore])
224 AT_CHECK(
225   [perl $srcdir/uuidfilt.pl stdout], 
226   [0], 
227   [[[{"rows":[{"managers":"punix:socket1"}]},{"rows":[{"is_connected":false,"target":"punix:socket2"}]}]
228 ]], 
229   [ignore])
230 AT_CLEANUP
231
232 AT_SETUP([SSL db: implementation])
233 AT_KEYWORDS([ovsdb server positive ssl $5])
234 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
235 PKIDIR=$abs_top_builddir/tests
236 AT_SKIP_IF([expr "$PKIDIR" : ".*[       '\"
237 \r\\]"])
238 AT_DATA([schema],
239   [[{"name": "mydb",
240      "tables": {
241        "SSL": {
242          "columns": {
243            "private_key": {"type": "string"},
244            "certificate": {"type": "string"},
245            "ca_cert": {"type": "string"}}}}}
246 ]])
247 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
248 AT_CHECK(
249   [[ovsdb-tool transact db \
250      '["mydb",
251        {"op": "insert",
252         "table": "SSL",
253         "row": {"private_key": "'"$PKIDIR/testpki-privkey2.pem"'",
254                 "certificate": "'"$PKIDIR/testpki-cert2.pem"'",
255                 "ca_cert": "'"$PKIDIR/testpki-cacert.pem"'"}}]']],
256   [0], [ignore], [ignore])
257 AT_CHECK([perl $srcdir/choose-port.pl], [0], [stdout])
258 SSL_PORT=`cat stdout`
259 AT_CHECK(
260   [ovsdb-server --detach --no-chdir --pidfile="`pwd`"/pid \
261         --private-key=db:SSL,private_key \
262         --certificate=db:SSL,certificate \
263         --ca-cert=db:SSL,ca_cert \
264          --remote=pssl:$SSL_PORT:127.0.0.1 --unixctl="`pwd`"/unixctl db],
265   [0], [ignore], [ignore])
266 AT_CHECK(
267   [[ovsdb-client \
268         --private-key=$PKIDIR/testpki-privkey.pem \
269         --certificate=$PKIDIR/testpki-cert.pem \
270         --ca-cert=$PKIDIR/testpki-cacert.pem \
271         transact ssl:127.0.0.1:$SSL_PORT \
272         '["mydb",
273           {"op": "select",
274            "table": "SSL",
275            "where": [],
276            "columns": ["private_key"]}]']], 
277   [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`])
278 cat stdout >> output
279 AT_CHECK_UNQUOTED(
280   [perl $srcdir/uuidfilt.pl output], [0], 
281   [[[{"rows":[{"private_key":"$PKIDIR/testpki-privkey2.pem"}]}]
282 ]], [ignore], [test ! -e pid || kill `cat pid`])
283 OVSDB_SERVER_SHUTDOWN
284 AT_CLEANUP
285
286 AT_SETUP([compacting online])
287 AT_KEYWORDS([ovsdb server compact])
288 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
289 ordinal_schema > schema
290 dnl Make sure that "ovsdb-tool create" works with a dangling symlink for
291 dnl the database and the lockfile, creating the target of each symlink rather
292 dnl than replacing the symlinks with regular files.
293 mkdir dir
294 ln -s dir/db db
295 ln -s dir/.db.~lock~ .db.~lock~
296 AT_SKIP_IF([test ! -h db || test ! -h .db.~lock~])
297 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
298 dnl Start ovsdb-server.
299 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])
300 AT_CAPTURE_FILE([ovsdb-server.log])
301 dnl Do a bunch of random transactions that put crap in the database log.
302 AT_CHECK(
303   [[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do
304       set -- $pair
305       ovsdb-client transact unix:socket '
306         ["ordinals",
307          {"op": "insert",
308           "table": "ordinals",
309           "row": {"name": "'$1'", "number": '$2'}},
310          {"op": "comment",
311           "comment": "add row for '"$pair"'"}]'
312       ovsdb-client transact unix:socket '
313         ["ordinals",
314          {"op": "delete",
315           "table": "ordinals",
316           "where": [["number", "==", '$2']]},
317          {"op": "comment",
318           "comment": "delete row for '"$2"'"}]'
319       ovsdb-client transact unix:socket '
320         ["ordinals",
321          {"op": "insert",
322           "table": "ordinals",
323           "row": {"name": "'$1'", "number": '$2'}},
324          {"op": "comment",
325           "comment": "add back row for '"$pair"'"}]'
326     done]],
327   [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`])
328 dnl Check that all the crap is in fact in the database log.
329 AT_CHECK([[perl $srcdir/uuidfilt.pl db | grep -v ^OVSDB | sed 's/"_date":[0-9]*/"_date":0/' | test-json --multiple -]], [0],
330   [[{"cksum":"12345678 9","name":"ordinals","tables":{"ordinals":{"columns":{"name":{"type":"string"},"number":{"type":"integer"}},"indexes":[["number"]]}},"version":"5.1.3"}
331 {"_comment":"add row for zero 0","_date":0,"ordinals":{"<0>":{"name":"zero"}}}
332 {"_comment":"delete row for 0","_date":0,"ordinals":{"<0>":null}}
333 {"_comment":"add back row for zero 0","_date":0,"ordinals":{"<1>":{"name":"zero"}}}
334 {"_comment":"add row for one 1","_date":0,"ordinals":{"<2>":{"name":"one","number":1}}}
335 {"_comment":"delete row for 1","_date":0,"ordinals":{"<2>":null}}
336 {"_comment":"add back row for one 1","_date":0,"ordinals":{"<3>":{"name":"one","number":1}}}
337 {"_comment":"add row for two 2","_date":0,"ordinals":{"<4>":{"name":"two","number":2}}}
338 {"_comment":"delete row for 2","_date":0,"ordinals":{"<4>":null}}
339 {"_comment":"add back row for two 2","_date":0,"ordinals":{"<5>":{"name":"two","number":2}}}
340 {"_comment":"add row for three 3","_date":0,"ordinals":{"<6>":{"name":"three","number":3}}}
341 {"_comment":"delete row for 3","_date":0,"ordinals":{"<6>":null}}
342 {"_comment":"add back row for three 3","_date":0,"ordinals":{"<7>":{"name":"three","number":3}}}
343 {"_comment":"add row for four 4","_date":0,"ordinals":{"<8>":{"name":"four","number":4}}}
344 {"_comment":"delete row for 4","_date":0,"ordinals":{"<8>":null}}
345 {"_comment":"add back row for four 4","_date":0,"ordinals":{"<9>":{"name":"four","number":4}}}
346 {"_comment":"add row for five 5","_date":0,"ordinals":{"<10>":{"name":"five","number":5}}}
347 {"_comment":"delete row for 5","_date":0,"ordinals":{"<10>":null}}
348 {"_comment":"add back row for five 5","_date":0,"ordinals":{"<11>":{"name":"five","number":5}}}
349 ]], [], [test ! -e pid || kill `cat pid`])
350 dnl Dump out and check the actual database contents.
351 AT_CHECK([[ovsdb-client dump unix:socket ordinals]],
352   [0], [stdout], [ignore])
353 AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [dnl
354 ordinals table
355 _uuid                                name  number
356 ------------------------------------ ----- ------
357 <0> five  5     @&t@
358 <1> four  4     @&t@
359 <2> one   1     @&t@
360 <3> three 3     @&t@
361 <4> two   2     @&t@
362 <5> zero  0     @&t@
363 ], [], [test ! -e pid || kill `cat pid`])
364 dnl Now compact the database in-place.
365 AT_CHECK([[ovs-appctl -t "`pwd`"/unixctl ovsdb-server/compact]],
366   [0], [], [ignore], [test ! -e pid || kill `cat pid`])
367 dnl Make sure that "db" is still a symlink to dir/db instead of getting
368 dnl replaced by a regular file, ditto for .db.~lock~.
369 AT_CHECK([test -h db])
370 AT_CHECK([test -h .db.~lock~])
371 AT_CHECK([test -f dir/db])
372 AT_CHECK([test -f dir/.db.~lock~])
373 dnl We can't fully re-check the contents of the database log, because the
374 dnl order of the records is not predictable, but there should only be 4 lines
375 dnl in it now.
376 AT_CAPTURE_FILE([db])
377 AT_CHECK([test `wc -l < db` -eq 4], [0], [], [],
378   [test ! -e pid || kill `cat pid`])
379 dnl And check that the dumped data is the same too:
380 AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore],
381   [test ! -e pid || kill `cat pid`])
382 AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [dnl
383 ordinals table
384 _uuid                                name  number
385 ------------------------------------ ----- ------
386 <0> five  5     @&t@
387 <1> four  4     @&t@
388 <2> one   1     @&t@
389 <3> three 3     @&t@
390 <4> two   2     @&t@
391 <5> zero  0     @&t@
392 ], [], [test ! -e pid || kill `cat pid`])
393 dnl Now do some more transactions.
394 AT_CHECK(
395   [[ovsdb-client transact unix:socket '
396      ["ordinals",
397       {"op": "delete",
398        "table": "ordinals",
399        "where": [["number", "<", 3]]}]']],
400   [0], [[[{"count":3}]
401 ]], [ignore], [test ! -e pid || kill `cat pid`])
402 dnl There should be 6 lines in the log now.
403 AT_CHECK([test `wc -l < db` -eq 6], [0], [], [],
404   [test ! -e pid || kill `cat pid`])
405 dnl Then check that the dumped data is correct.
406 AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore],
407   [test ! -e pid || kill `cat pid`])
408 AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [dnl
409 ordinals table
410 _uuid                                name  number
411 ------------------------------------ ----- ------
412 <0> five  5     @&t@
413 <1> four  4     @&t@
414 <2> three 3     @&t@
415 ], [], [test ! -e pid || kill `cat pid`])
416 OVSDB_SERVER_SHUTDOWN
417 AT_CLEANUP
418 \f
419 AT_BANNER([OVSDB -- ovsdb-server transactions (SSL sockets)])
420
421 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
422 #
423 # Creates a database with the given SCHEMA, starts an ovsdb-server on
424 # that database, and runs each of the TRANSACTIONS (which should be a
425 # quoted list of quoted strings) against it with ovsdb-client one at a
426 # time.
427 #
428 # Checks that the overall output is OUTPUT, but UUIDs in the output
429 # are replaced by markers of the form <N> where N is a number.  The
430 # first unique UUID is replaced by <0>, the next by <1>, and so on.
431 # If a given UUID appears more than once it is always replaced by the
432 # same marker.
433 #
434 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
435 m4_define([OVSDB_CHECK_EXECUTION], 
436   [AT_SETUP([$1])
437    AT_KEYWORDS([ovsdb server positive ssl $5])
438    AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
439    OVS_RUNDIR=`pwd`; export OVS_RUNDIR
440    $2 > schema
441    AT_CHECK([perl $srcdir/choose-port.pl], [0], [stdout])
442    SSL_PORT=`cat stdout`
443    PKIDIR=$abs_top_builddir/tests
444    AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
445    AT_CHECK([ovsdb-server --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:$SSL_PORT:127.0.0.1 --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
446    m4_foreach([txn], [$3], 
447      [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],
448      [test ! -e pid || kill `cat pid`])
449 cat stdout >> output
450 ])
451    AT_CHECK([perl $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
452             [test ! -e pid || kill `cat pid`])
453    OVSDB_SERVER_SHUTDOWN
454    AT_CLEANUP])
455
456 EXECUTION_EXAMPLES
457
458 AT_BANNER([OVSDB -- ovsdb-server transactions (TCP sockets)])
459
460 AT_SETUP([ovsdb-client get-schema-version - tcp socket])
461 AT_KEYWORDS([ovsdb server positive tcp])
462 ordinal_schema > schema
463 AT_CHECK([perl $srcdir/choose-port.pl], [0], [stdout])
464 TCP_PORT=`cat stdout`
465 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
466 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/pid --unixctl="`pwd`"/unixctl --remote=ptcp:$TCP_PORT:127.0.0.1 db], [0], [ignore], [ignore])
467 AT_CHECK([ovsdb-client get-schema-version tcp:127.0.0.1:$TCP_PORT ordinals], [0], [5.1.3
468 ])
469 OVSDB_SERVER_SHUTDOWN
470 AT_CLEANUP])
471
472 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
473 #
474 # Creates a database with the given SCHEMA, starts an ovsdb-server on
475 # that database, and runs each of the TRANSACTIONS (which should be a
476 # quoted list of quoted strings) against it with ovsdb-client one at a
477 # time.
478 #
479 # Checks that the overall output is OUTPUT, but UUIDs in the output
480 # are replaced by markers of the form <N> where N is a number.  The
481 # first unique UUID is replaced by <0>, the next by <1>, and so on.
482 # If a given UUID appears more than once it is always replaced by the
483 # same marker.
484 #
485 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
486 m4_define([OVSDB_CHECK_EXECUTION],
487   [AT_SETUP([$1])
488    AT_KEYWORDS([ovsdb server positive tcp $5])
489    OVS_RUNDIR=`pwd`; export OVS_RUNDIR
490    $2 > schema
491    AT_CHECK([perl $srcdir/choose-port.pl], [0], [stdout])
492    TCP_PORT=`cat stdout`
493    PKIDIR=$abs_top_builddir/tests
494    AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
495    AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/pid --remote=ptcp:$TCP_PORT:127.0.0.1 --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
496    m4_foreach([txn], [$3],
497      [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT 'txn'], [0], [stdout], [ignore],
498      [test ! -e pid || kill `cat pid`])
499 cat stdout >> output
500 ])
501    AT_CHECK([perl $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
502             [test ! -e pid || kill `cat pid`])
503    OVSDB_SERVER_SHUTDOWN
504    AT_CLEANUP])
505
506 EXECUTION_EXAMPLES
507 \f
508 AT_BANNER([OVSDB -- transactions on transient ovsdb-server])
509
510 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
511 #
512 # Creates a database with the given SCHEMA and runs each of the
513 # TRANSACTIONS (which should be a quoted list of quoted strings)
514 # against it with ovsdb-client one at a time.  Each ovsdb-client
515 # is run against a separately started ovsdb-server that executes
516 # only that single transaction.  (The idea is that this should
517 # help to ferret out any differences between what ovsdb-server has
518 # in memory and what actually gets committed to disk.)
519 #
520 # Checks that the overall output is OUTPUT, but UUIDs in the output
521 # are replaced by markers of the form <N> where N is a number.  The
522 # first unique UUID is replaced by <0>, the next by <1>, and so on.
523 # If a given UUID appears more than once it is always replaced by the
524 # same marker.
525 #
526 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
527 m4_define([OVSDB_CHECK_EXECUTION], 
528   [AT_SETUP([$1])
529    AT_KEYWORDS([ovsdb server positive transient $5])
530    OVS_RUNDIR=`pwd`; export OVS_RUNDIR
531    $2 > schema
532    AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
533    m4_foreach([txn], [$3], 
534      [AT_DATA([txnfile], [ovsdb-client transact unix:socket 'txn'
535 ])
536       AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [ignore])
537       cat stdout >> output
538 ])
539    AT_CHECK([perl $srcdir/uuidfilt.pl output], [0], [$4], [ignore])
540    AT_CLEANUP])
541
542 EXECUTION_EXAMPLES