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