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