]>
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], []) | |
c724bd67 | 144 | AT_CHECK([uuidfilt stdout], [0], [$4]) |
e51879e9 AZ |
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], []) |
c724bd67 | 182 | AT_CHECK([uuidfilt 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 | ||
a529e3cd BP |
252 | OVSDB_CHECK_EXECUTION([insert row with uuid, query table], |
253 | [ordinal_schema], | |
254 | dnl Insert initial row. | |
255 | [[[["ordinals", | |
256 | {"op": "insert", | |
257 | "uuid": "ffffffff-971b-4cba-bf42-520515973b7e", | |
258 | "table": "ordinals", | |
259 | "row": {"number": 0, "name": "zero"}}]]], | |
260 | dnl Query row back. | |
261 | [[["ordinals", | |
262 | {"op": "select", | |
263 | "table": "ordinals", | |
264 | "where": []}]]], | |
265 | dnl Attempt to insert second row with same UUID (fails). | |
266 | [[["ordinals", | |
267 | {"op": "insert", | |
268 | "uuid": "ffffffff-971b-4cba-bf42-520515973b7e", | |
269 | "table": "ordinals", | |
270 | "row": {"number": 0, "name": "zero"}}]]]], | |
271 | [[[{"uuid":["uuid","ffffffff-971b-4cba-bf42-520515973b7e"]}] | |
272 | [{"rows":[{"_uuid":["uuid","ffffffff-971b-4cba-bf42-520515973b7e"],"_version":["uuid","<0>"],"name":"zero","number":0}]}] | |
273 | [{"details":"This UUID would duplicate a UUID already present within the table or deleted within the same transaction.","error":"duplicate uuid","syntax":"\"ffffffff-971b-4cba-bf42-520515973b7e\""}] | |
274 | ]]) | |
275 | ||
f85f8ebb | 276 | OVSDB_CHECK_EXECUTION([insert rows, query by value], |
39ab07af | 277 | [ordinal_schema], |
9cb53f26 BP |
278 | [[[["ordinals", |
279 | {"op": "insert", | |
f85f8ebb | 280 | "table": "ordinals", |
21ff1aee | 281 | "row": {"number": 0, "name": "zero"}}]]], |
9cb53f26 BP |
282 | [[["ordinals", |
283 | {"op": "insert", | |
f85f8ebb | 284 | "table": "ordinals", |
21ff1aee | 285 | "row": {"number": 1, "name": "one"}}]]], |
9cb53f26 BP |
286 | [[["ordinals", |
287 | {"op": "select", | |
f85f8ebb | 288 | "table": "ordinals", |
21ff1aee | 289 | "where": [["name", "==", "zero"]]}]]], |
9cb53f26 BP |
290 | [[["ordinals", |
291 | {"op": "select", | |
f85f8ebb | 292 | "table": "ordinals", |
21ff1aee | 293 | "where": [["name", "==", "one"]]}]]]], |
f85f8ebb BP |
294 | [[[{"uuid":["uuid","<0>"]}] |
295 | [{"uuid":["uuid","<1>"]}] | |
296 | [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0}]}] | |
297 | [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}] | |
298 | ]]) | |
299 | ||
300 | OVSDB_CHECK_EXECUTION([insert rows, query by named-uuid], | |
39ab07af | 301 | [ordinal_schema], |
9cb53f26 BP |
302 | [[[["ordinals", |
303 | {"op": "insert", | |
f85f8ebb BP |
304 | "table": "ordinals", |
305 | "row": {"number": 0, "name": "zero"}, | |
306 | "uuid-name": "first"}, | |
307 | {"op": "insert", | |
308 | "table": "ordinals", | |
309 | "row": {"number": 1, "name": "one"}, | |
310 | "uuid-name": "second"}, | |
311 | {"op": "select", | |
312 | "table": "ordinals", | |
313 | "where": [["_uuid", "==", ["named-uuid", "first"]]]}, | |
314 | {"op": "select", | |
315 | "table": "ordinals", | |
21ff1aee | 316 | "where": [["_uuid", "==", ["named-uuid", "second"]]]}]]]], |
f85f8ebb BP |
317 | [[[{"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}]}] |
318 | ]]) | |
319 | ||
320 | OVSDB_CHECK_EXECUTION([insert rows, update rows by value], | |
39ab07af | 321 | [ordinal_schema], |
9cb53f26 BP |
322 | [[[["ordinals", |
323 | {"op": "insert", | |
f85f8ebb BP |
324 | "table": "ordinals", |
325 | "row": {"number": 0, "name": "zero"}, | |
21ff1aee | 326 | "uuid-name": "first"}]]], |
9cb53f26 BP |
327 | [[["ordinals", |
328 | {"op": "insert", | |
f85f8ebb BP |
329 | "table": "ordinals", |
330 | "row": {"number": 1, "name": "one"}, | |
21ff1aee | 331 | "uuid-name": "first"}]]], |
9cb53f26 BP |
332 | [[["ordinals", |
333 | {"op": "update", | |
f85f8ebb BP |
334 | "table": "ordinals", |
335 | "where": [["name", "==", "zero"]], | |
21ff1aee | 336 | "row": {"name": "nought"}}]]], |
9cb53f26 BP |
337 | [[["ordinals", |
338 | {"op": "select", | |
f85f8ebb BP |
339 | "table": "ordinals", |
340 | "where": [], | |
21ff1aee | 341 | "sort": ["number"]}]]]], |
f85f8ebb BP |
342 | [[[{"uuid":["uuid","<0>"]}] |
343 | [{"uuid":["uuid","<1>"]}] | |
344 | [{"count":1}] | |
345 | [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"nought","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}] | |
346 | ]]) | |
347 | ||
e9f8f936 | 348 | OVSDB_CHECK_EXECUTION([insert rows, mutate rows], |
39ab07af | 349 | [ordinal_schema], |
9cb53f26 BP |
350 | [[[["ordinals", |
351 | {"op": "insert", | |
e9f8f936 BP |
352 | "table": "ordinals", |
353 | "row": {"number": 0, "name": "zero"}, | |
354 | "uuid-name": "first"}]]], | |
9cb53f26 BP |
355 | [[["ordinals", |
356 | {"op": "insert", | |
e9f8f936 BP |
357 | "table": "ordinals", |
358 | "row": {"number": 1, "name": "one"}, | |
359 | "uuid-name": "first"}]]], | |
9cb53f26 BP |
360 | [[["ordinals", |
361 | {"op": "mutate", | |
e9f8f936 BP |
362 | "table": "ordinals", |
363 | "where": [["name", "==", "zero"]], | |
364 | "mutations": [["number", "+=", 2]]}]]], | |
9cb53f26 BP |
365 | [[["ordinals", |
366 | {"op": "select", | |
e9f8f936 BP |
367 | "table": "ordinals", |
368 | "where": [], | |
369 | "sort": ["number"]}]]]], | |
370 | [[[{"uuid":["uuid","<0>"]}] | |
371 | [{"uuid":["uuid","<1>"]}] | |
372 | [{"count":1}] | |
373 | [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<2>"],"name":"one","number":1},{"_uuid":["uuid","<0>"],"_version":["uuid","<3>"],"name":"zero","number":2}]}] | |
374 | ]]) | |
375 | ||
f85f8ebb | 376 | OVSDB_CHECK_EXECUTION([insert rows, delete by named-uuid], |
39ab07af | 377 | [ordinal_schema], |
9cb53f26 BP |
378 | [[[["ordinals", |
379 | {"op": "insert", | |
f85f8ebb BP |
380 | "table": "ordinals", |
381 | "row": {"number": 0, "name": "zero"}, | |
382 | "uuid-name": "first"}, | |
383 | {"op": "insert", | |
384 | "table": "ordinals", | |
385 | "row": {"number": 1, "name": "one"}, | |
386 | "uuid-name": "second"}, | |
387 | {"op": "delete", | |
388 | "table": "ordinals", | |
389 | "where": [["_uuid", "==", ["named-uuid", "first"]]]}, | |
390 | {"op": "select", | |
391 | "table": "ordinals", | |
392 | "where": [], | |
21ff1aee | 393 | "columns": ["name","number"]}]]]], |
f85f8ebb BP |
394 | [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":1},{"rows":[{"name":"one","number":1}]}] |
395 | ]]) | |
396 | ||
397 | OVSDB_CHECK_EXECUTION([insert rows, delete rows by value], | |
39ab07af | 398 | [ordinal_schema], |
9cb53f26 BP |
399 | [[[["ordinals", |
400 | {"op": "insert", | |
f85f8ebb BP |
401 | "table": "ordinals", |
402 | "row": {"number": 0, "name": "zero"}, | |
21ff1aee | 403 | "uuid-name": "first"}]]], |
9cb53f26 BP |
404 | [[["ordinals", |
405 | {"op": "insert", | |
f85f8ebb BP |
406 | "table": "ordinals", |
407 | "row": {"number": 1, "name": "one"}, | |
21ff1aee | 408 | "uuid-name": "first"}]]], |
9cb53f26 BP |
409 | [[["ordinals", |
410 | {"op": "delete", | |
f85f8ebb | 411 | "table": "ordinals", |
21ff1aee | 412 | "where": [["name", "==", "zero"]]}]]], |
9cb53f26 BP |
413 | [[["ordinals", |
414 | {"op": "select", | |
f85f8ebb | 415 | "table": "ordinals", |
21ff1aee | 416 | "where": []}]]]], |
f85f8ebb BP |
417 | [[[{"uuid":["uuid","<0>"]}] |
418 | [{"uuid":["uuid","<1>"]}] | |
419 | [{"count":1}] | |
420 | [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<2>"],"name":"one","number":1}]}] | |
421 | ]]) | |
422 | ||
423 | OVSDB_CHECK_EXECUTION([insert rows, delete by (non-matching) value], | |
39ab07af | 424 | [ordinal_schema], |
9cb53f26 BP |
425 | [[[["ordinals", |
426 | {"op": "insert", | |
f85f8ebb BP |
427 | "table": "ordinals", |
428 | "row": {"number": 0, "name": "zero"}, | |
21ff1aee | 429 | "uuid-name": "first"}]]], |
9cb53f26 BP |
430 | [[["ordinals", |
431 | {"op": "insert", | |
f85f8ebb BP |
432 | "table": "ordinals", |
433 | "row": {"number": 1, "name": "one"}, | |
21ff1aee | 434 | "uuid-name": "first"}]]], |
9cb53f26 BP |
435 | [[["ordinals", |
436 | {"op": "delete", | |
f85f8ebb | 437 | "table": "ordinals", |
21ff1aee | 438 | "where": [["name", "==", "nought"]]}]]], |
9cb53f26 BP |
439 | [[["ordinals", |
440 | {"op": "select", | |
f85f8ebb BP |
441 | "table": "ordinals", |
442 | "where": [], | |
21ff1aee | 443 | "sort": ["number"]}]]]], |
f85f8ebb BP |
444 | [[[{"uuid":["uuid","<0>"]}] |
445 | [{"uuid":["uuid","<1>"]}] | |
446 | [{"count":0}] | |
447 | [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}] | |
448 | ]]) | |
449 | ||
450 | OVSDB_CHECK_EXECUTION([insert rows, delete all], | |
39ab07af | 451 | [ordinal_schema], |
9cb53f26 BP |
452 | [[[["ordinals", |
453 | {"op": "insert", | |
f85f8ebb BP |
454 | "table": "ordinals", |
455 | "row": {"number": 0, "name": "zero"}, | |
456 | "uuid-name": "first"}, | |
457 | {"op": "insert", | |
458 | "table": "ordinals", | |
459 | "row": {"number": 1, "name": "one"}, | |
460 | "uuid-name": "second"}, | |
461 | {"op": "delete", | |
462 | "table": "ordinals", | |
463 | "where": []}, | |
464 | {"op": "select", | |
465 | "table": "ordinals", | |
466 | "where": [], | |
21ff1aee | 467 | "columns": ["name","number"]}]]]], |
f85f8ebb BP |
468 | [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":2},{"rows":[]}] |
469 | ]]) | |
470 | ||
471 | OVSDB_CHECK_EXECUTION([insert row, query table, commit], | |
39ab07af | 472 | [ordinal_schema], |
9cb53f26 BP |
473 | [[[["ordinals", |
474 | {"op": "insert", | |
f85f8ebb BP |
475 | "table": "ordinals", |
476 | "row": {"number": 0, "name": "zero"}}, | |
477 | {"op": "select", | |
478 | "table": "ordinals", | |
479 | "where": []}, | |
480 | {"op": "commit", | |
21ff1aee | 481 | "durable": false}]]]], |
f85f8ebb BP |
482 | [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}] |
483 | ]]) | |
484 | ||
485 | OVSDB_CHECK_EXECUTION([insert row, query table, commit durably], | |
39ab07af | 486 | [ordinal_schema], |
9cb53f26 BP |
487 | [[[["ordinals", |
488 | {"op": "insert", | |
f85f8ebb BP |
489 | "table": "ordinals", |
490 | "row": {"number": 0, "name": "zero"}}, | |
491 | {"op": "select", | |
492 | "table": "ordinals", | |
493 | "where": []}, | |
494 | {"op": "commit", | |
21ff1aee | 495 | "durable": true}]]]], |
f85f8ebb BP |
496 | [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}] |
497 | ]]) | |
498 | ||
499 | OVSDB_CHECK_EXECUTION([equality wait with correct rows], | |
39ab07af | 500 | [ordinal_schema], |
9cb53f26 BP |
501 | [[[["ordinals", |
502 | {"op": "insert", | |
f85f8ebb BP |
503 | "table": "ordinals", |
504 | "row": {"number": 0, "name": "zero"}}, | |
505 | {"op": "insert", | |
506 | "table": "ordinals", | |
507 | "row": {"number": 1, "name": "one"}}, | |
508 | {"op": "wait", | |
509 | "timeout": 0, | |
510 | "table": "ordinals", | |
511 | "where": [], | |
512 | "columns": ["name", "number"], | |
513 | "until": "==", | |
514 | "rows": [{"name": "zero", "number": 0}, | |
21ff1aee | 515 | {"name": "one", "number": 1}]}]]]], |
f85f8ebb BP |
516 | [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}] |
517 | ]]) | |
518 | ||
519 | OVSDB_CHECK_EXECUTION([equality wait with extra row], | |
39ab07af | 520 | [ordinal_schema], |
9cb53f26 BP |
521 | [[[["ordinals", |
522 | {"op": "insert", | |
f85f8ebb BP |
523 | "table": "ordinals", |
524 | "row": {"number": 0, "name": "zero"}}, | |
525 | {"op": "insert", | |
526 | "table": "ordinals", | |
527 | "row": {"number": 1, "name": "one"}}, | |
528 | {"op": "wait", | |
529 | "timeout": 0, | |
530 | "table": "ordinals", | |
531 | "where": [], | |
532 | "columns": ["name", "number"], | |
533 | "until": "==", | |
534 | "rows": [{"name": "zero", "number": 0}, | |
535 | {"name": "one", "number": 1}, | |
21ff1aee | 536 | {"name": "two", "number": 2}]}]]]], |
cd423a77 | 537 | [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"where\" clause test failed","error":"timed out"}] |
f85f8ebb BP |
538 | ]]) |
539 | ||
540 | OVSDB_CHECK_EXECUTION([equality wait with missing row], | |
39ab07af | 541 | [ordinal_schema], |
9cb53f26 BP |
542 | [[[["ordinals", |
543 | {"op": "insert", | |
f85f8ebb BP |
544 | "table": "ordinals", |
545 | "row": {"number": 0, "name": "zero"}}, | |
546 | {"op": "insert", | |
547 | "table": "ordinals", | |
548 | "row": {"number": 1, "name": "one"}}, | |
549 | {"op": "wait", | |
550 | "timeout": 0, | |
551 | "table": "ordinals", | |
552 | "where": [], | |
553 | "columns": ["name", "number"], | |
554 | "until": "==", | |
21ff1aee | 555 | "rows": [{"name": "one", "number": 1}]}]]]], |
cd423a77 | 556 | [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"where\" clause test failed","error":"timed out"}] |
f85f8ebb BP |
557 | ]]) |
558 | ||
559 | OVSDB_CHECK_EXECUTION([inequality wait with correct rows], | |
39ab07af | 560 | [ordinal_schema], |
9cb53f26 BP |
561 | [[[["ordinals", |
562 | {"op": "insert", | |
f85f8ebb BP |
563 | "table": "ordinals", |
564 | "row": {"number": 0, "name": "zero"}}, | |
565 | {"op": "insert", | |
566 | "table": "ordinals", | |
567 | "row": {"number": 1, "name": "one"}}, | |
568 | {"op": "wait", | |
569 | "timeout": 0, | |
570 | "table": "ordinals", | |
571 | "where": [], | |
572 | "columns": ["name", "number"], | |
573 | "until": "!=", | |
574 | "rows": [{"name": "zero", "number": 0}, | |
21ff1aee | 575 | {"name": "one", "number": 1}]}]]]], |
cd423a77 | 576 | [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"where\" clause test failed","error":"timed out"}] |
f85f8ebb BP |
577 | ]]) |
578 | ||
579 | OVSDB_CHECK_EXECUTION([inequality wait with extra row], | |
39ab07af | 580 | [ordinal_schema], |
9cb53f26 BP |
581 | [[[["ordinals", |
582 | {"op": "insert", | |
f85f8ebb BP |
583 | "table": "ordinals", |
584 | "row": {"number": 0, "name": "zero"}}, | |
585 | {"op": "insert", | |
586 | "table": "ordinals", | |
587 | "row": {"number": 1, "name": "one"}}, | |
588 | {"op": "wait", | |
589 | "timeout": 0, | |
590 | "table": "ordinals", | |
591 | "where": [], | |
592 | "columns": ["name", "number"], | |
593 | "until": "!=", | |
594 | "rows": [{"name": "zero", "number": 0}, | |
595 | {"name": "one", "number": 1}, | |
21ff1aee | 596 | {"name": "two", "number": 2}]}]]]], |
f85f8ebb BP |
597 | [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}] |
598 | ]]) | |
599 | ||
600 | OVSDB_CHECK_EXECUTION([inequality wait with missing row], | |
39ab07af | 601 | [ordinal_schema], |
9cb53f26 BP |
602 | [[[["ordinals", |
603 | {"op": "insert", | |
f85f8ebb BP |
604 | "table": "ordinals", |
605 | "row": {"number": 0, "name": "zero"}}, | |
606 | {"op": "insert", | |
607 | "table": "ordinals", | |
608 | "row": {"number": 1, "name": "one"}}, | |
609 | {"op": "wait", | |
610 | "timeout": 0, | |
611 | "table": "ordinals", | |
612 | "where": [], | |
613 | "columns": ["name", "number"], | |
614 | "until": "!=", | |
21ff1aee | 615 | "rows": [{"name": "one", "number": 1}]}]]]], |
f85f8ebb BP |
616 | [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}] |
617 | ]]) | |
bd76d25d BP |
618 | |
619 | OVSDB_CHECK_EXECUTION([insert and update constraints], | |
39ab07af | 620 | [constraint_schema], |
9cb53f26 BP |
621 | [[[["constraints", |
622 | {"op": "insert", | |
bd76d25d BP |
623 | "table": "constrained", |
624 | "row": {}}]]], | |
9cb53f26 BP |
625 | [[["constraints", |
626 | {"op": "insert", | |
bd76d25d BP |
627 | "table": "constrained", |
628 | "row": {"positive": -1}}]]], | |
9cb53f26 BP |
629 | [[["constraints", |
630 | {"op": "update", | |
bd76d25d BP |
631 | "table": "constrained", |
632 | "where": [], | |
87ab878c BP |
633 | "row": {"positive": -2}}]]], |
634 | [[["constraints", | |
635 | {"op": "insert", | |
636 | "table": "constrained", | |
637 | "row": {"positive": 1}}]]], | |
638 | [[["constraints", | |
639 | {"op": "insert", | |
640 | "table": "constrained", | |
641 | "row": {"positive": 2}}]]]], | |
bd76d25d BP |
642 | [[[{"details":"0 is less than minimum allowed value 1","error":"constraint violation"}] |
643 | [{"details":"-1 is less than minimum allowed value 1","error":"constraint violation"}] | |
644 | [{"details":"-2 is less than minimum allowed value 1","error":"constraint violation"}] | |
87ab878c BP |
645 | [{"uuid":["uuid","<0>"]}] |
646 | [{"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 |
647 | ]]) |
648 | ||
6910a6e6 | 649 | OVSDB_CHECK_EXECUTION([index uniqueness checking], |
39ab07af | 650 | [ordinal_schema], |
6910a6e6 BP |
651 | dnl Insert initial row. |
652 | [[[["ordinals", | |
653 | {"op": "insert", | |
654 | "table": "ordinals", | |
655 | "row": {"number": 1, "name": "one"}}]]], | |
656 | dnl Try to insert row with identical value (fails). | |
657 | [[["ordinals", | |
658 | {"op": "insert", | |
659 | "table": "ordinals", | |
660 | "row": {"number": 1, "name": "another one"}}]]], | |
661 | dnl Remove initial row and insert new row with identical value in a single | |
662 | dnl transaction (succeeds). | |
663 | [[["ordinals", | |
664 | {"op": "insert", | |
665 | "table": "ordinals", | |
666 | "row": {"number": 1, "name": "another one"}}, | |
667 | {"op": "delete", | |
668 | "table": "ordinals", | |
669 | "where": [["name", "==", "one"]]}]]], | |
670 | dnl Remove row and insert two new rows with identical value in a single | |
671 | dnl transaction (fails). | |
672 | [[["ordinals", | |
673 | {"op": "delete", | |
674 | "table": "ordinals", | |
675 | "where": []}, | |
676 | {"op": "insert", | |
677 | "table": "ordinals", | |
678 | "row": {"number": 1, "name": "one"}}, | |
679 | {"op": "insert", | |
680 | "table": "ordinals", | |
681 | "row": {"number": 1, "name": "still another one"}}]]], | |
682 | dnl Add new row with different value (succeeds). | |
683 | [[["ordinals", | |
684 | {"op": "insert", | |
685 | "table": "ordinals", | |
686 | "row": {"number": 2, "name": "two"}}]]], | |
687 | dnl Change rows so values collide (fails). | |
688 | [[["ordinals", | |
689 | {"op": "update", | |
690 | "table": "ordinals", | |
691 | "where": [], | |
692 | "row": {"number": 3}}]]], | |
693 | dnl Swap rows' values (succeeds). | |
694 | [[["ordinals", | |
695 | {"op": "update", | |
696 | "table": "ordinals", | |
697 | "where": [["number", "==", 1]], | |
698 | "row": {"number": 2, "name": "old two"}}, | |
699 | {"op": "update", | |
700 | "table": "ordinals", | |
701 | "where": [["name", "==", "two"]], | |
702 | "row": {"number": 1, "name": "old one"}}]]], | |
703 | dnl Change all rows' values to values not used before and insert values that | |
704 | dnl collide (only) with their previous values (succeeds). | |
705 | [[["ordinals", | |
706 | {"op": "mutate", | |
707 | "table": "ordinals", | |
708 | "where": [], | |
709 | "mutations": [["number", "*=", 10]]}, | |
710 | {"op": "insert", | |
711 | "table": "ordinals", | |
712 | "row": {"number": 1, "name": "new one"}}, | |
713 | {"op": "insert", | |
714 | "table": "ordinals", | |
715 | "row": {"number": 2, "name": "new two"}}, | |
716 | {"op": "select", | |
717 | "table": "ordinals", | |
718 | "where": [], | |
719 | "columns": ["number", "name"], | |
720 | "sort": ["number"]}]]]], | |
721 | [[[{"uuid":["uuid","<0>"]}] | |
722 | [{"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"}] | |
723 | [{"uuid":["uuid","<2>"]},{"count":1}] | |
724 | [{"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"}] | |
725 | [{"uuid":["uuid","<5>"]}] | |
726 | [{"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"}] | |
727 | [{"count":1},{"count":1}] | |
728 | [{"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}]}] | |
729 | ]]) | |
730 | ||
0d0f05b9 | 731 | OVSDB_CHECK_EXECUTION([referential integrity -- simple], |
39ab07af | 732 | [constraint_schema], |
9cb53f26 BP |
733 | [[[["constraints", |
734 | {"op": "insert", | |
0d0f05b9 BP |
735 | "table": "b", |
736 | "row": {"b": 1}, | |
737 | "uuid-name": "brow"}, | |
738 | {"op": "insert", | |
739 | "table": "a", | |
740 | "row": {"a": 0, | |
741 | "a2b": ["set", [["named-uuid", "brow"]]]}}, | |
742 | {"op": "insert", | |
743 | "table": "a", | |
744 | "row": {"a": 1, | |
745 | "a2b": ["set", [["named-uuid", "brow"]]]}}, | |
746 | {"op": "insert", | |
747 | "table": "a", | |
748 | "row": {"a": 2, | |
749 | "a2b": ["set", [["named-uuid", "brow"]]]}}]]], | |
9cb53f26 BP |
750 | [[["constraints", |
751 | {"op": "delete", | |
0d0f05b9 BP |
752 | "table": "b", |
753 | "where": []}]]], | |
b7585d1d BP |
754 | dnl Check that "mutate" honors number-of-elements constraints on sets and maps. |
755 | [[["constraints", | |
756 | {"op": "mutate", | |
757 | "table": "b", | |
758 | "where": [], | |
759 | "mutations": [["x", "delete", 0]]}]]], | |
9cb53f26 BP |
760 | [[["constraints", |
761 | {"op": "delete", | |
0d0f05b9 BP |
762 | "table": "a", |
763 | "where": [["a", "==", 0]]}]]], | |
9cb53f26 BP |
764 | [[["constraints", |
765 | {"op": "delete", | |
0d0f05b9 BP |
766 | "table": "b", |
767 | "where": []}]]], | |
9cb53f26 BP |
768 | [[["constraints", |
769 | {"op": "delete", | |
0d0f05b9 BP |
770 | "table": "a", |
771 | "where": [["a", "==", 1]]}]]], | |
9cb53f26 BP |
772 | [[["constraints", |
773 | {"op": "delete", | |
0d0f05b9 BP |
774 | "table": "b", |
775 | "where": []}]]], | |
9cb53f26 BP |
776 | [[["constraints", |
777 | {"op": "delete", | |
0d0f05b9 BP |
778 | "table": "a", |
779 | "where": [["a", "==", 2]]}]]], | |
9cb53f26 BP |
780 | [[["constraints", |
781 | {"op": "delete", | |
0d0f05b9 BP |
782 | "table": "b", |
783 | "where": []}]]]], | |
784 | [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}] | |
785 | [{"count":1},{"details":"cannot delete b row <0> because of 3 remaining reference(s)","error":"referential integrity violation"}] | |
b7585d1d | 786 | [{"details":"Attempted to store 0 elements in set of 1 to 2 integers.","error":"constraint violation"}] |
0d0f05b9 BP |
787 | [{"count":1}] |
788 | [{"count":1},{"details":"cannot delete b row <0> because of 2 remaining reference(s)","error":"referential integrity violation"}] | |
789 | [{"count":1}] | |
790 | [{"count":1},{"details":"cannot delete b row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}] | |
791 | [{"count":1}] | |
792 | [{"count":1}] | |
793 | ]]) | |
794 | ||
795 | OVSDB_CHECK_EXECUTION([referential integrity -- mutual references], | |
39ab07af | 796 | [constraint_schema], |
9cb53f26 BP |
797 | [[[["constraints", |
798 | {"op": "insert", | |
0d0f05b9 BP |
799 | "table": "a", |
800 | "row": {"a": 0, | |
801 | "a2b": ["set", [["named-uuid", "row2"]]], | |
802 | "a2a": ["set", [["named-uuid", "row1"]]]}, | |
803 | "uuid-name": "row1"}, | |
804 | {"op": "insert", | |
805 | "table": "b", | |
806 | "row": {"b": 1, | |
807 | "b2b": ["set", [["named-uuid", "row2"]]], | |
808 | "b2a": ["set", [["named-uuid", "row1"]]]}, | |
809 | "uuid-name": "row2"}]]], | |
9cb53f26 BP |
810 | [[["constraints", |
811 | {"op": "insert", | |
0d0f05b9 BP |
812 | "table": "a", |
813 | "row": {"a2b": ["set", [["uuid", "b516b960-5b19-4fc2-bb82-fe1cbd6d0241"]]]}}]]], | |
9cb53f26 BP |
814 | [[["constraints", |
815 | {"op": "delete", | |
0d0f05b9 BP |
816 | "table": "a", |
817 | "where": [["a", "==", 0]]}]]], | |
9cb53f26 BP |
818 | [[["constraints", |
819 | {"op": "delete", | |
0d0f05b9 BP |
820 | "table": "b", |
821 | "where": [["b", "==", 1]]}]]], | |
822 | dnl Try the deletions again to make sure that the refcounts got rolled back. | |
9cb53f26 BP |
823 | [[["constraints", |
824 | {"op": "delete", | |
0d0f05b9 BP |
825 | "table": "a", |
826 | "where": [["a", "==", 0]]}]]], | |
9cb53f26 BP |
827 | [[["constraints", |
828 | {"op": "delete", | |
0d0f05b9 BP |
829 | "table": "b", |
830 | "where": [["b", "==", 1]]}]]], | |
9cb53f26 BP |
831 | [[["constraints", |
832 | {"op": "delete", | |
0d0f05b9 BP |
833 | "table": "a", |
834 | "where": [["a", "==", 0]]}, | |
835 | {"op": "delete", | |
836 | "table": "b", | |
837 | "where": [["b", "==", 1]]}]]]], | |
fbf925e4 | 838 | [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}] |
97f7803b | 839 | [{"uuid":["uuid","<2>"]},{"details":"Table a column a2b row <2> references nonexistent row <3> in table b.","error":"referential integrity violation"}] |
0d0f05b9 BP |
840 | [{"count":1},{"details":"cannot delete a row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}] |
841 | [{"count":1},{"details":"cannot delete b row <1> because of 1 remaining reference(s)","error":"referential integrity violation"}] | |
842 | [{"count":1},{"details":"cannot delete a row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}] | |
843 | [{"count":1},{"details":"cannot delete b row <1> because of 1 remaining reference(s)","error":"referential integrity violation"}] | |
844 | [{"count":1},{"count":1}] | |
7360012b BP |
845 | ]]) |
846 | ||
847 | OVSDB_CHECK_EXECUTION([weak references], | |
39ab07af | 848 | [weak_schema], |
7360012b BP |
849 | [[[["weak", |
850 | {"op": "insert", | |
851 | "table": "a", | |
852 | "row": {"a": 0, | |
853 | "a2a": ["set", [["named-uuid", "row1"], | |
854 | ["named-uuid", "row2"], | |
855 | ["uuid", "0e767b36-6822-4044-8307-d58467e04669"]]], | |
856 | "a2a1": ["named-uuid", "row1"], | |
857 | "a2b": ["named-uuid", "row3"]}, | |
858 | "uuid-name": "row1"}, | |
859 | {"op": "insert", | |
860 | "table": "a", | |
861 | "row": {"a": 1, | |
862 | "a2a": ["set", [["named-uuid", "row1"], | |
863 | ["named-uuid", "row2"]]], | |
864 | "a2a1": ["named-uuid", "row2"], | |
865 | "a2b": ["named-uuid", "row3"]}, | |
866 | "uuid-name": "row2"}, | |
867 | {"op": "insert", | |
868 | "table": "a", | |
869 | "row": {"a": 2, | |
870 | "a2a": ["set", [["named-uuid", "row1"], | |
871 | ["named-uuid", "row2"]]], | |
872 | "a2a1": ["named-uuid", "row2"], | |
873 | "a2b": ["named-uuid", "row4"]}}, | |
874 | {"op": "insert", | |
875 | "table": "b", | |
876 | "row": {"b": 2, | |
877 | "b2a": ["named-uuid", "row1"]}, | |
878 | "uuid-name": "row3"}, | |
879 | {"op": "insert", | |
880 | "table": "b", | |
881 | "row": {"b": 3, | |
882 | "b2a": ["named-uuid", "row2"]}, | |
883 | "uuid-name": "row4"}]]], | |
884 | dnl Check that the nonexistent row UUID we added to row a0 was deleted, | |
885 | dnl and that other rows were inserted as requested. | |
886 | [[["weak", | |
887 | {"op": "select", | |
888 | "table": "a", | |
889 | "where": [], | |
890 | "columns": ["_uuid", "a2a", "a2a1", "a2b"], | |
891 | "sort": ["a"]}]]], | |
892 | [[["weak", | |
893 | {"op": "select", | |
894 | "table": "b", | |
895 | "where": [], | |
896 | "columns": ["_uuid", "b", "b2a"], | |
897 | "sort": ["b"]}]]], | |
898 | dnl Try to insert invalid all-zeros weak reference (the default) into | |
899 | dnl "a2b", which requires exactly one value. | |
900 | [[["weak", | |
901 | {"op": "insert", | |
902 | "table": "a", | |
1f4f3cd7 BP |
903 | "row": {"a2a1": ["named-uuid", "me"]}, |
904 | "uuid-name": "me"}]]], | |
7360012b BP |
905 | dnl Try to delete row from "b" that is referred to by weak references |
906 | dnl from "a" table "a2b" column that requires exactly one value. | |
907 | [[["weak", | |
908 | {"op": "delete", | |
909 | "table": "b", | |
910 | "where": [["b", "==", 3]]}]]], | |
911 | dnl Try to delete row from "a" that is referred to by weak references | |
912 | dnl from "a" table "a2a1" column that requires exactly one value. | |
913 | [[["weak", | |
914 | {"op": "delete", | |
915 | "table": "a", | |
916 | "where": [["a", "==", 1]]}]]], | |
917 | dnl Delete the row that had the reference that caused the previous | |
918 | dnl deletion to fail, then check that other rows are unchanged. | |
919 | [[["weak", | |
920 | {"op": "delete", | |
921 | "table": "a", | |
922 | "where": [["a", "==", 2]]}]]], | |
923 | [[["weak", | |
924 | {"op": "select", | |
925 | "table": "a", | |
926 | "where": [], | |
927 | "columns": ["_uuid", "a2a", "a2a1", "a2b"], | |
928 | "sort": ["a"]}]]], | |
929 | [[["weak", | |
930 | {"op": "select", | |
931 | "table": "b", | |
932 | "where": [], | |
933 | "columns": ["_uuid", "b", "b2a"], | |
934 | "sort": ["b"]}]]], | |
935 | dnl Delete row a0 then check that references to it were removed. | |
936 | [[["weak", | |
937 | {"op": "delete", | |
938 | "table": "a", | |
939 | "where": [["a", "==", 0]]}]]], | |
940 | [[["weak", | |
941 | {"op": "select", | |
942 | "table": "a", | |
943 | "where": [], | |
944 | "columns": ["_uuid", "a2a", "a2a1", "a2b"], | |
945 | "sort": ["a"]}]]], | |
946 | [[["weak", | |
947 | {"op": "select", | |
948 | "table": "b", | |
949 | "where": [], | |
950 | "columns": ["_uuid", "b", "b2a"], | |
951 | "sort": ["b"]}]]], | |
952 | dnl Delete row a1 then check that references to it were removed. | |
953 | [[["weak", | |
954 | {"op": "delete", | |
955 | "table": "a", | |
956 | "where": [["a", "==", 1]]}]]], | |
957 | [[["weak", | |
958 | {"op": "select", | |
959 | "table": "a", | |
960 | "where": [], | |
961 | "columns": ["_uuid", "a2a", "a2a1", "a2b"], | |
962 | "sort": ["a"]}]]], | |
963 | [[["weak", | |
964 | {"op": "select", | |
965 | "table": "b", | |
966 | "where": [], | |
967 | "columns": ["_uuid", "b", "b2a"], | |
968 | "sort": ["b"]}]]]], | |
969 | [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]},{"uuid":["uuid","<4>"]}] | |
970 | [{"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>"]}]}] | |
971 | [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["uuid","<0>"]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}] | |
972 | [{"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"}] | |
973 | [{"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"}] | |
974 | [{"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"}] | |
975 | [{"count":1}] | |
976 | [{"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>"]}]}] | |
977 | [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["uuid","<0>"]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}] | |
978 | [{"count":1}] | |
979 | [{"rows":[{"_uuid":["uuid","<1>"],"a2a":["uuid","<1>"],"a2a1":["uuid","<1>"],"a2b":["uuid","<3>"]}]}] | |
980 | [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["set",[]]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}] | |
981 | [{"count":1}] | |
982 | [{"rows":[]}] | |
983 | [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["set",[]]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["set",[]]}]}] | |
c5f341ab BP |
984 | ]]) |
985 | ||
341c4e59 BP |
986 | OVSDB_CHECK_EXECUTION([immutable columns], |
987 | [immutable_schema], | |
988 | [[[["immutable", | |
989 | {"op": "insert", | |
990 | "table": "a", | |
991 | "row": {"i": 5}, | |
992 | "uuid-name": "row1"}]]], | |
993 | [[["immutable", | |
994 | {"op": "update", | |
995 | "table": "a", | |
996 | "row": {"i": 10}, | |
997 | "where": []}]]], | |
998 | [[["immutable", | |
999 | {"op": "update", | |
1000 | "table": "a", | |
1001 | "row": {"i": 5}, | |
1002 | "where": []}]]], | |
1003 | [[["immutable", | |
1004 | {"op": "mutate", | |
1005 | "table": "a", | |
1006 | "where": [], | |
1007 | "mutations": [["i", "-=", 5]]}]]], | |
1008 | [[["immutable", | |
1009 | {"op": "mutate", | |
1010 | "table": "a", | |
1011 | "where": [], | |
1012 | "mutations": [["i", "*=", 1]]}]]]], | |
1013 | [[[{"uuid":["uuid","<0>"]}] | |
1014 | [{"details":"Cannot update immutable column i in table a.","error":"constraint violation","syntax":"{\"op\":\"update\",\"row\":{\"i\":10},\"table\":\"a\",\"where\":[]}"}] | |
1015 | [{"details":"Cannot update immutable column i in table a.","error":"constraint violation","syntax":"{\"op\":\"update\",\"row\":{\"i\":5},\"table\":\"a\",\"where\":[]}"}] | |
1016 | [{"details":"Cannot mutate immutable column i in table a.","error":"constraint violation","syntax":"[\"i\",\"-=\",5]"}] | |
1017 | [{"details":"Cannot mutate immutable column i in table a.","error":"constraint violation","syntax":"[\"i\",\"*=\",1]"}] | |
1018 | ]]) | |
1019 | ||
c5f341ab | 1020 | OVSDB_CHECK_EXECUTION([garbage collection], |
39ab07af | 1021 | [gc_schema], |
c5f341ab BP |
1022 | [dnl Check that inserting a row without any references is a no-op. |
1023 | [[["gc", | |
1024 | {"op": "insert", | |
1025 | "table": "a", | |
1026 | "row": {"a": 0}}]]], | |
1027 | [[["gc", | |
1028 | {"op": "select", | |
1029 | "table": "a", | |
1030 | "where": [], | |
1031 | "columns": ["a"]}]]], | |
1032 | dnl Check that inserting a chain of rows that reference each other | |
1033 | dnl in turn is also a no-op. | |
1034 | [[["gc", | |
1035 | {"op": "insert", | |
1036 | "table": "a", | |
1037 | "row": {"a": 0, "a2a": ["named-uuid", "row1"]}, | |
1038 | "uuid-name": "row0"}, | |
1039 | {"op": "insert", | |
1040 | "table": "a", | |
1041 | "row": {"a": 1, "a2a": ["named-uuid", "row2"]}, | |
1042 | "uuid-name": "row1"}, | |
1043 | {"op": "insert", | |
1044 | "table": "a", | |
1045 | "row": {"a": 2, "a2a": ["named-uuid", "row3"]}, | |
1046 | "uuid-name": "row2"}, | |
1047 | {"op": "insert", | |
1048 | "table": "a", | |
1049 | "row": {"a": 3}, | |
1050 | "uuid-name": "row3"}]]], | |
1051 | [[["gc", | |
1052 | {"op": "select", | |
1053 | "table": "a", | |
1054 | "where": [], | |
1055 | "columns": ["a"]}]]], | |
1056 | dnl Check that inserting a pair of rows that mutually reference each | |
1057 | dnl other causes the rows to be retained. | |
1058 | [[["gc", | |
1059 | {"op": "insert", | |
1060 | "table": "a", | |
1061 | "row": {"a": 4, "a2a": ["named-uuid", "row5"]}, | |
1062 | "uuid-name": "row4"}, | |
1063 | {"op": "insert", | |
1064 | "table": "a", | |
1065 | "row": {"a": 5, "a2a": ["named-uuid", "row4"]}, | |
1066 | "uuid-name": "row5"}]]], | |
1067 | [[["gc", | |
1068 | {"op": "select", | |
1069 | "table": "a", | |
1070 | "where": [], | |
1071 | "columns": ["a"], | |
1072 | "sort": ["a"]}]]], | |
1073 | dnl Check that unreferencing one of the rows causes the other to be deleted. | |
1074 | [[["gc", | |
1075 | {"op": "update", | |
1076 | "table": "a", | |
1077 | "where": [["a", "==", 4]], | |
1078 | "row": {"a2a": ["set", []]}}]]], | |
1079 | [[["gc", | |
1080 | {"op": "select", | |
1081 | "table": "a", | |
1082 | "where": [], | |
1083 | "columns": ["a"]}]]], | |
1084 | dnl Check that inserting a pair of rows that mutually weak reference each | |
1085 | dnl other is a no-op. | |
1086 | [[["gc", | |
1087 | {"op": "insert", | |
1088 | "table": "a", | |
1089 | "row": {"a": 6, "wa2a": ["named-uuid", "row7"]}, | |
1090 | "uuid-name": "row6"}, | |
1091 | {"op": "insert", | |
1092 | "table": "a", | |
1093 | "row": {"a": 7, "wa2a": ["named-uuid", "row6"]}, | |
1094 | "uuid-name": "row7"}]]], | |
1095 | [[["gc", | |
1096 | {"op": "select", | |
1097 | "table": "a", | |
1098 | "where": [], | |
1099 | "columns": ["a"]}]]], | |
1100 | dnl Check that a circular chain of rows is retained. | |
1101 | [[["gc", | |
1102 | {"op": "insert", | |
1103 | "table": "a", | |
1104 | "row": {"a": 8, "a2a": ["named-uuid", "row9"]}, | |
1105 | "uuid-name": "row8"}, | |
1106 | {"op": "insert", | |
1107 | "table": "a", | |
1108 | "row": {"a": 9, "a2a": ["named-uuid", "row10"]}, | |
1109 | "uuid-name": "row9"}, | |
1110 | {"op": "insert", | |
1111 | "table": "a", | |
1112 | "row": {"a": 10, "a2a": ["named-uuid", "row11"]}, | |
1113 | "uuid-name": "row10"}, | |
1114 | {"op": "insert", | |
1115 | "table": "a", | |
1116 | "row": {"a": 11, "a2a": ["named-uuid", "row8"]}, | |
1117 | "uuid-name": "row11"}]]], | |
1118 | [[["gc", | |
1119 | {"op": "select", | |
1120 | "table": "a", | |
1121 | "where": [], | |
1122 | "columns": ["a"], | |
1123 | "sort": ["a"]}]]], | |
1124 | dnl Check that breaking the chain causes all of the rows to be deleted. | |
1125 | [[["gc", | |
1126 | {"op": "update", | |
1127 | "table": "a", | |
1128 | "where": [["a", "==", 9]], | |
1129 | "row": {"a2a": ["set", []]}}]]], | |
1130 | [[["gc", | |
1131 | {"op": "select", | |
1132 | "table": "a", | |
1133 | "where": [], | |
1134 | "columns": ["a"]}]]], | |
1135 | dnl Check that inserting a row only referenced by itself is a no-op. | |
1136 | [[["gc", | |
1137 | {"op": "insert", | |
1138 | "table": "a", | |
1139 | "row": {"a": 12, "a2a": ["named-uuid", "self"]}, | |
1140 | "uuid-name": "self"}]]], | |
1141 | [[["gc", | |
1142 | {"op": "select", | |
1143 | "table": "a", | |
1144 | "where": [], | |
1145 | "columns": ["a"]}]]]], | |
1146 | [[[{"uuid":["uuid","<0>"]}] | |
1147 | [{"rows":[]}] | |
1148 | [{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]},{"uuid":["uuid","<4>"]}] | |
1149 | [{"rows":[]}] | |
1150 | [{"uuid":["uuid","<5>"]},{"uuid":["uuid","<6>"]}] | |
1151 | [{"rows":[{"a":4},{"a":5}]}] | |
1152 | [{"count":1}] | |
1153 | [{"rows":[]}] | |
1154 | [{"uuid":["uuid","<7>"]},{"uuid":["uuid","<8>"]}] | |
1155 | [{"rows":[]}] | |
1156 | [{"uuid":["uuid","<9>"]},{"uuid":["uuid","<10>"]},{"uuid":["uuid","<11>"]},{"uuid":["uuid","<12>"]}] | |
1157 | [{"rows":[{"a":8},{"a":9},{"a":10},{"a":11}]}] | |
1158 | [{"count":1}] | |
1159 | [{"rows":[]}] | |
1160 | [{"uuid":["uuid","<13>"]}] | |
1161 | [{"rows":[]}] | |
bd76d25d | 1162 | ]])]) |
21ff1aee BP |
1163 | |
1164 | EXECUTION_EXAMPLES |