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