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