]>
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 | |
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 | ||
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]) |
21ff1aee BP |
25 | AT_DATA([schema], [$2 |
26 | ]) | |
7c126fbb | 27 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) |
0b1fae1b | 28 | AT_CHECK([ovsdb-server --detach --pidfile=$PWD/pid --remote=punix:socket --unixctl=$PWD/unixctl db], [0], [ignore], [ignore]) |
21ff1aee | 29 | m4_foreach([txn], [$3], |
7c126fbb | 30 | [AT_CHECK([ovsdb-client transact unix:socket 'txn'], [0], [stdout], [ignore], |
21ff1aee BP |
31 | [test ! -e pid || kill `cat pid`]) |
32 | cat stdout >> output | |
33 | ]) | |
b12e3c41 | 34 | AT_CHECK([perl $srcdir/uuidfilt.pl output], [0], [$4], [ignore], |
21ff1aee | 35 | [test ! -e pid || kill `cat pid`]) |
028cbd99 | 36 | OVSDB_SERVER_SHUTDOWN |
21ff1aee BP |
37 | AT_CLEANUP]) |
38 | ||
39 | EXECUTION_EXAMPLES | |
80d326ad | 40 | \f |
db90b374 BP |
41 | AT_SETUP([truncating corrupted database log]) |
42 | AT_KEYWORDS([ovsdb server positive unix]) | |
43 | AT_DATA([schema], [ORDINAL_SCHEMA | |
44 | ]) | |
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 | ]]) | |
bc9dcfb3 | 53 | AT_CHECK([ovsdb-server --remote=punix:socket --unixctl=$PWD/unixctl db --run="sh txnfile"], [0], [stdout], []) |
db90b374 BP |
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 | ]]) | |
bc9dcfb3 | 64 | AT_CHECK([ovsdb-server --remote=punix:socket --unixctl=$PWD/unixctl db --run="sh txnfile"], [0], [stdout], [stderr]) |
db90b374 BP |
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 | ]]) | |
bc9dcfb3 | 78 | AT_CHECK([ovsdb-server --remote=punix:socket --unixctl=$PWD/unixctl db --run="sh txnfile"], [0], [stdout], []) |
43675e26 BP |
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 | AT_DATA([schema], [ORDINAL_SCHEMA | |
91 | ]) | |
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 | ]]) | |
bc9dcfb3 | 100 | AT_CHECK([ovsdb-server --remote=punix:socket --unixctl=$PWD/unixctl db --run="sh txnfile"], [0], [stdout], []) |
43675e26 BP |
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 | ]]) | |
bc9dcfb3 | 112 | AT_CHECK([ovsdb-server --remote=punix:socket --unixctl=$PWD/unixctl db --run="sh txnfile"], [0], [stdout], [stderr]) |
43675e26 BP |
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 | ]]) | |
bc9dcfb3 | 126 | AT_CHECK([ovsdb-server --remote=punix:socket --unixctl=$PWD/unixctl db --run="sh txnfile"], [0], [stdout], []) |
db90b374 BP |
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 | ||
8159b984 BP |
136 | AT_SETUP([ovsdb-client get-schema-version]) |
137 | AT_KEYWORDS([ovsdb server positive]) | |
138 | AT_DATA([schema], [ORDINAL_SCHEMA | |
139 | ]) | |
140 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) | |
141 | AT_CHECK([ovsdb-server --detach --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 | ||
9cb53f26 BP |
147 | AT_SETUP([database multiplexing implementation]) |
148 | AT_KEYWORDS([ovsdb server positive]) | |
149 | AT_DATA([schema], [ORDINAL_SCHEMA | |
150 | ]) | |
151 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) | |
152 | AT_CHECK([ovsdb-server --detach --pidfile=$PWD/pid --unixctl=$PWD/unixctl --remote=punix:socket db], [0], [ignore], [ignore]) | |
153 | AT_CHECK( | |
154 | [[ovsdb-client list-dbs unix:socket]], | |
155 | [0], [ordinals | |
156 | ], [ignore], [test ! -e pid || kill `cat pid`]) | |
157 | AT_CHECK( | |
158 | [[ovsdb-client get-schema unix:socket nonexistent]], | |
62c87d4a | 159 | [1], [], [[ovsdb-client: syntax "{"details":"get_schema request specifies unknown database nonexistent","error":"unknown database","syntax":"[\"nonexistent\"]"}": syntax error: Parsing database schema failed: Required 'name' member is missing. |
9cb53f26 BP |
160 | ]], [test ! -e pid || kill `cat pid`]) |
161 | OVSDB_SERVER_SHUTDOWN | |
162 | AT_CLEANUP | |
163 | ||
0b1fae1b BP |
164 | AT_SETUP([--remote=db: implementation]) |
165 | AT_KEYWORDS([ovsdb server positive]) | |
166 | AT_DATA([schema], | |
167 | [[{"name": "mydb", | |
168 | "tables": { | |
169 | "Manager": { | |
170 | "columns": { | |
171 | "manager": {"type": "string"}}}}} | |
172 | ]]) | |
7c126fbb BP |
173 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) |
174 | AT_CHECK( | |
0b1fae1b | 175 | [[ovsdb-tool transact db \ |
9cb53f26 BP |
176 | '["mydb", |
177 | {"op": "insert", | |
0b1fae1b BP |
178 | "table": "Manager", |
179 | "row": {"manager": "punix:socket"}}]']], [0], [ignore], [ignore]) | |
180 | AT_CHECK([ovsdb-server --detach --pidfile=$PWD/pid --remote=db:Manager,manager --unixctl=$PWD/unixctl db], [0], [ignore], [ignore]) | |
7c126fbb | 181 | AT_CHECK( |
0b1fae1b | 182 | [[ovsdb-client transact unix:socket \ |
9cb53f26 BP |
183 | '["mydb", |
184 | {"op": "select", | |
0b1fae1b BP |
185 | "table": "Manager", |
186 | "where": [], | |
187 | "columns": ["manager"]}]']], | |
188 | [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`]) | |
189 | AT_CHECK( | |
190 | [perl $srcdir/uuidfilt.pl stdout], | |
191 | [0], | |
192 | [[[{"rows":[{"manager":"punix:socket"}]}] | |
193 | ]], | |
194 | [ignore], | |
195 | [test ! -e pid || kill `cat pid`]) | |
028cbd99 | 196 | OVSDB_SERVER_SHUTDOWN |
0b1fae1b | 197 | AT_CLEANUP |
ada496b5 | 198 | |
78876719 BP |
199 | AT_SETUP([SSL db: implementation]) |
200 | AT_KEYWORDS([ovsdb server positive ssl $5]) | |
201 | AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) | |
202 | AT_SKIP_IF([test "x$RANDOM" = x]) | |
203 | SSL_PORT=`expr 32767 + \( $RANDOM % 32767 \)` | |
15b619e2 | 204 | PKIDIR=$abs_top_builddir/tests |
78876719 BP |
205 | AT_SKIP_IF([expr "$PKIDIR" : ".*[ '\" |
206 | \r\\]"]) | |
207 | AT_DATA([schema], | |
208 | [[{"name": "mydb", | |
209 | "tables": { | |
210 | "SSL": { | |
211 | "columns": { | |
212 | "private_key": {"type": "string"}, | |
213 | "certificate": {"type": "string"}, | |
214 | "ca_cert": {"type": "string"}}}}} | |
215 | ]]) | |
216 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) | |
217 | AT_CHECK( | |
218 | [[ovsdb-tool transact db \ | |
219 | '["mydb", | |
220 | {"op": "insert", | |
221 | "table": "SSL", | |
222 | "row": {"private_key": "'"$PKIDIR/testpki-privkey2.pem"'", | |
223 | "certificate": "'"$PKIDIR/testpki-cert2.pem"'", | |
224 | "ca_cert": "'"$PKIDIR/testpki-cacert.pem"'"}}]']], | |
225 | [0], [ignore], [ignore]) | |
226 | AT_CHECK( | |
227 | [ovsdb-server --detach --pidfile=$PWD/pid \ | |
228 | --private-key=db:SSL,private_key \ | |
229 | --certificate=db:SSL,certificate \ | |
230 | --ca-cert=db:SSL,ca_cert \ | |
231 | --remote=pssl:$SSL_PORT:127.0.0.1 --unixctl=$PWD/unixctl db], | |
232 | [0], [ignore], [ignore]) | |
233 | AT_CHECK( | |
234 | [[ovsdb-client \ | |
235 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
236 | --certificate=$PKIDIR/testpki-cert.pem \ | |
237 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
238 | transact ssl:127.0.0.1:$SSL_PORT \ | |
239 | '["mydb", | |
240 | {"op": "select", | |
241 | "table": "SSL", | |
242 | "where": [], | |
243 | "columns": ["private_key"]}]']], | |
244 | [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`]) | |
245 | cat stdout >> output | |
246 | AT_CHECK_UNQUOTED( | |
247 | [perl $srcdir/uuidfilt.pl output], [0], | |
248 | [[[{"rows":[{"private_key":"$PKIDIR/testpki-privkey2.pem"}]}] | |
249 | ]], [ignore], [test ! -e pid || kill `cat pid`]) | |
250 | OVSDB_SERVER_SHUTDOWN | |
251 | AT_CLEANUP | |
252 | ||
ada496b5 BP |
253 | AT_SETUP([compacting online]) |
254 | AT_KEYWORDS([ovsdb server compact]) | |
255 | AT_DATA([schema], [ORDINAL_SCHEMA | |
256 | ]) | |
257 | touch .db.~lock~ | |
258 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) | |
259 | AT_CHECK([ovsdb-server --detach --pidfile=$PWD/pid --unixctl=$PWD/unixctl --remote=punix:socket --log-file=$PWD/ovsdb-server.log db], [0], [ignore], [ignore]) | |
260 | AT_CAPTURE_FILE([ovsdb-server.log]) | |
261 | dnl Do a bunch of random transactions that put crap in the database log. | |
262 | AT_CHECK( | |
263 | [[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do | |
264 | set -- $pair | |
265 | ovsdb-client transact unix:socket ' | |
266 | ["ordinals", | |
267 | {"op": "insert", | |
268 | "table": "ordinals", | |
269 | "row": {"name": "'$1'", "number": '$2'}}, | |
270 | {"op": "comment", | |
271 | "comment": "add row for '"$pair"'"}]' | |
272 | ovsdb-client transact unix:socket ' | |
273 | ["ordinals", | |
274 | {"op": "delete", | |
275 | "table": "ordinals", | |
276 | "where": [["number", "==", '$2']]}, | |
277 | {"op": "comment", | |
278 | "comment": "delete row for '"$2"'"}]' | |
279 | ovsdb-client transact unix:socket ' | |
280 | ["ordinals", | |
281 | {"op": "insert", | |
282 | "table": "ordinals", | |
283 | "row": {"name": "'$1'", "number": '$2'}}, | |
284 | {"op": "comment", | |
285 | "comment": "add back row for '"$pair"'"}]' | |
286 | done]], | |
287 | [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`]) | |
288 | dnl Check that all the crap is in fact in the database log. | |
62c87d4a | 289 | AT_CHECK([[perl $srcdir/uuidfilt.pl db | grep -v ^OVSDB | sed 's/"_date":[0-9]*/"_date":0/' | test-json --multiple -]], [0], |
6aa09313 | 290 | [[{"cksum":"12345678 9","name":"ordinals","tables":{"ordinals":{"columns":{"name":{"type":"string"},"number":{"type":"integer"}}}},"version":"5.1.3"} |
62c87d4a BP |
291 | {"_comment":"add row for zero 0","_date":0,"ordinals":{"<0>":{"name":"zero"}}} |
292 | {"_comment":"delete row for 0","_date":0,"ordinals":{"<0>":null}} | |
293 | {"_comment":"add back row for zero 0","_date":0,"ordinals":{"<1>":{"name":"zero"}}} | |
294 | {"_comment":"add row for one 1","_date":0,"ordinals":{"<2>":{"name":"one","number":1}}} | |
295 | {"_comment":"delete row for 1","_date":0,"ordinals":{"<2>":null}} | |
296 | {"_comment":"add back row for one 1","_date":0,"ordinals":{"<3>":{"name":"one","number":1}}} | |
297 | {"_comment":"add row for two 2","_date":0,"ordinals":{"<4>":{"name":"two","number":2}}} | |
298 | {"_comment":"delete row for 2","_date":0,"ordinals":{"<4>":null}} | |
299 | {"_comment":"add back row for two 2","_date":0,"ordinals":{"<5>":{"name":"two","number":2}}} | |
300 | {"_comment":"add row for three 3","_date":0,"ordinals":{"<6>":{"name":"three","number":3}}} | |
301 | {"_comment":"delete row for 3","_date":0,"ordinals":{"<6>":null}} | |
302 | {"_comment":"add back row for three 3","_date":0,"ordinals":{"<7>":{"name":"three","number":3}}} | |
303 | {"_comment":"add row for four 4","_date":0,"ordinals":{"<8>":{"name":"four","number":4}}} | |
304 | {"_comment":"delete row for 4","_date":0,"ordinals":{"<8>":null}} | |
305 | {"_comment":"add back row for four 4","_date":0,"ordinals":{"<9>":{"name":"four","number":4}}} | |
306 | {"_comment":"add row for five 5","_date":0,"ordinals":{"<10>":{"name":"five","number":5}}} | |
307 | {"_comment":"delete row for 5","_date":0,"ordinals":{"<10>":null}} | |
308 | {"_comment":"add back row for five 5","_date":0,"ordinals":{"<11>":{"name":"five","number":5}}} | |
ada496b5 BP |
309 | ]], [], [test ! -e pid || kill `cat pid`]) |
310 | dnl Dump out and check the actual database contents. | |
311 | AT_CHECK([[ovsdb-client dump unix:socket ordinals]], | |
312 | [0], [stdout], [ignore]) | |
370a11b9 BP |
313 | AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [dnl |
314 | ordinals table | |
315 | _uuid name number | |
ada496b5 BP |
316 | ------------------------------------ ----- ------ |
317 | <0> five 5 @&t@ | |
318 | <1> four 4 @&t@ | |
319 | <2> one 1 @&t@ | |
320 | <3> three 3 @&t@ | |
321 | <4> two 2 @&t@ | |
322 | <5> zero 0 @&t@ | |
323 | ], [], [test ! -e pid || kill `cat pid`]) | |
324 | dnl Now compact the database in-place. | |
325 | AT_CHECK([[ovs-appctl -t $PWD/unixctl ovsdb-server/compact]], | |
326 | [0], [], [ignore], [test ! -e pid || kill `cat pid`]) | |
327 | dnl We can't fully re-check the contents of the database log, because the | |
328 | dnl order of the records is not predictable, but there should only be 4 lines | |
329 | dnl in it now. | |
330 | AT_CAPTURE_FILE([db]) | |
331 | AT_CHECK([wc -l < db], [0], [4 | |
332 | ], [], [test ! -e pid || kill `cat pid`]) | |
333 | dnl And check that the dumped data is the same too: | |
334 | AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore], | |
335 | [test ! -e pid || kill `cat pid`]) | |
370a11b9 BP |
336 | AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [dnl |
337 | ordinals table | |
338 | _uuid name number | |
ada496b5 BP |
339 | ------------------------------------ ----- ------ |
340 | <0> five 5 @&t@ | |
341 | <1> four 4 @&t@ | |
342 | <2> one 1 @&t@ | |
343 | <3> three 3 @&t@ | |
344 | <4> two 2 @&t@ | |
345 | <5> zero 0 @&t@ | |
346 | ], [], [test ! -e pid || kill `cat pid`]) | |
347 | dnl Now do some more transactions. | |
348 | AT_CHECK( | |
349 | [[ovsdb-client transact unix:socket ' | |
350 | ["ordinals", | |
351 | {"op": "delete", | |
352 | "table": "ordinals", | |
353 | "where": [["number", "<", 3]]}]']], | |
354 | [0], [[[{"count":3}] | |
355 | ]], [ignore], [test ! -e pid || kill `cat pid`]) | |
356 | dnl There should be 6 lines in the log now. | |
357 | AT_CHECK([wc -l < db], [0], [6 | |
358 | ], [], [test ! -e pid || kill `cat pid`]) | |
359 | dnl Then check that the dumped data is correct. | |
360 | AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore], | |
361 | [test ! -e pid || kill `cat pid`]) | |
370a11b9 BP |
362 | AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [dnl |
363 | ordinals table | |
364 | _uuid name number | |
ada496b5 BP |
365 | ------------------------------------ ----- ------ |
366 | <0> five 5 @&t@ | |
367 | <1> four 4 @&t@ | |
368 | <2> three 3 @&t@ | |
369 | ], [], [test ! -e pid || kill `cat pid`]) | |
370 | OVSDB_SERVER_SHUTDOWN | |
371 | AT_CLEANUP | |
80d326ad BP |
372 | \f |
373 | AT_BANNER([OVSDB -- ovsdb-server transactions (SSL sockets)]) | |
374 | ||
375 | # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) | |
376 | # | |
377 | # Creates a database with the given SCHEMA, starts an ovsdb-server on | |
378 | # that database, and runs each of the TRANSACTIONS (which should be a | |
379 | # quoted list of quoted strings) against it with ovsdb-client one at a | |
380 | # time. | |
381 | # | |
382 | # Checks that the overall output is OUTPUT, but UUIDs in the output | |
383 | # are replaced by markers of the form <N> where N is a number. The | |
384 | # first unique UUID is replaced by <0>, the next by <1>, and so on. | |
385 | # If a given UUID appears more than once it is always replaced by the | |
386 | # same marker. | |
387 | # | |
388 | # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. | |
389 | m4_define([OVSDB_CHECK_EXECUTION], | |
390 | [AT_SETUP([$1]) | |
391 | AT_KEYWORDS([ovsdb server positive ssl $5]) | |
392 | AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) | |
393 | AT_SKIP_IF([test "x$RANDOM" = x]) | |
394 | AT_DATA([schema], [$2 | |
395 | ]) | |
396 | SSL_PORT=`expr 32767 + \( $RANDOM % 32767 \)` | |
15b619e2 | 397 | PKIDIR=$abs_top_builddir/tests |
7c126fbb | 398 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) |
80d326ad BP |
399 | AT_CHECK([ovsdb-server --detach --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]) |
400 | m4_foreach([txn], [$3], | |
7c126fbb | 401 | [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 |
402 | [test ! -e pid || kill `cat pid`]) |
403 | cat stdout >> output | |
404 | ]) | |
405 | AT_CHECK([perl $srcdir/uuidfilt.pl output], [0], [$4], [ignore], | |
406 | [test ! -e pid || kill `cat pid`]) | |
028cbd99 | 407 | OVSDB_SERVER_SHUTDOWN |
80d326ad BP |
408 | AT_CLEANUP]) |
409 | ||
410 | EXECUTION_EXAMPLES | |
9ff373db BP |
411 | \f |
412 | AT_BANNER([OVSDB -- transactions on transient ovsdb-server]) | |
413 | ||
414 | # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) | |
415 | # | |
416 | # Creates a database with the given SCHEMA and runs each of the | |
417 | # TRANSACTIONS (which should be a quoted list of quoted strings) | |
418 | # against it with ovsdb-client one at a time. Each ovsdb-client | |
419 | # is run against a separately started ovsdb-server that executes | |
420 | # only that single transaction. (The idea is that this should | |
421 | # help to ferret out any differences between what ovsdb-server has | |
422 | # in memory and what actually gets committed to disk.) | |
423 | # | |
424 | # Checks that the overall output is OUTPUT, but UUIDs in the output | |
425 | # are replaced by markers of the form <N> where N is a number. The | |
426 | # first unique UUID is replaced by <0>, the next by <1>, and so on. | |
427 | # If a given UUID appears more than once it is always replaced by the | |
428 | # same marker. | |
429 | # | |
430 | # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. | |
431 | m4_define([OVSDB_CHECK_EXECUTION], | |
432 | [AT_SETUP([$1]) | |
433 | AT_KEYWORDS([ovsdb server positive transient $5]) | |
434 | AT_DATA([schema], [$2 | |
435 | ]) | |
436 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) | |
437 | m4_foreach([txn], [$3], | |
438 | [AT_DATA([txnfile], [ovsdb-client transact unix:socket 'txn' | |
439 | ]) | |
440 | AT_CHECK([ovsdb-server --remote=punix:socket --unixctl=$PWD/unixctl db --run="sh txnfile"], [0], [stdout], [ignore]) | |
441 | cat stdout >> output | |
442 | ]) | |
443 | AT_CHECK([perl $srcdir/uuidfilt.pl output], [0], [$4], [ignore]) | |
444 | AT_CLEANUP]) | |
445 | ||
446 | EXECUTION_EXAMPLES |