Prepare Open vSwitch 1.1.2 release.
[sliver-openvswitch.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      "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            "x": {"type": {"key": "integer", "min": 1, "max": 2}}}},
31        "constrained": {
32          "columns": {
33            "positive": {"type": {"key": {"type": "integer",
34                                          "minInteger": 1}}}},
35          "maxRows": 1}}}]])
36
37 m4_define([WEAK_SCHEMA],
38   [[{"name": "weak",
39      "tables": {
40        "a": {
41          "columns": {
42            "a": {"type": "integer"},
43            "a2a": {"type": {"key": {"type": "uuid",
44                                     "refTable": "a",
45                                     "refType": "weak"},
46                             "min": 0, "max": "unlimited"}},
47            "a2a1": {"type": {"key": {"type": "uuid",
48                                      "refTable": "a",
49                                      "refType": "weak"}}},
50            "a2b": {"type": {"key": {"type": "uuid",
51                                     "refTable": "b",
52                                     "refType": "weak"}}}}},
53        "b": {
54          "columns": {
55            "b": {"type": "integer"},
56            "b2a": {"type": {"key": {"type": "uuid",
57                                     "refTable": "a",
58                                     "refType": "weak"},
59                             "min": 0, "max": "unlimited"}}}}}}]])
60
61 m4_define([GC_SCHEMA],
62   [[{"name": "gc",
63      "tables": {
64        "root": {
65          "columns": {
66            "a": {"type": {"key": {"type": "uuid",
67                                   "refTable": "a"},
68                             "min": 0, "max": "unlimited"}}},
69          "isRoot": true},
70        "a": {
71          "columns": {
72            "a": {"type": "integer"},
73            "a2a": {"type": {"key": {"type": "uuid",
74                                     "refTable": "a"},
75                             "min": 0, "max": "unlimited"}},
76            "a2b": {"type": {"key": {"type": "uuid",
77                                     "refTable": "b"},
78                             "min": 0, "max": "unlimited"}},
79            "wa2a": {"type": {"key": {"type": "uuid",
80                                      "refTable": "a",
81                                      "refType": "weak"},
82                              "min": 0, "max": "unlimited"}},
83            "wa2b": {"type": {"key": {"type": "uuid",
84                                     "refTable": "b",
85                                     "refType": "weak"},
86                              "min": 0, "max": "unlimited"}}}},
87        "b": {
88          "columns": {
89            "b": {"type": "integer"},
90            "b2a": {"type": {"key": {"type": "uuid",
91                                     "refTable": "a"},
92                             "min": 0, "max": "unlimited"}},
93            "wb2a": {"type": {"key": {"type": "uuid",
94                                      "refTable": "a",
95                                      "refType": "weak"},
96                              "min": 0, "max": "unlimited"}}},
97          "isRoot": false}}}]])
98
99 # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS])
100 #
101 # Runs "test-ovsdb execute" with the given SCHEMA and each of the
102 # TRANSACTIONS (which should be a quoted list of quoted strings).
103 #
104 # Checks that the overall output is OUTPUT, but UUIDs in the output
105 # are replaced by markers of the form <N> where N is a number.  The
106 # first unique UUID is replaced by <0>, the next by <1>, and so on.
107 # If a given UUID appears more than once it is always replaced by the
108 # same marker.
109 #
110 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
111 m4_define([OVSDB_CHECK_EXECUTION], 
112   [AT_SETUP([$1])
113    AT_KEYWORDS([ovsdb execute execution positive $5])
114    AT_CHECK([test-ovsdb execute '$2' m4_foreach([txn], [$3], [ 'txn'])],
115      [0], [stdout], [])
116    AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], [$4])
117    AT_CLEANUP])
118
119 OVSDB_CHECK_EXECUTION([uuid-name must be <id>],
120   [CONSTRAINT_SCHEMA],
121   [[[["constraints",
122       {"op": "insert",
123        "table": "a",
124        "row": {},
125        "uuid-name": "0"}]]]],
126   [[[{"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\"}"}]
127 ]])
128
129 OVSDB_CHECK_EXECUTION([named-uuid must be <id>],
130   [CONSTRAINT_SCHEMA],
131   [[[["constraints",
132       {"op": "insert",
133        "table": "a",
134        "row": {"a2a": ["named-uuid", "0"]}}]]]],
135   [[[{"details":"named-uuid string is not a valid <id>","error":"syntax error","syntax":"[\"named-uuid\",\"0\"]"}]
136 ]])
137
138 OVSDB_CHECK_EXECUTION([duplicate uuid-name not allowed],
139   [ORDINAL_SCHEMA],
140   [[[["ordinals",
141       {"op": "insert",
142        "table": "ordinals",
143        "row": {},
144        "uuid-name": "x"},
145       {"op": "insert",
146        "table": "ordinals",
147        "row": {},
148        "uuid-name": "x"}]]]],
149   [[[{"uuid":["uuid","<0>"]},{"details":"This \"uuid-name\" appeared on an earlier \"insert\" operation.","error":"duplicate uuid-name","syntax":"\"x\""}]
150 ]])
151
152 m4_define([EXECUTION_EXAMPLES], [
153 dnl At one point the "commit" code ignored new rows with all-default values,
154 dnl so this checks for that problem.
155 OVSDB_CHECK_EXECUTION([insert default row, query table],
156   [ORDINAL_SCHEMA], 
157   [[[["ordinals",
158       {"op": "insert",
159        "table": "ordinals",
160        "row": {}}]]],
161    [[["ordinals",
162       {"op": "select",
163        "table": "ordinals",
164        "where": []}]]]],
165   [[[{"uuid":["uuid","<0>"]}]
166 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"","number":0}]}]
167 ]])
168
169 OVSDB_CHECK_EXECUTION([insert row, query table],
170   [ORDINAL_SCHEMA], 
171   [[[["ordinals",
172       {"op": "insert",
173        "table": "ordinals",
174        "row": {"number": 0, "name": "zero"}}]]],
175    [[["ordinals",
176       {"op": "select",
177        "table": "ordinals",
178        "where": []}]]]],
179   [[[{"uuid":["uuid","<0>"]}]
180 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]}]
181 ]])
182
183 OVSDB_CHECK_EXECUTION([insert rows, query by value],
184   [ORDINAL_SCHEMA],
185   [[[["ordinals",
186       {"op": "insert",
187        "table": "ordinals",
188        "row": {"number": 0, "name": "zero"}}]]],
189    [[["ordinals",
190       {"op": "insert",
191        "table": "ordinals",
192        "row": {"number": 1, "name": "one"}}]]],
193    [[["ordinals",
194       {"op": "select",
195        "table": "ordinals",
196        "where": [["name", "==", "zero"]]}]]],
197    [[["ordinals",
198       {"op": "select",
199        "table": "ordinals",
200        "where": [["name", "==", "one"]]}]]]],
201   [[[{"uuid":["uuid","<0>"]}]
202 [{"uuid":["uuid","<1>"]}]
203 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0}]}]
204 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
205 ]])
206
207 OVSDB_CHECK_EXECUTION([insert rows, query by named-uuid],
208   [ORDINAL_SCHEMA],
209   [[[["ordinals",
210       {"op": "insert",
211        "table": "ordinals",
212        "row": {"number": 0, "name": "zero"},
213        "uuid-name": "first"},
214       {"op": "insert",
215        "table": "ordinals",
216        "row": {"number": 1, "name": "one"},
217        "uuid-name": "second"},
218       {"op": "select",
219        "table": "ordinals",
220        "where": [["_uuid", "==", ["named-uuid", "first"]]]},
221       {"op": "select",
222        "table": "ordinals",
223        "where": [["_uuid", "==", ["named-uuid", "second"]]]}]]]],
224   [[[{"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}]}]
225 ]])
226
227 OVSDB_CHECK_EXECUTION([insert rows, update rows by value],
228   [ORDINAL_SCHEMA],
229   [[[["ordinals",
230       {"op": "insert",
231        "table": "ordinals",
232        "row": {"number": 0, "name": "zero"},
233        "uuid-name": "first"}]]],
234    [[["ordinals",
235       {"op": "insert",
236        "table": "ordinals",
237        "row": {"number": 1, "name": "one"},
238        "uuid-name": "first"}]]],
239    [[["ordinals",
240       {"op": "update",
241        "table": "ordinals",
242        "where": [["name", "==", "zero"]],
243        "row": {"name": "nought"}}]]],
244    [[["ordinals",
245       {"op": "select",
246        "table": "ordinals",
247        "where": [],
248        "sort": ["number"]}]]]],
249   [[[{"uuid":["uuid","<0>"]}]
250 [{"uuid":["uuid","<1>"]}]
251 [{"count":1}]
252 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"nought","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
253 ]])
254
255 OVSDB_CHECK_EXECUTION([insert rows, mutate rows],
256   [ORDINAL_SCHEMA],
257   [[[["ordinals",
258       {"op": "insert",
259        "table": "ordinals",
260        "row": {"number": 0, "name": "zero"},
261        "uuid-name": "first"}]]],
262    [[["ordinals",
263       {"op": "insert",
264        "table": "ordinals",
265        "row": {"number": 1, "name": "one"},
266        "uuid-name": "first"}]]],
267    [[["ordinals",
268       {"op": "mutate",
269        "table": "ordinals",
270        "where": [["name", "==", "zero"]],
271        "mutations": [["number", "+=", 2]]}]]],
272    [[["ordinals",
273       {"op": "select",
274        "table": "ordinals",
275        "where": [],
276        "sort": ["number"]}]]]],
277   [[[{"uuid":["uuid","<0>"]}]
278 [{"uuid":["uuid","<1>"]}]
279 [{"count":1}]
280 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<2>"],"name":"one","number":1},{"_uuid":["uuid","<0>"],"_version":["uuid","<3>"],"name":"zero","number":2}]}]
281 ]])
282
283 OVSDB_CHECK_EXECUTION([insert rows, delete by named-uuid],
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": [["_uuid", "==", ["named-uuid", "first"]]]},
297       {"op": "select",
298        "table": "ordinals",
299        "where": [],
300        "columns": ["name","number"]}]]]],
301   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":1},{"rows":[{"name":"one","number":1}]}]
302 ]])
303
304 OVSDB_CHECK_EXECUTION([insert rows, delete rows by value],
305   [ORDINAL_SCHEMA],
306   [[[["ordinals",
307       {"op": "insert",
308        "table": "ordinals",
309        "row": {"number": 0, "name": "zero"},
310        "uuid-name": "first"}]]],
311    [[["ordinals",
312       {"op": "insert",
313        "table": "ordinals",
314        "row": {"number": 1, "name": "one"},
315        "uuid-name": "first"}]]],
316    [[["ordinals",
317       {"op": "delete",
318        "table": "ordinals",
319        "where": [["name", "==", "zero"]]}]]],
320    [[["ordinals",
321       {"op": "select",
322        "table": "ordinals",
323        "where": []}]]]],
324   [[[{"uuid":["uuid","<0>"]}]
325 [{"uuid":["uuid","<1>"]}]
326 [{"count":1}]
327 [{"rows":[{"_uuid":["uuid","<1>"],"_version":["uuid","<2>"],"name":"one","number":1}]}]
328 ]])
329
330 OVSDB_CHECK_EXECUTION([insert rows, delete by (non-matching) value],
331   [ORDINAL_SCHEMA],
332   [[[["ordinals",
333       {"op": "insert",
334        "table": "ordinals",
335        "row": {"number": 0, "name": "zero"},
336        "uuid-name": "first"}]]],
337    [[["ordinals",
338       {"op": "insert",
339        "table": "ordinals",
340        "row": {"number": 1, "name": "one"},
341        "uuid-name": "first"}]]],
342    [[["ordinals",
343       {"op": "delete",
344        "table": "ordinals",
345        "where": [["name", "==", "nought"]]}]]],
346    [[["ordinals",
347       {"op": "select",
348        "table": "ordinals",
349        "where": [],
350        "sort": ["number"]}]]]],
351   [[[{"uuid":["uuid","<0>"]}]
352 [{"uuid":["uuid","<1>"]}]
353 [{"count":0}]
354 [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}]
355 ]])
356
357 OVSDB_CHECK_EXECUTION([insert rows, delete all],
358   [ORDINAL_SCHEMA],
359   [[[["ordinals",
360       {"op": "insert",
361        "table": "ordinals",
362        "row": {"number": 0, "name": "zero"},
363        "uuid-name": "first"},
364       {"op": "insert",
365        "table": "ordinals",
366        "row": {"number": 1, "name": "one"},
367        "uuid-name": "second"},
368       {"op": "delete",
369        "table": "ordinals",
370        "where": []},
371       {"op": "select",
372        "table": "ordinals",
373        "where": [],
374        "columns": ["name","number"]}]]]],
375   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"count":2},{"rows":[]}]
376 ]])
377
378 OVSDB_CHECK_EXECUTION([insert row, query table, commit],
379   [ORDINAL_SCHEMA],
380   [[[["ordinals",
381       {"op": "insert",
382        "table": "ordinals",
383        "row": {"number": 0, "name": "zero"}},
384       {"op": "select",
385        "table": "ordinals",
386        "where": []},
387       {"op": "commit",
388        "durable": false}]]]],
389   [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}]
390 ]])
391
392 OVSDB_CHECK_EXECUTION([insert row, query table, commit durably],
393   [ORDINAL_SCHEMA],
394   [[[["ordinals",
395       {"op": "insert",
396        "table": "ordinals",
397        "row": {"number": 0, "name": "zero"}},
398       {"op": "select",
399        "table": "ordinals",
400        "where": []},
401       {"op": "commit",
402        "durable": true}]]]],
403   [[[{"uuid":["uuid","<0>"]},{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<1>"],"name":"zero","number":0}]},{}]
404 ]])
405
406 OVSDB_CHECK_EXECUTION([equality wait with correct rows],
407   [ORDINAL_SCHEMA],
408   [[[["ordinals",
409       {"op": "insert",
410        "table": "ordinals",
411        "row": {"number": 0, "name": "zero"}},
412       {"op": "insert",
413        "table": "ordinals",
414        "row": {"number": 1, "name": "one"}},
415       {"op": "wait",
416        "timeout": 0,
417        "table": "ordinals",
418        "where": [],
419        "columns": ["name", "number"],
420        "until": "==",
421        "rows": [{"name": "zero", "number": 0},
422                 {"name": "one", "number": 1}]}]]]],
423   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
424 ]])
425
426 OVSDB_CHECK_EXECUTION([equality wait with extra row],
427   [ORDINAL_SCHEMA],
428   [[[["ordinals",
429       {"op": "insert",
430        "table": "ordinals",
431        "row": {"number": 0, "name": "zero"}},
432       {"op": "insert",
433        "table": "ordinals",
434        "row": {"number": 1, "name": "one"}},
435       {"op": "wait",
436        "timeout": 0,
437        "table": "ordinals",
438        "where": [],
439        "columns": ["name", "number"],
440        "until": "==",
441        "rows": [{"name": "zero", "number": 0},
442                 {"name": "one", "number": 1},
443                 {"name": "two", "number": 2}]}]]]],
444   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
445 ]])
446
447 OVSDB_CHECK_EXECUTION([equality wait with missing row],
448   [ORDINAL_SCHEMA],
449   [[[["ordinals",
450       {"op": "insert",
451        "table": "ordinals",
452        "row": {"number": 0, "name": "zero"}},
453       {"op": "insert",
454        "table": "ordinals",
455        "row": {"number": 1, "name": "one"}},
456       {"op": "wait",
457        "timeout": 0,
458        "table": "ordinals",
459        "where": [],
460        "columns": ["name", "number"],
461        "until": "==",
462        "rows": [{"name": "one", "number": 1}]}]]]],
463   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
464 ]])
465
466 OVSDB_CHECK_EXECUTION([inequality wait with correct rows],
467   [ORDINAL_SCHEMA],
468   [[[["ordinals",
469       {"op": "insert",
470        "table": "ordinals",
471        "row": {"number": 0, "name": "zero"}},
472       {"op": "insert",
473        "table": "ordinals",
474        "row": {"number": 1, "name": "one"}},
475       {"op": "wait",
476        "timeout": 0,
477        "table": "ordinals",
478        "where": [],
479        "columns": ["name", "number"],
480        "until": "!=",
481        "rows": [{"name": "zero", "number": 0},
482                 {"name": "one", "number": 1}]}]]]],
483   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"details":"\"wait\" timed out","error":"timed out"}]
484 ]])
485
486 OVSDB_CHECK_EXECUTION([inequality wait with extra row],
487   [ORDINAL_SCHEMA],
488   [[[["ordinals",
489       {"op": "insert",
490        "table": "ordinals",
491        "row": {"number": 0, "name": "zero"}},
492       {"op": "insert",
493        "table": "ordinals",
494        "row": {"number": 1, "name": "one"}},
495       {"op": "wait",
496        "timeout": 0,
497        "table": "ordinals",
498        "where": [],
499        "columns": ["name", "number"],
500        "until": "!=",
501        "rows": [{"name": "zero", "number": 0},
502                 {"name": "one", "number": 1},
503                 {"name": "two", "number": 2}]}]]]],
504   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
505 ]])
506
507 OVSDB_CHECK_EXECUTION([inequality wait with missing row],
508   [ORDINAL_SCHEMA],
509   [[[["ordinals",
510       {"op": "insert",
511        "table": "ordinals",
512        "row": {"number": 0, "name": "zero"}},
513       {"op": "insert",
514        "table": "ordinals",
515        "row": {"number": 1, "name": "one"}},
516       {"op": "wait",
517        "timeout": 0,
518        "table": "ordinals",
519        "where": [],
520        "columns": ["name", "number"],
521        "until": "!=",
522        "rows": [{"name": "one", "number": 1}]}]]]],
523   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{}]
524 ]])
525
526 OVSDB_CHECK_EXECUTION([insert and update constraints],
527   [CONSTRAINT_SCHEMA],
528   [[[["constraints",
529       {"op": "insert",
530        "table": "constrained",
531        "row": {}}]]],
532    [[["constraints",
533       {"op": "insert",
534        "table": "constrained",
535        "row": {"positive": -1}}]]],
536    [[["constraints",
537       {"op": "update",
538        "table": "constrained",
539        "where": [],
540        "row": {"positive": -2}}]]],
541    [[["constraints",
542       {"op": "insert",
543        "table": "constrained",
544        "row": {"positive": 1}}]]],
545    [[["constraints",
546       {"op": "insert",
547        "table": "constrained",
548        "row": {"positive": 2}}]]]],
549   [[[{"details":"0 is less than minimum allowed value 1","error":"constraint violation"}]
550 [{"details":"-1 is less than minimum allowed value 1","error":"constraint violation"}]
551 [{"details":"-2 is less than minimum allowed value 1","error":"constraint violation"}]
552 [{"uuid":["uuid","<0>"]}]
553 [{"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"}]
554 ]])
555
556 OVSDB_CHECK_EXECUTION([referential integrity -- simple],
557   [CONSTRAINT_SCHEMA],
558   [[[["constraints",
559       {"op": "insert",
560        "table": "b",
561        "row": {"b": 1},
562        "uuid-name": "brow"},
563       {"op": "insert",
564        "table": "a",
565        "row": {"a": 0,
566                "a2b": ["set", [["named-uuid", "brow"]]]}},
567       {"op": "insert",
568        "table": "a",
569        "row": {"a": 1,
570                "a2b": ["set", [["named-uuid", "brow"]]]}},
571       {"op": "insert",
572        "table": "a",
573        "row": {"a": 2,
574                "a2b": ["set", [["named-uuid", "brow"]]]}}]]],
575    [[["constraints",
576       {"op": "delete",
577        "table": "b",
578        "where": []}]]],
579 dnl Check that "mutate" honors number-of-elements constraints on sets and maps.
580    [[["constraints",
581       {"op": "mutate",
582        "table": "b",
583        "where": [],
584        "mutations": [["x", "delete", 0]]}]]],
585    [[["constraints",
586       {"op": "delete",
587        "table": "a",
588        "where": [["a", "==", 0]]}]]],
589    [[["constraints",
590       {"op": "delete",
591        "table": "b",
592        "where": []}]]],
593    [[["constraints",
594       {"op": "delete",
595        "table": "a",
596        "where": [["a", "==", 1]]}]]],
597    [[["constraints",
598       {"op": "delete",
599        "table": "b",
600        "where": []}]]],
601    [[["constraints",
602       {"op": "delete",
603        "table": "a",
604        "where": [["a", "==", 2]]}]]],
605    [[["constraints",
606       {"op": "delete",
607        "table": "b",
608        "where": []}]]]],
609   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]
610 [{"count":1},{"details":"cannot delete b row <0> because of 3 remaining reference(s)","error":"referential integrity violation"}]
611 [{"details":"Attempted to store 0 elements in set of 1 to 2 integers.","error":"constraint violation"}]
612 [{"count":1}]
613 [{"count":1},{"details":"cannot delete b row <0> because of 2 remaining reference(s)","error":"referential integrity violation"}]
614 [{"count":1}]
615 [{"count":1},{"details":"cannot delete b row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
616 [{"count":1}]
617 [{"count":1}]
618 ]])
619
620 OVSDB_CHECK_EXECUTION([referential integrity -- mutual references],
621   [CONSTRAINT_SCHEMA],
622   [[[["constraints",
623       {"op": "insert",
624        "table": "a",
625        "row": {"a": 0,
626                "a2b": ["set", [["named-uuid", "row2"]]],
627                "a2a": ["set", [["named-uuid", "row1"]]]},
628        "uuid-name": "row1"},
629       {"op": "insert",
630        "table": "b",
631        "row": {"b": 1,
632                "b2b": ["set", [["named-uuid", "row2"]]],
633                "b2a": ["set", [["named-uuid", "row1"]]]},
634        "uuid-name": "row2"}]]],
635    [[["constraints",
636       {"op": "insert",
637        "table": "a",
638        "row": {"a2b": ["set", [["uuid", "b516b960-5b19-4fc2-bb82-fe1cbd6d0241"]]]}}]]],
639    [[["constraints",
640       {"op": "delete",
641        "table": "a",
642        "where": [["a", "==", 0]]}]]],
643    [[["constraints",
644       {"op": "delete",
645        "table": "b",
646        "where": [["b", "==", 1]]}]]],
647    dnl Try the deletions again to make sure that the refcounts got rolled back.
648    [[["constraints",
649       {"op": "delete",
650        "table": "a",
651        "where": [["a", "==", 0]]}]]],
652    [[["constraints",
653       {"op": "delete",
654        "table": "b",
655        "where": [["b", "==", 1]]}]]],
656    [[["constraints",
657       {"op": "delete",
658        "table": "a",
659        "where": [["a", "==", 0]]},
660       {"op": "delete",
661        "table": "b",
662        "where": [["b", "==", 1]]}]]]],
663   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]
664 [{"uuid":["uuid","<2>"]},{"details":"Table a column a2b row <2> references nonexistent row <3> in table b.","error":"referential integrity violation"}]
665 [{"count":1},{"details":"cannot delete a row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
666 [{"count":1},{"details":"cannot delete b row <1> because of 1 remaining reference(s)","error":"referential integrity violation"}]
667 [{"count":1},{"details":"cannot delete a row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
668 [{"count":1},{"details":"cannot delete b row <1> because of 1 remaining reference(s)","error":"referential integrity violation"}]
669 [{"count":1},{"count":1}]
670 ]])
671
672 OVSDB_CHECK_EXECUTION([weak references],
673   [WEAK_SCHEMA],
674   [[[["weak",
675       {"op": "insert",
676        "table": "a",
677        "row": {"a": 0,
678                "a2a": ["set", [["named-uuid", "row1"],
679                                ["named-uuid", "row2"],
680                                ["uuid", "0e767b36-6822-4044-8307-d58467e04669"]]],
681                "a2a1": ["named-uuid", "row1"],
682                "a2b": ["named-uuid", "row3"]},
683        "uuid-name": "row1"},
684       {"op": "insert",
685        "table": "a",
686        "row": {"a": 1,
687                "a2a": ["set", [["named-uuid", "row1"],
688                                ["named-uuid", "row2"]]],
689                "a2a1": ["named-uuid", "row2"],
690                "a2b": ["named-uuid", "row3"]},
691        "uuid-name": "row2"},
692       {"op": "insert",
693        "table": "a",
694        "row": {"a": 2,
695                "a2a": ["set", [["named-uuid", "row1"],
696                                ["named-uuid", "row2"]]],
697                "a2a1": ["named-uuid", "row2"],
698                "a2b": ["named-uuid", "row4"]}},
699       {"op": "insert",
700        "table": "b",
701        "row": {"b": 2,
702                "b2a": ["named-uuid", "row1"]},
703        "uuid-name": "row3"},
704       {"op": "insert",
705        "table": "b",
706        "row": {"b": 3,
707                "b2a": ["named-uuid", "row2"]},
708        "uuid-name": "row4"}]]],
709    dnl Check that the nonexistent row UUID we added to row a0 was deleted,
710    dnl and that other rows were inserted as requested.
711    [[["weak",
712       {"op": "select",
713        "table": "a",
714        "where": [],
715        "columns": ["_uuid", "a2a", "a2a1", "a2b"],
716        "sort": ["a"]}]]],
717    [[["weak",
718       {"op": "select",
719        "table": "b",
720        "where": [],
721        "columns": ["_uuid", "b", "b2a"],
722        "sort": ["b"]}]]],
723    dnl Try to insert invalid all-zeros weak reference (the default) into
724    dnl "a2b", which requires exactly one value.
725    [[["weak",
726       {"op": "insert",
727        "table": "a",
728        "row": {"a2a1": ["named-uuid", "me"]},
729        "uuid-name": "me"}]]],
730    dnl Try to delete row from "b" that is referred to by weak references
731    dnl from "a" table "a2b" column that requires exactly one value.
732    [[["weak",
733       {"op": "delete",
734        "table": "b",
735        "where": [["b", "==", 3]]}]]],
736    dnl Try to delete row from "a" that is referred to by weak references
737    dnl from "a" table "a2a1" column that requires exactly one value.
738    [[["weak",
739       {"op": "delete",
740        "table": "a",
741        "where": [["a", "==", 1]]}]]],
742    dnl Delete the row that had the reference that caused the previous
743    dnl deletion to fail, then check that other rows are unchanged.
744    [[["weak",
745       {"op": "delete",
746        "table": "a",
747        "where": [["a", "==", 2]]}]]],
748    [[["weak",
749       {"op": "select",
750        "table": "a",
751        "where": [],
752        "columns": ["_uuid", "a2a", "a2a1", "a2b"],
753        "sort": ["a"]}]]],
754    [[["weak",
755       {"op": "select",
756        "table": "b",
757        "where": [],
758        "columns": ["_uuid", "b", "b2a"],
759        "sort": ["b"]}]]],
760    dnl Delete row a0 then check that references to it were removed.
761    [[["weak",
762       {"op": "delete",
763        "table": "a",
764        "where": [["a", "==", 0]]}]]],
765    [[["weak",
766       {"op": "select",
767        "table": "a",
768        "where": [],
769        "columns": ["_uuid", "a2a", "a2a1", "a2b"],
770        "sort": ["a"]}]]],
771    [[["weak",
772       {"op": "select",
773        "table": "b",
774        "where": [],
775        "columns": ["_uuid", "b", "b2a"],
776        "sort": ["b"]}]]],
777    dnl Delete row a1 then check that references to it were removed.
778    [[["weak",
779       {"op": "delete",
780        "table": "a",
781        "where": [["a", "==", 1]]}]]],
782    [[["weak",
783       {"op": "select",
784        "table": "a",
785        "where": [],
786        "columns": ["_uuid", "a2a", "a2a1", "a2b"],
787        "sort": ["a"]}]]],
788    [[["weak",
789       {"op": "select",
790        "table": "b",
791        "where": [],
792        "columns": ["_uuid", "b", "b2a"],
793        "sort": ["b"]}]]]],
794   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]},{"uuid":["uuid","<4>"]}]
795 [{"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>"]}]}]
796 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["uuid","<0>"]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
797 [{"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"}]
798 [{"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"}]
799 [{"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"}]
800 [{"count":1}]
801 [{"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>"]}]}]
802 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["uuid","<0>"]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
803 [{"count":1}]
804 [{"rows":[{"_uuid":["uuid","<1>"],"a2a":["uuid","<1>"],"a2a1":["uuid","<1>"],"a2b":["uuid","<3>"]}]}]
805 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["set",[]]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["uuid","<1>"]}]}]
806 [{"count":1}]
807 [{"rows":[]}]
808 [{"rows":[{"_uuid":["uuid","<3>"],"b":2,"b2a":["set",[]]},{"_uuid":["uuid","<4>"],"b":3,"b2a":["set",[]]}]}]
809 ]])
810
811 OVSDB_CHECK_EXECUTION([garbage collection],
812   [GC_SCHEMA],
813   [dnl Check that inserting a row without any references is a no-op.
814    [[["gc",
815       {"op": "insert",
816        "table": "a",
817        "row": {"a": 0}}]]],
818    [[["gc",
819       {"op": "select",
820        "table": "a",
821        "where": [],
822        "columns": ["a"]}]]],
823    dnl Check that inserting a chain of rows that reference each other
824    dnl in turn is also a no-op.
825    [[["gc",
826       {"op": "insert",
827        "table": "a",
828        "row": {"a": 0, "a2a": ["named-uuid", "row1"]},
829        "uuid-name": "row0"},
830       {"op": "insert",
831        "table": "a",
832        "row": {"a": 1, "a2a": ["named-uuid", "row2"]},
833        "uuid-name": "row1"},
834       {"op": "insert",
835        "table": "a",
836        "row": {"a": 2, "a2a": ["named-uuid", "row3"]},
837        "uuid-name": "row2"},
838       {"op": "insert",
839        "table": "a",
840        "row": {"a": 3},
841        "uuid-name": "row3"}]]],
842    [[["gc",
843       {"op": "select",
844        "table": "a",
845        "where": [],
846        "columns": ["a"]}]]],
847    dnl Check that inserting a pair of rows that mutually reference each
848    dnl other causes the rows to be retained.
849    [[["gc",
850       {"op": "insert",
851        "table": "a",
852        "row": {"a": 4, "a2a": ["named-uuid", "row5"]},
853        "uuid-name": "row4"},
854       {"op": "insert",
855        "table": "a",
856        "row": {"a": 5, "a2a": ["named-uuid", "row4"]},
857        "uuid-name": "row5"}]]],
858    [[["gc",
859       {"op": "select",
860        "table": "a",
861        "where": [],
862        "columns": ["a"],
863        "sort": ["a"]}]]],
864    dnl Check that unreferencing one of the rows causes the other to be deleted.
865    [[["gc",
866       {"op": "update",
867        "table": "a",
868        "where": [["a", "==", 4]],
869        "row": {"a2a": ["set", []]}}]]],
870    [[["gc",
871       {"op": "select",
872        "table": "a",
873        "where": [],
874        "columns": ["a"]}]]],
875    dnl Check that inserting a pair of rows that mutually weak reference each
876    dnl other is a no-op.
877    [[["gc",
878       {"op": "insert",
879        "table": "a",
880        "row": {"a": 6, "wa2a": ["named-uuid", "row7"]},
881        "uuid-name": "row6"},
882       {"op": "insert",
883        "table": "a",
884        "row": {"a": 7, "wa2a": ["named-uuid", "row6"]},
885        "uuid-name": "row7"}]]],
886    [[["gc",
887       {"op": "select",
888        "table": "a",
889        "where": [],
890        "columns": ["a"]}]]],
891    dnl Check that a circular chain of rows is retained.
892    [[["gc",
893       {"op": "insert",
894        "table": "a",
895        "row": {"a": 8, "a2a": ["named-uuid", "row9"]},
896        "uuid-name": "row8"},
897       {"op": "insert",
898        "table": "a",
899        "row": {"a": 9, "a2a": ["named-uuid", "row10"]},
900        "uuid-name": "row9"},
901       {"op": "insert",
902        "table": "a",
903        "row": {"a": 10, "a2a": ["named-uuid", "row11"]},
904        "uuid-name": "row10"},
905       {"op": "insert",
906        "table": "a",
907        "row": {"a": 11, "a2a": ["named-uuid", "row8"]},
908        "uuid-name": "row11"}]]],
909    [[["gc",
910       {"op": "select",
911        "table": "a",
912        "where": [],
913        "columns": ["a"],
914        "sort": ["a"]}]]],
915    dnl Check that breaking the chain causes all of the rows to be deleted.
916    [[["gc",
917       {"op": "update",
918        "table": "a",
919        "where": [["a", "==", 9]],
920        "row": {"a2a": ["set", []]}}]]],
921    [[["gc",
922       {"op": "select",
923        "table": "a",
924        "where": [],
925        "columns": ["a"]}]]],
926    dnl Check that inserting a row only referenced by itself is a no-op.
927    [[["gc",
928       {"op": "insert",
929        "table": "a",
930        "row": {"a": 12, "a2a": ["named-uuid", "self"]},
931        "uuid-name": "self"}]]],
932    [[["gc",
933       {"op": "select",
934        "table": "a",
935        "where": [],
936        "columns": ["a"]}]]]],
937   [[[{"uuid":["uuid","<0>"]}]
938 [{"rows":[]}]
939 [{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]},{"uuid":["uuid","<4>"]}]
940 [{"rows":[]}]
941 [{"uuid":["uuid","<5>"]},{"uuid":["uuid","<6>"]}]
942 [{"rows":[{"a":4},{"a":5}]}]
943 [{"count":1}]
944 [{"rows":[]}]
945 [{"uuid":["uuid","<7>"]},{"uuid":["uuid","<8>"]}]
946 [{"rows":[]}]
947 [{"uuid":["uuid","<9>"]},{"uuid":["uuid","<10>"]},{"uuid":["uuid","<11>"]},{"uuid":["uuid","<12>"]}]
948 [{"rows":[{"a":8},{"a":9},{"a":10},{"a":11}]}]
949 [{"count":1}]
950 [{"rows":[]}]
951 [{"uuid":["uuid","<13>"]}]
952 [{"rows":[]}]
953 ]])])
954
955 EXECUTION_EXAMPLES