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 AT_CHECK([[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",true]]
147 [["b","delete",false]]
149 [["s","delete",["set",["a","b"]]]]
150 [["u","insert",["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 integers with constraints],
286 [[execute-mutations \
287 '{"columns": {"i": {"type": {"key": {"type": "integer",
289 "maxInteger": 2}}}}}' \
301 row 2: constraint violation: 3 is not in the valid range 0 to 2 (inclusive)
304 row 0: constraint violation: -2 is not in the valid range 0 to 2 (inclusive)
305 row 1: constraint violation: -1 is not in the valid range 0 to 2 (inclusive)
310 row 1: constraint violation: 3 is not in the valid range 0 to 2 (inclusive)
311 row 2: constraint violation: 6 is not in the valid range 0 to 2 (inclusive)
324 OVSDB_CHECK_POSITIVE([executing mutations on reals],
325 [[execute-mutations \
326 '{"columns": {"r": {"type": "real"}}}' \
327 '[[["r", "+=", 0.5]],
355 OVSDB_CHECK_POSITIVE([real overflow detection],
356 [[execute-mutations \
357 '{"columns": {"r": {"type": "real"}}}' \
358 '[[["r", "+=", 1.7976931348623157e+308]],
359 [["r", "-=", 1.7976931348623157e+308]],
365 {"r": 1.7976931348623157e+308},
366 {"r": -1.7976931348623157e+308}']]],
368 row 0: {"r":1.79769313486232e+308}
369 row 1: range error: Result of "+=" operation is out of range.
373 row 0: {"r":-1.79769313486232e+308}
375 row 2: range error: Result of "-=" operation is out of range.
379 row 1: range error: Result of "*=" operation is out of range.
380 row 2: range error: Result of "*=" operation is out of range.
384 row 1: {"r":4.49423283715579e+307}
385 row 2: {"r":-4.49423283715579e+307}
389 row 1: range error: Result of "/=" operation is out of range.
390 row 2: range error: Result of "/=" operation is out of range.
393 row 0: domain error: Division by zero.
394 row 1: domain error: Division by zero.
395 row 2: domain error: Division by zero.
398 OVSDB_CHECK_POSITIVE([executing mutations on reals with constraints],
399 [[execute-mutations \
400 '{"columns": {"r": {"type": {"key": {"type": "real",
402 "maxReal": 1.75}}}}}' \
403 '[[["r", "+=", 0.5]],
417 row 1: constraint violation: -4 is not in the valid range -2.5 to 1.75 (inclusive)
422 row 1: constraint violation: -6.25 is not in the valid range -2.5 to 1.75 (inclusive)
423 row 2: constraint violation: 3.125 is not in the valid range -2.5 to 1.75 (inclusive)
431 OVSDB_CHECK_POSITIVE([executing mutations on integer sets],
432 [[execute-mutations \
433 '{"columns": {"i": {"type": {"key": {"type": "integer",
436 "max": "unlimited"}}}}' \
442 [["i", "insert", ["set", [1]]]],
443 [["i", "insert", ["set", [2, 3]]]],
444 [["i", "delete", ["set", [1]]]],
445 [["i", "delete", ["set", [2, 3]]]]]' \
446 '[{"i": ["set", []]},
448 {"i": ["set", [0, 1]]},
449 {"i": ["set", [0, 1, 2]]}']]],
453 row 2: {"i":["set",[1,2]]}
454 row 3: {"i":["set",[1,2,3]]}
459 row 2: {"i":["set",[-2,-1]]}
460 row 3: {"i":["set",[-2,-1,0]]}
465 row 2: {"i":["set",[0,3]]}
466 row 3: constraint violation: 6 is greater than maximum allowed value 5
471 row 2: constraint violation: Result of "/=" operation contains duplicates.
472 row 3: constraint violation: Result of "/=" operation contains duplicates.
478 row 3: constraint violation: Result of "%=" operation contains duplicates.
482 row 1: {"i":["set",[0,1]]}
487 row 0: {"i":["set",[2,3]]}
488 row 1: {"i":["set",[0,2,3]]}
489 row 2: {"i":["set",[0,1,2,3]]}
490 row 3: {"i":["set",[0,1,2,3]]}
496 row 3: {"i":["set",[0,2]]}
502 row 3: {"i":["set",[0,1]]}
505 OVSDB_CHECK_POSITIVE([executing mutations on real sets],
506 [[execute-mutations \
507 '{"columns": {"r": {"type": {"key": {"type": "real",
509 "min": 0, "max": "unlimited"}}}}' \
510 '[[["r", "+=", 0.5]],
515 [["r", "insert", 1.5]],
516 [["r", "insert", 3]],
517 [["r", "delete", ["set", [1.5, 3.5]]]],
518 [["r", "delete", ["set", [0.5, 1.5, 2.5]]]]]' \
519 '[{"r": ["set", []]},
521 {"r": ["set", [0.5, 1.5]]},
522 {"r": ["set", [0.5, 1.5, 2.5]]}']]],
526 row 2: {"r":["set",[1,2]]}
527 row 3: {"r":["set",[1,2,3]]}
532 row 2: {"r":["set",[-1,0]]}
533 row 3: {"r":["set",[-1,0,1]]}
538 row 2: {"r":["set",[1.25,3.75]]}
539 row 3: constraint violation: 6.25 is greater than maximum allowed value 6
544 row 2: {"r":["set",[0.125,0.375]]}
545 row 3: {"r":["set",[0.125,0.375,0.625]]}
550 row 2: constraint violation: Result of "*=" operation contains duplicates.
551 row 3: constraint violation: Result of "*=" operation contains duplicates.
555 row 1: {"r":["set",[0.5,1.5]]}
561 row 1: {"r":["set",[0.5,3]]}
562 row 2: {"r":["set",[0.5,1.5,3]]}
563 row 3: {"r":["set",[0.5,1.5,2.5,3]]}
569 row 3: {"r":["set",[0.5,2.5]]}
573 row 1: {"r":["set",[]]}
574 row 2: {"r":["set",[]]}
575 row 3: {"r":["set",[]]}
578 OVSDB_CHECK_POSITIVE([executing mutations on boolean sets],
579 [[execute-mutations \
580 '{"columns": {"b": {"type": {"key": "boolean", "min": 0, "max": "unlimited"}}}}' \
581 '[[["b", "insert", ["set", [false]]]],
582 [["b", "insert", ["set", [true]]]],
583 [["b", "insert", ["set", [false, true]]]],
584 [["b", "delete", ["set", [false]]]],
585 [["b", "delete", ["set", [true]]]],
586 [["b", "delete", ["set", [true, false]]]]]' \
587 '[{"b": ["set", []]},
588 {"b": ["set", [false]]},
589 {"b": ["set", [true]]},
590 {"b": ["set", [false, true]]}']]],
594 row 2: {"b":["set",[false,true]]}
599 row 1: {"b":["set",[false,true]]}
604 row 0: {"b":["set",[false,true]]}
605 row 1: {"b":["set",[false,true]]}
606 row 2: {"b":["set",[false,true]]}
611 row 1: {"b":["set",[]]}
618 row 2: {"b":["set",[]]}
623 row 1: {"b":["set",[]]}
624 row 2: {"b":["set",[]]}
625 row 3: {"b":["set",[]]}
628 OVSDB_CHECK_POSITIVE([executing mutations on string sets],
629 [[execute-mutations \
630 '{"columns": {"s": {"type": {"key": "string", "min": 0, "max": "unlimited"}}}}' \
631 '[[["s", "insert", ["set", ["a"]]]],
632 [["s", "insert", ["set", ["b"]]]],
633 [["s", "insert", ["set", ["c", "d"]]]],
634 [["s", "delete", ["set", ["a"]]]],
635 [["s", "delete", ["set", ["b"]]]],
636 [["s", "delete", ["set", ["c", "d"]]]]]' \
637 '[{"s": ["set", []]},
638 {"s": ["set", ["a"]]},
639 {"s": ["set", ["a", "b"]]},
640 {"s": ["set", ["a", "b", "c", "d"]]}']]],
649 row 1: {"s":["set",["a","b"]]}
654 row 0: {"s":["set",["c","d"]]}
655 row 1: {"s":["set",["a","c","d"]]}
656 row 2: {"s":["set",["a","b","c","d"]]}
661 row 1: {"s":["set",[]]}
663 row 3: {"s":["set",["b","c","d"]]}
669 row 3: {"s":["set",["a","c","d"]]}
675 row 3: {"s":["set",["a","b"]]}
678 OVSDB_CHECK_POSITIVE([executing mutations on uuid sets],
679 [[execute-mutations \
680 '{"columns": {"u": {"type": {"key": "uuid", "min": 0, "max": "unlimited"}}}}' \
681 '[[["u", "insert", ["set", [["uuid", "ddd9e79d-7782-414c-8b22-1046c60b6ec2"]]]]],
682 [["u", "insert", ["set", [["uuid", "a60fe7ff-317b-4568-9106-892b37445313"]]]]],
683 [["u", "insert", ["set", [["uuid", "2607d30e-e652-4927-9fec-8bbf1b60c7e9"]]]]],
684 [["u", "delete", ["set", [["uuid", "ddd9e79d-7782-414c-8b22-1046c60b6ec2"]]]]],
685 [["u", "delete", ["set", [["uuid", "a60fe7ff-317b-4568-9106-892b37445313"]]]]],
686 [["u", "delete", ["set", [["uuid", "2607d30e-e652-4927-9fec-8bbf1b60c7e9"]]]]]]' \
687 '[{"u": ["set", []]},
688 {"u": ["set", [["uuid", "ddd9e79d-7782-414c-8b22-1046c60b6ec2"]]]},
689 {"u": ["set", [["uuid", "a60fe7ff-317b-4568-9106-892b37445313"]]]},
690 {"u": ["set", [["uuid", "2607d30e-e652-4927-9fec-8bbf1b60c7e9"]]]}']]],
692 row 0: {"u":["uuid","ddd9e79d-7782-414c-8b22-1046c60b6ec2"]}
694 row 2: {"u":["set",[["uuid","a60fe7ff-317b-4568-9106-892b37445313"],["uuid","ddd9e79d-7782-414c-8b22-1046c60b6ec2"]]]}
695 row 3: {"u":["set",[["uuid","2607d30e-e652-4927-9fec-8bbf1b60c7e9"],["uuid","ddd9e79d-7782-414c-8b22-1046c60b6ec2"]]]}
698 row 0: {"u":["uuid","a60fe7ff-317b-4568-9106-892b37445313"]}
699 row 1: {"u":["set",[["uuid","a60fe7ff-317b-4568-9106-892b37445313"],["uuid","ddd9e79d-7782-414c-8b22-1046c60b6ec2"]]]}
701 row 3: {"u":["set",[["uuid","2607d30e-e652-4927-9fec-8bbf1b60c7e9"],["uuid","a60fe7ff-317b-4568-9106-892b37445313"]]]}
704 row 0: {"u":["uuid","2607d30e-e652-4927-9fec-8bbf1b60c7e9"]}
705 row 1: {"u":["set",[["uuid","2607d30e-e652-4927-9fec-8bbf1b60c7e9"],["uuid","ddd9e79d-7782-414c-8b22-1046c60b6ec2"]]]}
706 row 2: {"u":["set",[["uuid","2607d30e-e652-4927-9fec-8bbf1b60c7e9"],["uuid","a60fe7ff-317b-4568-9106-892b37445313"]]]}
711 row 1: {"u":["set",[]]}
718 row 2: {"u":["set",[]]}
725 row 3: {"u":["set",[]]}
728 OVSDB_CHECK_POSITIVE([executing mutations on integer maps],
729 [[execute-mutations \
730 '{"columns": {"i": {"type": {"key": "integer", "value": "integer", "min": 0, "max": "unlimited"}}}}' \
731 '[[["i", "insert", ["map", [[1, 2]]]]],
732 [["i", "insert", ["map", [[2, 4], [3, 5]]]]],
733 [["i", "delete", ["map", [[1, 2]]]]],
734 [["i", "delete", ["map", [[2, 3]]]]],
735 [["i", "delete", ["set", [1]]]],
736 [["i", "delete", ["set", [2, 3]]]]]' \
737 '[{"i": ["map", []]},
738 {"i": ["map", [[1, 2]]]},
739 {"i": ["map", [[1, 3], [2, 3]]]},
740 {"i": ["map", [[3, 5]]]}']]],
742 row 0: {"i":["map",[[1,2]]]}
745 row 3: {"i":["map",[[1,2],[3,5]]]}
748 row 0: {"i":["map",[[2,4],[3,5]]]}
749 row 1: {"i":["map",[[1,2],[2,4],[3,5]]]}
750 row 2: {"i":["map",[[1,3],[2,3],[3,5]]]}
751 row 3: {"i":["map",[[2,4],[3,5]]]}
755 row 1: {"i":["map",[]]}
762 row 2: {"i":["map",[[1,3]]]}
767 row 1: {"i":["map",[]]}
768 row 2: {"i":["map",[[2,3]]]}
774 row 2: {"i":["map",[[1,3]]]}
775 row 3: {"i":["map",[]]}