]>
Commit | Line | Data |
---|---|---|
80d326ad | 1 | AT_BANNER([OVSDB -- ovsdb-server transactions (Unix sockets)]) |
21ff1aee | 2 | |
028cbd99 BP |
3 | m4_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. | |
22 | m4_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`]) |
31 | cat 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 | ||
38 | EXECUTION_EXAMPLES | |
80d326ad | 39 | \f |
db90b374 BP |
40 | AT_SETUP([truncating corrupted database log]) |
41 | AT_KEYWORDS([ovsdb server positive unix]) | |
39ab07af | 42 | ordinal_schema > schema |
db90b374 BP |
43 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) |
44 | dnl Do one transaction and save the output. | |
45 | AT_DATA([txnfile], [[ovsdb-client transact unix:socket \ | |
46 | '["ordinals", | |
47 | {"op": "insert", | |
48 | "table": "ordinals", | |
49 | "row": {"number": 0, "name": "zero"}}]' | |
50 | ]]) | |
37d03458 | 51 | AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], []) |
db90b374 BP |
52 | cat stdout >> output |
53 | dnl Add some crap to the database log and run another transaction, which should | |
54 | dnl ignore the crap and truncate it out of the log. | |
55 | echo 'xxx' >> db | |
56 | AT_DATA([txnfile], [[ovsdb-client transact unix:socket \ | |
57 | '["ordinals", | |
58 | {"op": "insert", | |
59 | "table": "ordinals", | |
60 | "row": {"number": 1, "name": "one"}}]' | |
61 | ]]) | |
37d03458 | 62 | AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [stderr]) |
db90b374 BP |
63 | AT_CHECK([grep 'syntax error: db: parse error.* in header line "xxx"' stderr], |
64 | [0], [ignore]) | |
65 | cat stdout >> output | |
66 | dnl Run a final transaction to verify that both transactions succeeeded. | |
67 | dnl The crap that we added should have been truncated by the previous run, | |
68 | dnl so ovsdb-server shouldn't log a warning this time. | |
69 | AT_DATA([txnfile], [[ovsdb-client transact unix:socket \ | |
70 | '["ordinals", | |
71 | {"op": "select", | |
72 | "table": "ordinals", | |
73 | "where": [], | |
74 | "sort": ["number"]}]' | |
75 | ]]) | |
37d03458 | 76 | AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], []) |
43675e26 BP |
77 | cat stdout >> output |
78 | AT_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`]) | |
84 | AT_CLEANUP | |
85 | ||
86 | AT_SETUP([truncating database log with bad transaction]) | |
87 | AT_KEYWORDS([ovsdb server positive unix]) | |
39ab07af | 88 | ordinal_schema > schema |
43675e26 BP |
89 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) |
90 | dnl Do one transaction and save the output. | |
91 | AT_DATA([txnfile], [[ovsdb-client transact unix:socket \ | |
92 | '["ordinals", | |
93 | {"op": "insert", | |
94 | "table": "ordinals", | |
95 | "row": {"number": 0, "name": "zero"}}]' | |
96 | ]]) | |
37d03458 | 97 | AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], []) |
43675e26 BP |
98 | cat stdout >> output |
99 | dnl Add some crap to the database log and run another transaction, which should | |
100 | dnl ignore the crap and truncate it out of the log. | |
101 | echo 'OVSDB JSON 15 ffbcdae4b0386265f9ea3280dd7c8f0b72a20e56 | |
102 | {"invalid":{}}' >> db | |
103 | AT_DATA([txnfile], [[ovsdb-client transact unix:socket \ | |
104 | '["ordinals", | |
105 | {"op": "insert", | |
106 | "table": "ordinals", | |
107 | "row": {"number": 1, "name": "one"}}]' | |
108 | ]]) | |
37d03458 | 109 | AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [stderr]) |
43675e26 BP |
110 | AT_CHECK([grep 'syntax "{"invalid":{}}": unknown table: No table named invalid.' stderr], |
111 | [0], [ignore]) | |
112 | cat stdout >> output | |
113 | dnl Run a final transaction to verify that both transactions succeeeded. | |
114 | dnl The crap that we added should have been truncated by the previous run, | |
115 | dnl so ovsdb-server shouldn't log a warning this time. | |
116 | AT_DATA([txnfile], [[ovsdb-client transact unix:socket \ | |
117 | '["ordinals", | |
118 | {"op": "select", | |
119 | "table": "ordinals", | |
120 | "where": [], | |
121 | "sort": ["number"]}]' | |
122 | ]]) | |
37d03458 | 123 | AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], []) |
db90b374 BP |
124 | cat stdout >> output |
125 | AT_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`]) | |
131 | AT_CLEANUP | |
132 | ||
8159b984 BP |
133 | AT_SETUP([ovsdb-client get-schema-version]) |
134 | AT_KEYWORDS([ovsdb server positive]) | |
39ab07af | 135 | ordinal_schema > schema |
8159b984 | 136 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) |
77a922c7 | 137 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/pid --unixctl="`pwd`"/unixctl --remote=punix:socket db], [0], [ignore], [ignore]) |
8159b984 BP |
138 | AT_CHECK([ovsdb-client get-schema-version unix:socket ordinals], [0], [5.1.3 |
139 | ]) | |
140 | OVSDB_SERVER_SHUTDOWN | |
141 | AT_CLEANUP | |
142 | ||
9cb53f26 BP |
143 | AT_SETUP([database multiplexing implementation]) |
144 | AT_KEYWORDS([ovsdb server positive]) | |
b4e8d170 BP |
145 | ordinal_schema > schema1 |
146 | constraint_schema > schema2 | |
147 | AT_CHECK([ovsdb-tool create db1 schema1], [0], [ignore], [ignore]) | |
148 | AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore]) | |
149 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/pid --unixctl="`pwd`"/unixctl --remote=punix:socket db1 db2], [0], [ignore], [ignore]) | |
9cb53f26 BP |
150 | AT_CHECK( |
151 | [[ovsdb-client list-dbs unix:socket]], | |
b4e8d170 BP |
152 | [0], [constraints |
153 | ordinals | |
9cb53f26 BP |
154 | ], [ignore], [test ! -e pid || kill `cat pid`]) |
155 | AT_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 |
159 | OVSDB_SERVER_SHUTDOWN |
160 | AT_CLEANUP | |
161 | ||
0b1fae1b BP |
162 | AT_SETUP([--remote=db: implementation]) |
163 | AT_KEYWORDS([ovsdb server positive]) | |
b4e8d170 BP |
164 | OVS_RUNDIR=`pwd`; export OVS_RUNDIR |
165 | OVS_LOGDIR=`pwd`; export OVS_LOGDIR | |
0b1fae1b BP |
166 | AT_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 |
191 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) |
192 | AT_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]) | |
204 | ON_EXIT([kill `cat ovsdb-server.pid`]) | |
205 | 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]) | |
206 | for i in 1 2 3 4 5 6; do ovs-appctl -t ovsdb-server time/warp 1000; done | |
7c126fbb | 207 | AT_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 |
219 | AT_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 | 225 | AT_CLEANUP |
ada496b5 | 226 | |
78876719 BP |
227 | AT_SETUP([SSL db: implementation]) |
228 | AT_KEYWORDS([ovsdb server positive ssl $5]) | |
229 | AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) | |
15b619e2 | 230 | PKIDIR=$abs_top_builddir/tests |
78876719 BP |
231 | AT_SKIP_IF([expr "$PKIDIR" : ".*[ '\" |
232 | \r\\]"]) | |
233 | AT_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 | ]]) | |
242 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) | |
243 | AT_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 |
252 | AT_CHECK([perl $srcdir/choose-port.pl], [0], [stdout]) |
253 | SSL_PORT=`cat stdout` | |
78876719 | 254 | AT_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]) |
261 | AT_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`]) | |
273 | cat stdout >> output | |
274 | AT_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`]) | |
278 | OVSDB_SERVER_SHUTDOWN | |
279 | AT_CLEANUP | |
280 | ||
ada496b5 BP |
281 | AT_SETUP([compacting online]) |
282 | AT_KEYWORDS([ovsdb server compact]) | |
39ab07af | 283 | ordinal_schema > schema |
a35ae81c BP |
284 | dnl Make sure that "ovsdb-tool create" works with a dangling symlink for |
285 | dnl the database and the lockfile, creating the target of each symlink rather | |
286 | dnl than replacing the symlinks with regular files. | |
287 | mkdir dir | |
288 | ln -s dir/db db | |
289 | ln -s dir/.db.~lock~ .db.~lock~ | |
290 | AT_SKIP_IF([test ! -h db || test ! -h .db.~lock~]) | |
ada496b5 | 291 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) |
a35ae81c | 292 | dnl Start ovsdb-server. |
77a922c7 | 293 | 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]) |
ada496b5 BP |
294 | AT_CAPTURE_FILE([ovsdb-server.log]) |
295 | dnl Do a bunch of random transactions that put crap in the database log. | |
296 | AT_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`]) | |
322 | dnl Check that all the crap is in fact in the database log. | |
62c87d4a | 323 | AT_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`]) |
344 | dnl Dump out and check the actual database contents. | |
345 | AT_CHECK([[ovsdb-client dump unix:socket ordinals]], | |
346 | [0], [stdout], [ignore]) | |
370a11b9 BP |
347 | AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [dnl |
348 | ordinals 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`]) | |
358 | dnl Now compact the database in-place. | |
37d03458 | 359 | AT_CHECK([[ovs-appctl -t "`pwd`"/unixctl ovsdb-server/compact]], |
ada496b5 | 360 | [0], [], [ignore], [test ! -e pid || kill `cat pid`]) |
a35ae81c BP |
361 | dnl Make sure that "db" is still a symlink to dir/db instead of getting |
362 | dnl replaced by a regular file, ditto for .db.~lock~. | |
363 | AT_CHECK([test -h db]) | |
364 | AT_CHECK([test -h .db.~lock~]) | |
365 | AT_CHECK([test -f dir/db]) | |
366 | AT_CHECK([test -f dir/.db.~lock~]) | |
ada496b5 BP |
367 | dnl We can't fully re-check the contents of the database log, because the |
368 | dnl order of the records is not predictable, but there should only be 4 lines | |
369 | dnl in it now. | |
370 | AT_CAPTURE_FILE([db]) | |
e0c7697c EM |
371 | AT_CHECK([test `wc -l < db` -eq 4], [0], [], [], |
372 | [test ! -e pid || kill `cat pid`]) | |
ada496b5 BP |
373 | dnl And check that the dumped data is the same too: |
374 | AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore], | |
375 | [test ! -e pid || kill `cat pid`]) | |
370a11b9 BP |
376 | AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [dnl |
377 | ordinals 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`]) | |
387 | dnl Now do some more transactions. | |
388 | AT_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`]) | |
396 | dnl There should be 6 lines in the log now. | |
e0c7697c EM |
397 | AT_CHECK([test `wc -l < db` -eq 6], [0], [], [], |
398 | [test ! -e pid || kill `cat pid`]) | |
ada496b5 BP |
399 | dnl Then check that the dumped data is correct. |
400 | AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore], | |
401 | [test ! -e pid || kill `cat pid`]) | |
370a11b9 BP |
402 | AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [dnl |
403 | ordinals 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`]) | |
410 | OVSDB_SERVER_SHUTDOWN | |
411 | AT_CLEANUP | |
80d326ad BP |
412 | \f |
413 | AT_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. | |
429 | m4_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`]) |
442 | cat 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 | ||
449 | EXECUTION_EXAMPLES | |
9ff373db BP |
450 | \f |
451 | AT_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. | |
470 | m4_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 | ||
484 | EXECUTION_EXAMPLES |