]>
Commit | Line | Data |
---|---|---|
80d326ad | 1 | AT_BANNER([OVSDB -- ovsdb-server transactions (Unix sockets)]) |
21ff1aee | 2 | |
56120500 BP |
3 | m4_define([OVSDB_SERVER_SHUTDOWN], |
4 | [OVS_APP_EXIT_AND_WAIT_BY_TARGET([ovsdb-server], [ovsdb-server.pid])]) | |
028cbd99 | 5 | |
ae671c5f MC |
6 | m4_define([OVSDB_SERVER_SHUTDOWN2], |
7 | [cp pid2 savepid2 | |
8 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 -e exit], [0], [ignore], [ignore]) | |
9 | OVS_WAIT_WHILE([kill -0 `cat savepid2`], [kill `cat savepid2`])]) | |
10 | ||
21ff1aee BP |
11 | # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) |
12 | # | |
13 | # Creates a database with the given SCHEMA, starts an ovsdb-server on | |
14 | # that database, and runs each of the TRANSACTIONS (which should be a | |
15 | # quoted list of quoted strings) against it with ovsdb-client one at a | |
16 | # time. | |
17 | # | |
18 | # Checks that the overall output is OUTPUT, but UUIDs in the output | |
19 | # are replaced by markers of the form <N> where N is a number. The | |
20 | # first unique UUID is replaced by <0>, the next by <1>, and so on. | |
21 | # If a given UUID appears more than once it is always replaced by the | |
22 | # same marker. | |
23 | # | |
24 | # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. | |
25 | m4_define([OVSDB_CHECK_EXECUTION], | |
26 | [AT_SETUP([$1]) | |
9ff373db | 27 | AT_KEYWORDS([ovsdb server positive unix $5]) |
39ab07af | 28 | $2 > schema |
7c126fbb | 29 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) |
56120500 | 30 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket db], [0], [ignore], [ignore]) |
21ff1aee | 31 | m4_foreach([txn], [$3], |
7c126fbb | 32 | [AT_CHECK([ovsdb-client transact unix:socket 'txn'], [0], [stdout], [ignore], |
21ff1aee BP |
33 | [test ! -e pid || kill `cat pid`]) |
34 | cat stdout >> output | |
35 | ]) | |
5c6d0628 | 36 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore], |
21ff1aee | 37 | [test ! -e pid || kill `cat pid`]) |
028cbd99 | 38 | OVSDB_SERVER_SHUTDOWN |
21ff1aee BP |
39 | AT_CLEANUP]) |
40 | ||
41 | EXECUTION_EXAMPLES | |
80d326ad | 42 | \f |
48f6e410 BP |
43 | AT_BANNER([ovsdb-server miscellaneous features]) |
44 | ||
db90b374 BP |
45 | AT_SETUP([truncating corrupted database log]) |
46 | AT_KEYWORDS([ovsdb server positive unix]) | |
bdb2e73b | 47 | AT_SKIP_IF([test "$IS_WIN32" = "yes"]) |
39ab07af | 48 | ordinal_schema > schema |
db90b374 BP |
49 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) |
50 | dnl Do one transaction and save the output. | |
51 | AT_DATA([txnfile], [[ovsdb-client transact unix:socket \ | |
52 | '["ordinals", | |
53 | {"op": "insert", | |
54 | "table": "ordinals", | |
55 | "row": {"number": 0, "name": "zero"}}]' | |
56 | ]]) | |
56120500 | 57 | AT_CHECK([ovsdb-server --remote=punix:socket db --run="sh txnfile"], [0], [stdout], []) |
db90b374 BP |
58 | cat stdout >> output |
59 | dnl Add some crap to the database log and run another transaction, which should | |
60 | dnl ignore the crap and truncate it out of the log. | |
61 | echo 'xxx' >> db | |
62 | AT_DATA([txnfile], [[ovsdb-client transact unix:socket \ | |
63 | '["ordinals", | |
64 | {"op": "insert", | |
65 | "table": "ordinals", | |
66 | "row": {"number": 1, "name": "one"}}]' | |
67 | ]]) | |
56120500 | 68 | AT_CHECK([ovsdb-server --remote=punix:socket db --run="sh txnfile"], [0], [stdout], [stderr]) |
db90b374 BP |
69 | AT_CHECK([grep 'syntax error: db: parse error.* in header line "xxx"' stderr], |
70 | [0], [ignore]) | |
71 | cat stdout >> output | |
72 | dnl Run a final transaction to verify that both transactions succeeeded. | |
73 | dnl The crap that we added should have been truncated by the previous run, | |
74 | dnl so ovsdb-server shouldn't log a warning this time. | |
75 | AT_DATA([txnfile], [[ovsdb-client transact unix:socket \ | |
76 | '["ordinals", | |
77 | {"op": "select", | |
78 | "table": "ordinals", | |
79 | "where": [], | |
80 | "sort": ["number"]}]' | |
81 | ]]) | |
56120500 | 82 | AT_CHECK([ovsdb-server --remote=punix:socket db --run="sh txnfile"], [0], [stdout], []) |
43675e26 | 83 | cat stdout >> output |
5c6d0628 | 84 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], |
43675e26 BP |
85 | [[[{"uuid":["uuid","<0>"]}] |
86 | [{"uuid":["uuid","<1>"]}] | |
87 | [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}] | |
88 | ]], [], | |
89 | [test ! -e pid || kill `cat pid`]) | |
90 | AT_CLEANUP | |
91 | ||
92 | AT_SETUP([truncating database log with bad transaction]) | |
93 | AT_KEYWORDS([ovsdb server positive unix]) | |
bdb2e73b | 94 | AT_SKIP_IF([test "$IS_WIN32" = "yes"]) |
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 | ]]) | |
56120500 | 104 | AT_CHECK([ovsdb-server --remote=punix:socket 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 | ]]) | |
56120500 | 116 | AT_CHECK([ovsdb-server --remote=punix:socket 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 | ]]) | |
56120500 | 130 | AT_CHECK([ovsdb-server --remote=punix:socket 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]) | |
39ab07af | 142 | ordinal_schema > schema |
8159b984 | 143 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) |
56120500 | 144 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket db], [0], [ignore], [ignore]) |
8159b984 BP |
145 | AT_CHECK([ovsdb-client get-schema-version unix:socket ordinals], [0], [5.1.3 |
146 | ]) | |
147 | OVSDB_SERVER_SHUTDOWN | |
148 | AT_CLEANUP | |
149 | ||
9cb53f26 BP |
150 | AT_SETUP([database multiplexing implementation]) |
151 | AT_KEYWORDS([ovsdb server positive]) | |
b4e8d170 BP |
152 | ordinal_schema > schema1 |
153 | constraint_schema > schema2 | |
154 | AT_CHECK([ovsdb-tool create db1 schema1], [0], [ignore], [ignore]) | |
155 | AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore]) | |
56120500 | 156 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket db1 db2], [0], [ignore], [ignore]) |
9cb53f26 BP |
157 | AT_CHECK( |
158 | [[ovsdb-client list-dbs unix:socket]], | |
b4e8d170 BP |
159 | [0], [constraints |
160 | ordinals | |
9cb53f26 BP |
161 | ], [ignore], [test ! -e pid || kill `cat pid`]) |
162 | AT_CHECK( | |
eadd1644 | 163 | [[ovstest test-jsonrpc request unix:socket get_schema [\"nonexistent\"]]], [0], |
508624b6 | 164 | [[{"error":{"details":"get_schema request specifies unknown database nonexistent","error":"unknown database","syntax":"[\"nonexistent\"]"},"id":0,"result":null} |
53ffefe9 | 165 | ]], [], [test ! -e pid || kill `cat pid`]) |
9cb53f26 BP |
166 | OVSDB_SERVER_SHUTDOWN |
167 | AT_CLEANUP | |
168 | ||
0a3b723b BP |
169 | AT_SETUP([ovsdb-server/add-db and remove-db]) |
170 | AT_KEYWORDS([ovsdb server positive]) | |
53eb8cb8 | 171 | on_exit 'kill `cat ovsdb-server.pid`' |
0a3b723b BP |
172 | ordinal_schema > schema1 |
173 | constraint_schema > schema2 | |
174 | AT_CHECK([ovsdb-tool create db1 schema1], [0], [ignore], [ignore]) | |
175 | AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore]) | |
176 | ||
177 | # Start ovsdb-server with just a single database - db1. | |
178 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket db1], [0]) | |
179 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs], | |
180 | [0], [ordinals | |
181 | ]) | |
182 | ||
183 | # Add the second database. | |
184 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], [0]) | |
185 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs], | |
186 | [0], [constraints | |
187 | ordinals | |
188 | ]) | |
189 | ||
190 | # The databases are responsive. | |
191 | AT_CHECK([ovsdb-client list-tables unix:socket constraints], [0], [ignore], [ignore]) | |
192 | AT_CHECK([ovsdb-client list-tables unix:socket ordinals], [0], [ignore], [ignore]) | |
193 | ||
194 | # Add an already added database. | |
bd270dc3 GS |
195 | if test $IS_WIN32 = "yes"; then |
196 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], 2, [], | |
197 | [I/O error: db2: failed to lock lockfile (Resource deadlock avoided) | |
198 | ovs-appctl: ovsdb-server: server returned an error | |
199 | ]) | |
200 | else | |
201 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], 2, [], | |
ebed9f78 | 202 | [db2: already open |
0a3b723b BP |
203 | ovs-appctl: ovsdb-server: server returned an error |
204 | ]) | |
bd270dc3 | 205 | fi |
0a3b723b BP |
206 | |
207 | # Add a non-existing database. | |
208 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db3], 2, [], [stderr]) | |
209 | AT_CHECK([sed 's/(.*)/(...)/' stderr], [0], | |
a6be657b | 210 | [I/O error: db3: open failed (...) |
0a3b723b BP |
211 | ovs-appctl: ovsdb-server: server returned an error |
212 | ]) | |
213 | ||
214 | # Add a remote through a db path in db1. | |
215 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote db:ordinals,ordinals,name], [0]) | |
216 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes], | |
217 | [0], [db:ordinals,ordinals,name | |
218 | punix:socket | |
219 | ]) | |
220 | ||
221 | # Removing db1 has no effect on its remote. | |
222 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db ordinals], [0]) | |
223 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs], | |
224 | [0], [constraints | |
225 | ]) | |
226 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes], | |
227 | [0], [db:ordinals,ordinals,name | |
228 | punix:socket | |
229 | ]) | |
230 | AT_CHECK([ovsdb-client list-tables unix:socket ordinals], [1], [ignore], [ignore]) | |
231 | ||
232 | # Remove db2. | |
233 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db constraints], [0]) | |
234 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs], | |
235 | [0], []) | |
236 | AT_CHECK([ovsdb-client list-tables unix:socket constraints], [1], [ignore], [ignore]) | |
237 | ||
238 | # Remove a non-existent database. | |
239 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db ordinals], [2], | |
240 | [], [Failed to find the database. | |
241 | ovs-appctl: ovsdb-server: server returned an error | |
242 | ]) | |
3fc53787 GS |
243 | |
244 | # Add a removed database. | |
245 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], [0]) | |
246 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs], | |
247 | [0], [constraints | |
248 | ]) | |
249 | AT_CHECK([ovsdb-client list-tables unix:socket constraints], [0], [ignore], [ignore]) | |
d9c8c57c | 250 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) |
0a3b723b BP |
251 | AT_CLEANUP |
252 | ||
d7ae8d6b | 253 | AT_SETUP([ovsdb-server/add-db with --monitor]) |
0a3b723b | 254 | AT_KEYWORDS([ovsdb server positive]) |
36373c1a | 255 | AT_SKIP_IF([test "$IS_WIN32" = "yes"]) |
0a3b723b | 256 | # Start ovsdb-server, initially with one db. |
0a3b723b BP |
257 | ordinal_schema > schema |
258 | AT_CHECK([ovsdb-tool create db1 schema], [0], [ignore], [ignore]) | |
53eb8cb8 | 259 | on_exit 'kill `cat *.pid`' |
0a3b723b BP |
260 | AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db1]) |
261 | ||
262 | # Add the second database. | |
263 | constraint_schema > schema2 | |
264 | AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore]) | |
265 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], [0]) | |
266 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs], | |
267 | [0], [constraints | |
268 | ordinals | |
269 | ]) | |
270 | ||
271 | # Kill the daemon process, making it look like a segfault, | |
272 | # and wait for a new daemon process to get spawned. | |
273 | cp ovsdb-server.pid old.pid | |
274 | AT_CHECK([kill -SEGV `cat ovsdb-server.pid`]) | |
275 | OVS_WAIT_WHILE([kill -0 `cat old.pid`]) | |
276 | OVS_WAIT_UNTIL( | |
277 | [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`]) | |
857570c4 | 278 | OVS_WAIT_UNTIL([ovs-appctl -t ovsdb-server version]) |
0a3b723b BP |
279 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs], |
280 | [0], [constraints | |
281 | ordinals | |
282 | ]) | |
d9c8c57c | 283 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) |
d7ae8d6b BP |
284 | AT_CLEANUP |
285 | ||
286 | AT_SETUP([ovsdb-server/add-db and remove-db with --monitor]) | |
287 | AT_KEYWORDS([ovsdb server positive]) | |
36373c1a | 288 | AT_SKIP_IF([test "$IS_WIN32" = "yes"]) |
d7ae8d6b | 289 | # Start ovsdb-server, initially with one db. |
d7ae8d6b BP |
290 | ordinal_schema > schema |
291 | AT_CHECK([ovsdb-tool create db1 schema], [0], [ignore], [ignore]) | |
292 | constraint_schema > schema2 | |
293 | AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore]) | |
53eb8cb8 | 294 | on_exit 'kill `cat *.pid`' |
d7ae8d6b | 295 | AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db1 db2]) |
0a3b723b | 296 | |
d7ae8d6b | 297 | # Remove the second database. |
0a3b723b BP |
298 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db constraints]) |
299 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs], | |
300 | [0], [ordinals | |
301 | ]) | |
302 | ||
303 | # Kill the daemon process, making it look like a segfault, | |
304 | # and wait for a new daemon process to get spawned. | |
305 | cp ovsdb-server.pid old.pid | |
306 | AT_CHECK([kill -SEGV `cat ovsdb-server.pid`]) | |
307 | OVS_WAIT_WHILE([kill -0 `cat old.pid`]) | |
308 | OVS_WAIT_UNTIL( | |
309 | [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`]) | |
857570c4 | 310 | OVS_WAIT_UNTIL([ovs-appctl -t ovsdb-server version]) |
0a3b723b BP |
311 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs], |
312 | [0], [ordinals | |
313 | ]) | |
d9c8c57c | 314 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) |
0a3b723b BP |
315 | AT_CLEANUP |
316 | ||
0b1fae1b BP |
317 | AT_SETUP([--remote=db: implementation]) |
318 | AT_KEYWORDS([ovsdb server positive]) | |
319 | AT_DATA([schema], | |
320 | [[{"name": "mydb", | |
321 | "tables": { | |
b4e8d170 BP |
322 | "Root": { |
323 | "columns": { | |
324 | "managers": { | |
325 | "type": { | |
326 | "key": "string", | |
327 | "min": 0, | |
328 | "max": "unlimited"}}, | |
329 | "manager_options": { | |
330 | "type": { | |
331 | "key": {"type": "uuid", "refTable": "Manager"}, | |
332 | "min": 0, | |
333 | "max": "unlimited"}}}}, | |
0b1fae1b BP |
334 | "Manager": { |
335 | "columns": { | |
b4e8d170 BP |
336 | "target": { |
337 | "type": "string"}, | |
338 | "is_connected": { | |
339 | "type": { | |
340 | "key": "boolean", | |
341 | "min": 0, | |
342 | "max": 1}}}}}} | |
0b1fae1b | 343 | ]]) |
7c126fbb BP |
344 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) |
345 | AT_CHECK( | |
0b1fae1b | 346 | [[ovsdb-tool transact db \ |
9cb53f26 | 347 | '["mydb", |
b4e8d170 BP |
348 | {"op": "insert", |
349 | "table": "Root", | |
350 | "row": { | |
351 | "managers": "punix:socket1", | |
352 | "manager_options": ["set", [["named-uuid", "x"]]]}}, | |
9cb53f26 | 353 | {"op": "insert", |
0b1fae1b | 354 | "table": "Manager", |
b4e8d170 BP |
355 | "uuid-name": "x", |
356 | "row": {"target": "punix:socket2"}}]']], [0], [ignore], [ignore]) | |
53eb8cb8 | 357 | on_exit 'kill `cat ovsdb-server.pid`' |
8ad822c9 | 358 | 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 | 359 | ovs-appctl -t ovsdb-server time/warp 6000 1000 |
7c126fbb | 360 | AT_CHECK( |
b4e8d170 | 361 | [[ovsdb-client transact unix:socket1 \ |
9cb53f26 | 362 | '["mydb", |
b4e8d170 BP |
363 | {"op": "select", |
364 | "table": "Root", | |
365 | "where": [], | |
366 | "columns": ["managers"]}, | |
9cb53f26 | 367 | {"op": "select", |
0b1fae1b BP |
368 | "table": "Manager", |
369 | "where": [], | |
b4e8d170 BP |
370 | "columns": ["target", "is_connected"]}]']], |
371 | [0], [stdout], [ignore]) | |
0b1fae1b | 372 | AT_CHECK( |
5c6d0628 | 373 | [${PERL} $srcdir/uuidfilt.pl stdout], |
0b1fae1b | 374 | [0], |
b4e8d170 | 375 | [[[{"rows":[{"managers":"punix:socket1"}]},{"rows":[{"is_connected":false,"target":"punix:socket2"}]}] |
0b1fae1b | 376 | ]], |
b4e8d170 | 377 | [ignore]) |
d9c8c57c | 378 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) |
0b1fae1b | 379 | AT_CLEANUP |
ada496b5 | 380 | |
b421d2af BP |
381 | AT_SETUP([ovsdb-server/add-remote and remove-remote]) |
382 | AT_KEYWORDS([ovsdb server positive]) | |
b421d2af BP |
383 | ordinal_schema > schema |
384 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) | |
53eb8cb8 | 385 | on_exit 'kill `cat *.pid`' |
b421d2af BP |
386 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile db]) |
387 | ||
388 | AT_CHECK([test ! -e socket1]) | |
389 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1]) | |
91fc9298 | 390 | if test "$IS_WIN32" = "yes"; then |
922247c6 | 391 | OVS_WAIT_UNTIL([test -e socket1]) |
91fc9298 GS |
392 | else |
393 | OVS_WAIT_UNTIL([test -S socket1]) | |
394 | fi | |
b421d2af BP |
395 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes], |
396 | [0], [punix:socket1 | |
397 | ]) | |
398 | ||
399 | AT_CHECK([test ! -e socket2]) | |
400 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket2]) | |
91fc9298 | 401 | if test "$IS_WIN32" = "yes"; then |
922247c6 | 402 | OVS_WAIT_UNTIL([test -e socket2]) |
91fc9298 GS |
403 | else |
404 | OVS_WAIT_UNTIL([test -S socket2]) | |
405 | fi | |
b421d2af BP |
406 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes], |
407 | [0], [punix:socket1 | |
408 | punix:socket2 | |
409 | ]) | |
410 | ||
411 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote db:x,y,z], [2], | |
412 | [], ["db:x,y,z": no database named x | |
413 | ovs-appctl: ovsdb-server: server returned an error | |
414 | ]) | |
415 | ||
416 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket1]) | |
417 | OVS_WAIT_UNTIL([test ! -e socket1]) | |
91fc9298 | 418 | if test "$IS_WIN32" = "yes"; then |
922247c6 | 419 | AT_CHECK([test -e socket2]) |
91fc9298 GS |
420 | else |
421 | AT_CHECK([test -S socket2]) | |
422 | fi | |
b421d2af BP |
423 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes], |
424 | [0], [punix:socket2 | |
425 | ]) | |
426 | ||
427 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket2]) | |
428 | OVS_WAIT_UNTIL([test ! -e socket2]) | |
429 | AT_CHECK([test ! -e socket1]) | |
430 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes]) | |
d9c8c57c | 431 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) |
b421d2af BP |
432 | AT_CLEANUP |
433 | ||
09993217 | 434 | AT_SETUP([ovsdb-server/add-remote with --monitor]) |
5f36127e | 435 | AT_KEYWORDS([ovsdb server positive]) |
36373c1a | 436 | AT_SKIP_IF([test "$IS_WIN32" = "yes"]) |
5f36127e | 437 | # Start ovsdb-server, initially with no remotes. |
5f36127e BP |
438 | ordinal_schema > schema |
439 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) | |
53eb8cb8 | 440 | on_exit 'kill `cat *.pid`' |
5f36127e BP |
441 | AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db]) |
442 | ||
443 | # Add a remote. | |
444 | AT_CHECK([test ! -e socket1]) | |
445 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1]) | |
446 | OVS_WAIT_UNTIL([test -S socket1]) | |
447 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes], | |
448 | [0], [punix:socket1 | |
449 | ]) | |
450 | ||
451 | # Kill the daemon process, making it look like a segfault, | |
452 | # and wait for a new daemon process to get spawned and for it to | |
453 | # start listening on 'socket1'. | |
454 | cp ovsdb-server.pid old.pid | |
455 | rm socket1 | |
456 | AT_CHECK([kill -SEGV `cat ovsdb-server.pid`]) | |
457 | OVS_WAIT_WHILE([kill -0 `cat old.pid`]) | |
458 | OVS_WAIT_UNTIL( | |
459 | [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`]) | |
857570c4 | 460 | OVS_WAIT_UNTIL([ovs-appctl -t ovsdb-server version]) |
5f36127e | 461 | OVS_WAIT_UNTIL([test -S socket1]) |
d9c8c57c | 462 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) |
09993217 AW |
463 | AT_CLEANUP |
464 | ||
465 | AT_SETUP([ovsdb-server/add-remote and remove-remote with --monitor]) | |
466 | AT_KEYWORDS([ovsdb server positive]) | |
36373c1a | 467 | AT_SKIP_IF([test "$IS_WIN32" = "yes"]) |
09993217 | 468 | # Start ovsdb-server, initially with no remotes. |
09993217 AW |
469 | ordinal_schema > schema |
470 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) | |
53eb8cb8 | 471 | on_exit 'kill `cat *.pid`' |
09993217 AW |
472 | AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db]) |
473 | ||
474 | # Add a remote. | |
475 | AT_CHECK([test ! -e socket1]) | |
476 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1]) | |
477 | OVS_WAIT_UNTIL([test -S socket1]) | |
478 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes], | |
479 | [0], [punix:socket1 | |
480 | ]) | |
5f36127e BP |
481 | |
482 | # Remove the remote. | |
483 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket1]) | |
484 | OVS_WAIT_UNTIL([test ! -e socket1]) | |
485 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes]) | |
486 | ||
487 | # Kill the daemon process, making it look like a segfault, | |
488 | # and wait for a new daemon process to get spawned and make sure that it | |
489 | # does not listen on 'socket1'. | |
490 | cp ovsdb-server.pid old.pid | |
491 | AT_CHECK([kill -SEGV `cat ovsdb-server.pid`]) | |
492 | OVS_WAIT_WHILE([kill -0 `cat old.pid`]) | |
493 | OVS_WAIT_UNTIL( | |
494 | [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`]) | |
857570c4 | 495 | OVS_WAIT_UNTIL([ovs-appctl -t ovsdb-server version]) |
5f36127e | 496 | AT_CHECK([test ! -e socket1]) |
d9c8c57c | 497 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) |
5f36127e BP |
498 | AT_CLEANUP |
499 | ||
78876719 BP |
500 | AT_SETUP([SSL db: implementation]) |
501 | AT_KEYWORDS([ovsdb server positive ssl $5]) | |
502 | AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) | |
b028245a GS |
503 | # For this test, we pass PKIDIR through a ovsdb-tool transact and |
504 | # msys on Windows does not convert the path style automatically. | |
505 | # So, do that forcefully with a 'pwd -W' (called through pwd() function). | |
506 | PKIDIR="$(cd $abs_top_builddir/tests && pwd)" | |
78876719 | 507 | AT_SKIP_IF([expr "$PKIDIR" : ".*[ '\" |
0bcff889 | 508 | \\]"]) |
78876719 BP |
509 | AT_DATA([schema], |
510 | [[{"name": "mydb", | |
511 | "tables": { | |
512 | "SSL": { | |
513 | "columns": { | |
514 | "private_key": {"type": "string"}, | |
515 | "certificate": {"type": "string"}, | |
e18a1d08 ER |
516 | "ca_cert": {"type": "string"}, |
517 | "ssl_protocols" : {"type": "string"}, | |
518 | "ssl_ciphers" : {"type" : "string"}}}}} | |
78876719 BP |
519 | ]]) |
520 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) | |
e18a1d08 ER |
521 | # The !ECDHE-ECDSA-AES256-GCM-SHA384 in the ssl_ciphers is so that |
522 | # a cipher negotiation failure can be tested for later. | |
78876719 BP |
523 | AT_CHECK( |
524 | [[ovsdb-tool transact db \ | |
525 | '["mydb", | |
526 | {"op": "insert", | |
527 | "table": "SSL", | |
528 | "row": {"private_key": "'"$PKIDIR/testpki-privkey2.pem"'", | |
529 | "certificate": "'"$PKIDIR/testpki-cert2.pem"'", | |
e18a1d08 ER |
530 | "ca_cert": "'"$PKIDIR/testpki-cacert.pem"'", |
531 | "ssl_protocols": "'"TLSv1.2,TLSv1.1"'", | |
532 | "ssl_ciphers": "'"HIGH:!aNULL:!MD5:!ECDHE-ECDSA-AES256-GCM-SHA384"'"}}]']], | |
78876719 BP |
533 | [0], [ignore], [ignore]) |
534 | AT_CHECK( | |
56120500 | 535 | [ovsdb-server --log-file --detach --no-chdir --pidfile \ |
fb6de52c GS |
536 | --private-key=db:mydb,SSL,private_key \ |
537 | --certificate=db:mydb,SSL,certificate \ | |
538 | --ca-cert=db:mydb,SSL,ca_cert \ | |
e18a1d08 ER |
539 | --ssl-protocols=db:mydb,SSL,ssl_protocols \ |
540 | --ssl-ciphers=db:mydb,SSL,ssl_ciphers \ | |
56120500 | 541 | --remote=pssl:0:127.0.0.1 db], |
78876719 | 542 | [0], [ignore], [ignore]) |
fb28ef2d | 543 | PARSE_LISTENING_PORT([ovsdb-server.log], [SSL_PORT]) |
78876719 BP |
544 | AT_CHECK( |
545 | [[ovsdb-client \ | |
546 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
547 | --certificate=$PKIDIR/testpki-cert.pem \ | |
548 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
e18a1d08 ER |
549 | --ssl-protocols=TLSv1.2,TLSv1.1 \ |
550 | --ssl-ciphers=HIGH:!aNULL:!MD5 \ | |
78876719 BP |
551 | transact ssl:127.0.0.1:$SSL_PORT \ |
552 | '["mydb", | |
553 | {"op": "select", | |
554 | "table": "SSL", | |
555 | "where": [], | |
e18a1d08 | 556 | "columns": ["private_key"]}]']], |
78876719 BP |
557 | [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`]) |
558 | cat stdout >> output | |
559 | AT_CHECK_UNQUOTED( | |
b33bff0f | 560 | [cat output], [0], |
0877a018 | 561 | [[@<:@{"rows":@<:@{"private_key":"$PKIDIR/testpki-privkey2.pem"}@:>@}@:>@ |
78876719 | 562 | ]], [ignore], [test ! -e pid || kill `cat pid`]) |
e18a1d08 ER |
563 | # Check that when the server has TLSv1.1+ and the client has |
564 | # TLSv1 that the connection fails. | |
565 | AT_CHECK( | |
566 | [[ovsdb-client \ | |
567 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
568 | --certificate=$PKIDIR/testpki-cert.pem \ | |
569 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
570 | --ssl-protocols=TLSv1 \ | |
571 | --ssl-ciphers=HIGH:!aNULL:!MD5 \ | |
572 | transact ssl:127.0.0.1:$SSL_PORT \ | |
573 | '["mydb", | |
574 | {"op": "select", | |
575 | "table": "SSL", | |
576 | "where": [], | |
577 | "columns": ["private_key"]}]']], | |
578 | [1], [stdout], | |
579 | [stderr], | |
580 | [test ! -e pid || kill `cat pid`]) | |
581 | cat stderr > output | |
582 | AT_CHECK_UNQUOTED( | |
583 | [grep "failed to connect" output], [0], | |
584 | [ovsdb-client: failed to connect to "ssl:127.0.0.1:$SSL_PORT" (Protocol error) | |
585 | ], | |
586 | [ignore], [test ! -e pid || kill `cat pid`]) | |
587 | # Check that when ciphers are not compatible, that a negotiation | |
588 | # failure occurs. | |
589 | AT_CHECK( | |
590 | [[ovsdb-client \ | |
591 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
592 | --certificate=$PKIDIR/testpki-cert.pem \ | |
593 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
594 | --ssl-protocols=TLSv1.2,TLSv1.1 \ | |
595 | --ssl-ciphers=ECDHE-ECDSA-AES256-GCM-SHA384 \ | |
596 | transact ssl:127.0.0.1:$SSL_PORT \ | |
597 | '["mydb", | |
598 | {"op": "select", | |
599 | "table": "SSL", | |
600 | "where": [], | |
601 | "columns": ["private_key"]}]']], | |
602 | [1], [stdout], | |
603 | [stderr], | |
604 | [test ! -e pid || kill `cat pid`]) | |
605 | cat stderr > output | |
606 | AT_CHECK_UNQUOTED( | |
607 | [grep "failed to connect" output], [0], | |
608 | [ovsdb-client: failed to connect to "ssl:127.0.0.1:$SSL_PORT" (Protocol error) | |
609 | ], | |
610 | [ignore], [test ! -e pid || kill `cat pid`]) | |
611 | # The error message for being unable to negotiate a shared ciphersuite | |
612 | # is 'sslv3 alert handshake failure'. This is not the clearest message. | |
613 | AT_CHECK_UNQUOTED( | |
614 | [grep "sslv3 alert handshake failure" output], [0], | |
615 | [stdout], | |
616 | [ignore], [test ! -e pid || kill `cat pid`]) | |
78876719 BP |
617 | OVSDB_SERVER_SHUTDOWN |
618 | AT_CLEANUP | |
619 | ||
ada496b5 BP |
620 | AT_SETUP([compacting online]) |
621 | AT_KEYWORDS([ovsdb server compact]) | |
39ab07af | 622 | ordinal_schema > schema |
a35ae81c BP |
623 | dnl Make sure that "ovsdb-tool create" works with a dangling symlink for |
624 | dnl the database and the lockfile, creating the target of each symlink rather | |
625 | dnl than replacing the symlinks with regular files. | |
626 | mkdir dir | |
9e6b32f6 AS |
627 | if test "$IS_WIN32" = "no"; then |
628 | ln -s dir/db db | |
629 | ln -s dir/.db.~lock~ .db.~lock~ | |
630 | AT_SKIP_IF([test ! -h db || test ! -h .db.~lock~]) | |
631 | fi | |
ada496b5 | 632 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) |
a35ae81c | 633 | dnl Start ovsdb-server. |
56120500 | 634 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file="`pwd`"/ovsdb-server.log db], [0], [ignore], [ignore]) |
ada496b5 BP |
635 | AT_CAPTURE_FILE([ovsdb-server.log]) |
636 | dnl Do a bunch of random transactions that put crap in the database log. | |
637 | AT_CHECK( | |
638 | [[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do | |
639 | set -- $pair | |
640 | ovsdb-client transact unix:socket ' | |
641 | ["ordinals", | |
642 | {"op": "insert", | |
643 | "table": "ordinals", | |
644 | "row": {"name": "'$1'", "number": '$2'}}, | |
645 | {"op": "comment", | |
646 | "comment": "add row for '"$pair"'"}]' | |
647 | ovsdb-client transact unix:socket ' | |
648 | ["ordinals", | |
649 | {"op": "delete", | |
650 | "table": "ordinals", | |
651 | "where": [["number", "==", '$2']]}, | |
652 | {"op": "comment", | |
653 | "comment": "delete row for '"$2"'"}]' | |
654 | ovsdb-client transact unix:socket ' | |
655 | ["ordinals", | |
656 | {"op": "insert", | |
657 | "table": "ordinals", | |
658 | "row": {"name": "'$1'", "number": '$2'}}, | |
659 | {"op": "comment", | |
660 | "comment": "add back row for '"$pair"'"}]' | |
661 | done]], | |
662 | [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`]) | |
663 | dnl Check that all the crap is in fact in the database log. | |
eadd1644 | 664 | AT_CHECK([[${PERL} $srcdir/uuidfilt.pl db | grep -v ^OVSDB | sed 's/"_date":[0-9]*/"_date":0/' | ovstest test-json --multiple -]], [0], |
6910a6e6 | 665 | [[{"cksum":"12345678 9","name":"ordinals","tables":{"ordinals":{"columns":{"name":{"type":"string"},"number":{"type":"integer"}},"indexes":[["number"]]}},"version":"5.1.3"} |
62c87d4a BP |
666 | {"_comment":"add row for zero 0","_date":0,"ordinals":{"<0>":{"name":"zero"}}} |
667 | {"_comment":"delete row for 0","_date":0,"ordinals":{"<0>":null}} | |
668 | {"_comment":"add back row for zero 0","_date":0,"ordinals":{"<1>":{"name":"zero"}}} | |
669 | {"_comment":"add row for one 1","_date":0,"ordinals":{"<2>":{"name":"one","number":1}}} | |
670 | {"_comment":"delete row for 1","_date":0,"ordinals":{"<2>":null}} | |
671 | {"_comment":"add back row for one 1","_date":0,"ordinals":{"<3>":{"name":"one","number":1}}} | |
672 | {"_comment":"add row for two 2","_date":0,"ordinals":{"<4>":{"name":"two","number":2}}} | |
673 | {"_comment":"delete row for 2","_date":0,"ordinals":{"<4>":null}} | |
674 | {"_comment":"add back row for two 2","_date":0,"ordinals":{"<5>":{"name":"two","number":2}}} | |
675 | {"_comment":"add row for three 3","_date":0,"ordinals":{"<6>":{"name":"three","number":3}}} | |
676 | {"_comment":"delete row for 3","_date":0,"ordinals":{"<6>":null}} | |
677 | {"_comment":"add back row for three 3","_date":0,"ordinals":{"<7>":{"name":"three","number":3}}} | |
678 | {"_comment":"add row for four 4","_date":0,"ordinals":{"<8>":{"name":"four","number":4}}} | |
679 | {"_comment":"delete row for 4","_date":0,"ordinals":{"<8>":null}} | |
680 | {"_comment":"add back row for four 4","_date":0,"ordinals":{"<9>":{"name":"four","number":4}}} | |
681 | {"_comment":"add row for five 5","_date":0,"ordinals":{"<10>":{"name":"five","number":5}}} | |
682 | {"_comment":"delete row for 5","_date":0,"ordinals":{"<10>":null}} | |
683 | {"_comment":"add back row for five 5","_date":0,"ordinals":{"<11>":{"name":"five","number":5}}} | |
ada496b5 BP |
684 | ]], [], [test ! -e pid || kill `cat pid`]) |
685 | dnl Dump out and check the actual database contents. | |
686 | AT_CHECK([[ovsdb-client dump unix:socket ordinals]], | |
687 | [0], [stdout], [ignore]) | |
5c6d0628 | 688 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl |
370a11b9 BP |
689 | ordinals table |
690 | _uuid name number | |
ada496b5 BP |
691 | ------------------------------------ ----- ------ |
692 | <0> five 5 @&t@ | |
693 | <1> four 4 @&t@ | |
694 | <2> one 1 @&t@ | |
695 | <3> three 3 @&t@ | |
696 | <4> two 2 @&t@ | |
697 | <5> zero 0 @&t@ | |
698 | ], [], [test ! -e pid || kill `cat pid`]) | |
699 | dnl Now compact the database in-place. | |
56120500 | 700 | AT_CHECK([[ovs-appctl -t ovsdb-server ovsdb-server/compact]], |
ada496b5 | 701 | [0], [], [ignore], [test ! -e pid || kill `cat pid`]) |
a35ae81c BP |
702 | dnl Make sure that "db" is still a symlink to dir/db instead of getting |
703 | dnl replaced by a regular file, ditto for .db.~lock~. | |
9e6b32f6 AS |
704 | if test "$IS_WIN32" = "no"; then |
705 | AT_CHECK([test -h db]) | |
706 | AT_CHECK([test -h .db.~lock~]) | |
707 | AT_CHECK([test -f dir/db]) | |
708 | AT_CHECK([test -f dir/.db.~lock~]) | |
709 | fi | |
ada496b5 BP |
710 | dnl We can't fully re-check the contents of the database log, because the |
711 | dnl order of the records is not predictable, but there should only be 4 lines | |
712 | dnl in it now. | |
713 | AT_CAPTURE_FILE([db]) | |
e0c7697c EM |
714 | AT_CHECK([test `wc -l < db` -eq 4], [0], [], [], |
715 | [test ! -e pid || kill `cat pid`]) | |
ada496b5 BP |
716 | dnl And check that the dumped data is the same too: |
717 | AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore], | |
718 | [test ! -e pid || kill `cat pid`]) | |
5c6d0628 | 719 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl |
370a11b9 BP |
720 | ordinals table |
721 | _uuid name number | |
ada496b5 BP |
722 | ------------------------------------ ----- ------ |
723 | <0> five 5 @&t@ | |
724 | <1> four 4 @&t@ | |
725 | <2> one 1 @&t@ | |
726 | <3> three 3 @&t@ | |
727 | <4> two 2 @&t@ | |
728 | <5> zero 0 @&t@ | |
729 | ], [], [test ! -e pid || kill `cat pid`]) | |
730 | dnl Now do some more transactions. | |
731 | AT_CHECK( | |
732 | [[ovsdb-client transact unix:socket ' | |
733 | ["ordinals", | |
734 | {"op": "delete", | |
735 | "table": "ordinals", | |
736 | "where": [["number", "<", 3]]}]']], | |
737 | [0], [[[{"count":3}] | |
738 | ]], [ignore], [test ! -e pid || kill `cat pid`]) | |
739 | dnl There should be 6 lines in the log now. | |
e0c7697c EM |
740 | AT_CHECK([test `wc -l < db` -eq 6], [0], [], [], |
741 | [test ! -e pid || kill `cat pid`]) | |
84a13f61 AS |
742 | dnl Then check that the dumped data is correct. This time first kill |
743 | dnl and restart the database server to ensure that the data is correct on | |
744 | dnl disk as well as in memory. | |
745 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
746 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file="`pwd`"/ovsdb-server.log db], [0], [ignore], [ignore]) | |
ada496b5 BP |
747 | AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore], |
748 | [test ! -e pid || kill `cat pid`]) | |
5c6d0628 | 749 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl |
370a11b9 BP |
750 | ordinals table |
751 | _uuid name number | |
ada496b5 BP |
752 | ------------------------------------ ----- ------ |
753 | <0> five 5 @&t@ | |
754 | <1> four 4 @&t@ | |
755 | <2> three 3 @&t@ | |
756 | ], [], [test ! -e pid || kill `cat pid`]) | |
757 | OVSDB_SERVER_SHUTDOWN | |
758 | AT_CLEANUP | |
48f6e410 BP |
759 | |
760 | AT_SETUP([ovsdb-server combines updates on backlogged connections]) | |
53eb8cb8 | 761 | on_exit 'kill `cat *.pid`' |
48f6e410 BP |
762 | |
763 | # The maximum socket receive buffer size is important for this test, which | |
764 | # tests behavior when the receive buffer overflows. | |
765 | if test -e /proc/sys/net/core/rmem_max; then | |
766 | # Linux | |
767 | rmem_max=`cat /proc/sys/net/core/rmem_max` | |
768 | elif rmem_max=`sysctl -n net.inet.tcp.recvbuf_max 2>/dev/null`; then | |
81b9d305 | 769 | : # FreeBSD, NetBSD |
48f6e410 BP |
770 | else |
771 | # Don't know how to get maximum socket receive buffer on this OS | |
772 | AT_SKIP_IF([:]) | |
773 | fi | |
774 | ||
775 | # Calculate the number of iterations we need to queue. Each of the | |
776 | # iterations we execute, by itself, yields a monitor update of about | |
777 | # 25 kB, so fill up that much space plus a few for luck. | |
f5ca49d8 | 778 | n_iterations=`expr $rmem_max / 25000 + 5` |
48f6e410 BP |
779 | echo rmem_max=$rmem_max n_iterations=$n_iterations |
780 | ||
21aa35c3 BP |
781 | # If there's too much queuing skip the test to avoid timing out. |
782 | AT_SKIP_IF([test $rmem_max -gt 1048576]) | |
783 | ||
48f6e410 BP |
784 | # Calculate the exact number of monitor updates expected for $n_iterations, |
785 | # assuming no updates are combined. The "extra" update is for the initial | |
786 | # contents of the database. | |
787 | n_updates=`expr $n_iterations \* 3 + 1` | |
788 | ||
789 | # Start an ovsdb-server with the vswitchd schema. | |
790 | OVSDB_INIT([db]) | |
791 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:db.sock db], | |
792 | [0], [ignore], [ignore]) | |
793 | ||
794 | # Executes a set of transactions that add a bridge with 100 ports, and | |
795 | # then deletes that bridge. This yields three monitor updates that | |
796 | # add up to about 25 kB in size. | |
797 | # | |
798 | # The update also increments a counter held in the database so that we can | |
799 | # verify that the overall effect of the transactions took effect (e.g. | |
800 | # monitor updates at the end weren't just dropped). We add an arbitrary | |
801 | # string to the counter to make grepping for it more reliable. | |
802 | counter=0 | |
803 | trigger_big_update () { | |
804 | counter=`expr $counter + 1` | |
805 | ovs-vsctl --no-wait -- set open_vswitch . system_version=xyzzy$counter | |
806 | ovs-vsctl --no-wait -- add-br br0 $add | |
807 | ovs-vsctl --no-wait -- del-br br0 | |
808 | } | |
809 | add_ports () { | |
810 | for j in `seq 1 100`; do | |
811 | printf " -- add-port br0 p%d" $j | |
812 | done | |
813 | } | |
814 | add=`add_ports` | |
815 | ||
816 | AT_CAPTURE_FILE([ovsdb-client.err]) | |
c005fd61 AZ |
817 | AT_CAPTURE_FILE([ovsdb-client-nonblock.err]) |
818 | ||
819 | ||
820 | # Start an ovsdb-client monitoring all changes to the database, | |
821 | # By default, it is non-blocking, and will get update message | |
822 | # for each ovsdb-server transaactions. | |
823 | AT_CHECK([ovsdb-client --detach --no-chdir --pidfile=nonblock.pid monitor ALL >ovsdb-client-nonblock.out 2>ovsdb-client-nonblock.err]) | |
48f6e410 BP |
824 | |
825 | # Start an ovsdb-client monitoring all changes to the database, | |
826 | # make it block to force the buffers to fill up, and then execute | |
827 | # enough iterations that ovsdb-server starts combining updates. | |
828 | AT_CHECK([ovsdb-client --detach --no-chdir --pidfile monitor ALL >ovsdb-client.out 2>ovsdb-client.err]) | |
829 | AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/block]) | |
830 | for i in `seq 1 $n_iterations`; do | |
831 | echo "blocked update ($i of $n_iterations)" | |
832 | trigger_big_update $i | |
833 | done | |
834 | AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/unblock]) | |
835 | OVS_WAIT_UNTIL([grep "\"xyzzy$counter\"" ovsdb-client.out]) | |
c005fd61 | 836 | OVS_WAIT_UNTIL([grep "\"xyzzy$counter\"" ovsdb-client-nonblock.out]) |
d9c8c57c | 837 | OVS_APP_EXIT_AND_WAIT([ovsdb-client]) |
c005fd61 | 838 | AT_CHECK([kill `cat nonblock.pid`]) |
48f6e410 BP |
839 | |
840 | # Count the number of updates in the ovsdb-client output, by counting | |
841 | # the number of changes to the Open_vSwitch table. (All of our | |
842 | # transactions modify the Open_vSwitch table.) It should be less than | |
843 | # $n_updates updates. | |
844 | # | |
845 | # Check that the counter is what we expect. | |
846 | logged_updates=`grep -c '^Open_vSwitch' ovsdb-client.out` | |
c005fd61 AZ |
847 | logged_nonblock_updates=`grep -c '^Open_vSwitch' ovsdb-client-nonblock.out` |
848 | echo "logged_nonblock_updates=$logged_nonblock_updates (expected less or equal to $n_updates)" | |
849 | echo "logged_updates=$logged_updates (expected less than $logged_nonblock_updates)" | |
850 | AT_CHECK([test $logged_nonblock_updates -le $n_updates]) | |
851 | AT_CHECK([test $logged_updates -lt $logged_nonblock_updates]) | |
48f6e410 BP |
852 | AT_CHECK_UNQUOTED([ovs-vsctl get open_vswitch . system_version], [0], |
853 | ["xyzzy$counter" | |
854 | ]) | |
d9c8c57c | 855 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) |
48f6e410 | 856 | AT_CLEANUP |
80d326ad | 857 | \f |
e731d71b | 858 | AT_BANNER([OVSDB -- ovsdb-server transactions (SSL IPv4 sockets)]) |
80d326ad BP |
859 | |
860 | # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) | |
861 | # | |
862 | # Creates a database with the given SCHEMA, starts an ovsdb-server on | |
863 | # that database, and runs each of the TRANSACTIONS (which should be a | |
864 | # quoted list of quoted strings) against it with ovsdb-client one at a | |
865 | # time. | |
866 | # | |
867 | # Checks that the overall output is OUTPUT, but UUIDs in the output | |
868 | # are replaced by markers of the form <N> where N is a number. The | |
869 | # first unique UUID is replaced by <0>, the next by <1>, and so on. | |
870 | # If a given UUID appears more than once it is always replaced by the | |
871 | # same marker. | |
872 | # | |
873 | # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. | |
874 | m4_define([OVSDB_CHECK_EXECUTION], | |
875 | [AT_SETUP([$1]) | |
876 | AT_KEYWORDS([ovsdb server positive ssl $5]) | |
877 | AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) | |
39ab07af | 878 | $2 > schema |
15b619e2 | 879 | PKIDIR=$abs_top_builddir/tests |
7c126fbb | 880 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) |
56120500 | 881 | AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile --private-key=$PKIDIR/testpki-privkey2.pem --certificate=$PKIDIR/testpki-cert2.pem --ca-cert=$PKIDIR/testpki-cacert.pem --remote=pssl:0:127.0.0.1 db], [0], [ignore], [ignore]) |
fb28ef2d | 882 | PARSE_LISTENING_PORT([ovsdb-server.log], [SSL_PORT]) |
80d326ad | 883 | m4_foreach([txn], [$3], |
7c126fbb | 884 | [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 |
885 | [test ! -e pid || kill `cat pid`]) |
886 | cat stdout >> output | |
887 | ]) | |
5c6d0628 | 888 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore], |
80d326ad | 889 | [test ! -e pid || kill `cat pid`]) |
028cbd99 | 890 | OVSDB_SERVER_SHUTDOWN |
80d326ad BP |
891 | AT_CLEANUP]) |
892 | ||
e879d33e MM |
893 | EXECUTION_EXAMPLES |
894 | ||
e731d71b AS |
895 | AT_BANNER([OVSDB -- ovsdb-server transactions (SSL IPv6 sockets)]) |
896 | ||
897 | # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) | |
898 | # | |
899 | # Creates a database with the given SCHEMA, starts an ovsdb-server on | |
900 | # that database, and runs each of the TRANSACTIONS (which should be a | |
901 | # quoted list of quoted strings) against it with ovsdb-client one at a | |
902 | # time. | |
903 | # | |
904 | # Checks that the overall output is OUTPUT, but UUIDs in the output | |
905 | # are replaced by markers of the form <N> where N is a number. The | |
906 | # first unique UUID is replaced by <0>, the next by <1>, and so on. | |
907 | # If a given UUID appears more than once it is always replaced by the | |
908 | # same marker. | |
909 | # | |
910 | # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. | |
911 | m4_define([OVSDB_CHECK_EXECUTION], | |
912 | [AT_SETUP([$1]) | |
913 | AT_KEYWORDS([ovsdb server positive ssl6 $5]) | |
914 | AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) | |
4819b3a5 | 915 | AT_SKIP_IF([test $HAVE_IPV6 = no]) |
e731d71b AS |
916 | $2 > schema |
917 | PKIDIR=$abs_top_builddir/tests | |
918 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) | |
56120500 | 919 | AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile --private-key=$PKIDIR/testpki-privkey2.pem --certificate=$PKIDIR/testpki-cert2.pem --ca-cert=$PKIDIR/testpki-cacert.pem --remote=pssl:0:[[::1]] db], [0], [ignore], [ignore]) |
fb28ef2d | 920 | PARSE_LISTENING_PORT([ovsdb-server.log], [SSL_PORT]) |
e731d71b AS |
921 | m4_foreach([txn], [$3], |
922 | [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], | |
923 | [test ! -e pid || kill `cat pid`]) | |
924 | cat stdout >> output | |
925 | ]) | |
926 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore], | |
927 | [test ! -e pid || kill `cat pid`]) | |
928 | OVSDB_SERVER_SHUTDOWN | |
929 | AT_CLEANUP]) | |
930 | ||
931 | ONE_EXECUTION_EXAMPLE | |
932 | ||
933 | AT_BANNER([OVSDB -- ovsdb-server transactions (TCP IPv4 sockets)]) | |
e879d33e MM |
934 | |
935 | AT_SETUP([ovsdb-client get-schema-version - tcp socket]) | |
936 | AT_KEYWORDS([ovsdb server positive tcp]) | |
937 | ordinal_schema > schema | |
e879d33e | 938 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) |
56120500 | 939 | AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile --remote=ptcp:0:127.0.0.1 db], [0], [ignore], [ignore]) |
fb28ef2d | 940 | PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT]) |
e879d33e MM |
941 | AT_CHECK([ovsdb-client get-schema-version tcp:127.0.0.1:$TCP_PORT ordinals], [0], [5.1.3 |
942 | ]) | |
943 | OVSDB_SERVER_SHUTDOWN | |
944 | AT_CLEANUP]) | |
945 | ||
946 | # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) | |
947 | # | |
948 | # Creates a database with the given SCHEMA, starts an ovsdb-server on | |
949 | # that database, and runs each of the TRANSACTIONS (which should be a | |
950 | # quoted list of quoted strings) against it with ovsdb-client one at a | |
951 | # time. | |
952 | # | |
953 | # Checks that the overall output is OUTPUT, but UUIDs in the output | |
954 | # are replaced by markers of the form <N> where N is a number. The | |
955 | # first unique UUID is replaced by <0>, the next by <1>, and so on. | |
956 | # If a given UUID appears more than once it is always replaced by the | |
957 | # same marker. | |
958 | # | |
959 | # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. | |
960 | m4_define([OVSDB_CHECK_EXECUTION], | |
961 | [AT_SETUP([$1]) | |
962 | AT_KEYWORDS([ovsdb server positive tcp $5]) | |
963 | $2 > schema | |
e879d33e MM |
964 | PKIDIR=$abs_top_builddir/tests |
965 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) | |
56120500 | 966 | AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile --remote=ptcp:0:127.0.0.1 db], [0], [ignore], [ignore]) |
fb28ef2d | 967 | PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT]) |
e879d33e MM |
968 | m4_foreach([txn], [$3], |
969 | [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT 'txn'], [0], [stdout], [ignore], | |
970 | [test ! -e pid || kill `cat pid`]) | |
971 | cat stdout >> output | |
972 | ]) | |
5c6d0628 | 973 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore], |
e879d33e MM |
974 | [test ! -e pid || kill `cat pid`]) |
975 | OVSDB_SERVER_SHUTDOWN | |
976 | AT_CLEANUP]) | |
977 | ||
80d326ad | 978 | EXECUTION_EXAMPLES |
e731d71b | 979 | |
7daaec4e BP |
980 | AT_BANNER([OVSDB -- ovsdb-server transactions (TCP IPv6 sockets)]) |
981 | ||
e731d71b AS |
982 | # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) |
983 | # | |
984 | # Creates a database with the given SCHEMA, starts an ovsdb-server on | |
985 | # that database, and runs each of the TRANSACTIONS (which should be a | |
986 | # quoted list of quoted strings) against it with ovsdb-client one at a | |
987 | # time. | |
988 | # | |
989 | # Checks that the overall output is OUTPUT, but UUIDs in the output | |
990 | # are replaced by markers of the form <N> where N is a number. The | |
991 | # first unique UUID is replaced by <0>, the next by <1>, and so on. | |
992 | # If a given UUID appears more than once it is always replaced by the | |
993 | # same marker. | |
994 | # | |
995 | # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. | |
996 | m4_define([OVSDB_CHECK_EXECUTION], | |
997 | [AT_SETUP([$1]) | |
998 | AT_KEYWORDS([ovsdb server positive tcp6 $5]) | |
4819b3a5 | 999 | AT_SKIP_IF([test $HAVE_IPV6 = no]) |
e731d71b AS |
1000 | $2 > schema |
1001 | PKIDIR=$abs_top_builddir/tests | |
1002 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) | |
56120500 | 1003 | AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile --remote=ptcp:0:[[::1]] db], [0], [ignore], [ignore]) |
fb28ef2d | 1004 | PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT]) |
e731d71b AS |
1005 | m4_foreach([txn], [$3], |
1006 | [AT_CHECK([ovsdb-client transact tcp:[[::1]]:$TCP_PORT 'txn'], [0], [stdout], [ignore], | |
1007 | [test ! -e pid || kill `cat pid`]) | |
1008 | cat stdout >> output | |
1009 | ]) | |
1010 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore], | |
1011 | [test ! -e pid || kill `cat pid`]) | |
1012 | OVSDB_SERVER_SHUTDOWN | |
1013 | AT_CLEANUP]) | |
1014 | ||
1015 | ONE_EXECUTION_EXAMPLE | |
9ff373db BP |
1016 | \f |
1017 | AT_BANNER([OVSDB -- transactions on transient ovsdb-server]) | |
1018 | ||
1019 | # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) | |
1020 | # | |
1021 | # Creates a database with the given SCHEMA and runs each of the | |
1022 | # TRANSACTIONS (which should be a quoted list of quoted strings) | |
1023 | # against it with ovsdb-client one at a time. Each ovsdb-client | |
1024 | # is run against a separately started ovsdb-server that executes | |
1025 | # only that single transaction. (The idea is that this should | |
1026 | # help to ferret out any differences between what ovsdb-server has | |
1027 | # in memory and what actually gets committed to disk.) | |
1028 | # | |
1029 | # Checks that the overall output is OUTPUT, but UUIDs in the output | |
1030 | # are replaced by markers of the form <N> where N is a number. The | |
1031 | # first unique UUID is replaced by <0>, the next by <1>, and so on. | |
1032 | # If a given UUID appears more than once it is always replaced by the | |
1033 | # same marker. | |
1034 | # | |
1035 | # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. | |
1036 | m4_define([OVSDB_CHECK_EXECUTION], | |
1037 | [AT_SETUP([$1]) | |
c17b52e8 | 1038 | AT_SKIP_IF([test "$IS_WIN32" = "yes"]) |
9ff373db | 1039 | AT_KEYWORDS([ovsdb server positive transient $5]) |
39ab07af | 1040 | $2 > schema |
9ff373db BP |
1041 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) |
1042 | m4_foreach([txn], [$3], | |
1043 | [AT_DATA([txnfile], [ovsdb-client transact unix:socket 'txn' | |
1044 | ]) | |
56120500 | 1045 | AT_CHECK([ovsdb-server --remote=punix:socket db --run="sh txnfile"], [0], [stdout], [ignore]) |
9ff373db BP |
1046 | cat stdout >> output |
1047 | ]) | |
5c6d0628 | 1048 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore]) |
9ff373db BP |
1049 | AT_CLEANUP]) |
1050 | ||
1051 | EXECUTION_EXAMPLES | |
ae671c5f | 1052 | \f |
63b35ecc | 1053 | AT_BANNER([OVSDB -- ovsdb-server replication]) |
ae671c5f MC |
1054 | |
1055 | # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) | |
1056 | # | |
1057 | # Creates two databases with the given SCHEMA, and starts an ovsdb-server on | |
1058 | # each database. | |
1059 | # Runs each of the TRANSACTIONS (which should be a quoted list of | |
1060 | # quoted strings) against one of the servers with ovsdb-client one at a | |
1061 | # time. The server replicates its database to the other ovsdb-server. | |
1062 | # | |
1063 | # Checks that the dump of both databases are the same. | |
1064 | # | |
1065 | # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. | |
1066 | m4_define([OVSDB_CHECK_EXECUTION], | |
1067 | [AT_SETUP([$1]) | |
1068 | AT_KEYWORDS([ovsdb server tcp replication $5]) | |
1069 | $2 > schema | |
1070 | AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore]) | |
1071 | AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore]) | |
1072 | ||
56120500 | 1073 | AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile --remote=punix:db.sock db1], [0], [ignore], [ignore]) |
5dd81c22 AZ |
1074 | i |
1075 | on_exit 'test ! -e pid || kill `cat pid`' | |
ae671c5f | 1076 | |
56120500 | 1077 | AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile=pid2 --remote=punix:db2.sock --unixctl=unixctl2 --sync-from=unix:db.sock db2], [0], [ignore], [ignore]) |
5dd81c22 | 1078 | on_exit 'test ! -e pid2 || kill `cat pid2`' |
ae671c5f MC |
1079 | |
1080 | m4_foreach([txn], [$3], | |
5dd81c22 | 1081 | [AT_CHECK([ovsdb-client transact 'txn'], [0], [stdout], [ignore]) |
ae671c5f MC |
1082 | ]) |
1083 | ||
5dd81c22 AZ |
1084 | AT_CHECK([ovsdb-client dump], [0], [stdout], [ignore]) |
1085 | OVS_WAIT_UNTIL([ ovsdb-client dump unix:db2.sock > dump2; diff stdout dump2]) | |
ae671c5f | 1086 | |
ae671c5f MC |
1087 | OVSDB_SERVER_SHUTDOWN |
1088 | OVSDB_SERVER_SHUTDOWN2 | |
1089 | AT_CLEANUP]) | |
1090 | ||
1091 | EXECUTION_EXAMPLES | |
7a9d65d2 | 1092 | |
63b35ecc | 1093 | AT_BANNER([OVSDB -- ovsdb-server replication table-exclusion]) |
7a9d65d2 MC |
1094 | |
1095 | # OVSDB_CHECK_REPLICATION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) | |
1096 | # | |
1097 | # Creates two databases with the given SCHEMA, and starts an | |
1098 | # ovsdb-server on each database. | |
1099 | # Runs each of the TRANSACTIONS (which should be a quoted list of | |
1100 | # quoted strings) against one of the servers with ovsdb-client one at a | |
1101 | # time. The server replicates its database to the other ovsdb-server. | |
1102 | # | |
1103 | # Checks that the difference between the dump of the databases is | |
1104 | # OUTPUT, but UUIDs in the output are replaced by markers of the form | |
1105 | # <N> where N is a number. The first unique UUID is replaced by <0>, | |
1106 | # the next by <1>, and so on. | |
1107 | # If a given UUID appears more than once it is always replaced by the | |
1108 | # same marker. | |
1109 | # | |
1110 | # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. | |
1111 | m4_define([OVSDB_CHECK_REPLICATION], | |
1112 | [AT_SETUP([$1]) | |
1113 | AT_KEYWORDS([ovsdb server tcp replication table-exclusion]) | |
1114 | $2 > schema | |
1115 | AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore]) | |
1116 | AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore]) | |
1117 | ||
56120500 | 1118 | AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile --remote=punix:db.sock db1], [0], [ignore], [ignore]) |
5dd81c22 | 1119 | on_exit 'test ! -e pid || kill `cat pid`' |
7a9d65d2 | 1120 | |
56120500 | 1121 | AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile=pid2 --remote=punix:db2.sock --unixctl=unixctl2 --sync-from=unix:db.sock --sync-exclude-tables=mydb:b db2], [0], [ignore], [ignore]) |
5dd81c22 | 1122 | on_exit 'test ! -e pid2 || kill `cat pid2`' |
7a9d65d2 MC |
1123 | |
1124 | m4_foreach([txn], [$3], | |
5dd81c22 | 1125 | [AT_CHECK([ ovsdb-client transact 'txn' ], [0], [stdout], [ignore]) |
7a9d65d2 MC |
1126 | ]) |
1127 | ||
5dd81c22 AZ |
1128 | AT_CHECK([ovsdb-client dump], [0], [stdout], [ignore]) |
1129 | cat stdout > dump1 | |
7a9d65d2 | 1130 | |
5dd81c22 AZ |
1131 | OVS_WAIT_UNTIL([ ovsdb-client dump unix:db2.sock | grep one ]) |
1132 | AT_CHECK([ovsdb-client dump unix:db2.sock], [0], [stdout], [ignore]) | |
1133 | cat stdout > dump2 | |
7a9d65d2 | 1134 | |
5dd81c22 AZ |
1135 | AT_CHECK([diff dump1 dump2], [1], [stdout], [ignore]) |
1136 | cat stdout > output | |
1137 | ||
1138 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore]) | |
7a9d65d2 MC |
1139 | |
1140 | OVSDB_SERVER_SHUTDOWN | |
1141 | OVSDB_SERVER_SHUTDOWN2 | |
1142 | AT_CLEANUP]) | |
1143 | ||
1144 | REPLICATION_EXAMPLES | |
9dc05cdc MC |
1145 | |
1146 | AT_BANNER([OVSDB -- ovsdb-server replication runtime management commands]) | |
1147 | ||
f53d7518 AZ |
1148 | #ovsdb-server/get-active-ovsdb-server command |
1149 | AT_SETUP([ovsdb-server/get-active-ovsdb-server]) | |
1150 | AT_KEYWORDS([ovsdb server replication get-active]) | |
9dc05cdc MC |
1151 | ordinal_schema > schema |
1152 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) | |
1153 | on_exit 'kill `cat *.pid`' | |
1154 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --sync-from=tcp:127.0.0.1:9999 db]) | |
1155 | ||
f53d7518 | 1156 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/get-active-ovsdb-server], |
9dc05cdc MC |
1157 | [0], [tcp:127.0.0.1:9999 |
1158 | ]) | |
1159 | AT_CLEANUP | |
1160 | ||
f53d7518 AZ |
1161 | #*ovsdb-server/set-active-ovsdb-server command |
1162 | AT_SETUP([ovsdb-server/set-active-ovsdb-server]) | |
1163 | AT_KEYWORDS([ovsdb server replication set-active]) | |
9dc05cdc MC |
1164 | ordinal_schema > schema |
1165 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) | |
1166 | on_exit 'kill `cat *.pid`' | |
1167 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile db]) | |
1168 | ||
f53d7518 AZ |
1169 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/set-active-ovsdb-server tcp:127.0.0.1:9999]) |
1170 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/get-active-ovsdb-server], | |
9dc05cdc MC |
1171 | [0], [tcp:127.0.0.1:9999 |
1172 | ]) | |
1173 | AT_CLEANUP | |
1174 | ||
60e0cd04 AZ |
1175 | #ovsdb-server/get-sync-exclude-tables command |
1176 | AT_SETUP([ovsdb-server/get-sync-exclude-tables]) | |
1177 | AT_KEYWORDS([ovsdb server replication get-exclude-tables]) | |
9dc05cdc MC |
1178 | ordinal_schema > schema |
1179 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) | |
1180 | on_exit 'kill `cat *.pid`' | |
1181 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --sync-exclude-tables=mydb:db1,mydb:db2 db]) | |
1182 | ||
60e0cd04 | 1183 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/get-sync-exclude-tables], |
3109b4e1 | 1184 | [0], [mydb:db1,mydb:db2 |
9dc05cdc MC |
1185 | ]) |
1186 | AT_CLEANUP | |
1187 | ||
60e0cd04 AZ |
1188 | #ovsdb-server/set-sync-exclude-tables command |
1189 | AT_SETUP([ovsdb-server/set-sync-exclude-tables]) | |
1190 | AT_KEYWORDS([ovsdb server replication set-exclude-tables]) | |
9dc05cdc MC |
1191 | replication_schema > schema |
1192 | AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore]) | |
1193 | AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore]) | |
1194 | ||
56120500 | 1195 | AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile --remote=punix:db.sock db1], [0], [ignore], [ignore]) |
5dd81c22 | 1196 | on_exit 'test ! -e pid || kill `cat pid`' |
9dc05cdc | 1197 | |
56120500 | 1198 | AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile=pid2 --remote=punix:db2.sock --unixctl=unixctl2 --sync-from=unix:db.sock db2], [0], [ignore], [ignore]) |
5dd81c22 | 1199 | on_exit 'test ! -e pid2 || kill `cat pid2`' |
9dc05cdc | 1200 | |
60e0cd04 | 1201 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/set-sync-exclude-tables mydb:b], [0], [ignore], [ignore], [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`]) |
9dc05cdc | 1202 | |
63b35ecc | 1203 | AT_CHECK([ovsdb-client transact unix:db.sock \ |
9dc05cdc MC |
1204 | '[["mydb", |
1205 | {"op": "insert", | |
1206 | "table": "a", | |
1207 | "row": {"number": 0, "name": "zero"}}, | |
1208 | {"op": "insert", | |
1209 | "table": "b", | |
1210 | "row": {"number": 1, "name": "one"}}]]'], [0], [stdout], [ignore], | |
1211 | [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`]) | |
9dc05cdc | 1212 | |
63b35ecc | 1213 | AT_CHECK([ovsdb-client dump unix:db.sock], [0], [stdout], [ignore], |
9dc05cdc | 1214 | [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`]) |
5dd81c22 AZ |
1215 | cat stdout > dump1 |
1216 | OVS_WAIT_UNTIL([ ovsdb-client dump unix:db2.sock | grep zero ]) | |
1217 | AT_CHECK([ovsdb-client dump unix:db2.sock], [0], [stdout], [ignore]) | |
1218 | cat stdout > dump2 | |
9dc05cdc | 1219 | |
5dd81c22 AZ |
1220 | AT_CHECK([diff dump1 dump2], [1], [stdout], [ignore]) |
1221 | cat stdout > output | |
9dc05cdc MC |
1222 | |
1223 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [7,9c7,8 | |
1224 | < _uuid name number | |
1225 | < ------------------------------------ ---- ------ | |
1226 | < <0> one 1 @&t@ | |
1227 | --- | |
1228 | > _uuid name number | |
1229 | > ----- ---- ------ | |
5dd81c22 | 1230 | ]) |
9dc05cdc MC |
1231 | |
1232 | OVSDB_SERVER_SHUTDOWN | |
1233 | OVSDB_SERVER_SHUTDOWN2 | |
1234 | AT_CLEANUP | |
1235 | ||
f53d7518 AZ |
1236 | #ovsdb-server/connect-active-ovsdb-server |
1237 | AT_SETUP([ovsdb-server/connect-active-server]) | |
1238 | AT_KEYWORDS([ovsdb server replication connect-active-server]) | |
9dc05cdc MC |
1239 | replication_schema > schema |
1240 | AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore]) | |
1241 | AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore]) | |
1242 | ||
56120500 | 1243 | AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile --remote=punix:db.sock db1], [0], [ignore], [ignore]) |
5dd81c22 | 1244 | on_exit 'test ! -e pid || kill `cat pid`' |
9dc05cdc | 1245 | |
56120500 | 1246 | AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile=pid2 --remote=punix:db2.sock --unixctl=unixctl2 db2], [0], [ignore], [ignore]) |
5dd81c22 | 1247 | on_exit 'test ! -e pid2 || kill `cat pid2`' |
9dc05cdc | 1248 | |
60e0cd04 AZ |
1249 | dnl Try to connect without specifying the active server. |
1250 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/connect-active-ovsdb-server], [0], | |
1251 | [Unable to connect: active server is not specified. | |
1252 | ], [ignore]) | |
1253 | ||
5dd81c22 | 1254 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/set-active-ovsdb-server unix:db.sock], [0], [stdout], [ignore]) |
9dc05cdc | 1255 | |
5dd81c22 | 1256 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/connect-active-ovsdb-server], [0], [stdout], [ignore]) |
9dc05cdc | 1257 | |
63b35ecc | 1258 | AT_CHECK([ovsdb-client transact unix:db.sock \ |
9dc05cdc MC |
1259 | '[["mydb", |
1260 | {"op": "insert", | |
1261 | "table": "a", | |
5dd81c22 | 1262 | "row": {"number": 0, "name": "zero"}}]]'], [0], [stdout], [ignore]) |
9dc05cdc | 1263 | |
5dd81c22 AZ |
1264 | AT_CHECK([ovsdb-client dump unix:db.sock], [0], [stdout], [ignore]) |
1265 | cat stdout > dump1 | |
1266 | OVS_WAIT_UNTIL([ ovsdb-client dump unix:db2.sock | grep zero ]) | |
1267 | AT_CHECK([ovsdb-client dump unix:db2.sock], [0], [stdout], [ignore]) | |
1268 | cat stdout > dump2 | |
9dc05cdc | 1269 | |
5dd81c22 | 1270 | AT_CHECK([diff dump1 dump2], [0], [], [ignore]) |
9dc05cdc MC |
1271 | OVSDB_SERVER_SHUTDOWN |
1272 | OVSDB_SERVER_SHUTDOWN2 | |
1273 | AT_CLEANUP | |
1274 | ||
f53d7518 AZ |
1275 | #ovsdb-server/disconnect-active-server command |
1276 | AT_SETUP([ovsdb-server/disconnect-active-server]) | |
1277 | AT_KEYWORDS([ovsdb server replication disconnect-active-server]) | |
9dc05cdc MC |
1278 | replication_schema > schema |
1279 | AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore]) | |
1280 | AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore]) | |
1281 | ||
56120500 | 1282 | AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile --remote=punix:db.sock db1], [0], [ignore], [ignore]) |
5dd81c22 | 1283 | on_exit 'test ! -e pid || kill `cat pid`' |
9dc05cdc | 1284 | |
56120500 | 1285 | AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile=pid2 --remote=punix:db2.sock --unixctl=unixctl2 --sync-from=unix:db.sock db2], [0], [ignore], [ignore]) |
5dd81c22 | 1286 | on_exit 'test ! -e pid2 || kill `cat pid2`' |
9dc05cdc | 1287 | |
63b35ecc | 1288 | AT_CHECK([ovsdb-client transact unix:db.sock \ |
9dc05cdc MC |
1289 | '[["mydb", |
1290 | {"op": "insert", | |
1291 | "table": "a", | |
5dd81c22 | 1292 | "row": {"number": 0, "name": "zero"}}]]'], [0], [stdout], [ignore]) |
f7525086 | 1293 | |
e51879e9 AZ |
1294 | dnl Make sure the transaction shows up in db2. This also tests the back up server |
1295 | dnl can be read. | |
63b35ecc | 1296 | OVS_WAIT_UNTIL([ovsdb-client dump unix:db2.sock | grep zero]) |
9dc05cdc | 1297 | |
e51879e9 AZ |
1298 | dnl The backup server does not accept any write transaction |
1299 | AT_CHECK([ovsdb-client transact unix:db2.sock \ | |
1300 | '[["mydb", | |
1301 | {"op": "insert", | |
1302 | "table": "b", | |
1303 | "row": {"number": 1, "name": "one"}}]]'], [0], | |
1304 | [[[{"details":"insert operation not allowed when database server is in read only mode","error":"not allowed"}]] | |
1305 | ]) | |
1306 | ||
5dd81c22 | 1307 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/disconnect-active-ovsdb-server], [0], [ignore], [ignore]) |
9dc05cdc | 1308 | |
63b35ecc | 1309 | AT_CHECK([ovsdb-client transact unix:db.sock \ |
9dc05cdc MC |
1310 | '[["mydb", |
1311 | {"op": "insert", | |
1312 | "table": "b", | |
5dd81c22 | 1313 | "row": {"number": 1, "name": "one"}}]]'], [0], [stdout], [ignore]) |
9dc05cdc | 1314 | |
5dd81c22 AZ |
1315 | AT_CHECK([ovsdb-client dump unix:db.sock], [0], [stdout], [ignore]) |
1316 | cat stdout > dump1 | |
9dc05cdc | 1317 | |
5dd81c22 AZ |
1318 | sleep 1 |
1319 | AT_CHECK([ovsdb-client dump unix:db2.sock], [0], [stdout], [ignore]) | |
1320 | cat stdout > dump2 | |
9dc05cdc | 1321 | |
5dd81c22 AZ |
1322 | AT_CHECK([diff dump1 dump2], [1], [stdout], [ignore]) |
1323 | cat stdout > output | |
9dc05cdc MC |
1324 | |
1325 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [7,9c7,8 | |
1326 | < _uuid name number | |
1327 | < ------------------------------------ ---- ------ | |
1328 | < <0> one 1 @&t@ | |
1329 | --- | |
1330 | > _uuid name number | |
1331 | > ----- ---- ------ | |
1332 | ], [ignore], [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`]) | |
1333 | ||
e51879e9 AZ |
1334 | dnl The backup server now become active, and can accept write transactions. |
1335 | AT_CHECK([ovsdb-client transact unix:db2.sock \ | |
1336 | '[["mydb", | |
1337 | {"op": "insert", | |
1338 | "table": "b", | |
5dd81c22 | 1339 | "row": {"number": 1, "name": "one"}}]]'], [0], [stdout], [ignore]) |
e51879e9 AZ |
1340 | |
1341 | AT_CHECK([ovsdb-client dump unix:db2.sock], [0], [stdout]) | |
1342 | cat stdout > output | |
1343 | ||
1344 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [a table | |
1345 | _uuid name number | |
1346 | ------------------------------------ ---- ------ | |
1347 | <0> zero 0 @&t@ | |
1348 | ||
1349 | b table | |
1350 | _uuid name number | |
1351 | ------------------------------------ ---- ------ | |
1352 | <1> one 1 @&t@ | |
1353 | ]) | |
1354 | ||
9dc05cdc MC |
1355 | OVSDB_SERVER_SHUTDOWN |
1356 | OVSDB_SERVER_SHUTDOWN2 | |
1357 | AT_CLEANUP | |
60e0cd04 AZ |
1358 | |
1359 | #ovsdb-server/active-backup-role-switching | |
1360 | AT_SETUP([ovsdb-server/active-backup-role-switching]) | |
1361 | AT_KEYWORDS([ovsdb server replication active-backup-switching]) | |
1362 | replication_schema > schema | |
1363 | AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore]) | |
1364 | AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore]) | |
1365 | ||
1366 | dnl Add some data to both DBs | |
1367 | AT_CHECK([ovsdb-tool transact db1 \ | |
1368 | '[["mydb", | |
1369 | {"op": "insert", | |
1370 | "table": "a", | |
1371 | "row": {"number": 9, "name": "nine"}}]]'], [0], [ignore], [ignore]) | |
1372 | ||
1373 | AT_CHECK([ovsdb-tool transact db2 \ | |
1374 | '[["mydb", | |
1375 | {"op": "insert", | |
1376 | "table": "a", | |
1377 | "row": {"number": 9, "name": "nine"}}]]'], [0], [ignore], [ignore]) | |
1378 | ||
1379 | dnl Start both 'db1' and 'db2' in backup mode. Let them backup from each | |
1380 | dnl other. This is not an supported operation state, but to simulate a start | |
1381 | dnl up condition where an HA manger can select which one to be an active | |
1382 | dnl server soon after. | |
1383 | AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile="`pwd`"/pid --remote=punix:db.sock --unixctl="`pwd`"/unixctl db1 --sync-from=unix:db2.sock --active ], [0], [ignore], [ignore]) | |
1384 | on_exit 'test ! -e pid || kill `cat pid`' | |
1385 | ||
1386 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/connect-active-ovsdb-server]) | |
1387 | ||
1388 | AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile="`pwd`"/pid2 --remote=punix:db2.sock --unixctl="`pwd`"/unixctl2 --sync-from=unix:db.sock db2], [0], [ignore], [ignore]) | |
1389 | on_exit 'test ! -e pid2 || kill `cat pid2`' | |
1390 | ||
1391 | dnl | |
1392 | dnl make sure both servers reached the replication state | |
1393 | OVS_WAIT_UNTIL([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/sync-status |grep replicating]) | |
1394 | OVS_WAIT_UNTIL([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/sync-status |grep replicating]) | |
1395 | ||
1396 | dnl Switch the 'db1' to active | |
1397 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/disconnect-active-ovsdb-server]) | |
1398 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/sync-status], [0], [state: active | |
1399 | ]) | |
1400 | ||
1401 | dnl Issue a transaction to 'db1' | |
1402 | AT_CHECK([ovsdb-client transact unix:db.sock \ | |
1403 | '[["mydb", | |
1404 | {"op": "insert", | |
1405 | "table": "a", | |
1406 | "row": {"number": 0, "name": "zero"}}]]'], [0], [ignore]) | |
1407 | ||
1408 | dnl It should be replicated to 'db2' | |
1409 | OVS_WAIT_UNTIL([ovsdb-client dump unix:db2.sock | grep zero]) | |
1410 | ||
1411 | dnl Flip the role of 'db1' and 'db2'. 'db1' becomes backup, and db2 becomes active | |
1412 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/disconnect-active-ovsdb-server]) | |
1413 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/connect-active-ovsdb-server]) | |
1414 | ||
1415 | dnl Verify the change happend | |
1416 | OVS_WAIT_UNTIL([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/sync-status |grep replicating]) | |
1417 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/sync-status], [0], [state: active | |
1418 | ]) | |
1419 | ||
1420 | dnl Issue an transaction to 'db2' which is now active. | |
1421 | AT_CHECK([ovsdb-client transact unix:db2.sock \ | |
1422 | '[["mydb", | |
1423 | {"op": "insert", | |
1424 | "table": "b", | |
1425 | "row": {"number": 1, "name": "one"}}]]'], [0], [ignore]) | |
1426 | ||
1427 | dnl The transaction should be replicated to 'db1' | |
1428 | OVS_WAIT_UNTIL([ovsdb-client dump unix:db.sock | grep one]) | |
1429 | ||
1430 | dnl Both servers should have the same content. | |
1431 | AT_CHECK([ovsdb-client dump unix:db.sock], [0], [stdout]) | |
1432 | cat stdout > dump1 | |
1433 | ||
1434 | AT_CHECK([ovsdb-client dump unix:db2.sock], [0], [stdout]) | |
1435 | cat stdout > dump2 | |
1436 | ||
1437 | AT_CHECK([diff dump1 dump2]) | |
1438 | ||
1439 | dnl OVSDB_SERVER_SHUTDOWN | |
1440 | dnl OVSDB_SERVER_SHUTDOWN2 | |
1441 | AT_CLEANUP | |
9c1a1182 | 1442 | |
05ac209a AZ |
1443 | #ovsdb-server prevent self replicating |
1444 | AT_SETUP([ovsdb-server prevent self replicating]) | |
1445 | AT_KEYWORDS([ovsdb server replication]) | |
1446 | replication_schema > schema | |
1447 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) | |
1448 | ||
1449 | dnl Add some data to both DBs | |
1450 | AT_CHECK([ovsdb-tool transact db \ | |
1451 | '[["mydb", | |
1452 | {"op": "insert", | |
1453 | "table": "a", | |
1454 | "row": {"number": 9, "name": "nine"}}]]'], [0], [ignore], [ignore]) | |
1455 | ||
1456 | dnl Start 'db', then try to be a back up server of itself. | |
1457 | AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server.log --pidfile="`pwd`"/pid --remote=punix:db.sock --unixctl="`pwd`"/unixctl db --sync-from=unix:db.sock --active ], [0], [ignore], [ignore]) | |
1458 | on_exit 'test ! -e pid || kill `cat pid`' | |
1459 | ||
1460 | dnl Save the current content | |
1461 | AT_CHECK([ovsdb-client dump unix:db.sock], [0], [stdout]) | |
1462 | cp stdout dump1 | |
1463 | ||
1464 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/connect-active-ovsdb-server]) | |
1465 | dnl Check that self replicating is blocked. | |
1466 | AT_CHECK([grep "Self replicating is not allowed" ovsdb-server.log], [0], [stdout]) | |
1467 | ||
1468 | dnl Check current DB content is preserved. | |
1469 | AT_CHECK([ovsdb-client dump unix:db.sock], [0], [stdout]) | |
1470 | cat stdout > dump2 | |
1471 | ||
1472 | AT_CHECK([diff dump1 dump2]) | |
1473 | AT_CLEANUP | |
1474 | ||
9c1a1182 LR |
1475 | AT_SETUP([ovsdb-server/read-only db:ptcp connection]) |
1476 | AT_KEYWORDS([ovsdb server read-only]) | |
1477 | AT_DATA([schema], | |
1478 | [[{"name": "mydb", | |
1479 | "tables": { | |
1480 | "Root": { | |
1481 | "columns": { | |
1482 | "managers": { | |
1483 | "type": { | |
1484 | "key": {"type": "uuid", "refTable": "Manager"}, | |
1485 | "min": 0, | |
1486 | "max": "unlimited"}}}}, | |
1487 | "Manager": { | |
1488 | "columns": { | |
1489 | "target": { | |
1490 | "type": "string"}, | |
1491 | "read_only": { | |
1492 | "type": { | |
1493 | "key": "boolean", | |
1494 | "min": 0, | |
1495 | "max": 1}}, | |
1496 | "is_connected": { | |
1497 | "type": { | |
1498 | "key": "boolean", | |
1499 | "min": 0, | |
1500 | "max": 1}}}}, | |
1501 | "ordinals": { | |
1502 | "columns": { | |
1503 | "number": {"type": "integer"}, | |
1504 | "name": {"type": "string"}}, | |
1505 | "indexes": [["number"]]} | |
1506 | }, | |
1507 | "version": "5.1.3", | |
1508 | "cksum": "12345678 9" | |
1509 | } | |
1510 | ]]) | |
1511 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) | |
1512 | AT_CHECK( | |
1513 | [[ovsdb-tool transact db \ | |
1514 | '["mydb", | |
1515 | {"op": "insert", | |
1516 | "table": "Root", | |
1517 | "row": { | |
1518 | "managers": ["set", [["named-uuid", "x"]]]}}, | |
1519 | {"op": "insert", | |
1520 | "table": "Manager", | |
1521 | "uuid-name": "x", | |
1522 | "row": {"target": "ptcp:0:127.0.0.1", | |
1523 | "read_only": true}}]']], [0], [ignore], [ignore]) | |
1524 | ||
1525 | AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile --remote=db:mydb,Root,managers db], [0], [ignore], [ignore]) | |
1526 | PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT]) | |
1527 | AT_CHECK([ovsdb-client get-schema-version tcp:127.0.0.1:$TCP_PORT mydb], [0], [5.1.3 | |
1528 | ]) | |
1529 | ||
1530 | AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT \ | |
1531 | ['["mydb", | |
1532 | {"op": "insert", | |
1533 | "table": "ordinals", | |
1534 | "row": {"name": "two", "number": '2'}} | |
1535 | ]']], [0], [stdout], [ignore]) | |
1536 | cat stdout >> output | |
1537 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [[[{"details":"insert operation not allowed when database server is in read only mode","error":"not allowed"}]] | |
1538 | ], [ignore]) | |
1539 | OVSDB_SERVER_SHUTDOWN | |
1540 | AT_CLEANUP |