]>
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 | ]) | |
c724bd67 | 36 | AT_CHECK([uuidfilt 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 |
c724bd67 | 84 | AT_CHECK([uuidfilt 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 |
c724bd67 | 132 | AT_CHECK([uuidfilt 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 | ||
6bb9b060 BP |
140 | dnl CHECK_DBS([databases]) |
141 | dnl | |
142 | dnl Checks that ovsdb-server hosts the given 'databases', each of which | |
143 | dnl needs to be followed by a newline. | |
144 | m4_define([CHECK_DBS], | |
145 | [AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs], | |
146 | [0], [_Server | |
147 | $1]) | |
148 | AT_CHECK([ovsdb-client --no-headings dump _Server Database name | sort], [0], [dnl | |
149 | Database table | |
150 | _Server | |
151 | $1])]) | |
152 | ||
9cb53f26 BP |
153 | AT_SETUP([database multiplexing implementation]) |
154 | AT_KEYWORDS([ovsdb server positive]) | |
b4e8d170 BP |
155 | ordinal_schema > schema1 |
156 | constraint_schema > schema2 | |
157 | AT_CHECK([ovsdb-tool create db1 schema1], [0], [ignore], [ignore]) | |
158 | AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore]) | |
6bb9b060 BP |
159 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:db.sock db1 db2], [0], [ignore], [ignore]) |
160 | CHECK_DBS([constraints | |
b4e8d170 | 161 | ordinals |
6bb9b060 | 162 | ]) |
9cb53f26 | 163 | AT_CHECK( |
6bb9b060 | 164 | [[ovstest test-jsonrpc request unix:db.sock get_schema [\"nonexistent\"]]], [0], |
508624b6 | 165 | [[{"error":{"details":"get_schema request specifies unknown database nonexistent","error":"unknown database","syntax":"[\"nonexistent\"]"},"id":0,"result":null} |
53ffefe9 | 166 | ]], [], [test ! -e pid || kill `cat pid`]) |
9cb53f26 BP |
167 | OVSDB_SERVER_SHUTDOWN |
168 | AT_CLEANUP | |
169 | ||
0a3b723b BP |
170 | AT_SETUP([ovsdb-server/add-db and remove-db]) |
171 | AT_KEYWORDS([ovsdb server positive]) | |
10621d79 | 172 | on_exit 'kill `cat *.pid`' |
0a3b723b BP |
173 | ordinal_schema > schema1 |
174 | constraint_schema > schema2 | |
175 | AT_CHECK([ovsdb-tool create db1 schema1], [0], [ignore], [ignore]) | |
176 | AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore]) | |
177 | ||
178 | # Start ovsdb-server with just a single database - db1. | |
10621d79 BP |
179 | AT_CHECK([ovsdb-server -vfile -vvlog:off --log-file --detach --no-chdir --pidfile --remote=punix:db.sock db1], [0]) |
180 | CHECK_DBS([ordinals | |
181 | ]) | |
182 | ||
183 | # Remove the database. | |
184 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db ordinals], [0]) | |
185 | CHECK_DBS([]) | |
186 | ||
187 | # Start monitoring processes. | |
9a403b07 BP |
188 | AT_CHECK([ovsdb-client --detach --no-chdir --pidfile=ovsdb-client-1.pid --no-db-change-aware --no-headings monitor _Server Database name > db-change-unaware.stdout 2> db-change-unaware.stderr]) |
189 | AT_CHECK([ovsdb-client --detach --no-chdir --pidfile=ovsdb-client-2.pid --db-change-aware --no-headings monitor _Server Database name > db-change-aware.stdout 2> db-change-aware.stderr]) | |
10621d79 BP |
190 | AT_CAPTURE_FILE([db-change-unaware.stdout]) |
191 | AT_CAPTURE_FILE([db-change-unaware.stderr]) | |
192 | AT_CAPTURE_FILE([db-change-aware.stdout]) | |
193 | AT_CAPTURE_FILE([db-change-aware.stderr]) | |
194 | ||
195 | # Add the first database back. | |
196 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db1], [0]) | |
6bb9b060 | 197 | CHECK_DBS([ordinals |
0a3b723b BP |
198 | ]) |
199 | ||
200 | # Add the second database. | |
201 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], [0]) | |
6bb9b060 | 202 | CHECK_DBS([constraints |
0a3b723b BP |
203 | ordinals |
204 | ]) | |
205 | ||
206 | # The databases are responsive. | |
6bb9b060 BP |
207 | AT_CHECK([ovsdb-client list-tables unix:db.sock constraints], [0], [ignore], [ignore]) |
208 | AT_CHECK([ovsdb-client list-tables unix:db.sock ordinals], [0], [ignore], [ignore]) | |
0a3b723b BP |
209 | |
210 | # Add an already added database. | |
bd270dc3 GS |
211 | if test $IS_WIN32 = "yes"; then |
212 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], 2, [], | |
213 | [I/O error: db2: failed to lock lockfile (Resource deadlock avoided) | |
214 | ovs-appctl: ovsdb-server: server returned an error | |
215 | ]) | |
216 | else | |
217 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], 2, [], | |
1b1d2e6d | 218 | [ovsdb error: db2: already open |
0a3b723b BP |
219 | ovs-appctl: ovsdb-server: server returned an error |
220 | ]) | |
bd270dc3 | 221 | fi |
0a3b723b BP |
222 | |
223 | # Add a non-existing database. | |
224 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db3], 2, [], [stderr]) | |
225 | AT_CHECK([sed 's/(.*)/(...)/' stderr], [0], | |
a6be657b | 226 | [I/O error: db3: open failed (...) |
0a3b723b BP |
227 | ovs-appctl: ovsdb-server: server returned an error |
228 | ]) | |
229 | ||
230 | # Add a remote through a db path in db1. | |
231 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote db:ordinals,ordinals,name], [0]) | |
232 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes], | |
233 | [0], [db:ordinals,ordinals,name | |
6bb9b060 | 234 | punix:db.sock |
0a3b723b BP |
235 | ]) |
236 | ||
237 | # Removing db1 has no effect on its remote. | |
238 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db ordinals], [0]) | |
6bb9b060 | 239 | CHECK_DBS([constraints |
0a3b723b BP |
240 | ]) |
241 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes], | |
242 | [0], [db:ordinals,ordinals,name | |
6bb9b060 | 243 | punix:db.sock |
0a3b723b | 244 | ]) |
6bb9b060 | 245 | AT_CHECK([ovsdb-client list-tables unix:db.sock ordinals], [1], [ignore], [ignore]) |
0a3b723b BP |
246 | |
247 | # Remove db2. | |
248 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db constraints], [0]) | |
6bb9b060 BP |
249 | CHECK_DBS() |
250 | AT_CHECK([ovsdb-client list-tables unix:db.sock constraints], [1], [ignore], [ignore]) | |
0a3b723b BP |
251 | |
252 | # Remove a non-existent database. | |
253 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db ordinals], [2], | |
254 | [], [Failed to find the database. | |
255 | ovs-appctl: ovsdb-server: server returned an error | |
256 | ]) | |
3fc53787 GS |
257 | |
258 | # Add a removed database. | |
259 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], [0]) | |
6bb9b060 | 260 | CHECK_DBS([constraints |
3fc53787 | 261 | ]) |
6bb9b060 | 262 | AT_CHECK([ovsdb-client list-tables unix:db.sock constraints], [0], [ignore], [ignore]) |
10621d79 BP |
263 | |
264 | # Check the monitoring results. | |
265 | AT_CHECK([uuidfilt db-change-aware.stdout], [0], [dnl | |
266 | <0> initial _Server | |
267 | ||
268 | <1> insert ordinals | |
269 | ||
270 | <2> insert constraints | |
271 | ||
272 | <1> delete ordinals | |
273 | ||
274 | <2> delete constraints | |
275 | ||
276 | <3> insert constraints | |
277 | ]) | |
278 | AT_CHECK([uuidfilt db-change-unaware.stdout], [0], [dnl | |
279 | <0> initial _Server | |
280 | ]) | |
281 | ||
d9c8c57c | 282 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) |
0a3b723b BP |
283 | AT_CLEANUP |
284 | ||
d7ae8d6b | 285 | AT_SETUP([ovsdb-server/add-db with --monitor]) |
0a3b723b | 286 | AT_KEYWORDS([ovsdb server positive]) |
36373c1a | 287 | AT_SKIP_IF([test "$IS_WIN32" = "yes"]) |
5f223e92 BP |
288 | |
289 | # This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it. | |
290 | ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS | |
291 | ||
0a3b723b | 292 | # Start ovsdb-server, initially with one db. |
0a3b723b BP |
293 | ordinal_schema > schema |
294 | AT_CHECK([ovsdb-tool create db1 schema], [0], [ignore], [ignore]) | |
53eb8cb8 | 295 | on_exit 'kill `cat *.pid`' |
1b1d2e6d | 296 | AT_CHECK([ovsdb-server -vfile -vvlog:off --monitor --detach --no-chdir --pidfile --log-file --remote=punix:db.sock db1]) |
0a3b723b BP |
297 | |
298 | # Add the second database. | |
299 | constraint_schema > schema2 | |
300 | AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore]) | |
301 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], [0]) | |
6bb9b060 | 302 | CHECK_DBS([constraints |
0a3b723b BP |
303 | ordinals |
304 | ]) | |
305 | ||
306 | # Kill the daemon process, making it look like a segfault, | |
307 | # and wait for a new daemon process to get spawned. | |
308 | cp ovsdb-server.pid old.pid | |
309 | AT_CHECK([kill -SEGV `cat ovsdb-server.pid`]) | |
310 | OVS_WAIT_WHILE([kill -0 `cat old.pid`]) | |
311 | OVS_WAIT_UNTIL( | |
312 | [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`]) | |
857570c4 | 313 | OVS_WAIT_UNTIL([ovs-appctl -t ovsdb-server version]) |
6bb9b060 | 314 | CHECK_DBS([constraints |
0a3b723b BP |
315 | ordinals |
316 | ]) | |
d9c8c57c | 317 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) |
d7ae8d6b BP |
318 | AT_CLEANUP |
319 | ||
320 | AT_SETUP([ovsdb-server/add-db and remove-db with --monitor]) | |
321 | AT_KEYWORDS([ovsdb server positive]) | |
36373c1a | 322 | AT_SKIP_IF([test "$IS_WIN32" = "yes"]) |
5f223e92 BP |
323 | |
324 | # This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it. | |
325 | ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS | |
326 | ||
d7ae8d6b | 327 | # Start ovsdb-server, initially with one db. |
d7ae8d6b BP |
328 | ordinal_schema > schema |
329 | AT_CHECK([ovsdb-tool create db1 schema], [0], [ignore], [ignore]) | |
330 | constraint_schema > schema2 | |
331 | AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore]) | |
53eb8cb8 | 332 | on_exit 'kill `cat *.pid`' |
1b1d2e6d | 333 | AT_CHECK([ovsdb-server -vfile -vvlog:off --monitor --detach --no-chdir --pidfile --log-file --remote=punix:db.sock db1 db2]) |
0a3b723b | 334 | |
d7ae8d6b | 335 | # Remove the second database. |
0a3b723b | 336 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db constraints]) |
6bb9b060 | 337 | CHECK_DBS([ordinals |
0a3b723b BP |
338 | ]) |
339 | ||
340 | # Kill the daemon process, making it look like a segfault, | |
341 | # and wait for a new daemon process to get spawned. | |
342 | cp ovsdb-server.pid old.pid | |
343 | AT_CHECK([kill -SEGV `cat ovsdb-server.pid`]) | |
344 | OVS_WAIT_WHILE([kill -0 `cat old.pid`]) | |
345 | OVS_WAIT_UNTIL( | |
346 | [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`]) | |
857570c4 | 347 | OVS_WAIT_UNTIL([ovs-appctl -t ovsdb-server version]) |
6bb9b060 | 348 | CHECK_DBS([ordinals |
0a3b723b | 349 | ]) |
d9c8c57c | 350 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) |
0a3b723b BP |
351 | AT_CLEANUP |
352 | ||
0b1fae1b BP |
353 | AT_SETUP([--remote=db: implementation]) |
354 | AT_KEYWORDS([ovsdb server positive]) | |
355 | AT_DATA([schema], | |
356 | [[{"name": "mydb", | |
357 | "tables": { | |
b4e8d170 BP |
358 | "Root": { |
359 | "columns": { | |
360 | "managers": { | |
361 | "type": { | |
362 | "key": "string", | |
363 | "min": 0, | |
364 | "max": "unlimited"}}, | |
365 | "manager_options": { | |
366 | "type": { | |
367 | "key": {"type": "uuid", "refTable": "Manager"}, | |
368 | "min": 0, | |
369 | "max": "unlimited"}}}}, | |
0b1fae1b BP |
370 | "Manager": { |
371 | "columns": { | |
b4e8d170 BP |
372 | "target": { |
373 | "type": "string"}, | |
374 | "is_connected": { | |
375 | "type": { | |
376 | "key": "boolean", | |
377 | "min": 0, | |
378 | "max": 1}}}}}} | |
0b1fae1b | 379 | ]]) |
7c126fbb BP |
380 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) |
381 | AT_CHECK( | |
0b1fae1b | 382 | [[ovsdb-tool transact db \ |
9cb53f26 | 383 | '["mydb", |
b4e8d170 BP |
384 | {"op": "insert", |
385 | "table": "Root", | |
386 | "row": { | |
387 | "managers": "punix:socket1", | |
388 | "manager_options": ["set", [["named-uuid", "x"]]]}}, | |
9cb53f26 | 389 | {"op": "insert", |
0b1fae1b | 390 | "table": "Manager", |
b4e8d170 BP |
391 | "uuid-name": "x", |
392 | "row": {"target": "punix:socket2"}}]']], [0], [ignore], [ignore]) | |
53eb8cb8 | 393 | on_exit 'kill `cat ovsdb-server.pid`' |
8ad822c9 | 394 | 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 | 395 | ovs-appctl -t ovsdb-server time/warp 6000 1000 |
7c126fbb | 396 | AT_CHECK( |
b4e8d170 | 397 | [[ovsdb-client transact unix:socket1 \ |
9cb53f26 | 398 | '["mydb", |
b4e8d170 BP |
399 | {"op": "select", |
400 | "table": "Root", | |
401 | "where": [], | |
402 | "columns": ["managers"]}, | |
9cb53f26 | 403 | {"op": "select", |
0b1fae1b BP |
404 | "table": "Manager", |
405 | "where": [], | |
b4e8d170 BP |
406 | "columns": ["target", "is_connected"]}]']], |
407 | [0], [stdout], [ignore]) | |
0b1fae1b | 408 | AT_CHECK( |
c724bd67 | 409 | [uuidfilt stdout], |
0b1fae1b | 410 | [0], |
b4e8d170 | 411 | [[[{"rows":[{"managers":"punix:socket1"}]},{"rows":[{"is_connected":false,"target":"punix:socket2"}]}] |
0b1fae1b | 412 | ]], |
b4e8d170 | 413 | [ignore]) |
d9c8c57c | 414 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) |
0b1fae1b | 415 | AT_CLEANUP |
ada496b5 | 416 | |
b421d2af BP |
417 | AT_SETUP([ovsdb-server/add-remote and remove-remote]) |
418 | AT_KEYWORDS([ovsdb server positive]) | |
b421d2af BP |
419 | ordinal_schema > schema |
420 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) | |
53eb8cb8 | 421 | on_exit 'kill `cat *.pid`' |
b421d2af BP |
422 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile db]) |
423 | ||
424 | AT_CHECK([test ! -e socket1]) | |
425 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1]) | |
91fc9298 | 426 | if test "$IS_WIN32" = "yes"; then |
922247c6 | 427 | OVS_WAIT_UNTIL([test -e socket1]) |
91fc9298 GS |
428 | else |
429 | OVS_WAIT_UNTIL([test -S socket1]) | |
430 | fi | |
b421d2af BP |
431 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes], |
432 | [0], [punix:socket1 | |
433 | ]) | |
434 | ||
435 | AT_CHECK([test ! -e socket2]) | |
436 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket2]) | |
91fc9298 | 437 | if test "$IS_WIN32" = "yes"; then |
922247c6 | 438 | OVS_WAIT_UNTIL([test -e socket2]) |
91fc9298 GS |
439 | else |
440 | OVS_WAIT_UNTIL([test -S socket2]) | |
441 | fi | |
b421d2af BP |
442 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes], |
443 | [0], [punix:socket1 | |
444 | punix:socket2 | |
445 | ]) | |
446 | ||
447 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote db:x,y,z], [2], | |
448 | [], ["db:x,y,z": no database named x | |
449 | ovs-appctl: ovsdb-server: server returned an error | |
450 | ]) | |
451 | ||
452 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket1]) | |
453 | OVS_WAIT_UNTIL([test ! -e socket1]) | |
91fc9298 | 454 | if test "$IS_WIN32" = "yes"; then |
922247c6 | 455 | AT_CHECK([test -e socket2]) |
91fc9298 GS |
456 | else |
457 | AT_CHECK([test -S socket2]) | |
458 | fi | |
b421d2af BP |
459 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes], |
460 | [0], [punix:socket2 | |
461 | ]) | |
462 | ||
463 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket2]) | |
464 | OVS_WAIT_UNTIL([test ! -e socket2]) | |
465 | AT_CHECK([test ! -e socket1]) | |
466 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes]) | |
d9c8c57c | 467 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) |
b421d2af BP |
468 | AT_CLEANUP |
469 | ||
09993217 | 470 | AT_SETUP([ovsdb-server/add-remote with --monitor]) |
5f36127e | 471 | AT_KEYWORDS([ovsdb server positive]) |
36373c1a | 472 | AT_SKIP_IF([test "$IS_WIN32" = "yes"]) |
5f223e92 BP |
473 | |
474 | # This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it. | |
475 | ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS | |
476 | ||
5f36127e | 477 | # Start ovsdb-server, initially with no remotes. |
5f36127e BP |
478 | ordinal_schema > schema |
479 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) | |
53eb8cb8 | 480 | on_exit 'kill `cat *.pid`' |
1b1d2e6d | 481 | AT_CHECK([ovsdb-server -vfile -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db]) |
5f36127e BP |
482 | |
483 | # Add a remote. | |
484 | AT_CHECK([test ! -e socket1]) | |
485 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1]) | |
486 | OVS_WAIT_UNTIL([test -S socket1]) | |
487 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes], | |
488 | [0], [punix:socket1 | |
489 | ]) | |
490 | ||
491 | # Kill the daemon process, making it look like a segfault, | |
492 | # and wait for a new daemon process to get spawned and for it to | |
493 | # start listening on 'socket1'. | |
494 | cp ovsdb-server.pid old.pid | |
495 | rm socket1 | |
496 | AT_CHECK([kill -SEGV `cat ovsdb-server.pid`]) | |
497 | OVS_WAIT_WHILE([kill -0 `cat old.pid`]) | |
498 | OVS_WAIT_UNTIL( | |
499 | [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`]) | |
857570c4 | 500 | OVS_WAIT_UNTIL([ovs-appctl -t ovsdb-server version]) |
5f36127e | 501 | OVS_WAIT_UNTIL([test -S socket1]) |
d9c8c57c | 502 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) |
09993217 AW |
503 | AT_CLEANUP |
504 | ||
505 | AT_SETUP([ovsdb-server/add-remote and remove-remote with --monitor]) | |
506 | AT_KEYWORDS([ovsdb server positive]) | |
36373c1a | 507 | AT_SKIP_IF([test "$IS_WIN32" = "yes"]) |
5f223e92 BP |
508 | |
509 | # This test intentionally causes SIGSEGV, so make Address Sanitizer ignore it. | |
510 | ASAN_OPTIONS=$ASAN_OPTIONS:handle_segv=0; export ASAN_OPTIONS | |
511 | ||
09993217 | 512 | # Start ovsdb-server, initially with no remotes. |
09993217 AW |
513 | ordinal_schema > schema |
514 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) | |
53eb8cb8 | 515 | on_exit 'kill `cat *.pid`' |
1b1d2e6d | 516 | AT_CHECK([ovsdb-server -vfile -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db]) |
09993217 AW |
517 | |
518 | # Add a remote. | |
519 | AT_CHECK([test ! -e socket1]) | |
520 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1]) | |
521 | OVS_WAIT_UNTIL([test -S socket1]) | |
522 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes], | |
523 | [0], [punix:socket1 | |
524 | ]) | |
5f36127e BP |
525 | |
526 | # Remove the remote. | |
527 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket1]) | |
528 | OVS_WAIT_UNTIL([test ! -e socket1]) | |
529 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes]) | |
530 | ||
531 | # Kill the daemon process, making it look like a segfault, | |
532 | # and wait for a new daemon process to get spawned and make sure that it | |
533 | # does not listen on 'socket1'. | |
534 | cp ovsdb-server.pid old.pid | |
535 | AT_CHECK([kill -SEGV `cat ovsdb-server.pid`]) | |
536 | OVS_WAIT_WHILE([kill -0 `cat old.pid`]) | |
537 | OVS_WAIT_UNTIL( | |
538 | [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`]) | |
857570c4 | 539 | OVS_WAIT_UNTIL([ovs-appctl -t ovsdb-server version]) |
5f36127e | 540 | AT_CHECK([test ! -e socket1]) |
d9c8c57c | 541 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) |
5f36127e BP |
542 | AT_CLEANUP |
543 | ||
78876719 BP |
544 | AT_SETUP([SSL db: implementation]) |
545 | AT_KEYWORDS([ovsdb server positive ssl $5]) | |
546 | AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) | |
b028245a GS |
547 | # For this test, we pass PKIDIR through a ovsdb-tool transact and |
548 | # msys on Windows does not convert the path style automatically. | |
549 | # So, do that forcefully with a 'pwd -W' (called through pwd() function). | |
550 | PKIDIR="$(cd $abs_top_builddir/tests && pwd)" | |
5a0e4aec | 551 | AT_SKIP_IF([expr "$PKIDIR" : ".*[ '\" |
0bcff889 | 552 | \\]"]) |
78876719 BP |
553 | AT_DATA([schema], |
554 | [[{"name": "mydb", | |
555 | "tables": { | |
556 | "SSL": { | |
557 | "columns": { | |
558 | "private_key": {"type": "string"}, | |
559 | "certificate": {"type": "string"}, | |
e18a1d08 ER |
560 | "ca_cert": {"type": "string"}, |
561 | "ssl_protocols" : {"type": "string"}, | |
562 | "ssl_ciphers" : {"type" : "string"}}}}} | |
78876719 BP |
563 | ]]) |
564 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) | |
e18a1d08 ER |
565 | # The !ECDHE-ECDSA-AES256-GCM-SHA384 in the ssl_ciphers is so that |
566 | # a cipher negotiation failure can be tested for later. | |
78876719 BP |
567 | AT_CHECK( |
568 | [[ovsdb-tool transact db \ | |
569 | '["mydb", | |
570 | {"op": "insert", | |
571 | "table": "SSL", | |
572 | "row": {"private_key": "'"$PKIDIR/testpki-privkey2.pem"'", | |
573 | "certificate": "'"$PKIDIR/testpki-cert2.pem"'", | |
e18a1d08 ER |
574 | "ca_cert": "'"$PKIDIR/testpki-cacert.pem"'", |
575 | "ssl_protocols": "'"TLSv1.2,TLSv1.1"'", | |
576 | "ssl_ciphers": "'"HIGH:!aNULL:!MD5:!ECDHE-ECDSA-AES256-GCM-SHA384"'"}}]']], | |
78876719 | 577 | [0], [ignore], [ignore]) |
c6c17485 | 578 | on_exit 'kill `cat *.pid`' |
78876719 | 579 | AT_CHECK( |
56120500 | 580 | [ovsdb-server --log-file --detach --no-chdir --pidfile \ |
fb6de52c GS |
581 | --private-key=db:mydb,SSL,private_key \ |
582 | --certificate=db:mydb,SSL,certificate \ | |
583 | --ca-cert=db:mydb,SSL,ca_cert \ | |
e18a1d08 ER |
584 | --ssl-protocols=db:mydb,SSL,ssl_protocols \ |
585 | --ssl-ciphers=db:mydb,SSL,ssl_ciphers \ | |
56120500 | 586 | --remote=pssl:0:127.0.0.1 db], |
78876719 | 587 | [0], [ignore], [ignore]) |
fb28ef2d | 588 | PARSE_LISTENING_PORT([ovsdb-server.log], [SSL_PORT]) |
78876719 BP |
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 \ | |
e18a1d08 ER |
594 | --ssl-protocols=TLSv1.2,TLSv1.1 \ |
595 | --ssl-ciphers=HIGH:!aNULL:!MD5 \ | |
78876719 BP |
596 | transact ssl:127.0.0.1:$SSL_PORT \ |
597 | '["mydb", | |
598 | {"op": "select", | |
599 | "table": "SSL", | |
600 | "where": [], | |
e18a1d08 | 601 | "columns": ["private_key"]}]']], |
c6c17485 | 602 | [0], [stdout], [ignore]) |
78876719 BP |
603 | cat stdout >> output |
604 | AT_CHECK_UNQUOTED( | |
b33bff0f | 605 | [cat output], [0], |
0877a018 | 606 | [[@<:@{"rows":@<:@{"private_key":"$PKIDIR/testpki-privkey2.pem"}@:>@}@:>@ |
c6c17485 | 607 | ]], [ignore]) |
e18a1d08 ER |
608 | # Check that when the server has TLSv1.1+ and the client has |
609 | # TLSv1 that the connection fails. | |
610 | AT_CHECK( | |
611 | [[ovsdb-client \ | |
612 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
613 | --certificate=$PKIDIR/testpki-cert.pem \ | |
614 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
615 | --ssl-protocols=TLSv1 \ | |
616 | --ssl-ciphers=HIGH:!aNULL:!MD5 \ | |
617 | transact ssl:127.0.0.1:$SSL_PORT \ | |
618 | '["mydb", | |
619 | {"op": "select", | |
620 | "table": "SSL", | |
621 | "where": [], | |
622 | "columns": ["private_key"]}]']], | |
623 | [1], [stdout], | |
c6c17485 | 624 | [stderr]) |
e18a1d08 ER |
625 | cat stderr > output |
626 | AT_CHECK_UNQUOTED( | |
efd71505 BP |
627 | [sed -n "/failed to connect/s/ (.*)//p" output], [0], |
628 | [ovsdb-client: failed to connect to "ssl:127.0.0.1:$SSL_PORT" | |
e18a1d08 | 629 | ], |
c6c17485 | 630 | [ignore]) |
e18a1d08 ER |
631 | # Check that when ciphers are not compatible, that a negotiation |
632 | # failure occurs. | |
633 | AT_CHECK( | |
634 | [[ovsdb-client \ | |
635 | --private-key=$PKIDIR/testpki-privkey.pem \ | |
636 | --certificate=$PKIDIR/testpki-cert.pem \ | |
637 | --ca-cert=$PKIDIR/testpki-cacert.pem \ | |
638 | --ssl-protocols=TLSv1.2,TLSv1.1 \ | |
639 | --ssl-ciphers=ECDHE-ECDSA-AES256-GCM-SHA384 \ | |
640 | transact ssl:127.0.0.1:$SSL_PORT \ | |
641 | '["mydb", | |
642 | {"op": "select", | |
643 | "table": "SSL", | |
644 | "where": [], | |
645 | "columns": ["private_key"]}]']], | |
646 | [1], [stdout], | |
c6c17485 | 647 | [stderr]) |
e18a1d08 ER |
648 | cat stderr > output |
649 | AT_CHECK_UNQUOTED( | |
efd71505 BP |
650 | [sed -n "/failed to connect/s/ (.*)//p" output], [0], |
651 | [ovsdb-client: failed to connect to "ssl:127.0.0.1:$SSL_PORT" | |
e18a1d08 | 652 | ], |
c6c17485 | 653 | [ignore]) |
e18a1d08 ER |
654 | # The error message for being unable to negotiate a shared ciphersuite |
655 | # is 'sslv3 alert handshake failure'. This is not the clearest message. | |
656 | AT_CHECK_UNQUOTED( | |
657 | [grep "sslv3 alert handshake failure" output], [0], | |
658 | [stdout], | |
c6c17485 | 659 | [ignore]) |
78876719 BP |
660 | OVSDB_SERVER_SHUTDOWN |
661 | AT_CLEANUP | |
1b1d2e6d BP |
662 | \f |
663 | OVS_START_SHELL_HELPERS | |
664 | # ovsdb_check_online_compaction MODEL | |
665 | # | |
666 | # where MODEL is "standalone" or "cluster" | |
667 | ovsdb_check_online_compaction() { | |
668 | local model=$1 | |
669 | ||
670 | ordinal_schema > schema | |
671 | dnl Make sure that "ovsdb-tool create" works with a dangling symlink for | |
672 | dnl the database and the lockfile, creating the target of each symlink rather | |
673 | dnl than replacing the symlinks with regular files. | |
674 | mkdir dir | |
675 | if test "$IS_WIN32" = "no"; then | |
5a0e4aec BP |
676 | ln -s dir/db db |
677 | ln -s dir/.db.~lock~ .db.~lock~ | |
678 | AT_SKIP_IF([test ! -h db || test ! -h .db.~lock~]) | |
1b1d2e6d BP |
679 | fi |
680 | AT_CHECK([if test $model = standalone; then | |
681 | ovsdb-tool create db schema | |
682 | else | |
683 | ovsdb-tool create-cluster db schema unix:s1.raft | |
684 | fi]) | |
685 | dnl Start ovsdb-server. | |
686 | AT_CHECK([ovsdb-server -vvlog:off -vconsole:off --detach --no-chdir --pidfile --remote=punix:socket --log-file db], [0]) | |
d97af428 | 687 | AT_CHECK([ovsdb_client_wait unix:socket ordinals connected]) |
1b1d2e6d BP |
688 | AT_CAPTURE_FILE([ovsdb-server.log]) |
689 | dnl Do a bunch of random transactions that put crap in the database log. | |
690 | AT_CHECK( | |
691 | [[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do | |
5a0e4aec BP |
692 | set -- $pair |
693 | ovsdb-client transact unix:socket ' | |
694 | ["ordinals", | |
695 | {"op": "insert", | |
696 | "table": "ordinals", | |
697 | "row": {"name": "'$1'", "number": '$2'}}, | |
698 | {"op": "comment", | |
699 | "comment": "add row for '"$pair"'"}]' | |
700 | ovsdb-client transact unix:socket ' | |
701 | ["ordinals", | |
702 | {"op": "delete", | |
703 | "table": "ordinals", | |
704 | "where": [["number", "==", '$2']]}, | |
705 | {"op": "comment", | |
706 | "comment": "delete row for '"$2"'"}]' | |
707 | ovsdb-client transact unix:socket ' | |
708 | ["ordinals", | |
709 | {"op": "insert", | |
710 | "table": "ordinals", | |
711 | "row": {"name": "'$1'", "number": '$2'}}, | |
712 | {"op": "comment", | |
713 | "comment": "add back row for '"$pair"'"}]' | |
714 | done]], | |
1b1d2e6d BP |
715 | [0], [stdout]) |
716 | if test $model = standalone; then | |
5a0e4aec | 717 | dnl Check that all the crap is in fact in the database log. |
2ccd66f5 IM |
718 | AT_CHECK([[uuidfilt db | grep -v ^OVSDB | \ |
719 | sed 's/"_date":[0-9]*/"_date":0/' | sed 's/"_is_diff":true,//' | \ | |
720 | ovstest test-json --multiple -]], [0], | |
1b1d2e6d | 721 | [[{"cksum":"12345678 9","name":"ordinals","tables":{"ordinals":{"columns":{"name":{"type":"string"},"number":{"type":"integer"}},"indexes":[["number"]]}},"version":"5.1.3"} |
62c87d4a BP |
722 | {"_comment":"add row for zero 0","_date":0,"ordinals":{"<0>":{"name":"zero"}}} |
723 | {"_comment":"delete row for 0","_date":0,"ordinals":{"<0>":null}} | |
724 | {"_comment":"add back row for zero 0","_date":0,"ordinals":{"<1>":{"name":"zero"}}} | |
725 | {"_comment":"add row for one 1","_date":0,"ordinals":{"<2>":{"name":"one","number":1}}} | |
726 | {"_comment":"delete row for 1","_date":0,"ordinals":{"<2>":null}} | |
727 | {"_comment":"add back row for one 1","_date":0,"ordinals":{"<3>":{"name":"one","number":1}}} | |
728 | {"_comment":"add row for two 2","_date":0,"ordinals":{"<4>":{"name":"two","number":2}}} | |
729 | {"_comment":"delete row for 2","_date":0,"ordinals":{"<4>":null}} | |
730 | {"_comment":"add back row for two 2","_date":0,"ordinals":{"<5>":{"name":"two","number":2}}} | |
731 | {"_comment":"add row for three 3","_date":0,"ordinals":{"<6>":{"name":"three","number":3}}} | |
732 | {"_comment":"delete row for 3","_date":0,"ordinals":{"<6>":null}} | |
733 | {"_comment":"add back row for three 3","_date":0,"ordinals":{"<7>":{"name":"three","number":3}}} | |
734 | {"_comment":"add row for four 4","_date":0,"ordinals":{"<8>":{"name":"four","number":4}}} | |
735 | {"_comment":"delete row for 4","_date":0,"ordinals":{"<8>":null}} | |
736 | {"_comment":"add back row for four 4","_date":0,"ordinals":{"<9>":{"name":"four","number":4}}} | |
737 | {"_comment":"add row for five 5","_date":0,"ordinals":{"<10>":{"name":"five","number":5}}} | |
738 | {"_comment":"delete row for 5","_date":0,"ordinals":{"<10>":null}} | |
739 | {"_comment":"add back row for five 5","_date":0,"ordinals":{"<11>":{"name":"five","number":5}}} | |
1b1d2e6d BP |
740 | ]]) |
741 | else | |
742 | dnl Check that at least there's a lot of transactions. | |
5a0e4aec | 743 | AT_CHECK([test `wc -l < db` -gt 50]) |
1b1d2e6d BP |
744 | fi |
745 | dnl Dump out and check the actual database contents. | |
746 | AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout]) | |
747 | AT_CHECK([uuidfilt stdout], [0], [dnl | |
370a11b9 BP |
748 | ordinals table |
749 | _uuid name number | |
ada496b5 | 750 | ------------------------------------ ----- ------ |
e51d0a1d BP |
751 | <0> five 5 |
752 | <1> four 4 | |
753 | <2> one 1 | |
754 | <3> three 3 | |
755 | <4> two 2 | |
756 | <5> zero 0 | |
1b1d2e6d BP |
757 | ]) |
758 | cp db db.pre-compaction | |
759 | dnl Now compact the database in-place. | |
760 | AT_CHECK([[ovs-appctl -t ovsdb-server ovsdb-server/compact]], | |
761 | [0], [], [ignore]) | |
762 | dnl Negative test. | |
763 | AT_CHECK([[ovs-appctl -t ovsdb-server ovsdb-server/compact _Server]], | |
764 | [2], [], [cannot compact built-in databases | |
bc7bcc40 BP |
765 | ovs-appctl: ovsdb-server: server returned an error |
766 | ]) | |
1b1d2e6d BP |
767 | dnl Make sure that "db" is still a symlink to dir/db instead of getting |
768 | dnl replaced by a regular file, ditto for .db.~lock~. | |
769 | if test "$IS_WIN32" = "no"; then | |
5a0e4aec BP |
770 | AT_CHECK([test -h db]) |
771 | AT_CHECK([test -h .db.~lock~]) | |
772 | AT_CHECK([test -f dir/db]) | |
773 | AT_CHECK([test -f dir/.db.~lock~]) | |
1b1d2e6d BP |
774 | fi |
775 | ||
776 | # We can't fully re-check the contents of the database log, because the | |
777 | # order of the records is not predictable, but there should only be 4 lines | |
778 | # in it now in the standalone case | |
779 | AT_CAPTURE_FILE([db]) | |
780 | compacted_lines=`wc -l < db` | |
781 | echo compacted_lines=$compacted_lines | |
782 | if test $model = standalone; then | |
783 | AT_CHECK([test $compacted_lines -eq 4]) | |
784 | fi | |
785 | ||
786 | dnl And check that the dumped data is the same too: | |
787 | AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout]) | |
788 | AT_CHECK([uuidfilt stdout], [0], [dnl | |
370a11b9 BP |
789 | ordinals table |
790 | _uuid name number | |
ada496b5 | 791 | ------------------------------------ ----- ------ |
e51d0a1d BP |
792 | <0> five 5 |
793 | <1> four 4 | |
794 | <2> one 1 | |
795 | <3> three 3 | |
796 | <4> two 2 | |
797 | <5> zero 0 | |
1b1d2e6d BP |
798 | ]) |
799 | dnl Now do some more transactions. | |
800 | AT_CHECK( | |
801 | [[ovsdb-client transact unix:socket ' | |
5a0e4aec BP |
802 | ["ordinals", |
803 | {"op": "delete", | |
804 | "table": "ordinals", | |
805 | "where": [["number", "<", 3]]}]']], | |
1b1d2e6d BP |
806 | [0], [[[{"count":3}] |
807 | ]], [ignore]) | |
808 | ||
809 | dnl There should be 6 lines in the log now, for the standalone case, | |
810 | dnl and for the clustered case the file should at least have grown. | |
811 | updated_lines=`wc -l < db` | |
812 | echo compacted_lines=$compacted_lines updated_lines=$updated_lines | |
813 | if test $model = standalone; then | |
814 | AT_CHECK([test $updated_lines -eq 6]) | |
815 | else | |
816 | AT_CHECK([test $updated_lines -gt $compacted_lines]) | |
817 | fi | |
818 | ||
819 | dnl Then check that the dumped data is correct. This time first kill | |
820 | dnl and restart the database server to ensure that the data is correct on | |
821 | dnl disk as well as in memory. | |
822 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
823 | AT_CHECK([ovsdb-server -vvlog:off -vconsole:off --detach --no-chdir --pidfile --remote=punix:socket --log-file db]) | |
824 | AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout]) | |
825 | AT_CHECK([uuidfilt stdout], [0], [dnl | |
370a11b9 BP |
826 | ordinals table |
827 | _uuid name number | |
ada496b5 | 828 | ------------------------------------ ----- ------ |
e51d0a1d BP |
829 | <0> five 5 |
830 | <1> four 4 | |
831 | <2> three 3 | |
ada496b5 | 832 | ], [], [test ! -e pid || kill `cat pid`]) |
1b1d2e6d BP |
833 | OVSDB_SERVER_SHUTDOWN |
834 | } | |
835 | OVS_END_SHELL_HELPERS | |
836 | ||
837 | AT_SETUP([compacting online - standalone]) | |
838 | AT_KEYWORDS([ovsdb server compact]) | |
839 | ovsdb_check_online_compaction standalone | |
ada496b5 | 840 | AT_CLEANUP |
48f6e410 | 841 | |
1b1d2e6d BP |
842 | AT_SETUP([compacting online - cluster]) |
843 | AT_KEYWORDS([ovsdb server compact]) | |
844 | ovsdb_check_online_compaction cluster | |
845 | AT_CLEANUP | |
846 | \f | |
847 | OVS_START_SHELL_HELPERS | |
848 | # ovsdb_check_online_conversion MODEL | |
849 | # | |
850 | # where MODEL is "standalone" or "cluster" | |
851 | ovsdb_check_online_conversion() { | |
852 | local model=$1 | |
853 | on_exit 'kill `cat *.pid`' | |
854 | ordinal_schema > schema | |
855 | AT_DATA([new-schema], | |
856 | [[{"name": "ordinals", | |
53178986 BP |
857 | "tables": { |
858 | "ordinals": { | |
5a0e4aec BP |
859 | "columns": { |
860 | "number": {"type": "integer"}}}}} | |
53178986 | 861 | ]]) |
1b1d2e6d BP |
862 | dnl Make sure that "ovsdb-tool create" works with a dangling symlink for |
863 | dnl the database and the lockfile, creating the target of each symlink | |
864 | dnl rather than replacing the symlinks with regular files. | |
865 | mkdir dir | |
866 | if test "$IS_WIN32" = "no"; then | |
5a0e4aec BP |
867 | ln -s dir/db db |
868 | ln -s dir/.db.~lock~ .db.~lock~ | |
869 | AT_SKIP_IF([test ! -h db || test ! -h .db.~lock~]) | |
1b1d2e6d BP |
870 | fi |
871 | AT_CHECK([if test $model = standalone; then | |
872 | ovsdb-tool create db schema | |
873 | else | |
874 | ovsdb-tool create-cluster db schema unix:s1.raft | |
875 | fi]) | |
876 | ||
877 | dnl Start the database server. | |
878 | AT_CHECK([ovsdb-server -vfile -vvlog:off -vconsole:off --detach --no-chdir --pidfile --log-file --remote=punix:db.sock db], [0]) | |
879 | AT_CAPTURE_FILE([ovsdb-server.log]) | |
880 | ||
881 | dnl Put some data in the database. | |
882 | AT_CHECK( | |
883 | [[for pair in 'zero 0' 'one 1' 'two 2' 'three 3' 'four 4' 'five 5'; do | |
5a0e4aec BP |
884 | set -- $pair |
885 | ovsdb-client transact ' | |
886 | ["ordinals", | |
887 | {"op": "insert", | |
888 | "table": "ordinals", | |
889 | "row": {"name": "'$1'", "number": '$2'}}, | |
890 | {"op": "comment", | |
891 | "comment": "add row for '"$pair"'"}]' | |
892 | done | uuidfilt]], [0], | |
1b1d2e6d | 893 | [[[{"uuid":["uuid","<0>"]},{}] |
53178986 BP |
894 | [{"uuid":["uuid","<1>"]},{}] |
895 | [{"uuid":["uuid","<2>"]},{}] | |
896 | [{"uuid":["uuid","<3>"]},{}] | |
897 | [{"uuid":["uuid","<4>"]},{}] | |
898 | [{"uuid":["uuid","<5>"]},{}] | |
899 | ]], [ignore]) | |
900 | ||
1b1d2e6d BP |
901 | dnl Try "needs-conversion". |
902 | AT_CHECK([ovsdb-client needs-conversion schema], [0], [no | |
53178986 | 903 | ]) |
1b1d2e6d | 904 | AT_CHECK([ovsdb-client needs-conversion new-schema], [0], [yes |
53178986 BP |
905 | ]) |
906 | ||
1b1d2e6d BP |
907 | dnl Start two monitors on the 'ordinals' db, one that is database |
908 | dnl change aware and one that is not. | |
9a403b07 | 909 | AT_CHECK([ovsdb-client -vfile -vvlog:off --detach --no-chdir --pidfile=monitor-ordinals-aware.pid --log-file=monitor-ordinals-aware.log --db-change-aware --no-headings monitor ordinals ordinals number name > monitor-ordinals-aware.stdout 2> monitor-ordinals-aware.stderr]) |
1b1d2e6d BP |
910 | AT_CAPTURE_FILE([monitor-ordinals-aware.stdout]) |
911 | AT_CAPTURE_FILE([monitor-ordinals-aware.log]) | |
912 | AT_CAPTURE_FILE([monitor-ordinals-aware.stderr]) | |
913 | ||
9a403b07 | 914 | AT_CHECK([ovsdb-client -vfile -vvlog:off --detach --no-chdir --pidfile=monitor-ordinals-unaware.pid --log-file=monitor-ordinals-unaware.log --no-db-change-aware --no-headings monitor ordinals ordinals number name > monitor-ordinals-unaware.stdout 2> monitor-ordinals-unaware.stderr]) |
1b1d2e6d BP |
915 | AT_CAPTURE_FILE([monitor-ordinals-unaware.stdout]) |
916 | AT_CAPTURE_FILE([monitor-ordinals-unaware.log]) | |
917 | AT_CAPTURE_FILE([monitor-ordinals-unaware.stderr]) | |
918 | ||
919 | dnl Start two monitors on the '_Server' db, one that is database | |
920 | dnl change aware and one that is not. | |
9a403b07 | 921 | AT_CHECK([ovsdb-client -vfile -vvlog:off --detach --no-chdir --pidfile=monitor-server-aware.pid --log-file=monitor-server-aware.log --db-change-aware --no-headings monitor _Server Database name > monitor-server-aware.stdout 2> monitor-server-aware.stderr]) |
1b1d2e6d BP |
922 | AT_CAPTURE_FILE([monitor-server-aware.stdout]) |
923 | AT_CAPTURE_FILE([monitor-server-aware.log]) | |
924 | AT_CAPTURE_FILE([monitor-server-aware.stderr]) | |
925 | ||
9a403b07 | 926 | AT_CHECK([ovsdb-client -vfile -vvlog:off --detach --no-chdir --pidfile=monitor-server-unaware.pid --log-file=monitor-server-unaware.log --no-db-change-aware --no-headings monitor _Server Database name > monitor-server-unaware.stdout 2> monitor-server-unaware.stderr]) |
1b1d2e6d BP |
927 | AT_CAPTURE_FILE([monitor-server-unaware.stdout]) |
928 | AT_CAPTURE_FILE([monitor-server-unaware.log]) | |
929 | AT_CAPTURE_FILE([monitor-server-unaware.stderr]) | |
930 | ||
931 | dnl Start two long-running transactions (triggers) on the 'ordinals' db, | |
932 | dnl one that is database change aware and one that is not. | |
933 | ordinals_txn='[["ordinals", | |
5a0e4aec BP |
934 | {"op": "wait", |
935 | "table": "ordinals", | |
936 | "where": [["name", "==", "seven"]], | |
937 | "columns": ["name", "number"], | |
938 | "rows": [], | |
939 | "until": "!="}]]' | |
9a403b07 | 940 | AT_CHECK([ovsdb-client -vfile -vvlog:off --detach --no-chdir --pidfile=trigger-ordinals-aware.pid --log-file=trigger-ordinals-aware.log --db-change-aware transact "$ordinals_txn" > trigger-ordinals-aware.stdout 2> trigger-ordinals-aware.stderr]) |
1b1d2e6d BP |
941 | AT_CAPTURE_FILE([trigger-ordinals-aware.stdout]) |
942 | AT_CAPTURE_FILE([trigger-ordinals-aware.log]) | |
943 | AT_CAPTURE_FILE([trigger-ordinals-aware.stderr]) | |
944 | ||
9a403b07 | 945 | AT_CHECK([ovsdb-client -vfile -vvlog:off --detach --no-chdir --pidfile=trigger-ordinals-unaware.pid --log-file=trigger-ordinals-unaware.log --no-db-change-aware transact "$ordinals_txn" > trigger-ordinals-unaware.stdout 2> trigger-ordinals-unaware.stderr]) |
1b1d2e6d BP |
946 | AT_CAPTURE_FILE([trigger-ordinals-unaware.stdout]) |
947 | AT_CAPTURE_FILE([trigger-ordinals-unaware.log]) | |
948 | AT_CAPTURE_FILE([trigger-ordinals-unaware.stderr]) | |
949 | ||
950 | dnl Start two long-running transactions (triggers) on the _Server db, | |
951 | dnl one that is database change aware and one that is not. | |
952 | server_txn='[["_Server", | |
5a0e4aec BP |
953 | {"op": "wait", |
954 | "table": "Database", | |
955 | "where": [["name", "==", "xyzzy"]], | |
956 | "columns": ["name"], | |
957 | "rows": [], | |
958 | "until": "!="}]]' | |
9a403b07 | 959 | AT_CHECK([ovsdb-client -vfile -vvlog:off --detach --no-chdir --pidfile=trigger-server-aware.pid --log-file=trigger-server-aware.log --db-change-aware transact "$server_txn" > trigger-server-aware.stdout 2> trigger-server-aware.stderr]) |
1b1d2e6d BP |
960 | AT_CAPTURE_FILE([trigger-server-aware.stdout]) |
961 | AT_CAPTURE_FILE([trigger-server-aware.log]) | |
962 | AT_CAPTURE_FILE([trigger-server-aware.stderr]) | |
963 | ||
9a403b07 | 964 | AT_CHECK([ovsdb-client -vfile -vvlog:off --detach --no-chdir --pidfile=trigger-server-unaware.pid --log-file=trigger-server-unaware.log --no-db-change-aware transact "$server_txn" > trigger-server-unaware.stdout 2> trigger-server-unaware.stderr]) |
1b1d2e6d BP |
965 | AT_CAPTURE_FILE([trigger-server-unaware.stdout]) |
966 | AT_CAPTURE_FILE([trigger-server-unaware.log]) | |
967 | AT_CAPTURE_FILE([trigger-server-unaware.stderr]) | |
968 | ||
969 | dnl Dump out and check the actual database contents. | |
970 | AT_CHECK([ovsdb-client dump unix:db.sock ordinals], [0], [stdout]) | |
971 | AT_CHECK([uuidfilt stdout], [0], [dnl | |
53178986 BP |
972 | ordinals table |
973 | _uuid name number | |
974 | ------------------------------------ ----- ------ | |
975 | <0> five 5 | |
976 | <1> four 4 | |
977 | <2> one 1 | |
978 | <3> three 3 | |
979 | <4> two 2 | |
980 | <5> zero 0 | |
981 | ]) | |
982 | ||
1b1d2e6d BP |
983 | dnl Convert the database. |
984 | AT_CHECK([ovsdb-client convert new-schema]) | |
53178986 | 985 | |
1b1d2e6d BP |
986 | dnl Try "needs-conversion". |
987 | AT_CHECK([ovsdb-client needs-conversion schema], [0], [yes | |
53178986 | 988 | ]) |
1b1d2e6d | 989 | AT_CHECK([ovsdb-client needs-conversion new-schema], [0], [no |
53178986 BP |
990 | ]) |
991 | ||
1b1d2e6d BP |
992 | dnl Verify that the "ordinals" monitors behaved as they should have. |
993 | dnl Both should have exited, for different reasons. | |
994 | for x in aware unaware; do | |
5a0e4aec BP |
995 | echo $x |
996 | OVS_WAIT_WHILE([test -e monitor-ordinals-$x.pid]) | |
997 | AT_CHECK([sort -k 3 monitor-ordinals-$x.stdout | uuidfilt], [0], | |
1b1d2e6d | 998 | [<0> initial 0 zero |
53178986 BP |
999 | <1> initial 1 one |
1000 | <2> initial 2 two | |
1001 | <3> initial 3 three | |
1002 | <4> initial 4 four | |
1003 | <5> initial 5 five | |
1004 | ]) | |
1b1d2e6d BP |
1005 | done |
1006 | AT_CHECK([sed 's/.*: //' monitor-ordinals-unaware.stderr], [0], [receive failed (End of file) | |
53178986 | 1007 | ]) |
1b1d2e6d | 1008 | AT_CHECK([sed 's/.*: //' monitor-ordinals-aware.stderr], [0], [ordinals database was removed |
53178986 BP |
1009 | ]) |
1010 | ||
1b1d2e6d BP |
1011 | dnl Verify that the _Server monitors behaved as they should have. |
1012 | dnl The db-aware monitor should still be running, but not the unaware one. | |
1013 | for x in aware unaware; do | |
5a0e4aec | 1014 | AT_CHECK([sort -k 3 monitor-server-$x.stdout | uuidfilt], [0], |
1b1d2e6d | 1015 | [<0> initial _Server |
53178986 BP |
1016 | <1> initial ordinals |
1017 | ]) | |
1b1d2e6d BP |
1018 | done |
1019 | OVS_WAIT_WHILE([test -e monitor-server-unaware.pid]) | |
1020 | AT_CHECK([sed 's/.*: //' monitor-ordinals-unaware.stderr], [0], [receive failed (End of file) | |
53178986 | 1021 | ]) |
1b1d2e6d BP |
1022 | AT_CHECK([test -e monitor-server-aware.pid]) |
1023 | ||
1024 | dnl Verify that the "ordinals" triggers behaved as they should have: | |
1025 | dnl Both should have exited, for different reasons. | |
1026 | for x in unaware aware; do | |
5a0e4aec BP |
1027 | OVS_WAIT_WHILE([test -e trigger-ordinals-$x.pid]) |
1028 | AT_CHECK([cat trigger-ordinals-$x.stdout]) | |
1b1d2e6d BP |
1029 | done |
1030 | AT_CHECK([cat trigger-ordinals-unaware.stderr], [0], [ovsdb-client: transaction failed (End of file) | |
53178986 | 1031 | ]) |
1b1d2e6d | 1032 | AT_CHECK([cat trigger-ordinals-aware.stderr], [0], [ovsdb-client: transaction returned error: "canceled" |
53178986 BP |
1033 | ]) |
1034 | ||
1b1d2e6d BP |
1035 | dnl Verify that the _Server triggers behaved as they should have: |
1036 | dnl The db-aware trigger should still be waiting, but not the unaware one. | |
1037 | for x in aware unaware; do | |
5a0e4aec | 1038 | AT_CHECK([cat trigger-server-$x.stdout]) |
1b1d2e6d BP |
1039 | done |
1040 | OVS_WAIT_WHILE([test -e trigger-server-unaware.pid]) | |
1041 | AT_CHECK([sed 's/.*: //' trigger-ordinals-unaware.stderr], [0], [transaction failed (End of file) | |
53178986 | 1042 | ]) |
1b1d2e6d BP |
1043 | AT_CHECK([test -e trigger-server-aware.pid]) |
1044 | ||
1045 | AT_CAPTURE_FILE([db]) | |
1046 | if test $model = standalone; then | |
5a0e4aec BP |
1047 | dnl We can't fully re-check the contents of the database log, because the |
1048 | dnl order of the records is not predictable, but there should only be 4 lines | |
1049 | dnl in it now. | |
1050 | AT_CHECK([test `wc -l < db` -eq 4]) | |
1b1d2e6d BP |
1051 | fi |
1052 | dnl Check that the dumped data is the same except for the removed column: | |
1053 | AT_CHECK([ovsdb-client dump unix:db.sock ordinals | uuidfilt], [0], [dnl | |
53178986 BP |
1054 | ordinals table |
1055 | _uuid number | |
1056 | ------------------------------------ ------ | |
1057 | <0> 0 | |
1058 | <1> 1 | |
1059 | <2> 2 | |
1060 | <3> 3 | |
1061 | <4> 4 | |
1062 | <5> 5 | |
1063 | ]) | |
1b1d2e6d BP |
1064 | dnl Now check that the converted database is still online and can be modified, |
1065 | dnl then check that the database log has one more record and that the data | |
1066 | dnl is as expected. | |
1067 | AT_CHECK( | |
1068 | [[ovsdb-client transact ' | |
5a0e4aec BP |
1069 | ["ordinals", |
1070 | {"op": "insert", | |
1071 | "table": "ordinals", | |
1072 | "row": {"number": 6}}, | |
1073 | {"op": "comment", | |
1074 | "comment": "add row for 6"}]' | uuidfilt]], [0], | |
1b1d2e6d | 1075 | [[[{"uuid":["uuid","<0>"]},{}] |
53178986 | 1076 | ]]) |
1b1d2e6d BP |
1077 | if test $model = standalone; then |
1078 | AT_CHECK([test `wc -l < db` -eq 6]) | |
1079 | fi | |
1080 | AT_CHECK([ovsdb-client dump unix:db.sock ordinals | uuidfilt], [0], [dnl | |
53178986 BP |
1081 | ordinals table |
1082 | _uuid number | |
1083 | ------------------------------------ ------ | |
1084 | <0> 0 | |
1085 | <1> 1 | |
1086 | <2> 2 | |
1087 | <3> 3 | |
1088 | <4> 4 | |
1089 | <5> 5 | |
1090 | <6> 6 | |
1091 | ]) | |
1b1d2e6d BP |
1092 | dnl Now kill and restart the database server to ensure that the data is |
1093 | dnl correct on disk as well as in memory. | |
1094 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
1095 | AT_CHECK([[ovsdb-server -vfile -vvlog:off -vconsole:off --detach --no-chdir --pidfile --log-file --remote=punix:db.sock db]], | |
1096 | [0]) | |
1097 | AT_CHECK([ovsdb-client dump unix:db.sock ordinals | uuidfilt], [0], [dnl | |
53178986 BP |
1098 | ordinals table |
1099 | _uuid number | |
1100 | ------------------------------------ ------ | |
1101 | <0> 0 | |
1102 | <1> 1 | |
1103 | <2> 2 | |
1104 | <3> 3 | |
1105 | <4> 4 | |
1106 | <5> 5 | |
1107 | <6> 6 | |
1108 | ]) | |
1109 | ||
1b1d2e6d BP |
1110 | dnl Make sure that "db" is still a symlink to dir/db instead of getting |
1111 | dnl replaced by a regular file, ditto for .db.~lock~. | |
1112 | if test "$IS_WIN32" = "no"; then | |
5a0e4aec BP |
1113 | AT_CHECK([test -h db]) |
1114 | AT_CHECK([test -h .db.~lock~]) | |
1115 | AT_CHECK([test -f dir/db]) | |
1116 | AT_CHECK([test -f dir/.db.~lock~]) | |
1b1d2e6d BP |
1117 | fi |
1118 | ||
1119 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
1120 | } | |
1121 | OVS_END_SHELL_HELPERS | |
1122 | ||
1123 | AT_SETUP([schema conversion online - standalone]) | |
1124 | AT_KEYWORDS([ovsdb server convert needs-conversion standalone]) | |
1125 | ovsdb_check_online_conversion standalone | |
53178986 BP |
1126 | AT_CLEANUP |
1127 | ||
1b1d2e6d BP |
1128 | AT_SETUP([schema conversion online - clustered]) |
1129 | AT_KEYWORDS([ovsdb server convert needs-conversion cluster]) | |
1130 | ovsdb_check_online_conversion cluster | |
1131 | AT_CLEANUP | |
1132 | \f | |
48f6e410 | 1133 | AT_SETUP([ovsdb-server combines updates on backlogged connections]) |
53eb8cb8 | 1134 | on_exit 'kill `cat *.pid`' |
48f6e410 BP |
1135 | |
1136 | # The maximum socket receive buffer size is important for this test, which | |
1137 | # tests behavior when the receive buffer overflows. | |
1138 | if test -e /proc/sys/net/core/rmem_max; then | |
1139 | # Linux | |
1140 | rmem_max=`cat /proc/sys/net/core/rmem_max` | |
1141 | elif rmem_max=`sysctl -n net.inet.tcp.recvbuf_max 2>/dev/null`; then | |
81b9d305 | 1142 | : # FreeBSD, NetBSD |
48f6e410 BP |
1143 | else |
1144 | # Don't know how to get maximum socket receive buffer on this OS | |
1145 | AT_SKIP_IF([:]) | |
1146 | fi | |
1147 | ||
1148 | # Calculate the number of iterations we need to queue. Each of the | |
1149 | # iterations we execute, by itself, yields a monitor update of about | |
1150 | # 25 kB, so fill up that much space plus a few for luck. | |
f5ca49d8 | 1151 | n_iterations=`expr $rmem_max / 25000 + 5` |
48f6e410 BP |
1152 | echo rmem_max=$rmem_max n_iterations=$n_iterations |
1153 | ||
21aa35c3 BP |
1154 | # If there's too much queuing skip the test to avoid timing out. |
1155 | AT_SKIP_IF([test $rmem_max -gt 1048576]) | |
1156 | ||
48f6e410 BP |
1157 | # Calculate the exact number of monitor updates expected for $n_iterations, |
1158 | # assuming no updates are combined. The "extra" update is for the initial | |
1159 | # contents of the database. | |
1160 | n_updates=`expr $n_iterations \* 3 + 1` | |
1161 | ||
1162 | # Start an ovsdb-server with the vswitchd schema. | |
1163 | OVSDB_INIT([db]) | |
1164 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:db.sock db], | |
1165 | [0], [ignore], [ignore]) | |
1166 | ||
1167 | # Executes a set of transactions that add a bridge with 100 ports, and | |
1168 | # then deletes that bridge. This yields three monitor updates that | |
1169 | # add up to about 25 kB in size. | |
1170 | # | |
1171 | # The update also increments a counter held in the database so that we can | |
1172 | # verify that the overall effect of the transactions took effect (e.g. | |
1173 | # monitor updates at the end weren't just dropped). We add an arbitrary | |
1174 | # string to the counter to make grepping for it more reliable. | |
1175 | counter=0 | |
1176 | trigger_big_update () { | |
1177 | counter=`expr $counter + 1` | |
1178 | ovs-vsctl --no-wait -- set open_vswitch . system_version=xyzzy$counter | |
1179 | ovs-vsctl --no-wait -- add-br br0 $add | |
1180 | ovs-vsctl --no-wait -- del-br br0 | |
1181 | } | |
1182 | add_ports () { | |
1183 | for j in `seq 1 100`; do | |
1184 | printf " -- add-port br0 p%d" $j | |
1185 | done | |
1186 | } | |
1187 | add=`add_ports` | |
1188 | ||
1189 | AT_CAPTURE_FILE([ovsdb-client.err]) | |
c005fd61 AZ |
1190 | AT_CAPTURE_FILE([ovsdb-client-nonblock.err]) |
1191 | ||
1192 | ||
1193 | # Start an ovsdb-client monitoring all changes to the database, | |
1194 | # By default, it is non-blocking, and will get update message | |
1195 | # for each ovsdb-server transaactions. | |
1196 | AT_CHECK([ovsdb-client --detach --no-chdir --pidfile=nonblock.pid monitor ALL >ovsdb-client-nonblock.out 2>ovsdb-client-nonblock.err]) | |
48f6e410 BP |
1197 | |
1198 | # Start an ovsdb-client monitoring all changes to the database, | |
1199 | # make it block to force the buffers to fill up, and then execute | |
1200 | # enough iterations that ovsdb-server starts combining updates. | |
1201 | AT_CHECK([ovsdb-client --detach --no-chdir --pidfile monitor ALL >ovsdb-client.out 2>ovsdb-client.err]) | |
1202 | AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/block]) | |
1203 | for i in `seq 1 $n_iterations`; do | |
1204 | echo "blocked update ($i of $n_iterations)" | |
1205 | trigger_big_update $i | |
1206 | done | |
1207 | AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/unblock]) | |
29004db2 IM |
1208 | OVS_WAIT_UNTIL([grep "xyzzy$counter" ovsdb-client.out]) |
1209 | OVS_WAIT_UNTIL([grep "xyzzy$counter" ovsdb-client-nonblock.out]) | |
d9c8c57c | 1210 | OVS_APP_EXIT_AND_WAIT([ovsdb-client]) |
c005fd61 | 1211 | AT_CHECK([kill `cat nonblock.pid`]) |
48f6e410 BP |
1212 | |
1213 | # Count the number of updates in the ovsdb-client output, by counting | |
1214 | # the number of changes to the Open_vSwitch table. (All of our | |
1215 | # transactions modify the Open_vSwitch table.) It should be less than | |
1216 | # $n_updates updates. | |
1217 | # | |
1218 | # Check that the counter is what we expect. | |
1219 | logged_updates=`grep -c '^Open_vSwitch' ovsdb-client.out` | |
c005fd61 AZ |
1220 | logged_nonblock_updates=`grep -c '^Open_vSwitch' ovsdb-client-nonblock.out` |
1221 | echo "logged_nonblock_updates=$logged_nonblock_updates (expected less or equal to $n_updates)" | |
1222 | echo "logged_updates=$logged_updates (expected less than $logged_nonblock_updates)" | |
1223 | AT_CHECK([test $logged_nonblock_updates -le $n_updates]) | |
1224 | AT_CHECK([test $logged_updates -lt $logged_nonblock_updates]) | |
48f6e410 | 1225 | AT_CHECK_UNQUOTED([ovs-vsctl get open_vswitch . system_version], [0], |
29004db2 | 1226 | [xyzzy$counter |
48f6e410 | 1227 | ]) |
d9c8c57c | 1228 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) |
48f6e410 | 1229 | AT_CLEANUP |
80d326ad | 1230 | \f |
e731d71b | 1231 | AT_BANNER([OVSDB -- ovsdb-server transactions (SSL IPv4 sockets)]) |
80d326ad BP |
1232 | |
1233 | # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) | |
1234 | # | |
1235 | # Creates a database with the given SCHEMA, starts an ovsdb-server on | |
1236 | # that database, and runs each of the TRANSACTIONS (which should be a | |
1237 | # quoted list of quoted strings) against it with ovsdb-client one at a | |
1238 | # time. | |
1239 | # | |
1240 | # Checks that the overall output is OUTPUT, but UUIDs in the output | |
1241 | # are replaced by markers of the form <N> where N is a number. The | |
1242 | # first unique UUID is replaced by <0>, the next by <1>, and so on. | |
1243 | # If a given UUID appears more than once it is always replaced by the | |
1244 | # same marker. | |
1245 | # | |
1246 | # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. | |
1247 | m4_define([OVSDB_CHECK_EXECUTION], | |
1248 | [AT_SETUP([$1]) | |
1249 | AT_KEYWORDS([ovsdb server positive ssl $5]) | |
1250 | AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) | |
39ab07af | 1251 | $2 > schema |
15b619e2 | 1252 | PKIDIR=$abs_top_builddir/tests |
7c126fbb | 1253 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) |
56120500 | 1254 | 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 | 1255 | PARSE_LISTENING_PORT([ovsdb-server.log], [SSL_PORT]) |
80d326ad | 1256 | m4_foreach([txn], [$3], |
7c126fbb | 1257 | [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 |
1258 | [test ! -e pid || kill `cat pid`]) |
1259 | cat stdout >> output | |
1260 | ]) | |
c724bd67 | 1261 | AT_CHECK([uuidfilt output], [0], [$4], [ignore], |
80d326ad | 1262 | [test ! -e pid || kill `cat pid`]) |
028cbd99 | 1263 | OVSDB_SERVER_SHUTDOWN |
80d326ad BP |
1264 | AT_CLEANUP]) |
1265 | ||
e879d33e MM |
1266 | EXECUTION_EXAMPLES |
1267 | ||
e731d71b AS |
1268 | AT_BANNER([OVSDB -- ovsdb-server transactions (SSL IPv6 sockets)]) |
1269 | ||
1270 | # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) | |
1271 | # | |
1272 | # Creates a database with the given SCHEMA, starts an ovsdb-server on | |
1273 | # that database, and runs each of the TRANSACTIONS (which should be a | |
1274 | # quoted list of quoted strings) against it with ovsdb-client one at a | |
1275 | # time. | |
1276 | # | |
1277 | # Checks that the overall output is OUTPUT, but UUIDs in the output | |
1278 | # are replaced by markers of the form <N> where N is a number. The | |
1279 | # first unique UUID is replaced by <0>, the next by <1>, and so on. | |
1280 | # If a given UUID appears more than once it is always replaced by the | |
1281 | # same marker. | |
1282 | # | |
1283 | # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. | |
1284 | m4_define([OVSDB_CHECK_EXECUTION], | |
1285 | [AT_SETUP([$1]) | |
1286 | AT_KEYWORDS([ovsdb server positive ssl6 $5]) | |
1287 | AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) | |
4819b3a5 | 1288 | AT_SKIP_IF([test $HAVE_IPV6 = no]) |
e731d71b AS |
1289 | $2 > schema |
1290 | PKIDIR=$abs_top_builddir/tests | |
1291 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) | |
56120500 | 1292 | 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 | 1293 | PARSE_LISTENING_PORT([ovsdb-server.log], [SSL_PORT]) |
e731d71b AS |
1294 | m4_foreach([txn], [$3], |
1295 | [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], | |
1296 | [test ! -e pid || kill `cat pid`]) | |
1297 | cat stdout >> output | |
1298 | ]) | |
c724bd67 | 1299 | AT_CHECK([uuidfilt output], [0], [$4], [ignore], |
e731d71b AS |
1300 | [test ! -e pid || kill `cat pid`]) |
1301 | OVSDB_SERVER_SHUTDOWN | |
1302 | AT_CLEANUP]) | |
1303 | ||
1304 | ONE_EXECUTION_EXAMPLE | |
1305 | ||
1306 | AT_BANNER([OVSDB -- ovsdb-server transactions (TCP IPv4 sockets)]) | |
e879d33e | 1307 | |
e879d33e MM |
1308 | # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) |
1309 | # | |
1310 | # Creates a database with the given SCHEMA, starts an ovsdb-server on | |
1311 | # that database, and runs each of the TRANSACTIONS (which should be a | |
1312 | # quoted list of quoted strings) against it with ovsdb-client one at a | |
1313 | # time. | |
1314 | # | |
1315 | # Checks that the overall output is OUTPUT, but UUIDs in the output | |
1316 | # are replaced by markers of the form <N> where N is a number. The | |
1317 | # first unique UUID is replaced by <0>, the next by <1>, and so on. | |
1318 | # If a given UUID appears more than once it is always replaced by the | |
1319 | # same marker. | |
1320 | # | |
1321 | # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. | |
1322 | m4_define([OVSDB_CHECK_EXECUTION], | |
1323 | [AT_SETUP([$1]) | |
1324 | AT_KEYWORDS([ovsdb server positive tcp $5]) | |
1325 | $2 > schema | |
e879d33e MM |
1326 | PKIDIR=$abs_top_builddir/tests |
1327 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) | |
56120500 | 1328 | AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile --remote=ptcp:0:127.0.0.1 db], [0], [ignore], [ignore]) |
fb28ef2d | 1329 | PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT]) |
e879d33e MM |
1330 | m4_foreach([txn], [$3], |
1331 | [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT 'txn'], [0], [stdout], [ignore], | |
1332 | [test ! -e pid || kill `cat pid`]) | |
1333 | cat stdout >> output | |
1334 | ]) | |
c724bd67 | 1335 | AT_CHECK([uuidfilt output], [0], [$4], [ignore], |
e879d33e MM |
1336 | [test ! -e pid || kill `cat pid`]) |
1337 | OVSDB_SERVER_SHUTDOWN | |
1338 | AT_CLEANUP]) | |
1339 | ||
80d326ad | 1340 | EXECUTION_EXAMPLES |
e731d71b | 1341 | |
7daaec4e BP |
1342 | AT_BANNER([OVSDB -- ovsdb-server transactions (TCP IPv6 sockets)]) |
1343 | ||
e731d71b AS |
1344 | # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) |
1345 | # | |
1346 | # Creates a database with the given SCHEMA, starts an ovsdb-server on | |
1347 | # that database, and runs each of the TRANSACTIONS (which should be a | |
1348 | # quoted list of quoted strings) against it with ovsdb-client one at a | |
1349 | # time. | |
1350 | # | |
1351 | # Checks that the overall output is OUTPUT, but UUIDs in the output | |
1352 | # are replaced by markers of the form <N> where N is a number. The | |
1353 | # first unique UUID is replaced by <0>, the next by <1>, and so on. | |
1354 | # If a given UUID appears more than once it is always replaced by the | |
1355 | # same marker. | |
1356 | # | |
1357 | # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. | |
1358 | m4_define([OVSDB_CHECK_EXECUTION], | |
1359 | [AT_SETUP([$1]) | |
1360 | AT_KEYWORDS([ovsdb server positive tcp6 $5]) | |
4819b3a5 | 1361 | AT_SKIP_IF([test $HAVE_IPV6 = no]) |
e731d71b AS |
1362 | $2 > schema |
1363 | PKIDIR=$abs_top_builddir/tests | |
1364 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) | |
56120500 | 1365 | AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile --remote=ptcp:0:[[::1]] db], [0], [ignore], [ignore]) |
fb28ef2d | 1366 | PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT]) |
e731d71b AS |
1367 | m4_foreach([txn], [$3], |
1368 | [AT_CHECK([ovsdb-client transact tcp:[[::1]]:$TCP_PORT 'txn'], [0], [stdout], [ignore], | |
1369 | [test ! -e pid || kill `cat pid`]) | |
1370 | cat stdout >> output | |
1371 | ]) | |
c724bd67 | 1372 | AT_CHECK([uuidfilt output], [0], [$4], [ignore], |
e731d71b AS |
1373 | [test ! -e pid || kill `cat pid`]) |
1374 | OVSDB_SERVER_SHUTDOWN | |
1375 | AT_CLEANUP]) | |
1376 | ||
1377 | ONE_EXECUTION_EXAMPLE | |
9ff373db BP |
1378 | \f |
1379 | AT_BANNER([OVSDB -- transactions on transient ovsdb-server]) | |
1380 | ||
1381 | # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) | |
1382 | # | |
1383 | # Creates a database with the given SCHEMA and runs each of the | |
1384 | # TRANSACTIONS (which should be a quoted list of quoted strings) | |
1385 | # against it with ovsdb-client one at a time. Each ovsdb-client | |
1386 | # is run against a separately started ovsdb-server that executes | |
1387 | # only that single transaction. (The idea is that this should | |
1388 | # help to ferret out any differences between what ovsdb-server has | |
1389 | # in memory and what actually gets committed to disk.) | |
1390 | # | |
1391 | # Checks that the overall output is OUTPUT, but UUIDs in the output | |
1392 | # are replaced by markers of the form <N> where N is a number. The | |
1393 | # first unique UUID is replaced by <0>, the next by <1>, and so on. | |
1394 | # If a given UUID appears more than once it is always replaced by the | |
1395 | # same marker. | |
1396 | # | |
1397 | # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. | |
1398 | m4_define([OVSDB_CHECK_EXECUTION], | |
1399 | [AT_SETUP([$1]) | |
c17b52e8 | 1400 | AT_SKIP_IF([test "$IS_WIN32" = "yes"]) |
9ff373db | 1401 | AT_KEYWORDS([ovsdb server positive transient $5]) |
39ab07af | 1402 | $2 > schema |
9ff373db BP |
1403 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) |
1404 | m4_foreach([txn], [$3], | |
1405 | [AT_DATA([txnfile], [ovsdb-client transact unix:socket 'txn' | |
1406 | ]) | |
56120500 | 1407 | AT_CHECK([ovsdb-server --remote=punix:socket db --run="sh txnfile"], [0], [stdout], [ignore]) |
9ff373db BP |
1408 | cat stdout >> output |
1409 | ]) | |
c724bd67 | 1410 | AT_CHECK([uuidfilt output], [0], [$4], [ignore]) |
9ff373db BP |
1411 | AT_CLEANUP]) |
1412 | ||
1413 | EXECUTION_EXAMPLES | |
ae671c5f | 1414 | \f |
63b35ecc | 1415 | AT_BANNER([OVSDB -- ovsdb-server replication]) |
ae671c5f MC |
1416 | |
1417 | # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) | |
1418 | # | |
1419 | # Creates two databases with the given SCHEMA, and starts an ovsdb-server on | |
1420 | # each database. | |
1421 | # Runs each of the TRANSACTIONS (which should be a quoted list of | |
1422 | # quoted strings) against one of the servers with ovsdb-client one at a | |
1423 | # time. The server replicates its database to the other ovsdb-server. | |
1424 | # | |
1425 | # Checks that the dump of both databases are the same. | |
1426 | # | |
1427 | # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. | |
1428 | m4_define([OVSDB_CHECK_EXECUTION], | |
1429 | [AT_SETUP([$1]) | |
1430 | AT_KEYWORDS([ovsdb server tcp replication $5]) | |
1431 | $2 > schema | |
1432 | AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore]) | |
1433 | AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore]) | |
1434 | ||
56120500 | 1435 | AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile --remote=punix:db.sock db1], [0], [ignore], [ignore]) |
5dd81c22 AZ |
1436 | i |
1437 | on_exit 'test ! -e pid || kill `cat pid`' | |
ae671c5f | 1438 | |
56120500 | 1439 | 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 | 1440 | on_exit 'test ! -e pid2 || kill `cat pid2`' |
ae671c5f MC |
1441 | |
1442 | m4_foreach([txn], [$3], | |
5dd81c22 | 1443 | [AT_CHECK([ovsdb-client transact 'txn'], [0], [stdout], [ignore]) |
ae671c5f MC |
1444 | ]) |
1445 | ||
5dd81c22 AZ |
1446 | AT_CHECK([ovsdb-client dump], [0], [stdout], [ignore]) |
1447 | OVS_WAIT_UNTIL([ ovsdb-client dump unix:db2.sock > dump2; diff stdout dump2]) | |
ae671c5f | 1448 | |
ae671c5f MC |
1449 | OVSDB_SERVER_SHUTDOWN |
1450 | OVSDB_SERVER_SHUTDOWN2 | |
1451 | AT_CLEANUP]) | |
1452 | ||
1453 | EXECUTION_EXAMPLES | |
7a9d65d2 | 1454 | |
63b35ecc | 1455 | AT_BANNER([OVSDB -- ovsdb-server replication table-exclusion]) |
7a9d65d2 MC |
1456 | |
1457 | # OVSDB_CHECK_REPLICATION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) | |
1458 | # | |
1459 | # Creates two databases with the given SCHEMA, and starts an | |
1460 | # ovsdb-server on each database. | |
1461 | # Runs each of the TRANSACTIONS (which should be a quoted list of | |
1462 | # quoted strings) against one of the servers with ovsdb-client one at a | |
1463 | # time. The server replicates its database to the other ovsdb-server. | |
1464 | # | |
1465 | # Checks that the difference between the dump of the databases is | |
1466 | # OUTPUT, but UUIDs in the output are replaced by markers of the form | |
1467 | # <N> where N is a number. The first unique UUID is replaced by <0>, | |
1468 | # the next by <1>, and so on. | |
1469 | # If a given UUID appears more than once it is always replaced by the | |
1470 | # same marker. | |
1471 | # | |
1472 | # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. | |
1473 | m4_define([OVSDB_CHECK_REPLICATION], | |
1474 | [AT_SETUP([$1]) | |
1475 | AT_KEYWORDS([ovsdb server tcp replication table-exclusion]) | |
baee3741 | 1476 | AT_SKIP_IF([test $DIFF_SUPPORTS_NORMAL_FORMAT = no]) |
7a9d65d2 MC |
1477 | $2 > schema |
1478 | AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore]) | |
1479 | AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore]) | |
1480 | ||
56120500 | 1481 | AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile --remote=punix:db.sock db1], [0], [ignore], [ignore]) |
5dd81c22 | 1482 | on_exit 'test ! -e pid || kill `cat pid`' |
7a9d65d2 | 1483 | |
56120500 | 1484 | 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 | 1485 | on_exit 'test ! -e pid2 || kill `cat pid2`' |
7a9d65d2 MC |
1486 | |
1487 | m4_foreach([txn], [$3], | |
5dd81c22 | 1488 | [AT_CHECK([ ovsdb-client transact 'txn' ], [0], [stdout], [ignore]) |
7a9d65d2 MC |
1489 | ]) |
1490 | ||
5dd81c22 AZ |
1491 | AT_CHECK([ovsdb-client dump], [0], [stdout], [ignore]) |
1492 | cat stdout > dump1 | |
7a9d65d2 | 1493 | |
5dd81c22 AZ |
1494 | OVS_WAIT_UNTIL([ ovsdb-client dump unix:db2.sock | grep one ]) |
1495 | AT_CHECK([ovsdb-client dump unix:db2.sock], [0], [stdout], [ignore]) | |
1496 | cat stdout > dump2 | |
7a9d65d2 | 1497 | |
5dd81c22 AZ |
1498 | AT_CHECK([diff dump1 dump2], [1], [stdout], [ignore]) |
1499 | cat stdout > output | |
1500 | ||
c724bd67 | 1501 | AT_CHECK([uuidfilt output], [0], [$4], [ignore]) |
7a9d65d2 MC |
1502 | |
1503 | OVSDB_SERVER_SHUTDOWN | |
1504 | OVSDB_SERVER_SHUTDOWN2 | |
1505 | AT_CLEANUP]) | |
1506 | ||
1507 | REPLICATION_EXAMPLES | |
9dc05cdc MC |
1508 | |
1509 | AT_BANNER([OVSDB -- ovsdb-server replication runtime management commands]) | |
1510 | ||
f53d7518 AZ |
1511 | #ovsdb-server/get-active-ovsdb-server command |
1512 | AT_SETUP([ovsdb-server/get-active-ovsdb-server]) | |
1513 | AT_KEYWORDS([ovsdb server replication get-active]) | |
9dc05cdc MC |
1514 | ordinal_schema > schema |
1515 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) | |
1516 | on_exit 'kill `cat *.pid`' | |
1517 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --sync-from=tcp:127.0.0.1:9999 db]) | |
1518 | ||
f53d7518 | 1519 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/get-active-ovsdb-server], |
9dc05cdc MC |
1520 | [0], [tcp:127.0.0.1:9999 |
1521 | ]) | |
1522 | AT_CLEANUP | |
1523 | ||
f53d7518 AZ |
1524 | #*ovsdb-server/set-active-ovsdb-server command |
1525 | AT_SETUP([ovsdb-server/set-active-ovsdb-server]) | |
1526 | AT_KEYWORDS([ovsdb server replication set-active]) | |
9dc05cdc MC |
1527 | ordinal_schema > schema |
1528 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) | |
1529 | on_exit 'kill `cat *.pid`' | |
1530 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile db]) | |
1531 | ||
f53d7518 AZ |
1532 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/set-active-ovsdb-server tcp:127.0.0.1:9999]) |
1533 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/get-active-ovsdb-server], | |
9dc05cdc MC |
1534 | [0], [tcp:127.0.0.1:9999 |
1535 | ]) | |
1536 | AT_CLEANUP | |
1537 | ||
60e0cd04 AZ |
1538 | #ovsdb-server/get-sync-exclude-tables command |
1539 | AT_SETUP([ovsdb-server/get-sync-exclude-tables]) | |
1540 | AT_KEYWORDS([ovsdb server replication get-exclude-tables]) | |
9dc05cdc MC |
1541 | ordinal_schema > schema |
1542 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) | |
1543 | on_exit 'kill `cat *.pid`' | |
1544 | AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --sync-exclude-tables=mydb:db1,mydb:db2 db]) | |
1545 | ||
60e0cd04 | 1546 | AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/get-sync-exclude-tables], |
3109b4e1 | 1547 | [0], [mydb:db1,mydb:db2 |
9dc05cdc MC |
1548 | ]) |
1549 | AT_CLEANUP | |
1550 | ||
60e0cd04 AZ |
1551 | #ovsdb-server/set-sync-exclude-tables command |
1552 | AT_SETUP([ovsdb-server/set-sync-exclude-tables]) | |
1553 | AT_KEYWORDS([ovsdb server replication set-exclude-tables]) | |
baee3741 BP |
1554 | AT_SKIP_IF([test $DIFF_SUPPORTS_NORMAL_FORMAT = no]) |
1555 | ||
9dc05cdc MC |
1556 | replication_schema > schema |
1557 | AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore]) | |
1558 | AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore]) | |
1559 | ||
56120500 | 1560 | AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile --remote=punix:db.sock db1], [0], [ignore], [ignore]) |
5dd81c22 | 1561 | on_exit 'test ! -e pid || kill `cat pid`' |
9dc05cdc | 1562 | |
56120500 | 1563 | 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 | 1564 | on_exit 'test ! -e pid2 || kill `cat pid2`' |
9dc05cdc | 1565 | |
60e0cd04 | 1566 | 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 | 1567 | |
63b35ecc | 1568 | AT_CHECK([ovsdb-client transact unix:db.sock \ |
9dc05cdc MC |
1569 | '[["mydb", |
1570 | {"op": "insert", | |
1571 | "table": "a", | |
1572 | "row": {"number": 0, "name": "zero"}}, | |
1573 | {"op": "insert", | |
1574 | "table": "b", | |
1575 | "row": {"number": 1, "name": "one"}}]]'], [0], [stdout], [ignore], | |
1576 | [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`]) | |
9dc05cdc | 1577 | |
63b35ecc | 1578 | AT_CHECK([ovsdb-client dump unix:db.sock], [0], [stdout], [ignore], |
9dc05cdc | 1579 | [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`]) |
5dd81c22 AZ |
1580 | cat stdout > dump1 |
1581 | OVS_WAIT_UNTIL([ ovsdb-client dump unix:db2.sock | grep zero ]) | |
1582 | AT_CHECK([ovsdb-client dump unix:db2.sock], [0], [stdout], [ignore]) | |
1583 | cat stdout > dump2 | |
9dc05cdc | 1584 | |
5dd81c22 AZ |
1585 | AT_CHECK([diff dump1 dump2], [1], [stdout], [ignore]) |
1586 | cat stdout > output | |
9dc05cdc | 1587 | |
c724bd67 | 1588 | AT_CHECK([uuidfilt output], [0], [7,9c7,8 |
9dc05cdc MC |
1589 | < _uuid name number |
1590 | < ------------------------------------ ---- ------ | |
e51d0a1d | 1591 | < <0> one 1 |
9dc05cdc MC |
1592 | --- |
1593 | > _uuid name number | |
1594 | > ----- ---- ------ | |
5dd81c22 | 1595 | ]) |
9dc05cdc MC |
1596 | |
1597 | OVSDB_SERVER_SHUTDOWN | |
1598 | OVSDB_SERVER_SHUTDOWN2 | |
1599 | AT_CLEANUP | |
1600 | ||
f53d7518 AZ |
1601 | #ovsdb-server/connect-active-ovsdb-server |
1602 | AT_SETUP([ovsdb-server/connect-active-server]) | |
1603 | AT_KEYWORDS([ovsdb server replication connect-active-server]) | |
9dc05cdc MC |
1604 | replication_schema > schema |
1605 | AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore]) | |
1606 | AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore]) | |
1607 | ||
56120500 | 1608 | AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile --remote=punix:db.sock db1], [0], [ignore], [ignore]) |
5dd81c22 | 1609 | on_exit 'test ! -e pid || kill `cat pid`' |
9dc05cdc | 1610 | |
56120500 | 1611 | 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 | 1612 | on_exit 'test ! -e pid2 || kill `cat pid2`' |
9dc05cdc | 1613 | |
60e0cd04 AZ |
1614 | dnl Try to connect without specifying the active server. |
1615 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/connect-active-ovsdb-server], [0], | |
1616 | [Unable to connect: active server is not specified. | |
1617 | ], [ignore]) | |
1618 | ||
5dd81c22 | 1619 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/set-active-ovsdb-server unix:db.sock], [0], [stdout], [ignore]) |
9dc05cdc | 1620 | |
5dd81c22 | 1621 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/connect-active-ovsdb-server], [0], [stdout], [ignore]) |
9dc05cdc | 1622 | |
63b35ecc | 1623 | AT_CHECK([ovsdb-client transact unix:db.sock \ |
9dc05cdc MC |
1624 | '[["mydb", |
1625 | {"op": "insert", | |
1626 | "table": "a", | |
5dd81c22 | 1627 | "row": {"number": 0, "name": "zero"}}]]'], [0], [stdout], [ignore]) |
9dc05cdc | 1628 | |
5dd81c22 AZ |
1629 | AT_CHECK([ovsdb-client dump unix:db.sock], [0], [stdout], [ignore]) |
1630 | cat stdout > dump1 | |
1631 | OVS_WAIT_UNTIL([ ovsdb-client dump unix:db2.sock | grep zero ]) | |
1632 | AT_CHECK([ovsdb-client dump unix:db2.sock], [0], [stdout], [ignore]) | |
1633 | cat stdout > dump2 | |
9dc05cdc | 1634 | |
5dd81c22 | 1635 | AT_CHECK([diff dump1 dump2], [0], [], [ignore]) |
9dc05cdc MC |
1636 | OVSDB_SERVER_SHUTDOWN |
1637 | OVSDB_SERVER_SHUTDOWN2 | |
1638 | AT_CLEANUP | |
1639 | ||
f53d7518 AZ |
1640 | #ovsdb-server/disconnect-active-server command |
1641 | AT_SETUP([ovsdb-server/disconnect-active-server]) | |
1642 | AT_KEYWORDS([ovsdb server replication disconnect-active-server]) | |
baee3741 BP |
1643 | AT_SKIP_IF([test $DIFF_SUPPORTS_NORMAL_FORMAT = no]) |
1644 | ||
9dc05cdc MC |
1645 | replication_schema > schema |
1646 | AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore]) | |
1647 | AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore]) | |
1648 | ||
56120500 | 1649 | AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile --remote=punix:db.sock db1], [0], [ignore], [ignore]) |
5dd81c22 | 1650 | on_exit 'test ! -e pid || kill `cat pid`' |
9dc05cdc | 1651 | |
56120500 | 1652 | 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 | 1653 | on_exit 'test ! -e pid2 || kill `cat pid2`' |
9dc05cdc | 1654 | |
63b35ecc | 1655 | AT_CHECK([ovsdb-client transact unix:db.sock \ |
9dc05cdc MC |
1656 | '[["mydb", |
1657 | {"op": "insert", | |
1658 | "table": "a", | |
5dd81c22 | 1659 | "row": {"number": 0, "name": "zero"}}]]'], [0], [stdout], [ignore]) |
f7525086 | 1660 | |
e51879e9 AZ |
1661 | dnl Make sure the transaction shows up in db2. This also tests the back up server |
1662 | dnl can be read. | |
63b35ecc | 1663 | OVS_WAIT_UNTIL([ovsdb-client dump unix:db2.sock | grep zero]) |
9dc05cdc | 1664 | |
e51879e9 AZ |
1665 | dnl The backup server does not accept any write transaction |
1666 | AT_CHECK([ovsdb-client transact unix:db2.sock \ | |
1667 | '[["mydb", | |
1668 | {"op": "insert", | |
1669 | "table": "b", | |
1670 | "row": {"number": 1, "name": "one"}}]]'], [0], | |
1671 | [[[{"details":"insert operation not allowed when database server is in read only mode","error":"not allowed"}]] | |
1672 | ]) | |
1673 | ||
5dd81c22 | 1674 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/disconnect-active-ovsdb-server], [0], [ignore], [ignore]) |
9dc05cdc | 1675 | |
63b35ecc | 1676 | AT_CHECK([ovsdb-client transact unix:db.sock \ |
9dc05cdc MC |
1677 | '[["mydb", |
1678 | {"op": "insert", | |
1679 | "table": "b", | |
5dd81c22 | 1680 | "row": {"number": 1, "name": "one"}}]]'], [0], [stdout], [ignore]) |
9dc05cdc | 1681 | |
5dd81c22 AZ |
1682 | AT_CHECK([ovsdb-client dump unix:db.sock], [0], [stdout], [ignore]) |
1683 | cat stdout > dump1 | |
9dc05cdc | 1684 | |
5dd81c22 AZ |
1685 | sleep 1 |
1686 | AT_CHECK([ovsdb-client dump unix:db2.sock], [0], [stdout], [ignore]) | |
1687 | cat stdout > dump2 | |
9dc05cdc | 1688 | |
5dd81c22 AZ |
1689 | AT_CHECK([diff dump1 dump2], [1], [stdout], [ignore]) |
1690 | cat stdout > output | |
9dc05cdc | 1691 | |
c724bd67 | 1692 | AT_CHECK([uuidfilt output], [0], [7,9c7,8 |
9dc05cdc MC |
1693 | < _uuid name number |
1694 | < ------------------------------------ ---- ------ | |
e51d0a1d | 1695 | < <0> one 1 |
9dc05cdc MC |
1696 | --- |
1697 | > _uuid name number | |
1698 | > ----- ---- ------ | |
1699 | ], [ignore], [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`]) | |
1700 | ||
e51879e9 AZ |
1701 | dnl The backup server now become active, and can accept write transactions. |
1702 | AT_CHECK([ovsdb-client transact unix:db2.sock \ | |
1703 | '[["mydb", | |
1704 | {"op": "insert", | |
1705 | "table": "b", | |
5dd81c22 | 1706 | "row": {"number": 1, "name": "one"}}]]'], [0], [stdout], [ignore]) |
e51879e9 AZ |
1707 | |
1708 | AT_CHECK([ovsdb-client dump unix:db2.sock], [0], [stdout]) | |
1709 | cat stdout > output | |
1710 | ||
c724bd67 | 1711 | AT_CHECK([uuidfilt output], [0], [a table |
e51879e9 AZ |
1712 | _uuid name number |
1713 | ------------------------------------ ---- ------ | |
e51d0a1d | 1714 | <0> zero 0 |
e51879e9 AZ |
1715 | |
1716 | b table | |
1717 | _uuid name number | |
1718 | ------------------------------------ ---- ------ | |
e51d0a1d | 1719 | <1> one 1 |
e51879e9 AZ |
1720 | ]) |
1721 | ||
9dc05cdc MC |
1722 | OVSDB_SERVER_SHUTDOWN |
1723 | OVSDB_SERVER_SHUTDOWN2 | |
1724 | AT_CLEANUP | |
60e0cd04 AZ |
1725 | |
1726 | #ovsdb-server/active-backup-role-switching | |
1727 | AT_SETUP([ovsdb-server/active-backup-role-switching]) | |
1728 | AT_KEYWORDS([ovsdb server replication active-backup-switching]) | |
1729 | replication_schema > schema | |
1730 | AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore]) | |
1731 | AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore]) | |
1732 | ||
1733 | dnl Add some data to both DBs | |
1734 | AT_CHECK([ovsdb-tool transact db1 \ | |
1735 | '[["mydb", | |
1736 | {"op": "insert", | |
1737 | "table": "a", | |
1738 | "row": {"number": 9, "name": "nine"}}]]'], [0], [ignore], [ignore]) | |
1739 | ||
1740 | AT_CHECK([ovsdb-tool transact db2 \ | |
1741 | '[["mydb", | |
1742 | {"op": "insert", | |
1743 | "table": "a", | |
1744 | "row": {"number": 9, "name": "nine"}}]]'], [0], [ignore], [ignore]) | |
1745 | ||
1746 | dnl Start both 'db1' and 'db2' in backup mode. Let them backup from each | |
1747 | dnl other. This is not an supported operation state, but to simulate a start | |
1748 | dnl up condition where an HA manger can select which one to be an active | |
1749 | dnl server soon after. | |
1750 | 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]) | |
1751 | on_exit 'test ! -e pid || kill `cat pid`' | |
1752 | ||
1753 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/connect-active-ovsdb-server]) | |
1754 | ||
1755 | 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]) | |
1756 | on_exit 'test ! -e pid2 || kill `cat pid2`' | |
1757 | ||
1758 | dnl | |
1759 | dnl make sure both servers reached the replication state | |
1760 | OVS_WAIT_UNTIL([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/sync-status |grep replicating]) | |
1761 | OVS_WAIT_UNTIL([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/sync-status |grep replicating]) | |
1762 | ||
1763 | dnl Switch the 'db1' to active | |
1764 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/disconnect-active-ovsdb-server]) | |
1765 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/sync-status], [0], [state: active | |
1766 | ]) | |
1767 | ||
1768 | dnl Issue a transaction to 'db1' | |
1769 | AT_CHECK([ovsdb-client transact unix:db.sock \ | |
1770 | '[["mydb", | |
1771 | {"op": "insert", | |
1772 | "table": "a", | |
1773 | "row": {"number": 0, "name": "zero"}}]]'], [0], [ignore]) | |
1774 | ||
1775 | dnl It should be replicated to 'db2' | |
1776 | OVS_WAIT_UNTIL([ovsdb-client dump unix:db2.sock | grep zero]) | |
1777 | ||
1778 | dnl Flip the role of 'db1' and 'db2'. 'db1' becomes backup, and db2 becomes active | |
1779 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/disconnect-active-ovsdb-server]) | |
1780 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/connect-active-ovsdb-server]) | |
1781 | ||
1782 | dnl Verify the change happend | |
1783 | OVS_WAIT_UNTIL([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/sync-status |grep replicating]) | |
1784 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/sync-status], [0], [state: active | |
1785 | ]) | |
1786 | ||
1787 | dnl Issue an transaction to 'db2' which is now active. | |
1788 | AT_CHECK([ovsdb-client transact unix:db2.sock \ | |
1789 | '[["mydb", | |
1790 | {"op": "insert", | |
1791 | "table": "b", | |
1792 | "row": {"number": 1, "name": "one"}}]]'], [0], [ignore]) | |
1793 | ||
1794 | dnl The transaction should be replicated to 'db1' | |
1795 | OVS_WAIT_UNTIL([ovsdb-client dump unix:db.sock | grep one]) | |
1796 | ||
1797 | dnl Both servers should have the same content. | |
1798 | AT_CHECK([ovsdb-client dump unix:db.sock], [0], [stdout]) | |
1799 | cat stdout > dump1 | |
1800 | ||
1801 | AT_CHECK([ovsdb-client dump unix:db2.sock], [0], [stdout]) | |
1802 | cat stdout > dump2 | |
1803 | ||
1804 | AT_CHECK([diff dump1 dump2]) | |
1805 | ||
1806 | dnl OVSDB_SERVER_SHUTDOWN | |
1807 | dnl OVSDB_SERVER_SHUTDOWN2 | |
1808 | AT_CLEANUP | |
9c1a1182 | 1809 | |
05ac209a AZ |
1810 | #ovsdb-server prevent self replicating |
1811 | AT_SETUP([ovsdb-server prevent self replicating]) | |
1812 | AT_KEYWORDS([ovsdb server replication]) | |
1813 | replication_schema > schema | |
1814 | AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) | |
1815 | ||
1816 | dnl Add some data to both DBs | |
1817 | AT_CHECK([ovsdb-tool transact db \ | |
1818 | '[["mydb", | |
1819 | {"op": "insert", | |
1820 | "table": "a", | |
1821 | "row": {"number": 9, "name": "nine"}}]]'], [0], [ignore], [ignore]) | |
1822 | ||
1823 | dnl Start 'db', then try to be a back up server of itself. | |
1824 | 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]) | |
1825 | on_exit 'test ! -e pid || kill `cat pid`' | |
1826 | ||
1827 | dnl Save the current content | |
1828 | AT_CHECK([ovsdb-client dump unix:db.sock], [0], [stdout]) | |
1829 | cp stdout dump1 | |
1830 | ||
1831 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/connect-active-ovsdb-server]) | |
1832 | dnl Check that self replicating is blocked. | |
1833 | AT_CHECK([grep "Self replicating is not allowed" ovsdb-server.log], [0], [stdout]) | |
1834 | ||
1835 | dnl Check current DB content is preserved. | |
1836 | AT_CHECK([ovsdb-client dump unix:db.sock], [0], [stdout]) | |
1837 | cat stdout > dump2 | |
1838 | ||
1839 | AT_CHECK([diff dump1 dump2]) | |
1840 | AT_CLEANUP | |
1841 | ||
9c1a1182 LR |
1842 | AT_SETUP([ovsdb-server/read-only db:ptcp connection]) |
1843 | AT_KEYWORDS([ovsdb server read-only]) | |
1844 | AT_DATA([schema], | |
1845 | [[{"name": "mydb", | |
1846 | "tables": { | |
1847 | "Root": { | |
1848 | "columns": { | |
1849 | "managers": { | |
1850 | "type": { | |
1851 | "key": {"type": "uuid", "refTable": "Manager"}, | |
1852 | "min": 0, | |
1853 | "max": "unlimited"}}}}, | |
1854 | "Manager": { | |
1855 | "columns": { | |
1856 | "target": { | |
1857 | "type": "string"}, | |
1858 | "read_only": { | |
1859 | "type": { | |
1860 | "key": "boolean", | |
1861 | "min": 0, | |
1862 | "max": 1}}, | |
1863 | "is_connected": { | |
1864 | "type": { | |
1865 | "key": "boolean", | |
1866 | "min": 0, | |
1867 | "max": 1}}}}, | |
1868 | "ordinals": { | |
1869 | "columns": { | |
1870 | "number": {"type": "integer"}, | |
1871 | "name": {"type": "string"}}, | |
1872 | "indexes": [["number"]]} | |
1873 | }, | |
1874 | "version": "5.1.3", | |
1875 | "cksum": "12345678 9" | |
1876 | } | |
1877 | ]]) | |
1878 | AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) | |
1879 | AT_CHECK( | |
1880 | [[ovsdb-tool transact db \ | |
1881 | '["mydb", | |
1882 | {"op": "insert", | |
1883 | "table": "Root", | |
1884 | "row": { | |
1885 | "managers": ["set", [["named-uuid", "x"]]]}}, | |
1886 | {"op": "insert", | |
1887 | "table": "Manager", | |
1888 | "uuid-name": "x", | |
1889 | "row": {"target": "ptcp:0:127.0.0.1", | |
1890 | "read_only": true}}]']], [0], [ignore], [ignore]) | |
1891 | ||
1892 | AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile --remote=db:mydb,Root,managers db], [0], [ignore], [ignore]) | |
1893 | PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT]) | |
1894 | AT_CHECK([ovsdb-client get-schema-version tcp:127.0.0.1:$TCP_PORT mydb], [0], [5.1.3 | |
1895 | ]) | |
1896 | ||
1897 | AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT \ | |
1898 | ['["mydb", | |
1899 | {"op": "insert", | |
1900 | "table": "ordinals", | |
1901 | "row": {"name": "two", "number": '2'}} | |
1902 | ]']], [0], [stdout], [ignore]) | |
1903 | cat stdout >> output | |
c724bd67 | 1904 | AT_CHECK([uuidfilt output], [0], [[[{"details":"insert operation not allowed when database server is in read only mode","error":"not allowed"}]] |
9c1a1182 LR |
1905 | ], [ignore]) |
1906 | OVSDB_SERVER_SHUTDOWN | |
1907 | AT_CLEANUP | |
cec7005b NS |
1908 | |
1909 | AT_SETUP([ovsdb-server replication with schema mismatch]) | |
1910 | AT_KEYWORDS([ovsdb server replication]) | |
1911 | replication_schema > subset_schema | |
1912 | replication_schema_v2 > superset_schema | |
1913 | ||
1914 | AT_CHECK([ovsdb-tool create db1 subset_schema], [0], [stdout], [ignore]) | |
1915 | AT_CHECK([ovsdb-tool create db2 superset_schema], [0], [stdout], [ignore]) | |
1916 | ||
1917 | dnl Add some data to both DBs | |
1918 | AT_CHECK([ovsdb-tool transact db1 \ | |
1919 | '[["mydb", | |
1920 | {"op": "insert", | |
1921 | "table": "a", | |
1922 | "row": {"number": 9, "name": "nine"}}]]'], [0], [ignore], [ignore]) | |
1923 | ||
1924 | AT_CHECK([ovsdb-tool transact db2 \ | |
1925 | '[["mydb", | |
1926 | {"op": "insert", | |
1927 | "table": "a", | |
1928 | "row": {"number": 10, "name": "ten"}}]]'], [0], [ignore], [ignore]) | |
1929 | ||
1930 | dnl Start both 'db1' and 'db2'. | |
1931 | AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfile="`pwd`"/pid --remote=punix:db.sock --unixctl="`pwd`"/unixctl db1 --active ], [0], [ignore], [ignore]) | |
1932 | on_exit 'test ! -e pid || kill `cat pid`' | |
1933 | ||
1934 | ||
1935 | AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile="`pwd`"/pid2 --remote=punix:db2.sock --unixctl="`pwd`"/unixctl2 db2], [0], [ignore], [ignore]) | |
1936 | on_exit 'test ! -e pid2 || kill `cat pid2`' | |
1937 | ||
1938 | OVS_WAIT_UNTIL([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/sync-status |grep active]) | |
1939 | OVS_WAIT_UNTIL([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/sync-status |grep active]) | |
1940 | ||
1941 | AT_CHECK([ovsdb-client dump unix:db.sock a number name], 0, [dnl | |
1942 | a table | |
1943 | name number | |
1944 | ---- ------ | |
1945 | nine 9 | |
1946 | ]) | |
1947 | ||
1948 | AT_CHECK([ovsdb-client dump unix:db2.sock a number name], 0, [dnl | |
1949 | a table | |
1950 | name number | |
1951 | ---- ------ | |
1952 | ten 10 | |
1953 | ]) | |
1954 | ||
1955 | # Replicate db1 from db2. It should fail since db2 schema | |
1956 | # doesn't match with db1 and has additional tables/columns. | |
1957 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/set-active-ovsdb-server unix:db2.sock]) | |
1958 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/connect-active-ovsdb-server]) | |
1959 | ||
1960 | OVS_WAIT_UNTIL( | |
1961 | [test 1 = `cat ovsdb-server1.log | grep "Schema version mismatch, checking if mydb can still be replicated or not" | wc -l]` | |
1962 | ) | |
1963 | ||
1964 | OVS_WAIT_UNTIL( | |
1965 | [test 1 = `cat ovsdb-server1.log | grep "mydb cannot be replicated" | wc -l]` | |
1966 | ) | |
1967 | ||
1968 | OVS_WAIT_UNTIL([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/sync-status |grep active]) | |
1969 | ||
1970 | # Replicate db2 from db1. This should be successful. | |
1971 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl ovsdb-server/disconnect-active-ovsdb-server]) | |
1972 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/set-active-ovsdb-server unix:db.sock]) | |
1973 | AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/connect-active-ovsdb-server]) | |
1974 | ||
1975 | OVS_WAIT_UNTIL( | |
1976 | [test 1 = `cat ovsdb-server2.log | grep "Schema version mismatch, checking if mydb can still be replicated or not" | wc -l]` | |
1977 | ) | |
1978 | ||
1979 | OVS_WAIT_UNTIL( | |
1980 | [test 1 = `cat ovsdb-server2.log | grep "mydb can be replicated" | wc -l]` | |
1981 | ) | |
1982 | ||
1983 | OVS_WAIT_UNTIL([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/sync-status |grep replicating]) | |
1984 | ||
1985 | AT_CHECK([ovsdb-client dump unix:db.sock a number name], 0, [dnl | |
1986 | a table | |
1987 | name number | |
1988 | ---- ------ | |
1989 | nine 9 | |
1990 | ]) | |
1991 | ||
1992 | AT_CHECK([ovsdb-client dump unix:db2.sock a number name], 0, [dnl | |
1993 | a table | |
1994 | name number | |
1995 | ---- ------ | |
1996 | nine 9 | |
1997 | ]) | |
1998 | ||
1999 | AT_CHECK([ovsdb-client transact unix:db.sock \ | |
2000 | '[["mydb", | |
2001 | {"op": "insert", | |
2002 | "table": "a", | |
2003 | "row": {"number": 6, "name": "six"}}]]'], [0], [ignore], [ignore]) | |
2004 | ||
2005 | OVS_WAIT_UNTIL([test 1 = `ovsdb-client dump unix:db2.sock a number name | grep six | wc -l`]) | |
2006 | ||
2007 | AT_CHECK([ | |
2008 | ovsdb-client dump unix:db2.sock a number name], 0, [dnl | |
2009 | a table | |
2010 | name number | |
2011 | ---- ------ | |
2012 | nine 9 | |
2013 | six 6 | |
2014 | ]) | |
2015 | ||
2016 | AT_CLEANUP |