refactor for new netdev_rx class
[sliver-openvswitch.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([ovsdb-server/add-remote and remove-remote])
233 AT_KEYWORDS([ovsdb server positive])
234 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
235 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
236 ordinal_schema > schema
237 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
238 ON_EXIT([kill `cat *.pid`])
239 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile db])
240
241 AT_CHECK([test ! -e socket1])
242 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1])
243 OVS_WAIT_UNTIL([test -S socket1])
244 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
245   [0], [punix:socket1
246 ])
247
248 AT_CHECK([test ! -e socket2])
249 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket2])
250 OVS_WAIT_UNTIL([test -S socket2])
251 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
252   [0], [punix:socket1
253 punix:socket2
254 ])
255
256 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote db:x,y,z], [2],
257   [], ["db:x,y,z": no database named x
258 ovs-appctl: ovsdb-server: server returned an error
259 ])
260
261 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket1])
262 OVS_WAIT_UNTIL([test ! -e socket1])
263 AT_CHECK([test -S socket2])
264 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes],
265   [0], [punix:socket2
266 ])
267
268 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket2])
269 OVS_WAIT_UNTIL([test ! -e socket2])
270 AT_CHECK([test ! -e socket1])
271 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes])
272 AT_CLEANUP
273
274 AT_SETUP([SSL db: implementation])
275 AT_KEYWORDS([ovsdb server positive ssl $5])
276 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
277 PKIDIR=$abs_top_builddir/tests
278 AT_SKIP_IF([expr "$PKIDIR" : ".*[       '\"
279 \r\\]"])
280 AT_DATA([schema],
281   [[{"name": "mydb",
282      "tables": {
283        "SSL": {
284          "columns": {
285            "private_key": {"type": "string"},
286            "certificate": {"type": "string"},
287            "ca_cert": {"type": "string"}}}}}
288 ]])
289 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
290 AT_CHECK(
291   [[ovsdb-tool transact db \
292      '["mydb",
293        {"op": "insert",
294         "table": "SSL",
295         "row": {"private_key": "'"$PKIDIR/testpki-privkey2.pem"'",
296                 "certificate": "'"$PKIDIR/testpki-cert2.pem"'",
297                 "ca_cert": "'"$PKIDIR/testpki-cacert.pem"'"}}]']],
298   [0], [ignore], [ignore])
299 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
300 AT_CHECK(
301   [ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid \
302         --private-key=db:SSL,private_key \
303         --certificate=db:SSL,certificate \
304         --ca-cert=db:SSL,ca_cert \
305         --remote=pssl:0:127.0.0.1 --unixctl="`pwd`"/unixctl db],
306   [0], [ignore], [ignore])
307 SSL_PORT=`parse_listening_port < ovsdb-server.log`
308 AT_CHECK(
309   [[ovsdb-client \
310         --private-key=$PKIDIR/testpki-privkey.pem \
311         --certificate=$PKIDIR/testpki-cert.pem \
312         --ca-cert=$PKIDIR/testpki-cacert.pem \
313         transact ssl:127.0.0.1:$SSL_PORT \
314         '["mydb",
315           {"op": "select",
316            "table": "SSL",
317            "where": [],
318            "columns": ["private_key"]}]']], 
319   [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`])
320 cat stdout >> output
321 AT_CHECK_UNQUOTED(
322   [${PERL} $srcdir/uuidfilt.pl output], [0], 
323   [[[{"rows":[{"private_key":"$PKIDIR/testpki-privkey2.pem"}]}]
324 ]], [ignore], [test ! -e pid || kill `cat pid`])
325 OVSDB_SERVER_SHUTDOWN
326 AT_CLEANUP
327
328 AT_SETUP([compacting online])
329 AT_KEYWORDS([ovsdb server compact])
330 OVS_RUNDIR=`pwd`; export OVS_RUNDIR
331 ordinal_schema > schema
332 dnl Make sure that "ovsdb-tool create" works with a dangling symlink for
333 dnl the database and the lockfile, creating the target of each symlink rather
334 dnl than replacing the symlinks with regular files.
335 mkdir dir
336 ln -s dir/db db
337 ln -s dir/.db.~lock~ .db.~lock~
338 AT_SKIP_IF([test ! -h db || test ! -h .db.~lock~])
339 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
340 dnl Start ovsdb-server.
341 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])
342 AT_CAPTURE_FILE([ovsdb-server.log])
343 dnl Do a bunch of random transactions that put crap in the database log.
344 AT_CHECK(
345   [[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do
346       set -- $pair
347       ovsdb-client transact unix:socket '
348         ["ordinals",
349          {"op": "insert",
350           "table": "ordinals",
351           "row": {"name": "'$1'", "number": '$2'}},
352          {"op": "comment",
353           "comment": "add row for '"$pair"'"}]'
354       ovsdb-client transact unix:socket '
355         ["ordinals",
356          {"op": "delete",
357           "table": "ordinals",
358           "where": [["number", "==", '$2']]},
359          {"op": "comment",
360           "comment": "delete row for '"$2"'"}]'
361       ovsdb-client transact unix:socket '
362         ["ordinals",
363          {"op": "insert",
364           "table": "ordinals",
365           "row": {"name": "'$1'", "number": '$2'}},
366          {"op": "comment",
367           "comment": "add back row for '"$pair"'"}]'
368     done]],
369   [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`])
370 dnl Check that all the crap is in fact in the database log.
371 AT_CHECK([[${PERL} $srcdir/uuidfilt.pl db | grep -v ^OVSDB | sed 's/"_date":[0-9]*/"_date":0/' | test-json --multiple -]], [0],
372   [[{"cksum":"12345678 9","name":"ordinals","tables":{"ordinals":{"columns":{"name":{"type":"string"},"number":{"type":"integer"}},"indexes":[["number"]]}},"version":"5.1.3"}
373 {"_comment":"add row for zero 0","_date":0,"ordinals":{"<0>":{"name":"zero"}}}
374 {"_comment":"delete row for 0","_date":0,"ordinals":{"<0>":null}}
375 {"_comment":"add back row for zero 0","_date":0,"ordinals":{"<1>":{"name":"zero"}}}
376 {"_comment":"add row for one 1","_date":0,"ordinals":{"<2>":{"name":"one","number":1}}}
377 {"_comment":"delete row for 1","_date":0,"ordinals":{"<2>":null}}
378 {"_comment":"add back row for one 1","_date":0,"ordinals":{"<3>":{"name":"one","number":1}}}
379 {"_comment":"add row for two 2","_date":0,"ordinals":{"<4>":{"name":"two","number":2}}}
380 {"_comment":"delete row for 2","_date":0,"ordinals":{"<4>":null}}
381 {"_comment":"add back row for two 2","_date":0,"ordinals":{"<5>":{"name":"two","number":2}}}
382 {"_comment":"add row for three 3","_date":0,"ordinals":{"<6>":{"name":"three","number":3}}}
383 {"_comment":"delete row for 3","_date":0,"ordinals":{"<6>":null}}
384 {"_comment":"add back row for three 3","_date":0,"ordinals":{"<7>":{"name":"three","number":3}}}
385 {"_comment":"add row for four 4","_date":0,"ordinals":{"<8>":{"name":"four","number":4}}}
386 {"_comment":"delete row for 4","_date":0,"ordinals":{"<8>":null}}
387 {"_comment":"add back row for four 4","_date":0,"ordinals":{"<9>":{"name":"four","number":4}}}
388 {"_comment":"add row for five 5","_date":0,"ordinals":{"<10>":{"name":"five","number":5}}}
389 {"_comment":"delete row for 5","_date":0,"ordinals":{"<10>":null}}
390 {"_comment":"add back row for five 5","_date":0,"ordinals":{"<11>":{"name":"five","number":5}}}
391 ]], [], [test ! -e pid || kill `cat pid`])
392 dnl Dump out and check the actual database contents.
393 AT_CHECK([[ovsdb-client dump unix:socket ordinals]],
394   [0], [stdout], [ignore])
395 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl
396 ordinals table
397 _uuid                                name  number
398 ------------------------------------ ----- ------
399 <0> five  5     @&t@
400 <1> four  4     @&t@
401 <2> one   1     @&t@
402 <3> three 3     @&t@
403 <4> two   2     @&t@
404 <5> zero  0     @&t@
405 ], [], [test ! -e pid || kill `cat pid`])
406 dnl Now compact the database in-place.
407 AT_CHECK([[ovs-appctl -t "`pwd`"/unixctl ovsdb-server/compact]],
408   [0], [], [ignore], [test ! -e pid || kill `cat pid`])
409 dnl Make sure that "db" is still a symlink to dir/db instead of getting
410 dnl replaced by a regular file, ditto for .db.~lock~.
411 AT_CHECK([test -h db])
412 AT_CHECK([test -h .db.~lock~])
413 AT_CHECK([test -f dir/db])
414 AT_CHECK([test -f dir/.db.~lock~])
415 dnl We can't fully re-check the contents of the database log, because the
416 dnl order of the records is not predictable, but there should only be 4 lines
417 dnl in it now.
418 AT_CAPTURE_FILE([db])
419 AT_CHECK([test `wc -l < db` -eq 4], [0], [], [],
420   [test ! -e pid || kill `cat pid`])
421 dnl And check that the dumped data is the same too:
422 AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore],
423   [test ! -e pid || kill `cat pid`])
424 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl
425 ordinals table
426 _uuid                                name  number
427 ------------------------------------ ----- ------
428 <0> five  5     @&t@
429 <1> four  4     @&t@
430 <2> one   1     @&t@
431 <3> three 3     @&t@
432 <4> two   2     @&t@
433 <5> zero  0     @&t@
434 ], [], [test ! -e pid || kill `cat pid`])
435 dnl Now do some more transactions.
436 AT_CHECK(
437   [[ovsdb-client transact unix:socket '
438      ["ordinals",
439       {"op": "delete",
440        "table": "ordinals",
441        "where": [["number", "<", 3]]}]']],
442   [0], [[[{"count":3}]
443 ]], [ignore], [test ! -e pid || kill `cat pid`])
444 dnl There should be 6 lines in the log now.
445 AT_CHECK([test `wc -l < db` -eq 6], [0], [], [],
446   [test ! -e pid || kill `cat pid`])
447 dnl Then check that the dumped data is correct.
448 AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore],
449   [test ! -e pid || kill `cat pid`])
450 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl
451 ordinals table
452 _uuid                                name  number
453 ------------------------------------ ----- ------
454 <0> five  5     @&t@
455 <1> four  4     @&t@
456 <2> three 3     @&t@
457 ], [], [test ! -e pid || kill `cat pid`])
458 OVSDB_SERVER_SHUTDOWN
459 AT_CLEANUP
460 \f
461 AT_BANNER([OVSDB -- ovsdb-server transactions (SSL sockets)])
462
463 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
464 #
465 # Creates a database with the given SCHEMA, starts an ovsdb-server on
466 # that database, and runs each of the TRANSACTIONS (which should be a
467 # quoted list of quoted strings) against it with ovsdb-client one at a
468 # time.
469 #
470 # Checks that the overall output is OUTPUT, but UUIDs in the output
471 # are replaced by markers of the form <N> where N is a number.  The
472 # first unique UUID is replaced by <0>, the next by <1>, and so on.
473 # If a given UUID appears more than once it is always replaced by the
474 # same marker.
475 #
476 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
477 m4_define([OVSDB_CHECK_EXECUTION], 
478   [AT_SETUP([$1])
479    AT_KEYWORDS([ovsdb server positive ssl $5])
480    AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
481    OVS_RUNDIR=`pwd`; export OVS_RUNDIR
482    OVS_LOGDIR=`pwd`; export OVS_LOGDIR
483    $2 > schema
484    PKIDIR=$abs_top_builddir/tests
485    AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
486    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])
487    SSL_PORT=`parse_listening_port < ovsdb-server.log`
488    m4_foreach([txn], [$3], 
489      [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],
490      [test ! -e pid || kill `cat pid`])
491 cat stdout >> output
492 ])
493    AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
494             [test ! -e pid || kill `cat pid`])
495    OVSDB_SERVER_SHUTDOWN
496    AT_CLEANUP])
497
498 EXECUTION_EXAMPLES
499
500 AT_BANNER([OVSDB -- ovsdb-server transactions (TCP sockets)])
501
502 AT_SETUP([ovsdb-client get-schema-version - tcp socket])
503 AT_KEYWORDS([ovsdb server positive tcp])
504 ordinal_schema > schema
505 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
506 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
507 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])
508 TCP_PORT=`parse_listening_port < ovsdb-server.log`
509 AT_CHECK([ovsdb-client get-schema-version tcp:127.0.0.1:$TCP_PORT ordinals], [0], [5.1.3
510 ])
511 OVSDB_SERVER_SHUTDOWN
512 AT_CLEANUP])
513
514 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
515 #
516 # Creates a database with the given SCHEMA, starts an ovsdb-server on
517 # that database, and runs each of the TRANSACTIONS (which should be a
518 # quoted list of quoted strings) against it with ovsdb-client one at a
519 # time.
520 #
521 # Checks that the overall output is OUTPUT, but UUIDs in the output
522 # are replaced by markers of the form <N> where N is a number.  The
523 # first unique UUID is replaced by <0>, the next by <1>, and so on.
524 # If a given UUID appears more than once it is always replaced by the
525 # same marker.
526 #
527 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
528 m4_define([OVSDB_CHECK_EXECUTION],
529   [AT_SETUP([$1])
530    AT_KEYWORDS([ovsdb server positive tcp $5])
531    OVS_RUNDIR=`pwd`; export OVS_RUNDIR
532    OVS_LOGDIR=`pwd`; export OVS_LOGDIR
533    $2 > schema
534    PKIDIR=$abs_top_builddir/tests
535    AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
536    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])
537    TCP_PORT=`parse_listening_port < ovsdb-server.log`
538    m4_foreach([txn], [$3],
539      [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT 'txn'], [0], [stdout], [ignore],
540      [test ! -e pid || kill `cat pid`])
541 cat stdout >> output
542 ])
543    AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore],
544             [test ! -e pid || kill `cat pid`])
545    OVSDB_SERVER_SHUTDOWN
546    AT_CLEANUP])
547
548 EXECUTION_EXAMPLES
549 \f
550 AT_BANNER([OVSDB -- transactions on transient ovsdb-server])
551
552 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
553 #
554 # Creates a database with the given SCHEMA and runs each of the
555 # TRANSACTIONS (which should be a quoted list of quoted strings)
556 # against it with ovsdb-client one at a time.  Each ovsdb-client
557 # is run against a separately started ovsdb-server that executes
558 # only that single transaction.  (The idea is that this should
559 # help to ferret out any differences between what ovsdb-server has
560 # in memory and what actually gets committed to disk.)
561 #
562 # Checks that the overall output is OUTPUT, but UUIDs in the output
563 # are replaced by markers of the form <N> where N is a number.  The
564 # first unique UUID is replaced by <0>, the next by <1>, and so on.
565 # If a given UUID appears more than once it is always replaced by the
566 # same marker.
567 #
568 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
569 m4_define([OVSDB_CHECK_EXECUTION], 
570   [AT_SETUP([$1])
571    AT_KEYWORDS([ovsdb server positive transient $5])
572    OVS_RUNDIR=`pwd`; export OVS_RUNDIR
573    $2 > schema
574    AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
575    m4_foreach([txn], [$3], 
576      [AT_DATA([txnfile], [ovsdb-client transact unix:socket 'txn'
577 ])
578       AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [ignore])
579       cat stdout >> output
580 ])
581    AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore])
582    AT_CLEANUP])
583
584 EXECUTION_EXAMPLES