]>
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]) | |
2c487bc8 | 24 | OVS_RUNDIR=`pwd`; export OVS_RUNDIR |
9ff373db | 25 | AT_KEYWORDS([ovsdb server positive unix $5]) |
39ab07af | 26 | $2 > schema |
7c126fbb | 27 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) |
77a922c7 | 28 | AT_CHECK([ovsdb-server --detach --no-chdir --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 | ]) | |
5c6d0628 | 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 |
48f6e410 BP |
41 | AT_BANNER([ovsdb-server miscellaneous features]) |
42 | ||
db90b374 BP |
43 | AT_SETUP([truncating corrupted database log]) |
44 | AT_KEYWORDS([ovsdb server positive unix]) | |
bdb2e73b | 45 | AT_SKIP_IF([test "$IS_WIN32" = "yes"]) |
2c487bc8 | 46 | OVS_RUNDIR=`pwd`; export OVS_RUNDIR |
39ab07af | 47 | ordinal_schema > schema |
db90b374 BP |
48 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) |
49 | dnl Do one transaction and save the output. | |
50 | AT_DATA([txnfile], [[ovsdb-client transact unix:socket \ | |
51 | '["ordinals", | |
52 | {"op": "insert", | |
53 | "table": "ordinals", | |
54 | "row": {"number": 0, "name": "zero"}}]' | |
55 | ]]) | |
37d03458 | 56 | AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], []) |
db90b374 BP |
57 | cat stdout >> output |
58 | dnl Add some crap to the database log and run another transaction, which should | |
59 | dnl ignore the crap and truncate it out of the log. | |
60 | echo 'xxx' >> db | |
61 | AT_DATA([txnfile], [[ovsdb-client transact unix:socket \ | |
62 | '["ordinals", | |
63 | {"op": "insert", | |
64 | "table": "ordinals", | |
65 | "row": {"number": 1, "name": "one"}}]' | |
66 | ]]) | |
37d03458 | 67 | AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [stderr]) |
db90b374 BP |
68 | AT_CHECK([grep 'syntax error: db: parse error.* in header line "xxx"' stderr], |
69 | [0], [ignore]) | |
70 | cat stdout >> output | |
71 | dnl Run a final transaction to verify that both transactions succeeeded. | |
72 | dnl The crap that we added should have been truncated by the previous run, | |
73 | dnl so ovsdb-server shouldn't log a warning this time. | |
74 | AT_DATA([txnfile], [[ovsdb-client transact unix:socket \ | |
75 | '["ordinals", | |
76 | {"op": "select", | |
77 | "table": "ordinals", | |
78 | "where": [], | |
79 | "sort": ["number"]}]' | |
80 | ]]) | |
37d03458 | 81 | AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], []) |
43675e26 | 82 | cat stdout >> output |
5c6d0628 | 83 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], |
43675e26 BP |
84 | [[[{"uuid":["uuid","<0>"]}] |
85 | [{"uuid":["uuid","<1>"]}] | |
86 | [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}] | |
87 | ]], [], | |
88 | [test ! -e pid || kill `cat pid`]) | |
89 | AT_CLEANUP | |
90 | ||
91 | AT_SETUP([truncating database log with bad transaction]) | |
92 | AT_KEYWORDS([ovsdb server positive unix]) | |
bdb2e73b | 93 | AT_SKIP_IF([test "$IS_WIN32" = "yes"]) |
2c487bc8 | 94 | OVS_RUNDIR=`pwd`; export OVS_RUNDIR |
39ab07af | 95 | ordinal_schema > schema |
43675e26 BP |
96 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) |
97 | dnl Do one transaction and save the output. | |
98 | AT_DATA([txnfile], [[ovsdb-client transact unix:socket \ | |
99 | '["ordinals", | |
100 | {"op": "insert", | |
101 | "table": "ordinals", | |
102 | "row": {"number": 0, "name": "zero"}}]' | |
103 | ]]) | |
37d03458 | 104 | AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], []) |
43675e26 BP |
105 | cat stdout >> output |
106 | dnl Add some crap to the database log and run another transaction, which should | |
107 | dnl ignore the crap and truncate it out of the log. | |
108 | echo 'OVSDB JSON 15 ffbcdae4b0386265f9ea3280dd7c8f0b72a20e56 | |
109 | {"invalid":{}}' >> db | |
110 | AT_DATA([txnfile], [[ovsdb-client transact unix:socket \ | |
111 | '["ordinals", | |
112 | {"op": "insert", | |
113 | "table": "ordinals", | |
114 | "row": {"number": 1, "name": "one"}}]' | |
115 | ]]) | |
37d03458 | 116 | AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [stderr]) |
43675e26 BP |
117 | AT_CHECK([grep 'syntax "{"invalid":{}}": unknown table: No table named invalid.' stderr], |
118 | [0], [ignore]) | |
119 | cat stdout >> output | |
120 | dnl Run a final transaction to verify that both transactions succeeeded. | |
121 | dnl The crap that we added should have been truncated by the previous run, | |
122 | dnl so ovsdb-server shouldn't log a warning this time. | |
123 | AT_DATA([txnfile], [[ovsdb-client transact unix:socket \ | |
124 | '["ordinals", | |
125 | {"op": "select", | |
126 | "table": "ordinals", | |
127 | "where": [], | |
128 | "sort": ["number"]}]' | |
129 | ]]) | |
37d03458 | 130 | AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], []) |
db90b374 | 131 | cat stdout >> output |
5c6d0628 | 132 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], |
db90b374 BP |
133 | [[[{"uuid":["uuid","<0>"]}] |
134 | [{"uuid":["uuid","<1>"]}] | |
135 | [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}] | |
136 | ]], [], | |
137 | [test ! -e pid || kill `cat pid`]) | |
138 | AT_CLEANUP | |
139 | ||
8159b984 BP |
140 | AT_SETUP([ovsdb-client get-schema-version]) |
141 | AT_KEYWORDS([ovsdb server positive]) | |
2c487bc8 | 142 | OVS_RUNDIR=`pwd`; export OVS_RUNDIR |
39ab07af | 143 | ordinal_schema > schema |
8159b984 | 144 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) |
77a922c7 | 145 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/pid --unixctl="`pwd`"/unixctl --remote=punix:socket db], [0], [ignore], [ignore]) |
8159b984 BP |
146 | AT_CHECK([ovsdb-client get-schema-version unix:socket ordinals], [0], [5.1.3 |
147 | ]) | |
148 | OVSDB_SERVER_SHUTDOWN | |
149 | AT_CLEANUP | |
150 | ||
9cb53f26 BP |
151 | AT_SETUP([database multiplexing implementation]) |
152 | AT_KEYWORDS([ovsdb server positive]) | |
2c487bc8 | 153 | OVS_RUNDIR=`pwd`; export OVS_RUNDIR |
b4e8d170 BP |
154 | ordinal_schema > schema1 |
155 | constraint_schema > schema2 | |
156 | AT_CHECK([ovsdb-tool create db1 schema1], [0], [ignore], [ignore]) | |
157 | AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore]) | |
158 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/pid --unixctl="`pwd`"/unixctl --remote=punix:socket db1 db2], [0], [ignore], [ignore]) | |
9cb53f26 BP |
159 | AT_CHECK( |
160 | [[ovsdb-client list-dbs unix:socket]], | |
b4e8d170 BP |
161 | [0], [constraints |
162 | ordinals | |
9cb53f26 BP |
163 | ], [ignore], [test ! -e pid || kill `cat pid`]) |
164 | AT_CHECK( | |
eadd1644 | 165 | [[ovstest test-jsonrpc request unix:socket get_schema [\"nonexistent\"]]], [0], |
53ffefe9 BP |
166 | [[{"error":null,"id":0,"result":{"details":"get_schema request specifies unknown database nonexistent","error":"unknown database","syntax":"[\"nonexistent\"]"}} |
167 | ]], [], [test ! -e pid || kill `cat pid`]) | |
9cb53f26 BP |
168 | OVSDB_SERVER_SHUTDOWN |
169 | AT_CLEANUP | |
170 | ||
0a3b723b BP |
171 | AT_SETUP([ovsdb-server/add-db and remove-db]) |
172 | AT_KEYWORDS([ovsdb server positive]) | |
173 | ON_EXIT([kill `cat ovsdb-server.pid`]) | |
174 | OVS_RUNDIR=`pwd`; export OVS_RUNDIR | |
175 | OVS_LOGDIR=`pwd`; export OVS_LOGDIR | |
176 | ordinal_schema > schema1 | |
177 | constraint_schema > schema2 | |
178 | AT_CHECK([ovsdb-tool create db1 schema1], [0], [ignore], [ignore]) | |
179 | AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore]) | |
180 | ||
181 | # Start ovsdb-server with just a single database - db1. | |
182 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket db1], [0]) | |
183 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs], | |
184 | [0], [ordinals | |
185 | ]) | |
186 | ||
187 | # Add the second database. | |
188 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], [0]) | |
189 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs], | |
190 | [0], [constraints | |
191 | ordinals | |
192 | ]) | |
193 | ||
194 | # The databases are responsive. | |
195 | AT_CHECK([ovsdb-client list-tables unix:socket constraints], [0], [ignore], [ignore]) | |
196 | AT_CHECK([ovsdb-client list-tables unix:socket ordinals], [0], [ignore], [ignore]) | |
197 | ||
198 | # Add an already added database. | |
bd270dc3 GS |
199 | if test $IS_WIN32 = "yes"; then |
200 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], 2, [], | |
201 | [I/O error: db2: failed to lock lockfile (Resource deadlock avoided) | |
202 | ovs-appctl: ovsdb-server: server returned an error | |
203 | ]) | |
204 | else | |
205 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], 2, [], | |
ebed9f78 | 206 | [db2: already open |
0a3b723b BP |
207 | ovs-appctl: ovsdb-server: server returned an error |
208 | ]) | |
bd270dc3 | 209 | fi |
0a3b723b BP |
210 | |
211 | # Add a non-existing database. | |
212 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db3], 2, [], [stderr]) | |
213 | AT_CHECK([sed 's/(.*)/(...)/' stderr], [0], | |
214 | [I/O error: open: db3 failed (...) | |
215 | ovs-appctl: ovsdb-server: server returned an error | |
216 | ]) | |
217 | ||
218 | # Add a remote through a db path in db1. | |
219 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote db:ordinals,ordinals,name], [0]) | |
220 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes], | |
221 | [0], [db:ordinals,ordinals,name | |
222 | punix:socket | |
223 | ]) | |
224 | ||
225 | # Removing db1 has no effect on its remote. | |
226 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db ordinals], [0]) | |
227 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs], | |
228 | [0], [constraints | |
229 | ]) | |
230 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes], | |
231 | [0], [db:ordinals,ordinals,name | |
232 | punix:socket | |
233 | ]) | |
234 | AT_CHECK([ovsdb-client list-tables unix:socket ordinals], [1], [ignore], [ignore]) | |
235 | ||
236 | # Remove db2. | |
237 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db constraints], [0]) | |
238 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs], | |
239 | [0], []) | |
240 | AT_CHECK([ovsdb-client list-tables unix:socket constraints], [1], [ignore], [ignore]) | |
241 | ||
242 | # Remove a non-existent database. | |
243 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db ordinals], [2], | |
244 | [], [Failed to find the database. | |
245 | ovs-appctl: ovsdb-server: server returned an error | |
246 | ]) | |
3fc53787 GS |
247 | |
248 | # Add a removed database. | |
249 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], [0]) | |
250 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs], | |
251 | [0], [constraints | |
252 | ]) | |
253 | AT_CHECK([ovsdb-client list-tables unix:socket constraints], [0], [ignore], [ignore]) | |
0a3b723b BP |
254 | AT_CLEANUP |
255 | ||
d7ae8d6b | 256 | AT_SETUP([ovsdb-server/add-db with --monitor]) |
0a3b723b | 257 | AT_KEYWORDS([ovsdb server positive]) |
36373c1a | 258 | AT_SKIP_IF([test "$IS_WIN32" = "yes"]) |
0a3b723b BP |
259 | # Start ovsdb-server, initially with one db. |
260 | OVS_RUNDIR=`pwd`; export OVS_RUNDIR | |
261 | OVS_LOGDIR=`pwd`; export OVS_LOGDIR | |
262 | ordinal_schema > schema | |
263 | AT_CHECK([ovsdb-tool create db1 schema], [0], [ignore], [ignore]) | |
264 | ON_EXIT([kill `cat *.pid`]) | |
265 | AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db1]) | |
266 | ||
267 | # Add the second database. | |
268 | constraint_schema > schema2 | |
269 | AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore]) | |
270 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], [0]) | |
271 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs], | |
272 | [0], [constraints | |
273 | ordinals | |
274 | ]) | |
275 | ||
276 | # Kill the daemon process, making it look like a segfault, | |
277 | # and wait for a new daemon process to get spawned. | |
278 | cp ovsdb-server.pid old.pid | |
279 | AT_CHECK([kill -SEGV `cat ovsdb-server.pid`]) | |
280 | OVS_WAIT_WHILE([kill -0 `cat old.pid`]) | |
281 | OVS_WAIT_UNTIL( | |
282 | [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`]) | |
283 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs], | |
284 | [0], [constraints | |
285 | ordinals | |
286 | ]) | |
d7ae8d6b BP |
287 | AT_CLEANUP |
288 | ||
289 | AT_SETUP([ovsdb-server/add-db and remove-db with --monitor]) | |
290 | AT_KEYWORDS([ovsdb server positive]) | |
36373c1a | 291 | AT_SKIP_IF([test "$IS_WIN32" = "yes"]) |
d7ae8d6b BP |
292 | # Start ovsdb-server, initially with one db. |
293 | OVS_RUNDIR=`pwd`; export OVS_RUNDIR | |
294 | OVS_LOGDIR=`pwd`; export OVS_LOGDIR | |
295 | ordinal_schema > schema | |
296 | AT_CHECK([ovsdb-tool create db1 schema], [0], [ignore], [ignore]) | |
297 | constraint_schema > schema2 | |
298 | AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore]) | |
299 | ON_EXIT([kill `cat *.pid`]) | |
300 | AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db1 db2]) | |
0a3b723b | 301 | |
d7ae8d6b | 302 | # Remove the second database. |
0a3b723b BP |
303 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db constraints]) |
304 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs], | |
305 | [0], [ordinals | |
306 | ]) | |
307 | ||
308 | # Kill the daemon process, making it look like a segfault, | |
309 | # and wait for a new daemon process to get spawned. | |
310 | cp ovsdb-server.pid old.pid | |
311 | AT_CHECK([kill -SEGV `cat ovsdb-server.pid`]) | |
312 | OVS_WAIT_WHILE([kill -0 `cat old.pid`]) | |
313 | OVS_WAIT_UNTIL( | |
314 | [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`]) | |
315 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs], | |
316 | [0], [ordinals | |
317 | ]) | |
318 | AT_CLEANUP | |
319 | ||
0b1fae1b BP |
320 | AT_SETUP([--remote=db: implementation]) |
321 | AT_KEYWORDS([ovsdb server positive]) | |
b4e8d170 BP |
322 | OVS_RUNDIR=`pwd`; export OVS_RUNDIR |
323 | OVS_LOGDIR=`pwd`; export OVS_LOGDIR | |
0b1fae1b BP |
324 | AT_DATA([schema], |
325 | [[{"name": "mydb", | |
326 | "tables": { | |
b4e8d170 BP |
327 | "Root": { |
328 | "columns": { | |
329 | "managers": { | |
330 | "type": { | |
331 | "key": "string", | |
332 | "min": 0, | |
333 | "max": "unlimited"}}, | |
334 | "manager_options": { | |
335 | "type": { | |
336 | "key": {"type": "uuid", "refTable": "Manager"}, | |
337 | "min": 0, | |
338 | "max": "unlimited"}}}}, | |
0b1fae1b BP |
339 | "Manager": { |
340 | "columns": { | |
b4e8d170 BP |
341 | "target": { |
342 | "type": "string"}, | |
343 | "is_connected": { | |
344 | "type": { | |
345 | "key": "boolean", | |
346 | "min": 0, | |
347 | "max": 1}}}}}} | |
0b1fae1b | 348 | ]]) |
7c126fbb BP |
349 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) |
350 | AT_CHECK( | |
0b1fae1b | 351 | [[ovsdb-tool transact db \ |
9cb53f26 | 352 | '["mydb", |
b4e8d170 BP |
353 | {"op": "insert", |
354 | "table": "Root", | |
355 | "row": { | |
356 | "managers": "punix:socket1", | |
357 | "manager_options": ["set", [["named-uuid", "x"]]]}}, | |
9cb53f26 | 358 | {"op": "insert", |
0b1fae1b | 359 | "table": "Manager", |
b4e8d170 BP |
360 | "uuid-name": "x", |
361 | "row": {"target": "punix:socket2"}}]']], [0], [ignore], [ignore]) | |
362 | ON_EXIT([kill `cat ovsdb-server.pid`]) | |
8ad822c9 | 363 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=db:mydb,Root,managers --remote=db:mydb,Root,manager_options --log-file db], [0], [ignore], [ignore]) |
bdba1947 | 364 | ovs-appctl -t ovsdb-server time/warp 6000 1000 |
7c126fbb | 365 | AT_CHECK( |
b4e8d170 | 366 | [[ovsdb-client transact unix:socket1 \ |
9cb53f26 | 367 | '["mydb", |
b4e8d170 BP |
368 | {"op": "select", |
369 | "table": "Root", | |
370 | "where": [], | |
371 | "columns": ["managers"]}, | |
9cb53f26 | 372 | {"op": "select", |
0b1fae1b BP |
373 | "table": "Manager", |
374 | "where": [], | |
b4e8d170 BP |
375 | "columns": ["target", "is_connected"]}]']], |
376 | [0], [stdout], [ignore]) | |
0b1fae1b | 377 | AT_CHECK( |
5c6d0628 | 378 | [${PERL} $srcdir/uuidfilt.pl stdout], |
0b1fae1b | 379 | [0], |
b4e8d170 | 380 | [[[{"rows":[{"managers":"punix:socket1"}]},{"rows":[{"is_connected":false,"target":"punix:socket2"}]}] |
0b1fae1b | 381 | ]], |
b4e8d170 | 382 | [ignore]) |
0b1fae1b | 383 | AT_CLEANUP |
ada496b5 | 384 | |
b421d2af BP |
385 | AT_SETUP([ovsdb-server/add-remote and remove-remote]) |
386 | AT_KEYWORDS([ovsdb server positive]) | |
387 | OVS_RUNDIR=`pwd`; export OVS_RUNDIR | |
388 | OVS_LOGDIR=`pwd`; export OVS_LOGDIR | |
389 | ordinal_schema > schema | |
390 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) | |
391 | ON_EXIT([kill `cat *.pid`]) | |
392 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile db]) | |
393 | ||
394 | AT_CHECK([test ! -e socket1]) | |
395 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1]) | |
91fc9298 GS |
396 | if test "$IS_WIN32" = "yes"; then |
397 | OVS_WAIT_UNTIL([test -s socket1]) | |
398 | else | |
399 | OVS_WAIT_UNTIL([test -S socket1]) | |
400 | fi | |
b421d2af BP |
401 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes], |
402 | [0], [punix:socket1 | |
403 | ]) | |
404 | ||
405 | AT_CHECK([test ! -e socket2]) | |
406 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket2]) | |
91fc9298 GS |
407 | if test "$IS_WIN32" = "yes"; then |
408 | OVS_WAIT_UNTIL([test -s socket2]) | |
409 | else | |
410 | OVS_WAIT_UNTIL([test -S socket2]) | |
411 | fi | |
b421d2af BP |
412 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes], |
413 | [0], [punix:socket1 | |
414 | punix:socket2 | |
415 | ]) | |
416 | ||
417 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote db:x,y,z], [2], | |
418 | [], ["db:x,y,z": no database named x | |
419 | ovs-appctl: ovsdb-server: server returned an error | |
420 | ]) | |
421 | ||
422 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket1]) | |
423 | OVS_WAIT_UNTIL([test ! -e socket1]) | |
91fc9298 GS |
424 | if test "$IS_WIN32" = "yes"; then |
425 | AT_CHECK([test -s socket2]) | |
426 | else | |
427 | AT_CHECK([test -S socket2]) | |
428 | fi | |
b421d2af BP |
429 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes], |
430 | [0], [punix:socket2 | |
431 | ]) | |
432 | ||
433 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket2]) | |
434 | OVS_WAIT_UNTIL([test ! -e socket2]) | |
435 | AT_CHECK([test ! -e socket1]) | |
436 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes]) | |
437 | AT_CLEANUP | |
438 | ||
09993217 | 439 | AT_SETUP([ovsdb-server/add-remote with --monitor]) |
5f36127e | 440 | AT_KEYWORDS([ovsdb server positive]) |
36373c1a | 441 | AT_SKIP_IF([test "$IS_WIN32" = "yes"]) |
5f36127e BP |
442 | # Start ovsdb-server, initially with no remotes. |
443 | OVS_RUNDIR=`pwd`; export OVS_RUNDIR | |
444 | OVS_LOGDIR=`pwd`; export OVS_LOGDIR | |
445 | ordinal_schema > schema | |
446 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) | |
447 | ON_EXIT([kill `cat *.pid`]) | |
448 | AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db]) | |
449 | ||
450 | # Add a remote. | |
451 | AT_CHECK([test ! -e socket1]) | |
452 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1]) | |
453 | OVS_WAIT_UNTIL([test -S socket1]) | |
454 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes], | |
455 | [0], [punix:socket1 | |
456 | ]) | |
457 | ||
458 | # Kill the daemon process, making it look like a segfault, | |
459 | # and wait for a new daemon process to get spawned and for it to | |
460 | # start listening on 'socket1'. | |
461 | cp ovsdb-server.pid old.pid | |
462 | rm socket1 | |
463 | AT_CHECK([kill -SEGV `cat ovsdb-server.pid`]) | |
464 | OVS_WAIT_WHILE([kill -0 `cat old.pid`]) | |
465 | OVS_WAIT_UNTIL( | |
466 | [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`]) | |
467 | OVS_WAIT_UNTIL([test -S socket1]) | |
09993217 AW |
468 | AT_CLEANUP |
469 | ||
470 | AT_SETUP([ovsdb-server/add-remote and remove-remote with --monitor]) | |
471 | AT_KEYWORDS([ovsdb server positive]) | |
36373c1a | 472 | AT_SKIP_IF([test "$IS_WIN32" = "yes"]) |
09993217 AW |
473 | # Start ovsdb-server, initially with no remotes. |
474 | OVS_RUNDIR=`pwd`; export OVS_RUNDIR | |
475 | OVS_LOGDIR=`pwd`; export OVS_LOGDIR | |
476 | ordinal_schema > schema | |
477 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) | |
478 | ON_EXIT([kill `cat *.pid`]) | |
479 | AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db]) | |
480 | ||
481 | # Add a remote. | |
482 | AT_CHECK([test ! -e socket1]) | |
483 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1]) | |
484 | OVS_WAIT_UNTIL([test -S socket1]) | |
485 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes], | |
486 | [0], [punix:socket1 | |
487 | ]) | |
5f36127e BP |
488 | |
489 | # Remove the remote. | |
490 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket1]) | |
491 | OVS_WAIT_UNTIL([test ! -e socket1]) | |
492 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes]) | |
493 | ||
494 | # Kill the daemon process, making it look like a segfault, | |
495 | # and wait for a new daemon process to get spawned and make sure that it | |
496 | # does not listen on 'socket1'. | |
497 | cp ovsdb-server.pid old.pid | |
498 | AT_CHECK([kill -SEGV `cat ovsdb-server.pid`]) | |
499 | OVS_WAIT_WHILE([kill -0 `cat old.pid`]) | |
500 | OVS_WAIT_UNTIL( | |
501 | [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`]) | |
502 | AT_CHECK([test ! -e socket1]) | |
503 | AT_CLEANUP | |
504 | ||
78876719 BP |
505 | AT_SETUP([SSL db: implementation]) |
506 | AT_KEYWORDS([ovsdb server positive ssl $5]) | |
507 | AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) | |
b028245a GS |
508 | # For this test, we pass PKIDIR through a ovsdb-tool transact and |
509 | # msys on Windows does not convert the path style automatically. | |
510 | # So, do that forcefully with a 'pwd -W' (called through pwd() function). | |
511 | PKIDIR="$(cd $abs_top_builddir/tests && pwd)" | |
78876719 | 512 | AT_SKIP_IF([expr "$PKIDIR" : ".*[ '\" |
0bcff889 | 513 | \\]"]) |
78876719 BP |
514 | AT_DATA([schema], |
515 | [[{"name": "mydb", | |
516 | "tables": { | |
517 | "SSL": { | |
518 | "columns": { | |
519 | "private_key": {"type": "string"}, | |
520 | "certificate": {"type": "string"}, | |
521 | "ca_cert": {"type": "string"}}}}} | |
522 | ]]) | |
523 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) | |
524 | AT_CHECK( | |
525 | [[ovsdb-tool transact db \ | |
526 | '["mydb", | |
527 | {"op": "insert", | |
528 | "table": "SSL", | |
529 | "row": {"private_key": "'"$PKIDIR/testpki-privkey2.pem"'", | |
530 | "certificate": "'"$PKIDIR/testpki-cert2.pem"'", | |
531 | "ca_cert": "'"$PKIDIR/testpki-cacert.pem"'"}}]']], | |
532 | [0], [ignore], [ignore]) | |
1e04fcc8 | 533 | OVS_LOGDIR=`pwd`; export OVS_LOGDIR |
78876719 | 534 | AT_CHECK( |
1e04fcc8 | 535 | [ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid \ |
fb6de52c GS |
536 | --private-key=db:mydb,SSL,private_key \ |
537 | --certificate=db:mydb,SSL,certificate \ | |
538 | --ca-cert=db:mydb,SSL,ca_cert \ | |
1e04fcc8 | 539 | --remote=pssl:0:127.0.0.1 --unixctl="`pwd`"/unixctl db], |
78876719 | 540 | [0], [ignore], [ignore]) |
b52ecd96 | 541 | SSL_PORT=`parse_listening_port < ovsdb-server.log` |
78876719 BP |
542 | AT_CHECK( |
543 | [[ovsdb-client \ | |
544 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
545 | --certificate=$PKIDIR/testpki-cert.pem \ | |
546 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
547 | transact ssl:127.0.0.1:$SSL_PORT \ | |
548 | '["mydb", | |
549 | {"op": "select", | |
550 | "table": "SSL", | |
551 | "where": [], | |
552 | "columns": ["private_key"]}]']], | |
553 | [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`]) | |
554 | cat stdout >> output | |
555 | AT_CHECK_UNQUOTED( | |
b33bff0f | 556 | [cat output], [0], |
0877a018 | 557 | [[@<:@{"rows":@<:@{"private_key":"$PKIDIR/testpki-privkey2.pem"}@:>@}@:>@ |
78876719 BP |
558 | ]], [ignore], [test ! -e pid || kill `cat pid`]) |
559 | OVSDB_SERVER_SHUTDOWN | |
560 | AT_CLEANUP | |
561 | ||
ada496b5 BP |
562 | AT_SETUP([compacting online]) |
563 | AT_KEYWORDS([ovsdb server compact]) | |
2c487bc8 | 564 | OVS_RUNDIR=`pwd`; export OVS_RUNDIR |
39ab07af | 565 | ordinal_schema > schema |
a35ae81c BP |
566 | dnl Make sure that "ovsdb-tool create" works with a dangling symlink for |
567 | dnl the database and the lockfile, creating the target of each symlink rather | |
568 | dnl than replacing the symlinks with regular files. | |
569 | mkdir dir | |
570 | ln -s dir/db db | |
571 | ln -s dir/.db.~lock~ .db.~lock~ | |
572 | AT_SKIP_IF([test ! -h db || test ! -h .db.~lock~]) | |
ada496b5 | 573 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) |
a35ae81c | 574 | dnl Start ovsdb-server. |
77a922c7 | 575 | 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 |
576 | AT_CAPTURE_FILE([ovsdb-server.log]) |
577 | dnl Do a bunch of random transactions that put crap in the database log. | |
578 | AT_CHECK( | |
579 | [[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do | |
580 | set -- $pair | |
581 | ovsdb-client transact unix:socket ' | |
582 | ["ordinals", | |
583 | {"op": "insert", | |
584 | "table": "ordinals", | |
585 | "row": {"name": "'$1'", "number": '$2'}}, | |
586 | {"op": "comment", | |
587 | "comment": "add row for '"$pair"'"}]' | |
588 | ovsdb-client transact unix:socket ' | |
589 | ["ordinals", | |
590 | {"op": "delete", | |
591 | "table": "ordinals", | |
592 | "where": [["number", "==", '$2']]}, | |
593 | {"op": "comment", | |
594 | "comment": "delete row for '"$2"'"}]' | |
595 | ovsdb-client transact unix:socket ' | |
596 | ["ordinals", | |
597 | {"op": "insert", | |
598 | "table": "ordinals", | |
599 | "row": {"name": "'$1'", "number": '$2'}}, | |
600 | {"op": "comment", | |
601 | "comment": "add back row for '"$pair"'"}]' | |
602 | done]], | |
603 | [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`]) | |
604 | dnl Check that all the crap is in fact in the database log. | |
eadd1644 | 605 | AT_CHECK([[${PERL} $srcdir/uuidfilt.pl db | grep -v ^OVSDB | sed 's/"_date":[0-9]*/"_date":0/' | ovstest test-json --multiple -]], [0], |
6910a6e6 | 606 | [[{"cksum":"12345678 9","name":"ordinals","tables":{"ordinals":{"columns":{"name":{"type":"string"},"number":{"type":"integer"}},"indexes":[["number"]]}},"version":"5.1.3"} |
62c87d4a BP |
607 | {"_comment":"add row for zero 0","_date":0,"ordinals":{"<0>":{"name":"zero"}}} |
608 | {"_comment":"delete row for 0","_date":0,"ordinals":{"<0>":null}} | |
609 | {"_comment":"add back row for zero 0","_date":0,"ordinals":{"<1>":{"name":"zero"}}} | |
610 | {"_comment":"add row for one 1","_date":0,"ordinals":{"<2>":{"name":"one","number":1}}} | |
611 | {"_comment":"delete row for 1","_date":0,"ordinals":{"<2>":null}} | |
612 | {"_comment":"add back row for one 1","_date":0,"ordinals":{"<3>":{"name":"one","number":1}}} | |
613 | {"_comment":"add row for two 2","_date":0,"ordinals":{"<4>":{"name":"two","number":2}}} | |
614 | {"_comment":"delete row for 2","_date":0,"ordinals":{"<4>":null}} | |
615 | {"_comment":"add back row for two 2","_date":0,"ordinals":{"<5>":{"name":"two","number":2}}} | |
616 | {"_comment":"add row for three 3","_date":0,"ordinals":{"<6>":{"name":"three","number":3}}} | |
617 | {"_comment":"delete row for 3","_date":0,"ordinals":{"<6>":null}} | |
618 | {"_comment":"add back row for three 3","_date":0,"ordinals":{"<7>":{"name":"three","number":3}}} | |
619 | {"_comment":"add row for four 4","_date":0,"ordinals":{"<8>":{"name":"four","number":4}}} | |
620 | {"_comment":"delete row for 4","_date":0,"ordinals":{"<8>":null}} | |
621 | {"_comment":"add back row for four 4","_date":0,"ordinals":{"<9>":{"name":"four","number":4}}} | |
622 | {"_comment":"add row for five 5","_date":0,"ordinals":{"<10>":{"name":"five","number":5}}} | |
623 | {"_comment":"delete row for 5","_date":0,"ordinals":{"<10>":null}} | |
624 | {"_comment":"add back row for five 5","_date":0,"ordinals":{"<11>":{"name":"five","number":5}}} | |
ada496b5 BP |
625 | ]], [], [test ! -e pid || kill `cat pid`]) |
626 | dnl Dump out and check the actual database contents. | |
627 | AT_CHECK([[ovsdb-client dump unix:socket ordinals]], | |
628 | [0], [stdout], [ignore]) | |
5c6d0628 | 629 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl |
370a11b9 BP |
630 | ordinals table |
631 | _uuid name number | |
ada496b5 BP |
632 | ------------------------------------ ----- ------ |
633 | <0> five 5 @&t@ | |
634 | <1> four 4 @&t@ | |
635 | <2> one 1 @&t@ | |
636 | <3> three 3 @&t@ | |
637 | <4> two 2 @&t@ | |
638 | <5> zero 0 @&t@ | |
639 | ], [], [test ! -e pid || kill `cat pid`]) | |
640 | dnl Now compact the database in-place. | |
37d03458 | 641 | AT_CHECK([[ovs-appctl -t "`pwd`"/unixctl ovsdb-server/compact]], |
ada496b5 | 642 | [0], [], [ignore], [test ! -e pid || kill `cat pid`]) |
a35ae81c BP |
643 | dnl Make sure that "db" is still a symlink to dir/db instead of getting |
644 | dnl replaced by a regular file, ditto for .db.~lock~. | |
645 | AT_CHECK([test -h db]) | |
646 | AT_CHECK([test -h .db.~lock~]) | |
647 | AT_CHECK([test -f dir/db]) | |
648 | AT_CHECK([test -f dir/.db.~lock~]) | |
ada496b5 BP |
649 | dnl We can't fully re-check the contents of the database log, because the |
650 | dnl order of the records is not predictable, but there should only be 4 lines | |
651 | dnl in it now. | |
652 | AT_CAPTURE_FILE([db]) | |
e0c7697c EM |
653 | AT_CHECK([test `wc -l < db` -eq 4], [0], [], [], |
654 | [test ! -e pid || kill `cat pid`]) | |
ada496b5 BP |
655 | dnl And check that the dumped data is the same too: |
656 | AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore], | |
657 | [test ! -e pid || kill `cat pid`]) | |
5c6d0628 | 658 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl |
370a11b9 BP |
659 | ordinals table |
660 | _uuid name number | |
ada496b5 BP |
661 | ------------------------------------ ----- ------ |
662 | <0> five 5 @&t@ | |
663 | <1> four 4 @&t@ | |
664 | <2> one 1 @&t@ | |
665 | <3> three 3 @&t@ | |
666 | <4> two 2 @&t@ | |
667 | <5> zero 0 @&t@ | |
668 | ], [], [test ! -e pid || kill `cat pid`]) | |
669 | dnl Now do some more transactions. | |
670 | AT_CHECK( | |
671 | [[ovsdb-client transact unix:socket ' | |
672 | ["ordinals", | |
673 | {"op": "delete", | |
674 | "table": "ordinals", | |
675 | "where": [["number", "<", 3]]}]']], | |
676 | [0], [[[{"count":3}] | |
677 | ]], [ignore], [test ! -e pid || kill `cat pid`]) | |
678 | dnl There should be 6 lines in the log now. | |
e0c7697c EM |
679 | AT_CHECK([test `wc -l < db` -eq 6], [0], [], [], |
680 | [test ! -e pid || kill `cat pid`]) | |
ada496b5 BP |
681 | dnl Then check that the dumped data is correct. |
682 | AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore], | |
683 | [test ! -e pid || kill `cat pid`]) | |
5c6d0628 | 684 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl |
370a11b9 BP |
685 | ordinals table |
686 | _uuid name number | |
ada496b5 BP |
687 | ------------------------------------ ----- ------ |
688 | <0> five 5 @&t@ | |
689 | <1> four 4 @&t@ | |
690 | <2> three 3 @&t@ | |
691 | ], [], [test ! -e pid || kill `cat pid`]) | |
692 | OVSDB_SERVER_SHUTDOWN | |
693 | AT_CLEANUP | |
48f6e410 BP |
694 | |
695 | AT_SETUP([ovsdb-server combines updates on backlogged connections]) | |
696 | OVS_LOGDIR=`pwd`; export OVS_LOGDIR | |
697 | OVS_RUNDIR=`pwd`; export OVS_RUNDIR | |
698 | ON_EXIT([kill `cat *.pid`]) | |
699 | ||
700 | # The maximum socket receive buffer size is important for this test, which | |
701 | # tests behavior when the receive buffer overflows. | |
702 | if test -e /proc/sys/net/core/rmem_max; then | |
703 | # Linux | |
704 | rmem_max=`cat /proc/sys/net/core/rmem_max` | |
705 | elif rmem_max=`sysctl -n net.inet.tcp.recvbuf_max 2>/dev/null`; then | |
81b9d305 | 706 | : # FreeBSD, NetBSD |
48f6e410 BP |
707 | else |
708 | # Don't know how to get maximum socket receive buffer on this OS | |
709 | AT_SKIP_IF([:]) | |
710 | fi | |
711 | ||
712 | # Calculate the number of iterations we need to queue. Each of the | |
713 | # iterations we execute, by itself, yields a monitor update of about | |
714 | # 25 kB, so fill up that much space plus a few for luck. | |
f5ca49d8 | 715 | n_iterations=`expr $rmem_max / 25000 + 5` |
48f6e410 BP |
716 | echo rmem_max=$rmem_max n_iterations=$n_iterations |
717 | ||
21aa35c3 BP |
718 | # If there's too much queuing skip the test to avoid timing out. |
719 | AT_SKIP_IF([test $rmem_max -gt 1048576]) | |
720 | ||
48f6e410 BP |
721 | # Calculate the exact number of monitor updates expected for $n_iterations, |
722 | # assuming no updates are combined. The "extra" update is for the initial | |
723 | # contents of the database. | |
724 | n_updates=`expr $n_iterations \* 3 + 1` | |
725 | ||
726 | # Start an ovsdb-server with the vswitchd schema. | |
727 | OVSDB_INIT([db]) | |
728 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:db.sock db], | |
729 | [0], [ignore], [ignore]) | |
730 | ||
731 | # Executes a set of transactions that add a bridge with 100 ports, and | |
732 | # then deletes that bridge. This yields three monitor updates that | |
733 | # add up to about 25 kB in size. | |
734 | # | |
735 | # The update also increments a counter held in the database so that we can | |
736 | # verify that the overall effect of the transactions took effect (e.g. | |
737 | # monitor updates at the end weren't just dropped). We add an arbitrary | |
738 | # string to the counter to make grepping for it more reliable. | |
739 | counter=0 | |
740 | trigger_big_update () { | |
741 | counter=`expr $counter + 1` | |
742 | ovs-vsctl --no-wait -- set open_vswitch . system_version=xyzzy$counter | |
743 | ovs-vsctl --no-wait -- add-br br0 $add | |
744 | ovs-vsctl --no-wait -- del-br br0 | |
745 | } | |
746 | add_ports () { | |
747 | for j in `seq 1 100`; do | |
748 | printf " -- add-port br0 p%d" $j | |
749 | done | |
750 | } | |
751 | add=`add_ports` | |
752 | ||
753 | AT_CAPTURE_FILE([ovsdb-client.err]) | |
754 | ||
755 | # Start an ovsdb-client monitoring all changes to the database, | |
756 | # make it block to force the buffers to fill up, and then execute | |
757 | # enough iterations that ovsdb-server starts combining updates. | |
758 | AT_CHECK([ovsdb-client --detach --no-chdir --pidfile monitor ALL >ovsdb-client.out 2>ovsdb-client.err]) | |
759 | AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/block]) | |
760 | for i in `seq 1 $n_iterations`; do | |
761 | echo "blocked update ($i of $n_iterations)" | |
762 | trigger_big_update $i | |
763 | done | |
764 | AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/unblock]) | |
765 | OVS_WAIT_UNTIL([grep "\"xyzzy$counter\"" ovsdb-client.out]) | |
766 | AT_CHECK([ovs-appctl -t ovsdb-client exit]) | |
767 | OVS_WAIT_WHILE([test -e ovsdb-client.pid]) | |
768 | ||
769 | # Count the number of updates in the ovsdb-client output, by counting | |
770 | # the number of changes to the Open_vSwitch table. (All of our | |
771 | # transactions modify the Open_vSwitch table.) It should be less than | |
772 | # $n_updates updates. | |
773 | # | |
774 | # Check that the counter is what we expect. | |
775 | logged_updates=`grep -c '^Open_vSwitch' ovsdb-client.out` | |
776 | echo "logged_updates=$logged_updates (expected less than $n_updates)" | |
777 | AT_CHECK([test $logged_updates -lt $n_updates]) | |
778 | AT_CHECK_UNQUOTED([ovs-vsctl get open_vswitch . system_version], [0], | |
779 | ["xyzzy$counter" | |
780 | ]) | |
48f6e410 | 781 | AT_CLEANUP |
80d326ad | 782 | \f |
e731d71b | 783 | AT_BANNER([OVSDB -- ovsdb-server transactions (SSL IPv4 sockets)]) |
80d326ad BP |
784 | |
785 | # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) | |
786 | # | |
787 | # Creates a database with the given SCHEMA, starts an ovsdb-server on | |
788 | # that database, and runs each of the TRANSACTIONS (which should be a | |
789 | # quoted list of quoted strings) against it with ovsdb-client one at a | |
790 | # time. | |
791 | # | |
792 | # Checks that the overall output is OUTPUT, but UUIDs in the output | |
793 | # are replaced by markers of the form <N> where N is a number. The | |
794 | # first unique UUID is replaced by <0>, the next by <1>, and so on. | |
795 | # If a given UUID appears more than once it is always replaced by the | |
796 | # same marker. | |
797 | # | |
798 | # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. | |
799 | m4_define([OVSDB_CHECK_EXECUTION], | |
800 | [AT_SETUP([$1]) | |
801 | AT_KEYWORDS([ovsdb server positive ssl $5]) | |
802 | AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) | |
2c487bc8 | 803 | OVS_RUNDIR=`pwd`; export OVS_RUNDIR |
1e04fcc8 | 804 | OVS_LOGDIR=`pwd`; export OVS_LOGDIR |
39ab07af | 805 | $2 > schema |
15b619e2 | 806 | PKIDIR=$abs_top_builddir/tests |
7c126fbb | 807 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) |
1e04fcc8 | 808 | 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]) |
b52ecd96 | 809 | SSL_PORT=`parse_listening_port < ovsdb-server.log` |
80d326ad | 810 | m4_foreach([txn], [$3], |
7c126fbb | 811 | [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 |
812 | [test ! -e pid || kill `cat pid`]) |
813 | cat stdout >> output | |
814 | ]) | |
5c6d0628 | 815 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore], |
80d326ad | 816 | [test ! -e pid || kill `cat pid`]) |
028cbd99 | 817 | OVSDB_SERVER_SHUTDOWN |
80d326ad BP |
818 | AT_CLEANUP]) |
819 | ||
e879d33e MM |
820 | EXECUTION_EXAMPLES |
821 | ||
e731d71b AS |
822 | AT_BANNER([OVSDB -- ovsdb-server transactions (SSL IPv6 sockets)]) |
823 | ||
824 | # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) | |
825 | # | |
826 | # Creates a database with the given SCHEMA, starts an ovsdb-server on | |
827 | # that database, and runs each of the TRANSACTIONS (which should be a | |
828 | # quoted list of quoted strings) against it with ovsdb-client one at a | |
829 | # time. | |
830 | # | |
831 | # Checks that the overall output is OUTPUT, but UUIDs in the output | |
832 | # are replaced by markers of the form <N> where N is a number. The | |
833 | # first unique UUID is replaced by <0>, the next by <1>, and so on. | |
834 | # If a given UUID appears more than once it is always replaced by the | |
835 | # same marker. | |
836 | # | |
837 | # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. | |
838 | m4_define([OVSDB_CHECK_EXECUTION], | |
839 | [AT_SETUP([$1]) | |
840 | AT_KEYWORDS([ovsdb server positive ssl6 $5]) | |
841 | AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) | |
842 | OVS_RUNDIR=`pwd`; export OVS_RUNDIR | |
843 | OVS_LOGDIR=`pwd`; export OVS_LOGDIR | |
844 | $2 > schema | |
845 | PKIDIR=$abs_top_builddir/tests | |
846 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) | |
847 | 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:[[::1]] --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore]) | |
b52ecd96 | 848 | SSL_PORT=`parse_listening_port < ovsdb-server.log` |
e731d71b AS |
849 | m4_foreach([txn], [$3], |
850 | [AT_CHECK([ovsdb-client --private-key=$PKIDIR/testpki-privkey.pem --certificate=$PKIDIR/testpki-cert.pem --ca-cert=$PKIDIR/testpki-cacert.pem transact ssl:[[::1]]:$SSL_PORT 'txn'], [0], [stdout], [ignore], | |
851 | [test ! -e pid || kill `cat pid`]) | |
852 | cat stdout >> output | |
853 | ]) | |
854 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore], | |
855 | [test ! -e pid || kill `cat pid`]) | |
856 | OVSDB_SERVER_SHUTDOWN | |
857 | AT_CLEANUP]) | |
858 | ||
859 | ONE_EXECUTION_EXAMPLE | |
860 | ||
861 | AT_BANNER([OVSDB -- ovsdb-server transactions (TCP IPv4 sockets)]) | |
e879d33e MM |
862 | |
863 | AT_SETUP([ovsdb-client get-schema-version - tcp socket]) | |
864 | AT_KEYWORDS([ovsdb server positive tcp]) | |
865 | ordinal_schema > schema | |
e879d33e | 866 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) |
1e04fcc8 BP |
867 | OVS_LOGDIR=`pwd`; export OVS_LOGDIR |
868 | 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]) | |
b52ecd96 | 869 | TCP_PORT=`parse_listening_port < ovsdb-server.log` |
e879d33e MM |
870 | AT_CHECK([ovsdb-client get-schema-version tcp:127.0.0.1:$TCP_PORT ordinals], [0], [5.1.3 |
871 | ]) | |
872 | OVSDB_SERVER_SHUTDOWN | |
873 | AT_CLEANUP]) | |
874 | ||
875 | # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) | |
876 | # | |
877 | # Creates a database with the given SCHEMA, starts an ovsdb-server on | |
878 | # that database, and runs each of the TRANSACTIONS (which should be a | |
879 | # quoted list of quoted strings) against it with ovsdb-client one at a | |
880 | # time. | |
881 | # | |
882 | # Checks that the overall output is OUTPUT, but UUIDs in the output | |
883 | # are replaced by markers of the form <N> where N is a number. The | |
884 | # first unique UUID is replaced by <0>, the next by <1>, and so on. | |
885 | # If a given UUID appears more than once it is always replaced by the | |
886 | # same marker. | |
887 | # | |
888 | # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. | |
889 | m4_define([OVSDB_CHECK_EXECUTION], | |
890 | [AT_SETUP([$1]) | |
891 | AT_KEYWORDS([ovsdb server positive tcp $5]) | |
2c487bc8 | 892 | OVS_RUNDIR=`pwd`; export OVS_RUNDIR |
1e04fcc8 | 893 | OVS_LOGDIR=`pwd`; export OVS_LOGDIR |
e879d33e | 894 | $2 > schema |
e879d33e MM |
895 | PKIDIR=$abs_top_builddir/tests |
896 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) | |
1e04fcc8 | 897 | 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]) |
b52ecd96 | 898 | TCP_PORT=`parse_listening_port < ovsdb-server.log` |
e879d33e MM |
899 | m4_foreach([txn], [$3], |
900 | [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT 'txn'], [0], [stdout], [ignore], | |
901 | [test ! -e pid || kill `cat pid`]) | |
902 | cat stdout >> output | |
903 | ]) | |
5c6d0628 | 904 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore], |
e879d33e MM |
905 | [test ! -e pid || kill `cat pid`]) |
906 | OVSDB_SERVER_SHUTDOWN | |
907 | AT_CLEANUP]) | |
908 | ||
80d326ad | 909 | EXECUTION_EXAMPLES |
e731d71b | 910 | |
7daaec4e BP |
911 | AT_BANNER([OVSDB -- ovsdb-server transactions (TCP IPv6 sockets)]) |
912 | ||
e731d71b AS |
913 | # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) |
914 | # | |
915 | # Creates a database with the given SCHEMA, starts an ovsdb-server on | |
916 | # that database, and runs each of the TRANSACTIONS (which should be a | |
917 | # quoted list of quoted strings) against it with ovsdb-client one at a | |
918 | # time. | |
919 | # | |
920 | # Checks that the overall output is OUTPUT, but UUIDs in the output | |
921 | # are replaced by markers of the form <N> where N is a number. The | |
922 | # first unique UUID is replaced by <0>, the next by <1>, and so on. | |
923 | # If a given UUID appears more than once it is always replaced by the | |
924 | # same marker. | |
925 | # | |
926 | # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. | |
927 | m4_define([OVSDB_CHECK_EXECUTION], | |
928 | [AT_SETUP([$1]) | |
929 | AT_KEYWORDS([ovsdb server positive tcp6 $5]) | |
930 | OVS_RUNDIR=`pwd`; export OVS_RUNDIR | |
931 | OVS_LOGDIR=`pwd`; export OVS_LOGDIR | |
932 | $2 > schema | |
933 | PKIDIR=$abs_top_builddir/tests | |
934 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) | |
935 | AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid --remote=ptcp:0:[[::1]] --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore]) | |
b52ecd96 | 936 | TCP_PORT=`parse_listening_port < ovsdb-server.log` |
e731d71b AS |
937 | m4_foreach([txn], [$3], |
938 | [AT_CHECK([ovsdb-client transact tcp:[[::1]]:$TCP_PORT 'txn'], [0], [stdout], [ignore], | |
939 | [test ! -e pid || kill `cat pid`]) | |
940 | cat stdout >> output | |
941 | ]) | |
942 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore], | |
943 | [test ! -e pid || kill `cat pid`]) | |
944 | OVSDB_SERVER_SHUTDOWN | |
945 | AT_CLEANUP]) | |
946 | ||
947 | ONE_EXECUTION_EXAMPLE | |
9ff373db BP |
948 | \f |
949 | AT_BANNER([OVSDB -- transactions on transient ovsdb-server]) | |
950 | ||
951 | # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) | |
952 | # | |
953 | # Creates a database with the given SCHEMA and runs each of the | |
954 | # TRANSACTIONS (which should be a quoted list of quoted strings) | |
955 | # against it with ovsdb-client one at a time. Each ovsdb-client | |
956 | # is run against a separately started ovsdb-server that executes | |
957 | # only that single transaction. (The idea is that this should | |
958 | # help to ferret out any differences between what ovsdb-server has | |
959 | # in memory and what actually gets committed to disk.) | |
960 | # | |
961 | # Checks that the overall output is OUTPUT, but UUIDs in the output | |
962 | # are replaced by markers of the form <N> where N is a number. The | |
963 | # first unique UUID is replaced by <0>, the next by <1>, and so on. | |
964 | # If a given UUID appears more than once it is always replaced by the | |
965 | # same marker. | |
966 | # | |
967 | # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. | |
968 | m4_define([OVSDB_CHECK_EXECUTION], | |
969 | [AT_SETUP([$1]) | |
c17b52e8 | 970 | AT_SKIP_IF([test "$IS_WIN32" = "yes"]) |
9ff373db | 971 | AT_KEYWORDS([ovsdb server positive transient $5]) |
2c487bc8 | 972 | OVS_RUNDIR=`pwd`; export OVS_RUNDIR |
39ab07af | 973 | $2 > schema |
9ff373db BP |
974 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) |
975 | m4_foreach([txn], [$3], | |
976 | [AT_DATA([txnfile], [ovsdb-client transact unix:socket 'txn' | |
977 | ]) | |
37d03458 | 978 | AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [ignore]) |
9ff373db BP |
979 | cat stdout >> output |
980 | ]) | |
5c6d0628 | 981 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore]) |
9ff373db BP |
982 | AT_CLEANUP]) |
983 | ||
984 | EXECUTION_EXAMPLES |