1 AT_BANNER([OVSDB -- mutations])
3 OVSDB_CHECK_POSITIVE([null mutation],
5 '{"columns": {"name": {"type": "string"}}}' \
9 OVSDB_CHECK_POSITIVE([mutations on scalars],
12 {"i": {"type": "integer"},
13 "r": {"type": "real"},
14 "b": {"type": "boolean"},
15 "s": {"type": "string"},
16 "u": {"type": "uuid"}}}' \
22 '[["r", "+=", 0.5]]' \
23 '[["r", "-=", 1.5]]' \
24 '[["r", "*=", 2.5]]' \
25 '[["r", "/=", 3.5]]']],
37 AT_SETUP([disallowed mutations on scalars])
38 AT_KEYWORDS([ovsdb negative mutation])
39 OVS_CHECK_LCOV([[test-ovsdb parse-mutations \
41 {"i": {"type": "integer"},
42 "r": {"type": "real"},
43 "b": {"type": "boolean"},
44 "s": {"type": "string"},
45 "u": {"type": "uuid"}}}' \
47 '[["i", "insert", 1]]' \
48 '[["i", "delete", 2]]' \
49 '[["r", "%=", 0.5]]' \
50 '[["r", "insert", 1.5]]' \
51 '[["r", "delete", 2.5]]' \
52 '[["b", "+=", true]]' \
53 '[["b", "-=", false]]' \
54 '[["b", "*=", true]]' \
55 '[["b", "/=", false]]' \
56 '[["b", "%=", true]]' \
57 '[["b", "insert", false]]' \
58 '[["b", "delete", true]]' \
59 '[["s", "+=", "a"]]' \
60 '[["s", "-=", "b"]]' \
61 '[["s", "*=", "c"]]' \
62 '[["s", "/=", "d"]]' \
63 '[["s", "%=", "e"]]' \
64 '[["s", "insert", "f"]]' \
65 '[["s", "delete", "g"]]' \
66 '[["u", "+=", ["uuid", "9179ca6d-6d65-400a-b455-3ad92783a099"]]]' \
67 '[["u", "-=", ["uuid", "9179ca6d-6d65-400a-b455-3ad92783a099"]]]' \
68 '[["u", "*=", ["uuid", "9179ca6d-6d65-400a-b455-3ad92783a099"]]]' \
69 '[["u", "/=", ["uuid", "9179ca6d-6d65-400a-b455-3ad92783a099"]]]' \
70 '[["u", "insert", ["uuid", "9179ca6d-6d65-400a-b455-3ad92783a099"]]]' \
71 '[["u", "delete", ["uuid", "9179ca6d-6d65-400a-b455-3ad92783a099"]]]']],
73 [[test-ovsdb: unknown mutator: No mutator named xxx.
74 test-ovsdb: syntax "["i","insert",1]": syntax error: Type mismatch: "insert" operator may not be applied to column i of type integer.
75 test-ovsdb: syntax "["i","delete",2]": syntax error: Type mismatch: "delete" operator may not be applied to column i of type integer.
76 test-ovsdb: syntax "["r","%=",0.5]": syntax error: Type mismatch: "%=" operator may not be applied to column r of type real.
77 test-ovsdb: syntax "["r","insert",1.5]": syntax error: Type mismatch: "insert" operator may not be applied to column r of type real.
78 test-ovsdb: syntax "["r","delete",2.5]": syntax error: Type mismatch: "delete" operator may not be applied to column r of type real.
79 test-ovsdb: syntax "["b","+=",true]": syntax error: Type mismatch: "+=" operator may not be applied to column b of type boolean.
80 test-ovsdb: syntax "["b","-=",false]": syntax error: Type mismatch: "-=" operator may not be applied to column b of type boolean.
81 test-ovsdb: syntax "["b","*=",true]": syntax error: Type mismatch: "*=" operator may not be applied to column b of type boolean.
82 test-ovsdb: syntax "["b","/=",false]": syntax error: Type mismatch: "/=" operator may not be applied to column b of type boolean.
83 test-ovsdb: syntax "["b","%=",true]": syntax error: Type mismatch: "%=" operator may not be applied to column b of type boolean.
84 test-ovsdb: syntax "["b","insert",false]": syntax error: Type mismatch: "insert" operator may not be applied to column b of type boolean.
85 test-ovsdb: syntax "["b","delete",true]": syntax error: Type mismatch: "delete" operator may not be applied to column b of type boolean.
86 test-ovsdb: syntax "["s","+=","a"]": syntax error: Type mismatch: "+=" operator may not be applied to column s of type string.
87 test-ovsdb: syntax "["s","-=","b"]": syntax error: Type mismatch: "-=" operator may not be applied to column s of type string.
88 test-ovsdb: syntax "["s","*=","c"]": syntax error: Type mismatch: "*=" operator may not be applied to column s of type string.
89 test-ovsdb: syntax "["s","/=","d"]": syntax error: Type mismatch: "/=" operator may not be applied to column s of type string.
90 test-ovsdb: syntax "["s","%=","e"]": syntax error: Type mismatch: "%=" operator may not be applied to column s of type string.
91 test-ovsdb: syntax "["s","insert","f"]": syntax error: Type mismatch: "insert" operator may not be applied to column s of type string.
92 test-ovsdb: syntax "["s","delete","g"]": syntax error: Type mismatch: "delete" operator may not be applied to column s of type string.
93 test-ovsdb: syntax "["u","+=",["uuid","9179ca6d-6d65-400a-b455-3ad92783a099"]]": syntax error: Type mismatch: "+=" operator may not be applied to column u of type uuid.
94 test-ovsdb: syntax "["u","-=",["uuid","9179ca6d-6d65-400a-b455-3ad92783a099"]]": syntax error: Type mismatch: "-=" operator may not be applied to column u of type uuid.
95 test-ovsdb: syntax "["u","*=",["uuid","9179ca6d-6d65-400a-b455-3ad92783a099"]]": syntax error: Type mismatch: "*=" operator may not be applied to column u of type uuid.
96 test-ovsdb: syntax "["u","/=",["uuid","9179ca6d-6d65-400a-b455-3ad92783a099"]]": syntax error: Type mismatch: "/=" operator may not be applied to column u of type uuid.
97 test-ovsdb: syntax "["u","insert",["uuid","9179ca6d-6d65-400a-b455-3ad92783a099"]]": syntax error: Type mismatch: "insert" operator may not be applied to column u of type uuid.
98 test-ovsdb: syntax "["u","delete",["uuid","9179ca6d-6d65-400a-b455-3ad92783a099"]]": syntax error: Type mismatch: "delete" operator may not be applied to column u of type uuid.
102 OVSDB_CHECK_POSITIVE([mutations on sets],
105 {"i": {"type": {"key": "integer", "min": 0, "max": "unlimited"}},
106 "r": {"type": {"key": "real", "min": 0, "max": "unlimited"}},
107 "b": {"type": {"key": "boolean", "min": 0, "max": "unlimited"}},
108 "s": {"type": {"key": "string", "min": 0, "max": "unlimited"}},
109 "u": {"type": {"key": "uuid", "min": 0, "max": "unlimited"}}}}' \
115 '[["i", "insert", ["set", [1, 2]]]]' \
116 '[["i", "delete", ["set", [1, 2, 3]]]]' \
121 '[["r", "insert", ["set", [1, 2]]]]' \
122 '[["r", "delete", ["set", [1, 2, 3]]]]' \
123 '[["b", "insert", ["set", [true]]]]' \
124 '[["b", "delete", ["set", [false]]]]' \
125 '[["s", "insert", ["set", ["a"]]]]' \
126 '[["s", "delete", ["set", ["a", "b"]]]]' \
128 ["set", [["uuid", "b10d28f7-af18-4a67-9e78-2a6394516c59"]]]]]' \
130 ["set", [["uuid", "b10d28f7-af18-4a67-9e78-2a6394516c59"],
131 ["uuid", "9179ca6d-6d65-400a-b455-3ad92783a099"]]]]]' \
138 [["i","insert",["set",[1,2]]]]
139 [["i","delete",["set",[1,2,3]]]]
144 [["r","insert",["set",[1,2]]]]
145 [["r","delete",["set",[1,2,3]]]]
146 [["b","insert",["set",[true]]]]
147 [["b","delete",["set",[false]]]]
148 [["s","insert",["set",["a"]]]]
149 [["s","delete",["set",["a","b"]]]]
150 [["u","insert",["set",[["uuid","b10d28f7-af18-4a67-9e78-2a6394516c59"]]]]]
151 [["u","delete",["set",[["uuid","9179ca6d-6d65-400a-b455-3ad92783a099"],["uuid","b10d28f7-af18-4a67-9e78-2a6394516c59"]]]]]]],
154 OVSDB_CHECK_POSITIVE([executing null mutation],
155 [[execute-mutations \
156 '{"columns": {"i": {"type": "integer"}}}' \
167 OVSDB_CHECK_POSITIVE([executing mutations on integers],
168 [[execute-mutations \
169 '{"columns": {"i": {"type": "integer"}}}' \
204 OVSDB_CHECK_POSITIVE([integer overflow detection],
205 [[execute-mutations \
206 '{"columns": {"i": {"type": "integer"}}}' \
207 '[[["i", "+=", 9223372036854775807]],
208 [["i", "+=", -9223372036854775808]],
209 [["i", "-=", -9223372036854775808]],
210 [["i", "-=", 9223372036854775807]],
211 [["i", "*=", 3037000500]],
217 {"i": 9223372036854775807},
218 {"i": -9223372036854775808},
220 {"i": -3037000500}']]],
222 row 0: {"i":9223372036854775807}
223 row 1: range error: Result of "+=" operation is out of range.
224 row 2: {"i":9223372036854775806}
225 row 3: range error: Result of "+=" operation is out of range.
227 row 5: range error: Result of "+=" operation is out of range.
228 row 6: {"i":9223372033817775307}
231 row 0: {"i":-9223372036854775808}
232 row 1: {"i":-9223372036854775807}
233 row 2: range error: Result of "+=" operation is out of range.
235 row 4: range error: Result of "+=" operation is out of range.
236 row 5: {"i":-9223372033817775308}
237 row 6: range error: Result of "+=" operation is out of range.
240 row 0: range error: Result of "-=" operation is out of range.
241 row 1: range error: Result of "-=" operation is out of range.
242 row 2: {"i":9223372036854775807}
243 row 3: range error: Result of "-=" operation is out of range.
245 row 5: range error: Result of "-=" operation is out of range.
246 row 6: {"i":9223372033817775308}
249 row 0: {"i":-9223372036854775807}
250 row 1: {"i":-9223372036854775806}
251 row 2: {"i":-9223372036854775808}
253 row 4: range error: Result of "-=" operation is out of range.
254 row 5: {"i":-9223372033817775307}
255 row 6: range error: Result of "-=" operation is out of range.
259 row 1: {"i":3037000500}
260 row 2: {"i":-3037000500}
261 row 3: range error: Result of "*=" operation is out of range.
262 row 4: range error: Result of "*=" operation is out of range.
263 row 5: range error: Result of "*=" operation is out of range.
264 row 6: range error: Result of "*=" operation is out of range.
270 row 3: {"i":-9223372036854775807}
271 row 4: range error: Result of "/=" operation is out of range.
272 row 5: {"i":-3037000500}
273 row 6: {"i":3037000500}
276 row 0: domain error: Division by zero.
277 row 1: domain error: Division by zero.
278 row 2: domain error: Division by zero.
279 row 3: domain error: Division by zero.
280 row 4: domain error: Division by zero.
281 row 5: domain error: Division by zero.
282 row 6: domain error: Division by zero.
285 OVSDB_CHECK_POSITIVE([executing mutations on reals],
286 [[execute-mutations \
287 '{"columns": {"r": {"type": "real"}}}' \
288 '[[["r", "+=", 0.5]],
316 OVSDB_CHECK_POSITIVE([real overflow detection],
317 [[execute-mutations \
318 '{"columns": {"r": {"type": "real"}}}' \
319 '[[["r", "+=", 1.7976931348623157e+308]],
320 [["r", "-=", 1.7976931348623157e+308]],
326 {"r": 1.7976931348623157e+308},
327 {"r": -1.7976931348623157e+308}']]],
329 row 0: {"r":1.79769313486232e+308}
330 row 1: range error: Result of "+=" operation is out of range.
334 row 0: {"r":-1.79769313486232e+308}
336 row 2: range error: Result of "-=" operation is out of range.
340 row 1: range error: Result of "*=" operation is out of range.
341 row 2: range error: Result of "*=" operation is out of range.
345 row 1: {"r":4.49423283715579e+307}
346 row 2: {"r":-4.49423283715579e+307}
350 row 1: range error: Result of "/=" operation is out of range.
351 row 2: range error: Result of "/=" operation is out of range.
354 row 0: domain error: Division by zero.
355 row 1: domain error: Division by zero.
356 row 2: domain error: Division by zero.
359 OVSDB_CHECK_POSITIVE([executing mutations on integer sets],
360 [[execute-mutations \
361 '{"columns": {"i": {"type": {"key": "integer", "min": 0, "max": "unlimited"}}}}' \
367 [["i", "insert", ["set", [1]]]],
368 [["i", "insert", ["set", [2, 3]]]],
369 [["i", "delete", ["set", [1]]]],
370 [["i", "delete", ["set", [2, 3]]]]]' \
371 '[{"i": ["set", []]},
373 {"i": ["set", [0, 1]]},
374 {"i": ["set", [0, 1, 2]]}']]],
377 row 1: {"i":["set",[1]]}
378 row 2: {"i":["set",[1,2]]}
379 row 3: {"i":["set",[1,2,3]]}
383 row 1: {"i":["set",[-2]]}
384 row 2: {"i":["set",[-2,-1]]}
385 row 3: {"i":["set",[-2,-1,0]]}
390 row 2: {"i":["set",[0,3]]}
391 row 3: {"i":["set",[0,3,6]]}
396 row 2: constraint violation: Result of "/=" operation contains duplicates.
397 row 3: constraint violation: Result of "/=" operation contains duplicates.
403 row 3: constraint violation: Result of "%=" operation contains duplicates.
406 row 0: {"i":["set",[1]]}
407 row 1: {"i":["set",[0,1]]}
412 row 0: {"i":["set",[2,3]]}
413 row 1: {"i":["set",[0,2,3]]}
414 row 2: {"i":["set",[0,1,2,3]]}
415 row 3: {"i":["set",[0,1,2,3]]}
420 row 2: {"i":["set",[0]]}
421 row 3: {"i":["set",[0,2]]}
427 row 3: {"i":["set",[0,1]]}
430 OVSDB_CHECK_POSITIVE([executing mutations on real sets],
431 [[execute-mutations \
432 '{"columns": {"r": {"type": {"key": "real", "min": 0, "max": "unlimited"}}}}' \
433 '[[["r", "+=", 0.5]],
438 [["r", "insert", ["set", [1.5]]]],
439 [["r", "insert", ["set", [3]]]],
440 [["r", "delete", ["set", [1.5, 3.5]]]],
441 [["r", "delete", ["set", [0.5, 1.5, 2.5]]]]]' \
442 '[{"r": ["set", []]},
443 {"r": ["set", [0.5]]},
444 {"r": ["set", [0.5, 1.5]]},
445 {"r": ["set", [0.5, 1.5, 2.5]]}']]],
448 row 1: {"r":["set",[1]]}
449 row 2: {"r":["set",[1,2]]}
450 row 3: {"r":["set",[1,2,3]]}
454 row 1: {"r":["set",[-1]]}
455 row 2: {"r":["set",[-1,0]]}
456 row 3: {"r":["set",[-1,0,1]]}
460 row 1: {"r":["set",[1.25]]}
461 row 2: {"r":["set",[1.25,3.75]]}
462 row 3: {"r":["set",[1.25,3.75,6.25]]}
466 row 1: {"r":["set",[0.125]]}
467 row 2: {"r":["set",[0.125,0.375]]}
468 row 3: {"r":["set",[0.125,0.375,0.625]]}
472 row 1: {"r":["set",[0]]}
473 row 2: constraint violation: Result of "*=" operation contains duplicates.
474 row 3: constraint violation: Result of "*=" operation contains duplicates.
477 row 0: {"r":["set",[1.5]]}
478 row 1: {"r":["set",[0.5,1.5]]}
483 row 0: {"r":["set",[3]]}
484 row 1: {"r":["set",[0.5,3]]}
485 row 2: {"r":["set",[0.5,1.5,3]]}
486 row 3: {"r":["set",[0.5,1.5,2.5,3]]}
491 row 2: {"r":["set",[0.5]]}
492 row 3: {"r":["set",[0.5,2.5]]}
496 row 1: {"r":["set",[]]}
497 row 2: {"r":["set",[]]}
498 row 3: {"r":["set",[]]}
501 OVSDB_CHECK_POSITIVE([executing mutations on boolean sets],
502 [[execute-mutations \
503 '{"columns": {"b": {"type": {"key": "boolean", "min": 0, "max": "unlimited"}}}}' \
504 '[[["b", "insert", ["set", [false]]]],
505 [["b", "insert", ["set", [true]]]],
506 [["b", "insert", ["set", [false, true]]]],
507 [["b", "delete", ["set", [false]]]],
508 [["b", "delete", ["set", [true]]]],
509 [["b", "delete", ["set", [true, false]]]]]' \
510 '[{"b": ["set", []]},
511 {"b": ["set", [false]]},
512 {"b": ["set", [true]]},
513 {"b": ["set", [false, true]]}']]],
515 row 0: {"b":["set",[false]]}
517 row 2: {"b":["set",[false,true]]}
521 row 0: {"b":["set",[true]]}
522 row 1: {"b":["set",[false,true]]}
527 row 0: {"b":["set",[false,true]]}
528 row 1: {"b":["set",[false,true]]}
529 row 2: {"b":["set",[false,true]]}
534 row 1: {"b":["set",[]]}
536 row 3: {"b":["set",[true]]}
541 row 2: {"b":["set",[]]}
542 row 3: {"b":["set",[false]]}
546 row 1: {"b":["set",[]]}
547 row 2: {"b":["set",[]]}
548 row 3: {"b":["set",[]]}
551 OVSDB_CHECK_POSITIVE([executing mutations on string sets],
552 [[execute-mutations \
553 '{"columns": {"s": {"type": {"key": "string", "min": 0, "max": "unlimited"}}}}' \
554 '[[["s", "insert", ["set", ["a"]]]],
555 [["s", "insert", ["set", ["b"]]]],
556 [["s", "insert", ["set", ["c", "d"]]]],
557 [["s", "delete", ["set", ["a"]]]],
558 [["s", "delete", ["set", ["b"]]]],
559 [["s", "delete", ["set", ["c", "d"]]]]]' \
560 '[{"s": ["set", []]},
561 {"s": ["set", ["a"]]},
562 {"s": ["set", ["a", "b"]]},
563 {"s": ["set", ["a", "b", "c", "d"]]}']]],
565 row 0: {"s":["set",["a"]]}
571 row 0: {"s":["set",["b"]]}
572 row 1: {"s":["set",["a","b"]]}
577 row 0: {"s":["set",["c","d"]]}
578 row 1: {"s":["set",["a","c","d"]]}
579 row 2: {"s":["set",["a","b","c","d"]]}
584 row 1: {"s":["set",[]]}
585 row 2: {"s":["set",["b"]]}
586 row 3: {"s":["set",["b","c","d"]]}
591 row 2: {"s":["set",["a"]]}
592 row 3: {"s":["set",["a","c","d"]]}
598 row 3: {"s":["set",["a","b"]]}
601 OVSDB_CHECK_POSITIVE([executing mutations on uuid sets],
602 [[execute-mutations \
603 '{"columns": {"u": {"type": {"key": "uuid", "min": 0, "max": "unlimited"}}}}' \
604 '[[["u", "insert", ["set", [["uuid", "ddd9e79d-7782-414c-8b22-1046c60b6ec2"]]]]],
605 [["u", "insert", ["set", [["uuid", "a60fe7ff-317b-4568-9106-892b37445313"]]]]],
606 [["u", "insert", ["set", [["uuid", "2607d30e-e652-4927-9fec-8bbf1b60c7e9"]]]]],
607 [["u", "delete", ["set", [["uuid", "ddd9e79d-7782-414c-8b22-1046c60b6ec2"]]]]],
608 [["u", "delete", ["set", [["uuid", "a60fe7ff-317b-4568-9106-892b37445313"]]]]],
609 [["u", "delete", ["set", [["uuid", "2607d30e-e652-4927-9fec-8bbf1b60c7e9"]]]]]]' \
610 '[{"u": ["set", []]},
611 {"u": ["set", [["uuid", "ddd9e79d-7782-414c-8b22-1046c60b6ec2"]]]},
612 {"u": ["set", [["uuid", "a60fe7ff-317b-4568-9106-892b37445313"]]]},
613 {"u": ["set", [["uuid", "2607d30e-e652-4927-9fec-8bbf1b60c7e9"]]]}']]],
615 row 0: {"u":["set",[["uuid","ddd9e79d-7782-414c-8b22-1046c60b6ec2"]]]}
617 row 2: {"u":["set",[["uuid","a60fe7ff-317b-4568-9106-892b37445313"],["uuid","ddd9e79d-7782-414c-8b22-1046c60b6ec2"]]]}
618 row 3: {"u":["set",[["uuid","2607d30e-e652-4927-9fec-8bbf1b60c7e9"],["uuid","ddd9e79d-7782-414c-8b22-1046c60b6ec2"]]]}
621 row 0: {"u":["set",[["uuid","a60fe7ff-317b-4568-9106-892b37445313"]]]}
622 row 1: {"u":["set",[["uuid","a60fe7ff-317b-4568-9106-892b37445313"],["uuid","ddd9e79d-7782-414c-8b22-1046c60b6ec2"]]]}
624 row 3: {"u":["set",[["uuid","2607d30e-e652-4927-9fec-8bbf1b60c7e9"],["uuid","a60fe7ff-317b-4568-9106-892b37445313"]]]}
627 row 0: {"u":["set",[["uuid","2607d30e-e652-4927-9fec-8bbf1b60c7e9"]]]}
628 row 1: {"u":["set",[["uuid","2607d30e-e652-4927-9fec-8bbf1b60c7e9"],["uuid","ddd9e79d-7782-414c-8b22-1046c60b6ec2"]]]}
629 row 2: {"u":["set",[["uuid","2607d30e-e652-4927-9fec-8bbf1b60c7e9"],["uuid","a60fe7ff-317b-4568-9106-892b37445313"]]]}
634 row 1: {"u":["set",[]]}
641 row 2: {"u":["set",[]]}
648 row 3: {"u":["set",[]]}
652 OVSDB_CHECK_POSITIVE([executing mutations on integer maps],
653 [[execute-mutations \
654 '{"columns": {"i": {"type": {"key": "integer", "value": "integer", "min": 0, "max": "unlimited"}}}}' \
655 '[[["i", "insert", ["map", [[1, 2]]]]],
656 [["i", "insert", ["map", [[2, 4], [3, 5]]]]],
657 [["i", "delete", ["map", [[1, 2]]]]],
658 [["i", "delete", ["map", [[2, 3]]]]],
659 [["i", "delete", ["set", [1]]]],
660 [["i", "delete", ["set", [2, 3]]]]]' \
661 '[{"i": ["map", []]},
662 {"i": ["map", [[1, 2]]]},
663 {"i": ["map", [[1, 3], [2, 3]]]},
664 {"i": ["map", [[3, 5]]]}']]],
666 row 0: {"i":["map",[[1,2]]]}
669 row 3: {"i":["map",[[1,2],[3,5]]]}
672 row 0: {"i":["map",[[2,4],[3,5]]]}
673 row 1: {"i":["map",[[1,2],[2,4],[3,5]]]}
674 row 2: {"i":["map",[[1,3],[2,3],[3,5]]]}
675 row 3: {"i":["map",[[2,4],[3,5]]]}
679 row 1: {"i":["map",[]]}
686 row 2: {"i":["map",[[1,3]]]}
691 row 1: {"i":["map",[]]}
692 row 2: {"i":["map",[[2,3]]]}
698 row 2: {"i":["map",[[1,3]]]}
699 row 3: {"i":["map",[]]}