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