]>
Commit | Line | Data |
---|---|---|
f85f8ebb BP |
1 | AT_BANNER([OVSDB -- execution]) |
2 | ||
39ab07af BP |
3 | m4_divert_push([PREPARE_TESTS]) |
4 | [ | |
5 | ||
6 | ordinal_schema () { | |
7 | cat <<'EOF' | |
8 | {"name": "ordinals", | |
f85f8ebb BP |
9 | "tables": { |
10 | "ordinals": { | |
11 | "columns": { | |
12 | "number": {"type": "integer"}, | |
6910a6e6 BP |
13 | "name": {"type": "string"}}, |
14 | "indexes": [["number"]]}}, | |
6aa09313 | 15 | "version": "5.1.3", |
39ab07af BP |
16 | "cksum": "12345678 9"} |
17 | EOF | |
18 | } | |
f85f8ebb | 19 | |
39ab07af BP |
20 | constraint_schema () { |
21 | cat << 'EOF' | |
22 | {"name": "constraints", | |
bd76d25d | 23 | "tables": { |
0d0f05b9 BP |
24 | "a": { |
25 | "columns": { | |
26 | "a": {"type": "integer"}, | |
27 | "a2a": {"type": {"key": {"type": "uuid", "refTable": "a"}, | |
28 | "min": 0, "max": "unlimited"}}, | |
29 | "a2b": {"type": {"key": {"type": "uuid", "refTable": "b"}, | |
30 | "min": 0, "max": "unlimited"}}}}, | |
31 | "b": { | |
32 | "columns": { | |
33 | "b": {"type": "integer"}, | |
34 | "b2a": {"type": {"key": {"type": "uuid", "refTable": "a"}, | |
35 | "min": 0, "max": "unlimited"}}, | |
36 | "b2b": {"type": {"key": {"type": "uuid", "refTable": "b"}, | |
b7585d1d BP |
37 | "min": 0, "max": "unlimited"}}, |
38 | "x": {"type": {"key": "integer", "min": 1, "max": 2}}}}, | |
bd76d25d BP |
39 | "constrained": { |
40 | "columns": { | |
41 | "positive": {"type": {"key": {"type": "integer", | |
87ab878c | 42 | "minInteger": 1}}}}, |
39ab07af BP |
43 | "maxRows": 1}}} |
44 | EOF | |
45 | } | |
bd76d25d | 46 | |
39ab07af BP |
47 | weak_schema () { |
48 | cat <<'EOF' | |
49 | {"name": "weak", | |
7360012b BP |
50 | "tables": { |
51 | "a": { | |
52 | "columns": { | |
53 | "a": {"type": "integer"}, | |
54 | "a2a": {"type": {"key": {"type": "uuid", | |
55 | "refTable": "a", | |
56 | "refType": "weak"}, | |
57 | "min": 0, "max": "unlimited"}}, | |
58 | "a2a1": {"type": {"key": {"type": "uuid", | |
59 | "refTable": "a", | |
60 | "refType": "weak"}}}, | |
61 | "a2b": {"type": {"key": {"type": "uuid", | |
62 | "refTable": "b", | |
63 | "refType": "weak"}}}}}, | |
64 | "b": { | |
65 | "columns": { | |
66 | "b": {"type": "integer"}, | |
67 | "b2a": {"type": {"key": {"type": "uuid", | |
68 | "refTable": "a", | |
69 | "refType": "weak"}, | |
39ab07af BP |
70 | "min": 0, "max": "unlimited"}}}}}} |
71 | EOF | |
72 | } | |
7360012b | 73 | |
39ab07af BP |
74 | gc_schema () { |
75 | cat <<'EOF' | |
76 | {"name": "gc", | |
c5f341ab BP |
77 | "tables": { |
78 | "root": { | |
79 | "columns": { | |
80 | "a": {"type": {"key": {"type": "uuid", | |
81 | "refTable": "a"}, | |
82 | "min": 0, "max": "unlimited"}}}, | |
83 | "isRoot": true}, | |
84 | "a": { | |
85 | "columns": { | |
86 | "a": {"type": "integer"}, | |
87 | "a2a": {"type": {"key": {"type": "uuid", | |
88 | "refTable": "a"}, | |
89 | "min": 0, "max": "unlimited"}}, | |
90 | "a2b": {"type": {"key": {"type": "uuid", | |
91 | "refTable": "b"}, | |
92 | "min": 0, "max": "unlimited"}}, | |
93 | "wa2a": {"type": {"key": {"type": "uuid", | |
94 | "refTable": "a", | |
95 | "refType": "weak"}, | |
96 | "min": 0, "max": "unlimited"}}, | |
97 | "wa2b": {"type": {"key": {"type": "uuid", | |
98 | "refTable": "b", | |
99 | "refType": "weak"}, | |
100 | "min": 0, "max": "unlimited"}}}}, | |
101 | "b": { | |
102 | "columns": { | |
103 | "b": {"type": "integer"}, | |
104 | "b2a": {"type": {"key": {"type": "uuid", | |
105 | "refTable": "a"}, | |
106 | "min": 0, "max": "unlimited"}}, | |
107 | "wb2a": {"type": {"key": {"type": "uuid", | |
108 | "refTable": "a", | |
109 | "refType": "weak"}, | |
110 | "min": 0, "max": "unlimited"}}}, | |
39ab07af BP |
111 | "isRoot": false}}} |
112 | EOF | |
113 | } | |
341c4e59 BP |
114 | |
115 | immutable_schema () { | |
116 | cat <<'EOF' | |
117 | {"name": "immutable", | |
118 | "tables": { | |
119 | "a": { | |
120 | "columns": {"i": {"type": "integer", "mutable": false}}}}} | |
121 | EOF | |
122 | } | |
39ab07af BP |
123 | ] |
124 | m4_divert_pop([PREPARE_TESTS]) | |
c5f341ab | 125 | |
e51879e9 AZ |
126 | # |
127 | # OVSDB_CHECK_EXECUTION_RO(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) | |
128 | # | |
129 | # Runs "test-ovsdb execute-readonly" with the given SCHEMA and each of the | |
130 | # TRANSACTIONS (which should be a quoted list of quoted strings). | |
131 | # | |
132 | # Checks that the overall output is OUTPUT, but UUIDs in the output | |
133 | # are replaced by markers of the form <N> where N is a number. The | |
134 | # first unique UUID is replaced by <0>, the next by <1>, and so on. | |
135 | # If a given UUID appears more than once it is always replaced by the | |
136 | # same marker. | |
137 | # | |
138 | # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. | |
139 | m4_define([OVSDB_CHECK_EXECUTION_RO], | |
140 | [AT_SETUP([$1]) | |
141 | AT_KEYWORDS([ovsdb execute execution positive $5]) | |
142 | AT_CHECK([test-ovsdb execute-readonly "`$2`" m4_foreach([txn], [$3], | |
143 | [ 'txn'])], [0], [stdout], []) | |
144 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [$4]) | |
145 | AT_CLEANUP]) | |
146 | ||
147 | OVSDB_CHECK_EXECUTION_RO([block insert on read only DB], | |
148 | [ordinal_schema], | |
149 | [[[["ordinals", | |
150 | {"op": "insert", | |
151 | "table": "ordinals", | |
152 | "row": {}}]]]], | |
153 | [[[{"details":"insert operation not allowed when database server is in read only mode","error":"not allowed"}] | |
154 | ]]) | |
155 | ||
156 | OVSDB_CHECK_EXECUTION_RO([allow select on read only DB], | |
157 | [ordinal_schema], | |
158 | [[[["ordinals", | |
159 | {"op": "select", | |
160 | "table": "ordinals", | |
161 | "where": []}]]]], | |
162 | [[[{"rows":[]}] | |
163 | ]]) | |
164 | ||
21ff1aee BP |
165 | # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) |
166 | # | |
167 | # Runs "test-ovsdb execute" with the given SCHEMA and each of the | |
168 | # TRANSACTIONS (which should be a quoted list of quoted strings). | |
169 | # | |
170 | # Checks that the overall output is OUTPUT, but UUIDs in the output | |
f85f8ebb BP |
171 | # are replaced by markers of the form <N> where N is a number. The |
172 | # first unique UUID is replaced by <0>, the next by <1>, and so on. | |
173 | # If a given UUID appears more than once it is always replaced by the | |
174 | # same marker. | |
21ff1aee BP |
175 | # |
176 | # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. | |
39ab07af | 177 | m4_define([OVSDB_CHECK_EXECUTION], |
f85f8ebb | 178 | [AT_SETUP([$1]) |
21ff1aee | 179 | AT_KEYWORDS([ovsdb execute execution positive $5]) |
39ab07af | 180 | AT_CHECK([test-ovsdb execute "`$2`" m4_foreach([txn], [$3], [ 'txn'])], |
21ff1aee | 181 | [0], [stdout], []) |
5c6d0628 | 182 | AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [$4]) |
f85f8ebb BP |
183 | AT_CLEANUP]) |
184 | ||
d198c4be | 185 | OVSDB_CHECK_EXECUTION([uuid-name must be <id>], |
39ab07af | 186 | [constraint_schema], |
d198c4be BP |
187 | [[[["constraints", |
188 | {"op": "insert", | |
189 | "table": "a", | |
190 | "row": {}, | |
191 | "uuid-name": "0"}]]]], | |
192 | [[[{"details":"Parsing ovsdb operation 1 of 1 failed: Type mismatch for member 'uuid-name'.","error":"syntax error","syntax":"{\"op\":\"insert\",\"row\":{},\"table\":\"a\",\"uuid-name\":\"0\"}"}] | |
193 | ]]) | |
194 | ||
195 | OVSDB_CHECK_EXECUTION([named-uuid must be <id>], | |
39ab07af | 196 | [constraint_schema], |
d198c4be BP |
197 | [[[["constraints", |
198 | {"op": "insert", | |
199 | "table": "a", | |
200 | "row": {"a2a": ["named-uuid", "0"]}}]]]], | |
201 | [[[{"details":"named-uuid string is not a valid <id>","error":"syntax error","syntax":"[\"named-uuid\",\"0\"]"}] | |
202 | ]]) | |
203 | ||
19b48a81 | 204 | OVSDB_CHECK_EXECUTION([duplicate uuid-name not allowed], |
39ab07af | 205 | [ordinal_schema], |
19b48a81 BP |
206 | [[[["ordinals", |
207 | {"op": "insert", | |
208 | "table": "ordinals", | |
209 | "row": {}, | |
210 | "uuid-name": "x"}, | |
211 | {"op": "insert", | |
212 | "table": "ordinals", | |
213 | "row": {}, | |
214 | "uuid-name": "x"}]]]], | |
215 | [[[{"uuid":["uuid","<0>"]},{"details":"This \"uuid-name\" appeared on an earlier \"insert\" operation.","error":"duplicate uuid-name","syntax":"\"x\""}] | |
216 | ]]) | |
217 | ||
e731d71b | 218 | m4_define([ONE_EXECUTION_EXAMPLE], [dnl |
88942565 BP |
219 | dnl At one point the "commit" code ignored new rows with all-default values, |
220 | dnl so this checks for that problem. | |
221 | OVSDB_CHECK_EXECUTION([insert default row, query table], | |
39ab07af | 222 | [ordinal_schema], |
88942565 BP |
223 | [[[["ordinals", |
224 | {"op": "insert", | |
225 | "table": "ordinals", | |
226 | "row": {}}]]], | |
227 | [[["ordinals", | |
228 | {"op": "select", | |
229 | "table": "ordinals", | |
230 | "where": []}]]]], | |
231 | [[[{"uuid":["uuid","<0>"]}] | |
232 | [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"","number":0}]}] | |
233 | ]]) | |
e731d71b | 234 | ]) |
88942565 | 235 | |
e731d71b AS |
236 | m4_define([EXECUTION_EXAMPLES], [ |
237 | ONE_EXECUTION_EXAMPLE | |
f85f8ebb | 238 | OVSDB_CHECK_EXECUTION([insert row, query table], |
39ab07af | 239 | [ordinal_schema], |
9cb53f26 BP |
240 | [[[["ordinals", |
241 | {"op": "insert", | |
f85f8ebb | 242 | "table": "ordinals", |
21ff1aee | 243 | "row": {"number": 0, "name": "zero"}}]]], |
9cb53f26 BP |
244 | [[["ordinals", |
245 | {"op": "select", | |
f85f8ebb | 246 | "table": "ordinals", |
21ff1aee | 247 | "where": []}]]]], |
f85f8ebb BP |
248 | [[[{"uuid":["uuid","<0>"]}] |
249 | [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]}] | |
250 | ]]) | |
251 | ||
252 | OVSDB_CHECK_EXECUTION([insert rows, query by value], | |
39ab07af | 253 | [ordinal_schema], |
9cb53f26 BP |
254 | [[[["ordinals", |
255 | {"op": "insert", | |
f85f8ebb | 256 | "table": "ordinals", |
21ff1aee | 257 | "row": {"number": 0, "name": "zero"}}]]], |
9cb53f26 BP |
258 | [[["ordinals", |
259 | {"op": "insert", | |
f85f8ebb | 260 | "table": "ordinals", |
21ff1aee | 261 | "row": {"number": 1, "name": "one"}}]]], |
9cb53f26 BP |
262 | [[["ordinals", |
263 | {"op": "select", | |
f85f8ebb | 264 | "table": "ordinals", |
21ff1aee | 265 | "where": [["name", "==", "zero"]]}]]], |
9cb53f26 BP |
266 | [[["ordinals", |
267 | {"op": "select", | |
f85f8ebb | 268 | "table": "ordinals", |
21ff1aee | 269 | "where": [["name", "==", "one"]]}]]]], |
f85f8ebb BP |
270 | [[[{"uuid":["uuid","<0>"]}] |
271 | [{"uuid":["uuid","<1>"]}] | |
272 | [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0}]}] | |
273 | [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}] | |
274 | ]]) | |
275 | ||
276 | OVSDB_CHECK_EXECUTION([insert rows, query by named-uuid], | |
39ab07af | 277 | [ordinal_schema], |
9cb53f26 BP |
278 | [[[["ordinals", |
279 | {"op": "insert", | |
f85f8ebb BP |
280 | "table": "ordinals", |
281 | "row": {"number": 0, "name": "zero"}, | |
282 | "uuid-name": "first"}, | |
283 | {"op": "insert", | |
284 | "table": "ordinals", | |
285 | "row": {"number": 1, "name": "one"}, | |
286 | "uuid-name": "second"}, | |
287 | {"op": "select", | |
288 | "table": "ordinals", | |
289 | "where": [["_uuid", "==", ["named-uuid", "first"]]]}, | |
290 | {"op": "select", | |
291 | "table": "ordinals", | |
21ff1aee | 292 | "where": [["_uuid", "==", ["named-uuid", "second"]]]}]]]], |
f85f8ebb BP |
293 | [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0}]},{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}] |
294 | ]]) | |
295 | ||
296 | OVSDB_CHECK_EXECUTION([insert rows, update rows by value], | |
39ab07af | 297 | [ordinal_schema], |
9cb53f26 BP |
298 | [[[["ordinals", |
299 | {"op": "insert", | |
f85f8ebb BP |
300 | "table": "ordinals", |
301 | "row": {"number": 0, "name": "zero"}, | |
21ff1aee | 302 | "uuid-name": "first"}]]], |
9cb53f26 BP |
303 | [[["ordinals", |
304 | {"op": "insert", | |
f85f8ebb BP |
305 | "table": "ordinals", |
306 | "row": {"number": 1, "name": "one"}, | |
21ff1aee | 307 | "uuid-name": "first"}]]], |
9cb53f26 BP |
308 | [[["ordinals", |
309 | {"op": "update", | |
f85f8ebb BP |
310 | "table": "ordinals", |
311 | "where": [["name", "==", "zero"]], | |
21ff1aee | 312 | "row": {"name": "nought"}}]]], |
9cb53f26 BP |
313 | [[["ordinals", |
314 | {"op": "select", | |
f85f8ebb BP |
315 | "table": "ordinals", |
316 | "where": [], | |
21ff1aee | 317 | "sort": ["number"]}]]]], |
f85f8ebb BP |
318 | [[[{"uuid":["uuid","<0>"]}] |
319 | [{"uuid":["uuid","<1>"]}] | |
320 | [{"count":1}] | |
321 | [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"nought","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}] | |
322 | ]]) | |
323 | ||
e9f8f936 | 324 | OVSDB_CHECK_EXECUTION([insert rows, mutate rows], |
39ab07af | 325 | [ordinal_schema], |
9cb53f26 BP |
326 | [[[["ordinals", |
327 | {"op": "insert", | |
e9f8f936 BP |
328 | "table": "ordinals", |
329 | "row": {"number": 0, "name": "zero"}, | |
330 | "uuid-name": "first"}]]], | |
9cb53f26 BP |
331 | [[["ordinals", |
332 | {"op": "insert", | |
e9f8f936 BP |
333 | "table": "ordinals", |
334 | "row": {"number": 1, "name": "one"}, | |
335 | "uuid-name": "first"}]]], | |
9cb53f26 BP |
336 | [[["ordinals", |
337 | {"op": "mutate", | |
e9f8f936 BP |
338 | "table": "ordinals", |
339 | "where": [["name", "==", "zero"]], | |
340 | "mutations": [["number", "+=", 2]]}]]], | |
9cb53f26 BP |
341 | [[["ordinals", |
342 | {"op": "select", | |
e9f8f936 BP |
343 | "table": "ordinals", |
344 | "where": [], | |
345 | "sort": ["number"]}]]]], | |
346 | [[[{"uuid":["uuid","<0>"]}] | |
347 | [{"uuid":["uuid","<1>"]}] | |
348 | [{"count":1}] | |
349 | [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<2>"],"name":"one","number":1},{"_uuid":["uuid","<0>"],"_version":["uuid","<3>"],"name":"zero","number":2}]}] | |
350 | ]]) | |
351 | ||
f85f8ebb | 352 | OVSDB_CHECK_EXECUTION([insert rows, delete by named-uuid], |
39ab07af | 353 | [ordinal_schema], |
9cb53f26 BP |
354 | [[[["ordinals", |
355 | {"op": "insert", | |
f85f8ebb BP |
356 | "table": "ordinals", |
357 | "row": {"number": 0, "name": "zero"}, | |
358 | "uuid-name": "first"}, | |
359 | {"op": "insert", | |
360 | "table": "ordinals", | |
361 | "row": {"number": 1, "name": "one"}, | |
362 | "uuid-name": "second"}, | |
363 | {"op": "delete", | |
364 | "table": "ordinals", | |
365 | "where": [["_uuid", "==", ["named-uuid", "first"]]]}, | |
366 | {"op": "select", | |
367 | "table": "ordinals", | |
368 | "where": [], | |
21ff1aee | 369 | "columns": ["name","number"]}]]]], |
f85f8ebb BP |
370 | [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":1},{"rows":[{"name":"one","number":1}]}] |
371 | ]]) | |
372 | ||
373 | OVSDB_CHECK_EXECUTION([insert rows, delete rows by value], | |
39ab07af | 374 | [ordinal_schema], |
9cb53f26 BP |
375 | [[[["ordinals", |
376 | {"op": "insert", | |
f85f8ebb BP |
377 | "table": "ordinals", |
378 | "row": {"number": 0, "name": "zero"}, | |
21ff1aee | 379 | "uuid-name": "first"}]]], |
9cb53f26 BP |
380 | [[["ordinals", |
381 | {"op": "insert", | |
f85f8ebb BP |
382 | "table": "ordinals", |
383 | "row": {"number": 1, "name": "one"}, | |
21ff1aee | 384 | "uuid-name": "first"}]]], |
9cb53f26 BP |
385 | [[["ordinals", |
386 | {"op": "delete", | |
f85f8ebb | 387 | "table": "ordinals", |
21ff1aee | 388 | "where": [["name", "==", "zero"]]}]]], |
9cb53f26 BP |
389 | [[["ordinals", |
390 | {"op": "select", | |
f85f8ebb | 391 | "table": "ordinals", |
21ff1aee | 392 | "where": []}]]]], |
f85f8ebb BP |
393 | [[[{"uuid":["uuid","<0>"]}] |
394 | [{"uuid":["uuid","<1>"]}] | |
395 | [{"count":1}] | |
396 | [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<2>"],"name":"one","number":1}]}] | |
397 | ]]) | |
398 | ||
399 | OVSDB_CHECK_EXECUTION([insert rows, delete by (non-matching) value], | |
39ab07af | 400 | [ordinal_schema], |
9cb53f26 BP |
401 | [[[["ordinals", |
402 | {"op": "insert", | |
f85f8ebb BP |
403 | "table": "ordinals", |
404 | "row": {"number": 0, "name": "zero"}, | |
21ff1aee | 405 | "uuid-name": "first"}]]], |
9cb53f26 BP |
406 | [[["ordinals", |
407 | {"op": "insert", | |
f85f8ebb BP |
408 | "table": "ordinals", |
409 | "row": {"number": 1, "name": "one"}, | |
21ff1aee | 410 | "uuid-name": "first"}]]], |
9cb53f26 BP |
411 | [[["ordinals", |
412 | {"op": "delete", | |
f85f8ebb | 413 | "table": "ordinals", |
21ff1aee | 414 | "where": [["name", "==", "nought"]]}]]], |
9cb53f26 BP |
415 | [[["ordinals", |
416 | {"op": "select", | |
f85f8ebb BP |
417 | "table": "ordinals", |
418 | "where": [], | |
21ff1aee | 419 | "sort": ["number"]}]]]], |
f85f8ebb BP |
420 | [[[{"uuid":["uuid","<0>"]}] |
421 | [{"uuid":["uuid","<1>"]}] | |
422 | [{"count":0}] | |
423 | [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}] | |
424 | ]]) | |
425 | ||
426 | OVSDB_CHECK_EXECUTION([insert rows, delete all], | |
39ab07af | 427 | [ordinal_schema], |
9cb53f26 BP |
428 | [[[["ordinals", |
429 | {"op": "insert", | |
f85f8ebb BP |
430 | "table": "ordinals", |
431 | "row": {"number": 0, "name": "zero"}, | |
432 | "uuid-name": "first"}, | |
433 | {"op": "insert", | |
434 | "table": "ordinals", | |
435 | "row": {"number": 1, "name": "one"}, | |
436 | "uuid-name": "second"}, | |
437 | {"op": "delete", | |
438 | "table": "ordinals", | |
439 | "where": []}, | |
440 | {"op": "select", | |
441 | "table": "ordinals", | |
442 | "where": [], | |
21ff1aee | 443 | "columns": ["name","number"]}]]]], |
f85f8ebb BP |
444 | [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":2},{"rows":[]}] |
445 | ]]) | |
446 | ||
447 | OVSDB_CHECK_EXECUTION([insert row, query table, commit], | |
39ab07af | 448 | [ordinal_schema], |
9cb53f26 BP |
449 | [[[["ordinals", |
450 | {"op": "insert", | |
f85f8ebb BP |
451 | "table": "ordinals", |
452 | "row": {"number": 0, "name": "zero"}}, | |
453 | {"op": "select", | |
454 | "table": "ordinals", | |
455 | "where": []}, | |
456 | {"op": "commit", | |
21ff1aee | 457 | "durable": false}]]]], |
f85f8ebb BP |
458 | [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}] |
459 | ]]) | |
460 | ||
461 | OVSDB_CHECK_EXECUTION([insert row, query table, commit durably], | |
39ab07af | 462 | [ordinal_schema], |
9cb53f26 BP |
463 | [[[["ordinals", |
464 | {"op": "insert", | |
f85f8ebb BP |
465 | "table": "ordinals", |
466 | "row": {"number": 0, "name": "zero"}}, | |
467 | {"op": "select", | |
468 | "table": "ordinals", | |
469 | "where": []}, | |
470 | {"op": "commit", | |
21ff1aee | 471 | "durable": true}]]]], |
f85f8ebb BP |
472 | [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}] |
473 | ]]) | |
474 | ||
475 | OVSDB_CHECK_EXECUTION([equality wait with correct rows], | |
39ab07af | 476 | [ordinal_schema], |
9cb53f26 BP |
477 | [[[["ordinals", |
478 | {"op": "insert", | |
f85f8ebb BP |
479 | "table": "ordinals", |
480 | "row": {"number": 0, "name": "zero"}}, | |
481 | {"op": "insert", | |
482 | "table": "ordinals", | |
483 | "row": {"number": 1, "name": "one"}}, | |
484 | {"op": "wait", | |
485 | "timeout": 0, | |
486 | "table": "ordinals", | |
487 | "where": [], | |
488 | "columns": ["name", "number"], | |
489 | "until": "==", | |
490 | "rows": [{"name": "zero", "number": 0}, | |
21ff1aee | 491 | {"name": "one", "number": 1}]}]]]], |
f85f8ebb BP |
492 | [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}] |
493 | ]]) | |
494 | ||
495 | OVSDB_CHECK_EXECUTION([equality wait with extra row], | |
39ab07af | 496 | [ordinal_schema], |
9cb53f26 BP |
497 | [[[["ordinals", |
498 | {"op": "insert", | |
f85f8ebb BP |
499 | "table": "ordinals", |
500 | "row": {"number": 0, "name": "zero"}}, | |
501 | {"op": "insert", | |
502 | "table": "ordinals", | |
503 | "row": {"number": 1, "name": "one"}}, | |
504 | {"op": "wait", | |
505 | "timeout": 0, | |
506 | "table": "ordinals", | |
507 | "where": [], | |
508 | "columns": ["name", "number"], | |
509 | "until": "==", | |
510 | "rows": [{"name": "zero", "number": 0}, | |
511 | {"name": "one", "number": 1}, | |
21ff1aee | 512 | {"name": "two", "number": 2}]}]]]], |
cd423a77 | 513 | [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"where\" clause test failed","error":"timed out"}] |
f85f8ebb BP |
514 | ]]) |
515 | ||
516 | OVSDB_CHECK_EXECUTION([equality wait with missing row], | |
39ab07af | 517 | [ordinal_schema], |
9cb53f26 BP |
518 | [[[["ordinals", |
519 | {"op": "insert", | |
f85f8ebb BP |
520 | "table": "ordinals", |
521 | "row": {"number": 0, "name": "zero"}}, | |
522 | {"op": "insert", | |
523 | "table": "ordinals", | |
524 | "row": {"number": 1, "name": "one"}}, | |
525 | {"op": "wait", | |
526 | "timeout": 0, | |
527 | "table": "ordinals", | |
528 | "where": [], | |
529 | "columns": ["name", "number"], | |
530 | "until": "==", | |
21ff1aee | 531 | "rows": [{"name": "one", "number": 1}]}]]]], |
cd423a77 | 532 | [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"where\" clause test failed","error":"timed out"}] |
f85f8ebb BP |
533 | ]]) |
534 | ||
535 | OVSDB_CHECK_EXECUTION([inequality wait with correct rows], | |
39ab07af | 536 | [ordinal_schema], |
9cb53f26 BP |
537 | [[[["ordinals", |
538 | {"op": "insert", | |
f85f8ebb BP |
539 | "table": "ordinals", |
540 | "row": {"number": 0, "name": "zero"}}, | |
541 | {"op": "insert", | |
542 | "table": "ordinals", | |
543 | "row": {"number": 1, "name": "one"}}, | |
544 | {"op": "wait", | |
545 | "timeout": 0, | |
546 | "table": "ordinals", | |
547 | "where": [], | |
548 | "columns": ["name", "number"], | |
549 | "until": "!=", | |
550 | "rows": [{"name": "zero", "number": 0}, | |
21ff1aee | 551 | {"name": "one", "number": 1}]}]]]], |
cd423a77 | 552 | [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"where\" clause test failed","error":"timed out"}] |
f85f8ebb BP |
553 | ]]) |
554 | ||
555 | OVSDB_CHECK_EXECUTION([inequality wait with extra row], | |
39ab07af | 556 | [ordinal_schema], |
9cb53f26 BP |
557 | [[[["ordinals", |
558 | {"op": "insert", | |
f85f8ebb BP |
559 | "table": "ordinals", |
560 | "row": {"number": 0, "name": "zero"}}, | |
561 | {"op": "insert", | |
562 | "table": "ordinals", | |
563 | "row": {"number": 1, "name": "one"}}, | |
564 | {"op": "wait", | |
565 | "timeout": 0, | |
566 | "table": "ordinals", | |
567 | "where": [], | |
568 | "columns": ["name", "number"], | |
569 | "until": "!=", | |
570 | "rows": [{"name": "zero", "number": 0}, | |
571 | {"name": "one", "number": 1}, | |
21ff1aee | 572 | {"name": "two", "number": 2}]}]]]], |
f85f8ebb BP |
573 | [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}] |
574 | ]]) | |
575 | ||
576 | OVSDB_CHECK_EXECUTION([inequality wait with missing row], | |
39ab07af | 577 | [ordinal_schema], |
9cb53f26 BP |
578 | [[[["ordinals", |
579 | {"op": "insert", | |
f85f8ebb BP |
580 | "table": "ordinals", |
581 | "row": {"number": 0, "name": "zero"}}, | |
582 | {"op": "insert", | |
583 | "table": "ordinals", | |
584 | "row": {"number": 1, "name": "one"}}, | |
585 | {"op": "wait", | |
586 | "timeout": 0, | |
587 | "table": "ordinals", | |
588 | "where": [], | |
589 | "columns": ["name", "number"], | |
590 | "until": "!=", | |
21ff1aee | 591 | "rows": [{"name": "one", "number": 1}]}]]]], |
f85f8ebb BP |
592 | [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}] |
593 | ]]) | |
bd76d25d BP |
594 | |
595 | OVSDB_CHECK_EXECUTION([insert and update constraints], | |
39ab07af | 596 | [constraint_schema], |
9cb53f26 BP |
597 | [[[["constraints", |
598 | {"op": "insert", | |
bd76d25d BP |
599 | "table": "constrained", |
600 | "row": {}}]]], | |
9cb53f26 BP |
601 | [[["constraints", |
602 | {"op": "insert", | |
bd76d25d BP |
603 | "table": "constrained", |
604 | "row": {"positive": -1}}]]], | |
9cb53f26 BP |
605 | [[["constraints", |
606 | {"op": "update", | |
bd76d25d BP |
607 | "table": "constrained", |
608 | "where": [], | |
87ab878c BP |
609 | "row": {"positive": -2}}]]], |
610 | [[["constraints", | |
611 | {"op": "insert", | |
612 | "table": "constrained", | |
613 | "row": {"positive": 1}}]]], | |
614 | [[["constraints", | |
615 | {"op": "insert", | |
616 | "table": "constrained", | |
617 | "row": {"positive": 2}}]]]], | |
bd76d25d BP |
618 | [[[{"details":"0 is less than minimum allowed value 1","error":"constraint violation"}] |
619 | [{"details":"-1 is less than minimum allowed value 1","error":"constraint violation"}] | |
620 | [{"details":"-2 is less than minimum allowed value 1","error":"constraint violation"}] | |
87ab878c BP |
621 | [{"uuid":["uuid","<0>"]}] |
622 | [{"uuid":["uuid","<1>"]},{"details":"transaction causes \"constrained\" table to contain 2 rows, greater than the schema-defined limit of 1 row(s)","error":"constraint violation"}] | |
0d0f05b9 BP |
623 | ]]) |
624 | ||
6910a6e6 | 625 | OVSDB_CHECK_EXECUTION([index uniqueness checking], |
39ab07af | 626 | [ordinal_schema], |
6910a6e6 BP |
627 | dnl Insert initial row. |
628 | [[[["ordinals", | |
629 | {"op": "insert", | |
630 | "table": "ordinals", | |
631 | "row": {"number": 1, "name": "one"}}]]], | |
632 | dnl Try to insert row with identical value (fails). | |
633 | [[["ordinals", | |
634 | {"op": "insert", | |
635 | "table": "ordinals", | |
636 | "row": {"number": 1, "name": "another one"}}]]], | |
637 | dnl Remove initial row and insert new row with identical value in a single | |
638 | dnl transaction (succeeds). | |
639 | [[["ordinals", | |
640 | {"op": "insert", | |
641 | "table": "ordinals", | |
642 | "row": {"number": 1, "name": "another one"}}, | |
643 | {"op": "delete", | |
644 | "table": "ordinals", | |
645 | "where": [["name", "==", "one"]]}]]], | |
646 | dnl Remove row and insert two new rows with identical value in a single | |
647 | dnl transaction (fails). | |
648 | [[["ordinals", | |
649 | {"op": "delete", | |
650 | "table": "ordinals", | |
651 | "where": []}, | |
652 | {"op": "insert", | |
653 | "table": "ordinals", | |
654 | "row": {"number": 1, "name": "one"}}, | |
655 | {"op": "insert", | |
656 | "table": "ordinals", | |
657 | "row": {"number": 1, "name": "still another one"}}]]], | |
658 | dnl Add new row with different value (succeeds). | |
659 | [[["ordinals", | |
660 | {"op": "insert", | |
661 | "table": "ordinals", | |
662 | "row": {"number": 2, "name": "two"}}]]], | |
663 | dnl Change rows so values collide (fails). | |
664 | [[["ordinals", | |
665 | {"op": "update", | |
666 | "table": "ordinals", | |
667 | "where": [], | |
668 | "row": {"number": 3}}]]], | |
669 | dnl Swap rows' values (succeeds). | |
670 | [[["ordinals", | |
671 | {"op": "update", | |
672 | "table": "ordinals", | |
673 | "where": [["number", "==", 1]], | |
674 | "row": {"number": 2, "name": "old two"}}, | |
675 | {"op": "update", | |
676 | "table": "ordinals", | |
677 | "where": [["name", "==", "two"]], | |
678 | "row": {"number": 1, "name": "old one"}}]]], | |
679 | dnl Change all rows' values to values not used before and insert values that | |
680 | dnl collide (only) with their previous values (succeeds). | |
681 | [[["ordinals", | |
682 | {"op": "mutate", | |
683 | "table": "ordinals", | |
684 | "where": [], | |
685 | "mutations": [["number", "*=", 10]]}, | |
686 | {"op": "insert", | |
687 | "table": "ordinals", | |
688 | "row": {"number": 1, "name": "new one"}}, | |
689 | {"op": "insert", | |
690 | "table": "ordinals", | |
691 | "row": {"number": 2, "name": "new two"}}, | |
692 | {"op": "select", | |
693 | "table": "ordinals", | |
694 | "where": [], | |
695 | "columns": ["number", "name"], | |
696 | "sort": ["number"]}]]]], | |
697 | [[[{"uuid":["uuid","<0>"]}] | |
698 | [{"uuid":["uuid","<1>"]},{"details":"Transaction causes multiple rows in \"ordinals\" table to have identical values (1) for index on column \"number\". First row, with UUID <0>, existed in the database before this transaction and was not modified by the transaction. Second row, with UUID <1>, was inserted by this transaction.","error":"constraint violation"}] | |
699 | [{"uuid":["uuid","<2>"]},{"count":1}] | |
700 | [{"count":1},{"uuid":["uuid","<3>"]},{"uuid":["uuid","<4>"]},{"details":"Transaction causes multiple rows in \"ordinals\" table to have identical values (1) for index on column \"number\". First row, with UUID <4>, was inserted by this transaction. Second row, with UUID <3>, was inserted by this transaction.","error":"constraint violation"}] | |
701 | [{"uuid":["uuid","<5>"]}] | |
702 | [{"count":2},{"details":"Transaction causes multiple rows in \"ordinals\" table to have identical values (3) for index on column \"number\". First row, with UUID <5>, had the following index values before the transaction: 2. Second row, with UUID <2>, had the following index values before the transaction: 1.","error":"constraint violation"}] | |
703 | [{"count":1},{"count":1}] | |
704 | [{"count":2},{"uuid":["uuid","<6>"]},{"uuid":["uuid","<7>"]},{"rows":[{"name":"new one","number":1},{"name":"new two","number":2},{"name":"old one","number":10},{"name":"old two","number":20}]}] | |
705 | ]]) | |
706 | ||
0d0f05b9 | 707 | OVSDB_CHECK_EXECUTION([referential integrity -- simple], |
39ab07af | 708 | [constraint_schema], |
9cb53f26 BP |
709 | [[[["constraints", |
710 | {"op": "insert", | |
0d0f05b9 BP |
711 | "table": "b", |
712 | "row": {"b": 1}, | |
713 | "uuid-name": "brow"}, | |
714 | {"op": "insert", | |
715 | "table": "a", | |
716 | "row": {"a": 0, | |
717 | "a2b": ["set", [["named-uuid", "brow"]]]}}, | |
718 | {"op": "insert", | |
719 | "table": "a", | |
720 | "row": {"a": 1, | |
721 | "a2b": ["set", [["named-uuid", "brow"]]]}}, | |
722 | {"op": "insert", | |
723 | "table": "a", | |
724 | "row": {"a": 2, | |
725 | "a2b": ["set", [["named-uuid", "brow"]]]}}]]], | |
9cb53f26 BP |
726 | [[["constraints", |
727 | {"op": "delete", | |
0d0f05b9 BP |
728 | "table": "b", |
729 | "where": []}]]], | |
b7585d1d BP |
730 | dnl Check that "mutate" honors number-of-elements constraints on sets and maps. |
731 | [[["constraints", | |
732 | {"op": "mutate", | |
733 | "table": "b", | |
734 | "where": [], | |
735 | "mutations": [["x", "delete", 0]]}]]], | |
9cb53f26 BP |
736 | [[["constraints", |
737 | {"op": "delete", | |
0d0f05b9 BP |
738 | "table": "a", |
739 | "where": [["a", "==", 0]]}]]], | |
9cb53f26 BP |
740 | [[["constraints", |
741 | {"op": "delete", | |
0d0f05b9 BP |
742 | "table": "b", |
743 | "where": []}]]], | |
9cb53f26 BP |
744 | [[["constraints", |
745 | {"op": "delete", | |
0d0f05b9 BP |
746 | "table": "a", |
747 | "where": [["a", "==", 1]]}]]], | |
9cb53f26 BP |
748 | [[["constraints", |
749 | {"op": "delete", | |
0d0f05b9 BP |
750 | "table": "b", |
751 | "where": []}]]], | |
9cb53f26 BP |
752 | [[["constraints", |
753 | {"op": "delete", | |
0d0f05b9 BP |
754 | "table": "a", |
755 | "where": [["a", "==", 2]]}]]], | |
9cb53f26 BP |
756 | [[["constraints", |
757 | {"op": "delete", | |
0d0f05b9 BP |
758 | "table": "b", |
759 | "where": []}]]]], | |
760 | [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}] | |
761 | [{"count":1},{"details":"cannot delete b row <0> because of 3 remaining reference(s)","error":"referential integrity violation"}] | |
b7585d1d | 762 | [{"details":"Attempted to store 0 elements in set of 1 to 2 integers.","error":"constraint violation"}] |
0d0f05b9 BP |
763 | [{"count":1}] |
764 | [{"count":1},{"details":"cannot delete b row <0> because of 2 remaining reference(s)","error":"referential integrity violation"}] | |
765 | [{"count":1}] | |
766 | [{"count":1},{"details":"cannot delete b row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}] | |
767 | [{"count":1}] | |
768 | [{"count":1}] | |
769 | ]]) | |
770 | ||
771 | OVSDB_CHECK_EXECUTION([referential integrity -- mutual references], | |
39ab07af | 772 | [constraint_schema], |
9cb53f26 BP |
773 | [[[["constraints", |
774 | {"op": "insert", | |
0d0f05b9 BP |
775 | "table": "a", |
776 | "row": {"a": 0, | |
777 | "a2b": ["set", [["named-uuid", "row2"]]], | |
778 | "a2a": ["set", [["named-uuid", "row1"]]]}, | |
779 | "uuid-name": "row1"}, | |
780 | {"op": "insert", | |
781 | "table": "b", | |
782 | "row": {"b": 1, | |
783 | "b2b": ["set", [["named-uuid", "row2"]]], | |
784 | "b2a": ["set", [["named-uuid", "row1"]]]}, | |
785 | "uuid-name": "row2"}]]], | |
9cb53f26 BP |
786 | [[["constraints", |
787 | {"op": "insert", | |
0d0f05b9 BP |
788 | "table": "a", |
789 | "row": {"a2b": ["set", [["uuid", "b516b960-5b19-4fc2-bb82-fe1cbd6d0241"]]]}}]]], | |
9cb53f26 BP |
790 | [[["constraints", |
791 | {"op": "delete", | |
0d0f05b9 BP |
792 | "table": "a", |
793 | "where": [["a", "==", 0]]}]]], | |
9cb53f26 BP |
794 | [[["constraints", |
795 | {"op": "delete", | |
0d0f05b9 BP |
796 | "table": "b", |
797 | "where": [["b", "==", 1]]}]]], | |
798 | dnl Try the deletions again to make sure that the refcounts got rolled back. | |
9cb53f26 BP |
799 | [[["constraints", |
800 | {"op": "delete", | |
0d0f05b9 BP |
801 | "table": "a", |
802 | "where": [["a", "==", 0]]}]]], | |
9cb53f26 BP |
803 | [[["constraints", |
804 | {"op": "delete", | |
0d0f05b9 BP |
805 | "table": "b", |
806 | "where": [["b", "==", 1]]}]]], | |
9cb53f26 BP |
807 | [[["constraints", |
808 | {"op": "delete", | |
0d0f05b9 BP |
809 | "table": "a", |
810 | "where": [["a", "==", 0]]}, | |
811 | {"op": "delete", | |
812 | "table": "b", | |
813 | "where": [["b", "==", 1]]}]]]], | |
fbf925e4 | 814 | [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}] |
97f7803b | 815 | [{"uuid":["uuid","<2>"]},{"details":"Table a column a2b row <2> references nonexistent row <3> in table b.","error":"referential integrity violation"}] |
0d0f05b9 BP |
816 | [{"count":1},{"details":"cannot delete a row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}] |
817 | [{"count":1},{"details":"cannot delete b row <1> because of 1 remaining reference(s)","error":"referential integrity violation"}] | |
818 | [{"count":1},{"details":"cannot delete a row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}] | |
819 | [{"count":1},{"details":"cannot delete b row <1> because of 1 remaining reference(s)","error":"referential integrity violation"}] | |
820 | [{"count":1},{"count":1}] | |
7360012b BP |
821 | ]]) |
822 | ||
823 | OVSDB_CHECK_EXECUTION([weak references], | |
39ab07af | 824 | [weak_schema], |
7360012b BP |
825 | [[[["weak", |
826 | {"op": "insert", | |
827 | "table": "a", | |
828 | "row": {"a": 0, | |
829 | "a2a": ["set", [["named-uuid", "row1"], | |
830 | ["named-uuid", "row2"], | |
831 | ["uuid", "0e767b36-6822-4044-8307-d58467e04669"]]], | |
832 | "a2a1": ["named-uuid", "row1"], | |
833 | "a2b": ["named-uuid", "row3"]}, | |
834 | "uuid-name": "row1"}, | |
835 | {"op": "insert", | |
836 | "table": "a", | |
837 | "row": {"a": 1, | |
838 | "a2a": ["set", [["named-uuid", "row1"], | |
839 | ["named-uuid", "row2"]]], | |
840 | "a2a1": ["named-uuid", "row2"], | |
841 | "a2b": ["named-uuid", "row3"]}, | |
842 | "uuid-name": "row2"}, | |
843 | {"op": "insert", | |
844 | "table": "a", | |
845 | "row": {"a": 2, | |
846 | "a2a": ["set", [["named-uuid", "row1"], | |
847 | ["named-uuid", "row2"]]], | |
848 | "a2a1": ["named-uuid", "row2"], | |
849 | "a2b": ["named-uuid", "row4"]}}, | |
850 | {"op": "insert", | |
851 | "table": "b", | |
852 | "row": {"b": 2, | |
853 | "b2a": ["named-uuid", "row1"]}, | |
854 | "uuid-name": "row3"}, | |
855 | {"op": "insert", | |
856 | "table": "b", | |
857 | "row": {"b": 3, | |
858 | "b2a": ["named-uuid", "row2"]}, | |
859 | "uuid-name": "row4"}]]], | |
860 | dnl Check that the nonexistent row UUID we added to row a0 was deleted, | |
861 | dnl and that other rows were inserted as requested. | |
862 | [[["weak", | |
863 | {"op": "select", | |
864 | "table": "a", | |
865 | "where": [], | |
866 | "columns": ["_uuid", "a2a", "a2a1", "a2b"], | |
867 | "sort": ["a"]}]]], | |
868 | [[["weak", | |
869 | {"op": "select", | |
870 | "table": "b", | |
871 | "where": [], | |
872 | "columns": ["_uuid", "b", "b2a"], | |
873 | "sort": ["b"]}]]], | |
874 | dnl Try to insert invalid all-zeros weak reference (the default) into | |
875 | dnl "a2b", which requires exactly one value. | |
876 | [[["weak", | |
877 | {"op": "insert", | |
878 | "table": "a", | |
1f4f3cd7 BP |
879 | "row": {"a2a1": ["named-uuid", "me"]}, |
880 | "uuid-name": "me"}]]], | |
7360012b BP |
881 | dnl Try to delete row from "b" that is referred to by weak references |
882 | dnl from "a" table "a2b" column that requires exactly one value. | |
883 | [[["weak", | |
884 | {"op": "delete", | |
885 | "table": "b", | |
886 | "where": [["b", "==", 3]]}]]], | |
887 | dnl Try to delete row from "a" that is referred to by weak references | |
888 | dnl from "a" table "a2a1" column that requires exactly one value. | |
889 | [[["weak", | |
890 | {"op": "delete", | |
891 | "table": "a", | |
892 | "where": [["a", "==", 1]]}]]], | |
893 | dnl Delete the row that had the reference that caused the previous | |
894 | dnl deletion to fail, then check that other rows are unchanged. | |
895 | [[["weak", | |
896 | {"op": "delete", | |
897 | "table": "a", | |
898 | "where": [["a", "==", 2]]}]]], | |
899 | [[["weak", | |
900 | {"op": "select", | |
901 | "table": "a", | |
902 | "where": [], | |
903 | "columns": ["_uuid", "a2a", "a2a1", "a2b"], | |
904 | "sort": ["a"]}]]], | |
905 | [[["weak", | |
906 | {"op": "select", | |
907 | "table": "b", | |
908 | "where": [], | |
909 | "columns": ["_uuid", "b", "b2a"], | |
910 | "sort": ["b"]}]]], | |
911 | dnl Delete row a0 then check that references to it were removed. | |
912 | [[["weak", | |
913 | {"op": "delete", | |
914 | "table": "a", | |
915 | "where": [["a", "==", 0]]}]]], | |
916 | [[["weak", | |
917 | {"op": "select", | |
918 | "table": "a", | |
919 | "where": [], | |
920 | "columns": ["_uuid", "a2a", "a2a1", "a2b"], | |
921 | "sort": ["a"]}]]], | |
922 | [[["weak", | |
923 | {"op": "select", | |
924 | "table": "b", | |
925 | "where": [], | |
926 | "columns": ["_uuid", "b", "b2a"], | |
927 | "sort": ["b"]}]]], | |
928 | dnl Delete row a1 then check that references to it were removed. | |
929 | [[["weak", | |
930 | {"op": "delete", | |
931 | "table": "a", | |
932 | "where": [["a", "==", 1]]}]]], | |
933 | [[["weak", | |
934 | {"op": "select", | |
935 | "table": "a", | |
936 | "where": [], | |
937 | "columns": ["_uuid", "a2a", "a2a1", "a2b"], | |
938 | "sort": ["a"]}]]], | |
939 | [[["weak", | |
940 | {"op": "select", | |
941 | "table": "b", | |
942 | "where": [], | |
943 | "columns": ["_uuid", "b", "b2a"], | |
944 | "sort": ["b"]}]]]], | |
945 | [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]},{"uuid":["uuid","<4>"]}] | |
946 | [{"rows":[{"_uuid":["uuid","<0>"],"a2a":["set",[["uuid","<0>"],["uuid","<1>"]]],"a2a1":["uuid","<0>"],"a2b":["uuid","<3>"]},{"_uuid":["uuid","<1>"],"a2a":["set",[["uuid","<0>"],["uuid","<1>"]]],"a2a1":["uuid","<1>"],"a2b":["uuid","<3>"]},{"_uuid":["uuid","<2>"],"a2a":["set",[["uuid","<0>"],["uuid","<1>"]]],"a2a1":["uuid","<1>"],"a2b":["uuid","<4>"]}]}] | |
947 | [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["uuid","<0>"]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}] | |
948 | [{"uuid":["uuid","<5>"]},{"details":"Weak reference column \"a2b\" in \"a\" row <5> (inserted within this transaction) contained all-zeros UUID (probably as the default value for this column) but deleting this value caused a constraint volation because this column is not allowed to be empty.","error":"constraint violation"}] | |
949 | [{"count":1},{"details":"Deletion of 1 weak reference(s) to deleted (or never-existing) rows from column \"a2b\" in \"a\" row <2> caused this column to become empty, but constraints on this column disallow an empty column.","error":"constraint violation"}] | |
950 | [{"count":1},{"details":"Deletion of 1 weak reference(s) to deleted (or never-existing) rows from column \"a2a1\" in \"a\" row <2> caused this column to become empty, but constraints on this column disallow an empty column.","error":"constraint violation"}] | |
951 | [{"count":1}] | |
952 | [{"rows":[{"_uuid":["uuid","<0>"],"a2a":["set",[["uuid","<0>"],["uuid","<1>"]]],"a2a1":["uuid","<0>"],"a2b":["uuid","<3>"]},{"_uuid":["uuid","<1>"],"a2a":["set",[["uuid","<0>"],["uuid","<1>"]]],"a2a1":["uuid","<1>"],"a2b":["uuid","<3>"]}]}] | |
953 | [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["uuid","<0>"]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}] | |
954 | [{"count":1}] | |
955 | [{"rows":[{"_uuid":["uuid","<1>"],"a2a":["uuid","<1>"],"a2a1":["uuid","<1>"],"a2b":["uuid","<3>"]}]}] | |
956 | [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["set",[]]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}] | |
957 | [{"count":1}] | |
958 | [{"rows":[]}] | |
959 | [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["set",[]]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["set",[]]}]}] | |
c5f341ab BP |
960 | ]]) |
961 | ||
341c4e59 BP |
962 | OVSDB_CHECK_EXECUTION([immutable columns], |
963 | [immutable_schema], | |
964 | [[[["immutable", | |
965 | {"op": "insert", | |
966 | "table": "a", | |
967 | "row": {"i": 5}, | |
968 | "uuid-name": "row1"}]]], | |
969 | [[["immutable", | |
970 | {"op": "update", | |
971 | "table": "a", | |
972 | "row": {"i": 10}, | |
973 | "where": []}]]], | |
974 | [[["immutable", | |
975 | {"op": "update", | |
976 | "table": "a", | |
977 | "row": {"i": 5}, | |
978 | "where": []}]]], | |
979 | [[["immutable", | |
980 | {"op": "mutate", | |
981 | "table": "a", | |
982 | "where": [], | |
983 | "mutations": [["i", "-=", 5]]}]]], | |
984 | [[["immutable", | |
985 | {"op": "mutate", | |
986 | "table": "a", | |
987 | "where": [], | |
988 | "mutations": [["i", "*=", 1]]}]]]], | |
989 | [[[{"uuid":["uuid","<0>"]}] | |
990 | [{"details":"Cannot update immutable column i in table a.","error":"constraint violation","syntax":"{\"op\":\"update\",\"row\":{\"i\":10},\"table\":\"a\",\"where\":[]}"}] | |
991 | [{"details":"Cannot update immutable column i in table a.","error":"constraint violation","syntax":"{\"op\":\"update\",\"row\":{\"i\":5},\"table\":\"a\",\"where\":[]}"}] | |
992 | [{"details":"Cannot mutate immutable column i in table a.","error":"constraint violation","syntax":"[\"i\",\"-=\",5]"}] | |
993 | [{"details":"Cannot mutate immutable column i in table a.","error":"constraint violation","syntax":"[\"i\",\"*=\",1]"}] | |
994 | ]]) | |
995 | ||
c5f341ab | 996 | OVSDB_CHECK_EXECUTION([garbage collection], |
39ab07af | 997 | [gc_schema], |
c5f341ab BP |
998 | [dnl Check that inserting a row without any references is a no-op. |
999 | [[["gc", | |
1000 | {"op": "insert", | |
1001 | "table": "a", | |
1002 | "row": {"a": 0}}]]], | |
1003 | [[["gc", | |
1004 | {"op": "select", | |
1005 | "table": "a", | |
1006 | "where": [], | |
1007 | "columns": ["a"]}]]], | |
1008 | dnl Check that inserting a chain of rows that reference each other | |
1009 | dnl in turn is also a no-op. | |
1010 | [[["gc", | |
1011 | {"op": "insert", | |
1012 | "table": "a", | |
1013 | "row": {"a": 0, "a2a": ["named-uuid", "row1"]}, | |
1014 | "uuid-name": "row0"}, | |
1015 | {"op": "insert", | |
1016 | "table": "a", | |
1017 | "row": {"a": 1, "a2a": ["named-uuid", "row2"]}, | |
1018 | "uuid-name": "row1"}, | |
1019 | {"op": "insert", | |
1020 | "table": "a", | |
1021 | "row": {"a": 2, "a2a": ["named-uuid", "row3"]}, | |
1022 | "uuid-name": "row2"}, | |
1023 | {"op": "insert", | |
1024 | "table": "a", | |
1025 | "row": {"a": 3}, | |
1026 | "uuid-name": "row3"}]]], | |
1027 | [[["gc", | |
1028 | {"op": "select", | |
1029 | "table": "a", | |
1030 | "where": [], | |
1031 | "columns": ["a"]}]]], | |
1032 | dnl Check that inserting a pair of rows that mutually reference each | |
1033 | dnl other causes the rows to be retained. | |
1034 | [[["gc", | |
1035 | {"op": "insert", | |
1036 | "table": "a", | |
1037 | "row": {"a": 4, "a2a": ["named-uuid", "row5"]}, | |
1038 | "uuid-name": "row4"}, | |
1039 | {"op": "insert", | |
1040 | "table": "a", | |
1041 | "row": {"a": 5, "a2a": ["named-uuid", "row4"]}, | |
1042 | "uuid-name": "row5"}]]], | |
1043 | [[["gc", | |
1044 | {"op": "select", | |
1045 | "table": "a", | |
1046 | "where": [], | |
1047 | "columns": ["a"], | |
1048 | "sort": ["a"]}]]], | |
1049 | dnl Check that unreferencing one of the rows causes the other to be deleted. | |
1050 | [[["gc", | |
1051 | {"op": "update", | |
1052 | "table": "a", | |
1053 | "where": [["a", "==", 4]], | |
1054 | "row": {"a2a": ["set", []]}}]]], | |
1055 | [[["gc", | |
1056 | {"op": "select", | |
1057 | "table": "a", | |
1058 | "where": [], | |
1059 | "columns": ["a"]}]]], | |
1060 | dnl Check that inserting a pair of rows that mutually weak reference each | |
1061 | dnl other is a no-op. | |
1062 | [[["gc", | |
1063 | {"op": "insert", | |
1064 | "table": "a", | |
1065 | "row": {"a": 6, "wa2a": ["named-uuid", "row7"]}, | |
1066 | "uuid-name": "row6"}, | |
1067 | {"op": "insert", | |
1068 | "table": "a", | |
1069 | "row": {"a": 7, "wa2a": ["named-uuid", "row6"]}, | |
1070 | "uuid-name": "row7"}]]], | |
1071 | [[["gc", | |
1072 | {"op": "select", | |
1073 | "table": "a", | |
1074 | "where": [], | |
1075 | "columns": ["a"]}]]], | |
1076 | dnl Check that a circular chain of rows is retained. | |
1077 | [[["gc", | |
1078 | {"op": "insert", | |
1079 | "table": "a", | |
1080 | "row": {"a": 8, "a2a": ["named-uuid", "row9"]}, | |
1081 | "uuid-name": "row8"}, | |
1082 | {"op": "insert", | |
1083 | "table": "a", | |
1084 | "row": {"a": 9, "a2a": ["named-uuid", "row10"]}, | |
1085 | "uuid-name": "row9"}, | |
1086 | {"op": "insert", | |
1087 | "table": "a", | |
1088 | "row": {"a": 10, "a2a": ["named-uuid", "row11"]}, | |
1089 | "uuid-name": "row10"}, | |
1090 | {"op": "insert", | |
1091 | "table": "a", | |
1092 | "row": {"a": 11, "a2a": ["named-uuid", "row8"]}, | |
1093 | "uuid-name": "row11"}]]], | |
1094 | [[["gc", | |
1095 | {"op": "select", | |
1096 | "table": "a", | |
1097 | "where": [], | |
1098 | "columns": ["a"], | |
1099 | "sort": ["a"]}]]], | |
1100 | dnl Check that breaking the chain causes all of the rows to be deleted. | |
1101 | [[["gc", | |
1102 | {"op": "update", | |
1103 | "table": "a", | |
1104 | "where": [["a", "==", 9]], | |
1105 | "row": {"a2a": ["set", []]}}]]], | |
1106 | [[["gc", | |
1107 | {"op": "select", | |
1108 | "table": "a", | |
1109 | "where": [], | |
1110 | "columns": ["a"]}]]], | |
1111 | dnl Check that inserting a row only referenced by itself is a no-op. | |
1112 | [[["gc", | |
1113 | {"op": "insert", | |
1114 | "table": "a", | |
1115 | "row": {"a": 12, "a2a": ["named-uuid", "self"]}, | |
1116 | "uuid-name": "self"}]]], | |
1117 | [[["gc", | |
1118 | {"op": "select", | |
1119 | "table": "a", | |
1120 | "where": [], | |
1121 | "columns": ["a"]}]]]], | |
1122 | [[[{"uuid":["uuid","<0>"]}] | |
1123 | [{"rows":[]}] | |
1124 | [{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]},{"uuid":["uuid","<4>"]}] | |
1125 | [{"rows":[]}] | |
1126 | [{"uuid":["uuid","<5>"]},{"uuid":["uuid","<6>"]}] | |
1127 | [{"rows":[{"a":4},{"a":5}]}] | |
1128 | [{"count":1}] | |
1129 | [{"rows":[]}] | |
1130 | [{"uuid":["uuid","<7>"]},{"uuid":["uuid","<8>"]}] | |
1131 | [{"rows":[]}] | |
1132 | [{"uuid":["uuid","<9>"]},{"uuid":["uuid","<10>"]},{"uuid":["uuid","<11>"]},{"uuid":["uuid","<12>"]}] | |
1133 | [{"rows":[{"a":8},{"a":9},{"a":10},{"a":11}]}] | |
1134 | [{"count":1}] | |
1135 | [{"rows":[]}] | |
1136 | [{"uuid":["uuid","<13>"]}] | |
1137 | [{"rows":[]}] | |
bd76d25d | 1138 | ]])]) |
21ff1aee BP |
1139 | |
1140 | EXECUTION_EXAMPLES |