]> git.proxmox.com Git - mirror_ovs.git/blob - tests/ovsdb-execution.at
classifier: Fix segfault iterating with rules that differ only in priority.
[mirror_ovs.git] / tests / ovsdb-execution.at
1 AT_BANNER([OVSDB -- execution])
2
3 m4_define([ORDINAL_SCHEMA],
4 [[{"name": "ordinals",
5 "tables": {
6 "ordinals": {
7 "columns": {
8 "number": {"type": "integer"},
9 "name": {"type": "string"}}}}}]])
10
11 m4_define([CONSTRAINT_SCHEMA],
12 [[{"name": "constraints",
13 "tables": {
14 "a": {
15 "columns": {
16 "a": {"type": "integer"},
17 "a2a": {"type": {"key": {"type": "uuid", "refTable": "a"},
18 "min": 0, "max": "unlimited"}},
19 "a2b": {"type": {"key": {"type": "uuid", "refTable": "b"},
20 "min": 0, "max": "unlimited"}}}},
21 "b": {
22 "columns": {
23 "b": {"type": "integer"},
24 "b2a": {"type": {"key": {"type": "uuid", "refTable": "a"},
25 "min": 0, "max": "unlimited"}},
26 "b2b": {"type": {"key": {"type": "uuid", "refTable": "b"},
27 "min": 0, "max": "unlimited"}}}},
28 "constrained": {
29 "columns": {
30 "positive": {"type": {"key": {"type": "integer",
31 "minInteger": 1}}}},
32 "maxRows": 1}}}]])
33
34 m4_define([WEAK_SCHEMA],
35 [[{"name": "weak",
36 "tables": {
37 "a": {
38 "columns": {
39 "a": {"type": "integer"},
40 "a2a": {"type": {"key": {"type": "uuid",
41 "refTable": "a",
42 "refType": "weak"},
43 "min": 0, "max": "unlimited"}},
44 "a2a1": {"type": {"key": {"type": "uuid",
45 "refTable": "a",
46 "refType": "weak"}}},
47 "a2b": {"type": {"key": {"type": "uuid",
48 "refTable": "b",
49 "refType": "weak"}}}}},
50 "b": {
51 "columns": {
52 "b": {"type": "integer"},
53 "b2a": {"type": {"key": {"type": "uuid",
54 "refTable": "a",
55 "refType": "weak"},
56 "min": 0, "max": "unlimited"}}}}}}]])
57
58 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
59 #
60 # Runs "test-ovsdb execute" with the given SCHEMA and each of the
61 # TRANSACTIONS (which should be a quoted list of quoted strings).
62 #
63 # Checks that the overall output is OUTPUT, but UUIDs in the output
64 # are replaced by markers of the form <N> where N is a number. The
65 # first unique UUID is replaced by <0>, the next by <1>, and so on.
66 # If a given UUID appears more than once it is always replaced by the
67 # same marker.
68 #
69 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
70 m4_define([OVSDB_CHECK_EXECUTION],
71 [AT_SETUP([$1])
72 AT_KEYWORDS([ovsdb execute execution positive $5])
73 AT_CHECK([test-ovsdb execute '$2' m4_foreach([txn], [$3], [ 'txn'])],
74 [0], [stdout], [])
75 AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [$4])
76 AT_CLEANUP])
77
78 m4_define([EXECUTION_EXAMPLES], [
79 dnl At one point the "commit" code ignored new rows with all-default values,
80 dnl so this checks for that problem.
81 OVSDB_CHECK_EXECUTION([insert default row, query table],
82 [ORDINAL_SCHEMA],
83 [[[["ordinals",
84 {"op": "insert",
85 "table": "ordinals",
86 "row": {}}]]],
87 [[["ordinals",
88 {"op": "select",
89 "table": "ordinals",
90 "where": []}]]]],
91 [[[{"uuid":["uuid","<0>"]}]
92 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"","number":0}]}]
93 ]])
94
95 OVSDB_CHECK_EXECUTION([insert row, query table],
96 [ORDINAL_SCHEMA],
97 [[[["ordinals",
98 {"op": "insert",
99 "table": "ordinals",
100 "row": {"number": 0, "name": "zero"}}]]],
101 [[["ordinals",
102 {"op": "select",
103 "table": "ordinals",
104 "where": []}]]]],
105 [[[{"uuid":["uuid","<0>"]}]
106 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]}]
107 ]])
108
109 OVSDB_CHECK_EXECUTION([insert rows, query by value],
110 [ORDINAL_SCHEMA],
111 [[[["ordinals",
112 {"op": "insert",
113 "table": "ordinals",
114 "row": {"number": 0, "name": "zero"}}]]],
115 [[["ordinals",
116 {"op": "insert",
117 "table": "ordinals",
118 "row": {"number": 1, "name": "one"}}]]],
119 [[["ordinals",
120 {"op": "select",
121 "table": "ordinals",
122 "where": [["name", "==", "zero"]]}]]],
123 [[["ordinals",
124 {"op": "select",
125 "table": "ordinals",
126 "where": [["name", "==", "one"]]}]]]],
127 [[[{"uuid":["uuid","<0>"]}]
128 [{"uuid":["uuid","<1>"]}]
129 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0}]}]
130 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
131 ]])
132
133 OVSDB_CHECK_EXECUTION([insert rows, query by named-uuid],
134 [ORDINAL_SCHEMA],
135 [[[["ordinals",
136 {"op": "insert",
137 "table": "ordinals",
138 "row": {"number": 0, "name": "zero"},
139 "uuid-name": "first"},
140 {"op": "insert",
141 "table": "ordinals",
142 "row": {"number": 1, "name": "one"},
143 "uuid-name": "second"},
144 {"op": "select",
145 "table": "ordinals",
146 "where": [["_uuid", "==", ["named-uuid", "first"]]]},
147 {"op": "select",
148 "table": "ordinals",
149 "where": [["_uuid", "==", ["named-uuid", "second"]]]}]]]],
150 [[[{"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}]}]
151 ]])
152
153 OVSDB_CHECK_EXECUTION([insert rows, update rows by value],
154 [ORDINAL_SCHEMA],
155 [[[["ordinals",
156 {"op": "insert",
157 "table": "ordinals",
158 "row": {"number": 0, "name": "zero"},
159 "uuid-name": "first"}]]],
160 [[["ordinals",
161 {"op": "insert",
162 "table": "ordinals",
163 "row": {"number": 1, "name": "one"},
164 "uuid-name": "first"}]]],
165 [[["ordinals",
166 {"op": "update",
167 "table": "ordinals",
168 "where": [["name", "==", "zero"]],
169 "row": {"name": "nought"}}]]],
170 [[["ordinals",
171 {"op": "select",
172 "table": "ordinals",
173 "where": [],
174 "sort": ["number"]}]]]],
175 [[[{"uuid":["uuid","<0>"]}]
176 [{"uuid":["uuid","<1>"]}]
177 [{"count":1}]
178 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"nought","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
179 ]])
180
181 OVSDB_CHECK_EXECUTION([insert rows, mutate rows],
182 [ORDINAL_SCHEMA],
183 [[[["ordinals",
184 {"op": "insert",
185 "table": "ordinals",
186 "row": {"number": 0, "name": "zero"},
187 "uuid-name": "first"}]]],
188 [[["ordinals",
189 {"op": "insert",
190 "table": "ordinals",
191 "row": {"number": 1, "name": "one"},
192 "uuid-name": "first"}]]],
193 [[["ordinals",
194 {"op": "mutate",
195 "table": "ordinals",
196 "where": [["name", "==", "zero"]],
197 "mutations": [["number", "+=", 2]]}]]],
198 [[["ordinals",
199 {"op": "select",
200 "table": "ordinals",
201 "where": [],
202 "sort": ["number"]}]]]],
203 [[[{"uuid":["uuid","<0>"]}]
204 [{"uuid":["uuid","<1>"]}]
205 [{"count":1}]
206 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<2>"],"name":"one","number":1},{"_uuid":["uuid","<0>"],"_version":["uuid","<3>"],"name":"zero","number":2}]}]
207 ]])
208
209 OVSDB_CHECK_EXECUTION([insert rows, delete by named-uuid],
210 [ORDINAL_SCHEMA],
211 [[[["ordinals",
212 {"op": "insert",
213 "table": "ordinals",
214 "row": {"number": 0, "name": "zero"},
215 "uuid-name": "first"},
216 {"op": "insert",
217 "table": "ordinals",
218 "row": {"number": 1, "name": "one"},
219 "uuid-name": "second"},
220 {"op": "delete",
221 "table": "ordinals",
222 "where": [["_uuid", "==", ["named-uuid", "first"]]]},
223 {"op": "select",
224 "table": "ordinals",
225 "where": [],
226 "columns": ["name","number"]}]]]],
227 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":1},{"rows":[{"name":"one","number":1}]}]
228 ]])
229
230 OVSDB_CHECK_EXECUTION([insert rows, delete rows by value],
231 [ORDINAL_SCHEMA],
232 [[[["ordinals",
233 {"op": "insert",
234 "table": "ordinals",
235 "row": {"number": 0, "name": "zero"},
236 "uuid-name": "first"}]]],
237 [[["ordinals",
238 {"op": "insert",
239 "table": "ordinals",
240 "row": {"number": 1, "name": "one"},
241 "uuid-name": "first"}]]],
242 [[["ordinals",
243 {"op": "delete",
244 "table": "ordinals",
245 "where": [["name", "==", "zero"]]}]]],
246 [[["ordinals",
247 {"op": "select",
248 "table": "ordinals",
249 "where": []}]]]],
250 [[[{"uuid":["uuid","<0>"]}]
251 [{"uuid":["uuid","<1>"]}]
252 [{"count":1}]
253 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<2>"],"name":"one","number":1}]}]
254 ]])
255
256 OVSDB_CHECK_EXECUTION([insert rows, delete by (non-matching) value],
257 [ORDINAL_SCHEMA],
258 [[[["ordinals",
259 {"op": "insert",
260 "table": "ordinals",
261 "row": {"number": 0, "name": "zero"},
262 "uuid-name": "first"}]]],
263 [[["ordinals",
264 {"op": "insert",
265 "table": "ordinals",
266 "row": {"number": 1, "name": "one"},
267 "uuid-name": "first"}]]],
268 [[["ordinals",
269 {"op": "delete",
270 "table": "ordinals",
271 "where": [["name", "==", "nought"]]}]]],
272 [[["ordinals",
273 {"op": "select",
274 "table": "ordinals",
275 "where": [],
276 "sort": ["number"]}]]]],
277 [[[{"uuid":["uuid","<0>"]}]
278 [{"uuid":["uuid","<1>"]}]
279 [{"count":0}]
280 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
281 ]])
282
283 OVSDB_CHECK_EXECUTION([insert rows, delete all],
284 [ORDINAL_SCHEMA],
285 [[[["ordinals",
286 {"op": "insert",
287 "table": "ordinals",
288 "row": {"number": 0, "name": "zero"},
289 "uuid-name": "first"},
290 {"op": "insert",
291 "table": "ordinals",
292 "row": {"number": 1, "name": "one"},
293 "uuid-name": "second"},
294 {"op": "delete",
295 "table": "ordinals",
296 "where": []},
297 {"op": "select",
298 "table": "ordinals",
299 "where": [],
300 "columns": ["name","number"]}]]]],
301 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":2},{"rows":[]}]
302 ]])
303
304 OVSDB_CHECK_EXECUTION([insert row, query table, commit],
305 [ORDINAL_SCHEMA],
306 [[[["ordinals",
307 {"op": "insert",
308 "table": "ordinals",
309 "row": {"number": 0, "name": "zero"}},
310 {"op": "select",
311 "table": "ordinals",
312 "where": []},
313 {"op": "commit",
314 "durable": false}]]]],
315 [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}]
316 ]])
317
318 OVSDB_CHECK_EXECUTION([insert row, query table, commit durably],
319 [ORDINAL_SCHEMA],
320 [[[["ordinals",
321 {"op": "insert",
322 "table": "ordinals",
323 "row": {"number": 0, "name": "zero"}},
324 {"op": "select",
325 "table": "ordinals",
326 "where": []},
327 {"op": "commit",
328 "durable": true}]]]],
329 [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}]
330 ]])
331
332 OVSDB_CHECK_EXECUTION([equality wait with correct rows],
333 [ORDINAL_SCHEMA],
334 [[[["ordinals",
335 {"op": "insert",
336 "table": "ordinals",
337 "row": {"number": 0, "name": "zero"}},
338 {"op": "insert",
339 "table": "ordinals",
340 "row": {"number": 1, "name": "one"}},
341 {"op": "wait",
342 "timeout": 0,
343 "table": "ordinals",
344 "where": [],
345 "columns": ["name", "number"],
346 "until": "==",
347 "rows": [{"name": "zero", "number": 0},
348 {"name": "one", "number": 1}]}]]]],
349 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
350 ]])
351
352 OVSDB_CHECK_EXECUTION([equality wait with extra row],
353 [ORDINAL_SCHEMA],
354 [[[["ordinals",
355 {"op": "insert",
356 "table": "ordinals",
357 "row": {"number": 0, "name": "zero"}},
358 {"op": "insert",
359 "table": "ordinals",
360 "row": {"number": 1, "name": "one"}},
361 {"op": "wait",
362 "timeout": 0,
363 "table": "ordinals",
364 "where": [],
365 "columns": ["name", "number"],
366 "until": "==",
367 "rows": [{"name": "zero", "number": 0},
368 {"name": "one", "number": 1},
369 {"name": "two", "number": 2}]}]]]],
370 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
371 ]])
372
373 OVSDB_CHECK_EXECUTION([equality wait with missing row],
374 [ORDINAL_SCHEMA],
375 [[[["ordinals",
376 {"op": "insert",
377 "table": "ordinals",
378 "row": {"number": 0, "name": "zero"}},
379 {"op": "insert",
380 "table": "ordinals",
381 "row": {"number": 1, "name": "one"}},
382 {"op": "wait",
383 "timeout": 0,
384 "table": "ordinals",
385 "where": [],
386 "columns": ["name", "number"],
387 "until": "==",
388 "rows": [{"name": "one", "number": 1}]}]]]],
389 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
390 ]])
391
392 OVSDB_CHECK_EXECUTION([inequality wait with correct rows],
393 [ORDINAL_SCHEMA],
394 [[[["ordinals",
395 {"op": "insert",
396 "table": "ordinals",
397 "row": {"number": 0, "name": "zero"}},
398 {"op": "insert",
399 "table": "ordinals",
400 "row": {"number": 1, "name": "one"}},
401 {"op": "wait",
402 "timeout": 0,
403 "table": "ordinals",
404 "where": [],
405 "columns": ["name", "number"],
406 "until": "!=",
407 "rows": [{"name": "zero", "number": 0},
408 {"name": "one", "number": 1}]}]]]],
409 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
410 ]])
411
412 OVSDB_CHECK_EXECUTION([inequality wait with extra row],
413 [ORDINAL_SCHEMA],
414 [[[["ordinals",
415 {"op": "insert",
416 "table": "ordinals",
417 "row": {"number": 0, "name": "zero"}},
418 {"op": "insert",
419 "table": "ordinals",
420 "row": {"number": 1, "name": "one"}},
421 {"op": "wait",
422 "timeout": 0,
423 "table": "ordinals",
424 "where": [],
425 "columns": ["name", "number"],
426 "until": "!=",
427 "rows": [{"name": "zero", "number": 0},
428 {"name": "one", "number": 1},
429 {"name": "two", "number": 2}]}]]]],
430 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
431 ]])
432
433 OVSDB_CHECK_EXECUTION([inequality wait with missing row],
434 [ORDINAL_SCHEMA],
435 [[[["ordinals",
436 {"op": "insert",
437 "table": "ordinals",
438 "row": {"number": 0, "name": "zero"}},
439 {"op": "insert",
440 "table": "ordinals",
441 "row": {"number": 1, "name": "one"}},
442 {"op": "wait",
443 "timeout": 0,
444 "table": "ordinals",
445 "where": [],
446 "columns": ["name", "number"],
447 "until": "!=",
448 "rows": [{"name": "one", "number": 1}]}]]]],
449 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
450 ]])
451
452 OVSDB_CHECK_EXECUTION([insert and update constraints],
453 [CONSTRAINT_SCHEMA],
454 [[[["constraints",
455 {"op": "insert",
456 "table": "constrained",
457 "row": {}}]]],
458 [[["constraints",
459 {"op": "insert",
460 "table": "constrained",
461 "row": {"positive": -1}}]]],
462 [[["constraints",
463 {"op": "update",
464 "table": "constrained",
465 "where": [],
466 "row": {"positive": -2}}]]],
467 [[["constraints",
468 {"op": "insert",
469 "table": "constrained",
470 "row": {"positive": 1}}]]],
471 [[["constraints",
472 {"op": "insert",
473 "table": "constrained",
474 "row": {"positive": 2}}]]]],
475 [[[{"details":"0 is less than minimum allowed value 1","error":"constraint violation"}]
476 [{"details":"-1 is less than minimum allowed value 1","error":"constraint violation"}]
477 [{"details":"-2 is less than minimum allowed value 1","error":"constraint violation"}]
478 [{"uuid":["uuid","<0>"]}]
479 [{"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"}]
480 ]])
481
482 OVSDB_CHECK_EXECUTION([referential integrity -- simple],
483 [CONSTRAINT_SCHEMA],
484 [[[["constraints",
485 {"op": "insert",
486 "table": "b",
487 "row": {"b": 1},
488 "uuid-name": "brow"},
489 {"op": "insert",
490 "table": "a",
491 "row": {"a": 0,
492 "a2b": ["set", [["named-uuid", "brow"]]]}},
493 {"op": "insert",
494 "table": "a",
495 "row": {"a": 1,
496 "a2b": ["set", [["named-uuid", "brow"]]]}},
497 {"op": "insert",
498 "table": "a",
499 "row": {"a": 2,
500 "a2b": ["set", [["named-uuid", "brow"]]]}}]]],
501 [[["constraints",
502 {"op": "delete",
503 "table": "b",
504 "where": []}]]],
505 [[["constraints",
506 {"op": "delete",
507 "table": "a",
508 "where": [["a", "==", 0]]}]]],
509 [[["constraints",
510 {"op": "delete",
511 "table": "b",
512 "where": []}]]],
513 [[["constraints",
514 {"op": "delete",
515 "table": "a",
516 "where": [["a", "==", 1]]}]]],
517 [[["constraints",
518 {"op": "delete",
519 "table": "b",
520 "where": []}]]],
521 [[["constraints",
522 {"op": "delete",
523 "table": "a",
524 "where": [["a", "==", 2]]}]]],
525 [[["constraints",
526 {"op": "delete",
527 "table": "b",
528 "where": []}]]]],
529 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]
530 [{"count":1},{"details":"cannot delete b row <0> because of 3 remaining reference(s)","error":"referential integrity violation"}]
531 [{"count":1}]
532 [{"count":1},{"details":"cannot delete b row <0> because of 2 remaining reference(s)","error":"referential integrity violation"}]
533 [{"count":1}]
534 [{"count":1},{"details":"cannot delete b row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
535 [{"count":1}]
536 [{"count":1}]
537 ]])
538
539 OVSDB_CHECK_EXECUTION([referential integrity -- mutual references],
540 [CONSTRAINT_SCHEMA],
541 [[[["constraints",
542 {"op": "insert",
543 "table": "a",
544 "row": {"a": 0,
545 "a2b": ["set", [["named-uuid", "row2"]]],
546 "a2a": ["set", [["named-uuid", "row1"]]]},
547 "uuid-name": "row1"},
548 {"op": "insert",
549 "table": "b",
550 "row": {"b": 1,
551 "b2b": ["set", [["named-uuid", "row2"]]],
552 "b2a": ["set", [["named-uuid", "row1"]]]},
553 "uuid-name": "row2"}]]],
554 [[["constraints",
555 {"op": "insert",
556 "table": "a",
557 "row": {"a2b": ["set", [["uuid", "b516b960-5b19-4fc2-bb82-fe1cbd6d0241"]]]}}]]],
558 [[["constraints",
559 {"op": "delete",
560 "table": "a",
561 "where": [["a", "==", 0]]}]]],
562 [[["constraints",
563 {"op": "delete",
564 "table": "b",
565 "where": [["b", "==", 1]]}]]],
566 dnl Try the deletions again to make sure that the refcounts got rolled back.
567 [[["constraints",
568 {"op": "delete",
569 "table": "a",
570 "where": [["a", "==", 0]]}]]],
571 [[["constraints",
572 {"op": "delete",
573 "table": "b",
574 "where": [["b", "==", 1]]}]]],
575 [[["constraints",
576 {"op": "delete",
577 "table": "a",
578 "where": [["a", "==", 0]]},
579 {"op": "delete",
580 "table": "b",
581 "where": [["b", "==", 1]]}]]]],
582 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]
583 [{"uuid":["uuid","<2>"]},{"details":"Table a column a2b row <2> references nonexistent row <3> in table b.","error":"referential integrity violation"}]
584 [{"count":1},{"details":"cannot delete a row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
585 [{"count":1},{"details":"cannot delete b row <1> because of 1 remaining reference(s)","error":"referential integrity violation"}]
586 [{"count":1},{"details":"cannot delete a row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
587 [{"count":1},{"details":"cannot delete b row <1> because of 1 remaining reference(s)","error":"referential integrity violation"}]
588 [{"count":1},{"count":1}]
589 ]])
590
591 OVSDB_CHECK_EXECUTION([weak references],
592 [WEAK_SCHEMA],
593 [[[["weak",
594 {"op": "insert",
595 "table": "a",
596 "row": {"a": 0,
597 "a2a": ["set", [["named-uuid", "row1"],
598 ["named-uuid", "row2"],
599 ["uuid", "0e767b36-6822-4044-8307-d58467e04669"]]],
600 "a2a1": ["named-uuid", "row1"],
601 "a2b": ["named-uuid", "row3"]},
602 "uuid-name": "row1"},
603 {"op": "insert",
604 "table": "a",
605 "row": {"a": 1,
606 "a2a": ["set", [["named-uuid", "row1"],
607 ["named-uuid", "row2"]]],
608 "a2a1": ["named-uuid", "row2"],
609 "a2b": ["named-uuid", "row3"]},
610 "uuid-name": "row2"},
611 {"op": "insert",
612 "table": "a",
613 "row": {"a": 2,
614 "a2a": ["set", [["named-uuid", "row1"],
615 ["named-uuid", "row2"]]],
616 "a2a1": ["named-uuid", "row2"],
617 "a2b": ["named-uuid", "row4"]}},
618 {"op": "insert",
619 "table": "b",
620 "row": {"b": 2,
621 "b2a": ["named-uuid", "row1"]},
622 "uuid-name": "row3"},
623 {"op": "insert",
624 "table": "b",
625 "row": {"b": 3,
626 "b2a": ["named-uuid", "row2"]},
627 "uuid-name": "row4"}]]],
628 dnl Check that the nonexistent row UUID we added to row a0 was deleted,
629 dnl and that other rows were inserted as requested.
630 [[["weak",
631 {"op": "select",
632 "table": "a",
633 "where": [],
634 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
635 "sort": ["a"]}]]],
636 [[["weak",
637 {"op": "select",
638 "table": "b",
639 "where": [],
640 "columns": ["_uuid", "b", "b2a"],
641 "sort": ["b"]}]]],
642 dnl Try to insert invalid all-zeros weak reference (the default) into
643 dnl "a2b", which requires exactly one value.
644 [[["weak",
645 {"op": "insert",
646 "table": "a",
647 "row": {"a2a1": ["named-uuid", "me"]},
648 "uuid-name": "me"}]]],
649 dnl Try to delete row from "b" that is referred to by weak references
650 dnl from "a" table "a2b" column that requires exactly one value.
651 [[["weak",
652 {"op": "delete",
653 "table": "b",
654 "where": [["b", "==", 3]]}]]],
655 dnl Try to delete row from "a" that is referred to by weak references
656 dnl from "a" table "a2a1" column that requires exactly one value.
657 [[["weak",
658 {"op": "delete",
659 "table": "a",
660 "where": [["a", "==", 1]]}]]],
661 dnl Delete the row that had the reference that caused the previous
662 dnl deletion to fail, then check that other rows are unchanged.
663 [[["weak",
664 {"op": "delete",
665 "table": "a",
666 "where": [["a", "==", 2]]}]]],
667 [[["weak",
668 {"op": "select",
669 "table": "a",
670 "where": [],
671 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
672 "sort": ["a"]}]]],
673 [[["weak",
674 {"op": "select",
675 "table": "b",
676 "where": [],
677 "columns": ["_uuid", "b", "b2a"],
678 "sort": ["b"]}]]],
679 dnl Delete row a0 then check that references to it were removed.
680 [[["weak",
681 {"op": "delete",
682 "table": "a",
683 "where": [["a", "==", 0]]}]]],
684 [[["weak",
685 {"op": "select",
686 "table": "a",
687 "where": [],
688 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
689 "sort": ["a"]}]]],
690 [[["weak",
691 {"op": "select",
692 "table": "b",
693 "where": [],
694 "columns": ["_uuid", "b", "b2a"],
695 "sort": ["b"]}]]],
696 dnl Delete row a1 then check that references to it were removed.
697 [[["weak",
698 {"op": "delete",
699 "table": "a",
700 "where": [["a", "==", 1]]}]]],
701 [[["weak",
702 {"op": "select",
703 "table": "a",
704 "where": [],
705 "columns": ["_uuid", "a2a", "a2a1", "a2b"],
706 "sort": ["a"]}]]],
707 [[["weak",
708 {"op": "select",
709 "table": "b",
710 "where": [],
711 "columns": ["_uuid", "b", "b2a"],
712 "sort": ["b"]}]]]],
713 [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]},{"uuid":["uuid","<4>"]}]
714 [{"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>"]}]}]
715 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["uuid","<0>"]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
716 [{"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"}]
717 [{"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"}]
718 [{"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"}]
719 [{"count":1}]
720 [{"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>"]}]}]
721 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["uuid","<0>"]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
722 [{"count":1}]
723 [{"rows":[{"_uuid":["uuid","<1>"],"a2a":["uuid","<1>"],"a2a1":["uuid","<1>"],"a2b":["uuid","<3>"]}]}]
724 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["set",[]]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
725 [{"count":1}]
726 [{"rows":[]}]
727 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["set",[]]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["set",[]]}]}]
728 ]])])
729
730 EXECUTION_EXAMPLES