Initial implementation of OVSDB.
[cascardo/ovs.git] / tests / ovsdb-row.at
1 AT_BANNER([OVSDB -- rows])
2
3 # Autoconf 2.63 has a bug that causes the double-quotes below to be
4 # lost, so that the following tests fail, so we mark them as XFAIL for
5 # Autoconf < 2.64.
6
7 m4_define([RESERVED_COLUMNS], [["_uuid":["uuid","00000000-0000-0000-0000-000000000000"],"_version":["uuid","00000000-0000-0000-0000-000000000000"]]])
8
9 OVSDB_CHECK_POSITIVE([row with one string column],
10   [[parse-rows \
11     '{"columns": {"name": {"type": "string"}}}' \
12     '{"name": "value"}' \
13     '{"name": ""}' \
14     '{"name": "longer string with spaces"}' \
15     '{}']],
16   [{RESERVED_COLUMNS,"name":"value"}
17 name
18 {RESERVED_COLUMNS,"name":""}
19 name
20 {RESERVED_COLUMNS,"name":"longer string with spaces"}
21 name
22 {RESERVED_COLUMNS,"name":""}
23 <none>], [], [2.64])
24
25 OVSDB_CHECK_POSITIVE([row with one integer column],
26   [[parse-rows \
27     '{"columns": {"count": {"type": "integer"}}}' \
28     '{"count": 1}' \
29     '{"count": -1}' \
30     '{"count": 2e10}' \
31     '{}']],
32   [{RESERVED_COLUMNS,"count":1}
33 count
34 {RESERVED_COLUMNS,"count":-1}
35 count
36 {RESERVED_COLUMNS,"count":20000000000}
37 count
38 {RESERVED_COLUMNS,"count":0}
39 <none>], [], [2.64])
40
41 OVSDB_CHECK_POSITIVE([row with one real column],
42   [[parse-rows \
43     '{"columns": {"cost": {"type": "real"}}}' \
44     '{"cost": 1.0}' \
45     '{"cost": -2.0}' \
46     '{"cost": 123000}' \
47     '{}']],
48   [{RESERVED_COLUMNS,"cost":1}
49 cost
50 {RESERVED_COLUMNS,"cost":-2}
51 cost
52 {RESERVED_COLUMNS,"cost":123000}
53 cost
54 {RESERVED_COLUMNS,"cost":0}
55 <none>], [], [2.64])
56
57 OVSDB_CHECK_POSITIVE([row with one boolean column],
58   [[parse-rows \
59     '{"columns": {"feasible": {"type": "boolean"}}}' \
60     '{"feasible": true}' \
61     '{"feasible": false}' \
62     '{}']],
63   [{RESERVED_COLUMNS,"feasible":true}
64 feasible
65 {RESERVED_COLUMNS,"feasible":false}
66 feasible
67 {RESERVED_COLUMNS,"feasible":false}
68 <none>], [], [2.64])
69
70 OVSDB_CHECK_POSITIVE([row with one uuid column],
71   [[parse-rows \
72     '{"columns": {"ref": {"type": "uuid"}}}' \
73     '{"ref": ["uuid", "f707423d-bf5b-48b5-b6c0-797c900ba4b6"]}' \
74     '{"ref": ["uuid", "33583cc5-d2f4-43de-b1ca-8aac14071b51"]}' \
75     '{}']],
76   [{RESERVED_COLUMNS,"ref":[["uuid","f707423d-bf5b-48b5-b6c0-797c900ba4b6"]]}
77 ref
78 {RESERVED_COLUMNS,"ref":[["uuid","33583cc5-d2f4-43de-b1ca-8aac14071b51"]]}
79 ref
80 {RESERVED_COLUMNS,"ref":[["uuid","00000000-0000-0000-0000-000000000000"]]}
81 <none>], [], [2.64])
82
83 OVSDB_CHECK_POSITIVE([row with set of 1 to 2 elements],
84   [[parse-rows \
85     '{"columns": {"myset": {"type": {"key": "integer", "min": 1, "max": 2}}}}' \
86     '{}']],
87   [{RESERVED_COLUMNS,["myset":["set",[0]]]}
88 <none>])
89
90 OVSDB_CHECK_POSITIVE([row with map of 1 to 2 elements],
91   [[parse-rows \
92     '{"columns": {"mymap": {"type": {"key": "integer", "value": "uuid", "min": 1, "max": 2}}}}' \
93     '{}']],
94   [{RESERVED_COLUMNS,["mymap":["map",[[0,["uuid","00000000-0000-0000-0000-000000000000"]]]]]}
95 <none>], [], [2.64])
96
97 OVSDB_CHECK_POSITIVE([row with several columns],
98   [[parse-rows \
99     '{"columns":
100         {"vswitch": {"type": "uuid"},
101          "name": {"type": "string"},
102          "datapath_id": {"type": {"key": "string", "min": 0}},
103          "hwaddr": {"type": "string"},
104          "mirrors": {"type": {"key": "uuid", "min": 0, "max": "unlimited"}},
105          "netflows": {"type": {"key": "uuid", "min": 0, "max": "unlimited"}},
106          "controller": {"type": {"key": "uuid", "min": 0}},
107          "listeners": {"type": {"key": "uuid", "min": 0, "max": "unlimited"}},
108          "snoops": {"type": {"key": "uuid", "min": 0, "max": "unlimited"}}}}' \
109     '{"vswitch": ["uuid", "1a5c7280-0d4c-4e34-9ec7-c772339f7774"],
110       "name": "br0",
111       "datapath_id": ["set", ["000ae4256bb0"]],
112       "hwaddr": "00:0a:e4:25:6b:b0"}' \
113     '{}']],
114  [{RESERVED_COLUMNS,["controller":["set",[]],"datapath_id":["set",["000ae4256bb0"]],"hwaddr":"00:0a:e4:25:6b:b0","listeners":["set",[]],"mirrors":["set",[]],"name":"br0","netflows":["set",[]],"snoops":["set",[]],"vswitch":["uuid","1a5c7280-0d4c-4e34-9ec7-c772339f7774"]]}
115 datapath_id, hwaddr, name, vswitch
116 {RESERVED_COLUMNS,["controller":["set",[]],"datapath_id":["set",[]],"hwaddr":"","listeners":["set",[]],"mirrors":["set",[]],"name":"","netflows":["set",[]],"snoops":["set",[]],"vswitch":["uuid","00000000-0000-0000-0000-000000000000"]]}
117 <none>], [], [2.64])
118
119 OVSDB_CHECK_POSITIVE([row hashing (scalars)],
120   [[compare-rows \
121     '{"columns":
122         {"i": {"type": "integer"},
123          "r": {"type": "real"},
124          "b": {"type": "boolean"},
125          "s": {"type": "string"},
126          "u": {"type": "uuid"}}}' \
127      '["null", {}]' \
128      '["i1", {"i": 1}]' \
129      '["i2", {"i": 2}]' \
130      '["i4", {"i": 4}]' \
131      '["i8", {"i": 8}]' \
132      '["i16", {"i": 16}]' \
133      '["i32", {"i": 32}]' \
134      '["i64", {"i": 64}]' \
135      '["i128", {"i": 128}]' \
136      '["i256", {"i": 256}]' \
137      '["null2", {"r": -0}]' \
138      '["r123", {"r": 123}]' \
139      '["r0.0625", {"r": 0.0625}]' \
140      '["r0.125", {"r": 0.125}]' \
141      '["r0.25", {"r": 0.25}]' \
142      '["r0.5", {"r": 0.5}]' \
143      '["r1", {"r": 1}]' \
144      '["r2", {"r": 2}]' \
145      '["r4", {"r": 4}]' \
146      '["r8", {"r": 8}]' \
147      '["r16", {"r": 16}]' \
148      '["r32", {"r": 32}]' \
149      '["null3", {"b": false}]' \
150      '["b1", {"b": true}]' \
151      '["null4", {"s": ""}]' \
152      '["s0", {"s": "a"}]' \
153      '["s1", {"s": "b"}]' \
154      '["s2", {"s": "c"}]' \
155      '["s3", {"s": "d"}]' \
156      '["s4", {"s": "e"}]' \
157      '["s5", {"s": "f"}]' \
158      '["s6", {"s": "g"}]' \
159      '["s7", {"s": "h"}]' \
160      '["s8", {"s": "i"}]' \
161      '["s9", {"s": "j"}]' \
162      '["null5", {"u": ["uuid","00000000-0000-0000-0000-000000000000"]}]' \
163      '["u1", {"u": ["uuid","10000000-0000-0000-0000-000000000000"]}]' \
164      '["u2", {"u": ["uuid","01000000-0000-0000-0000-000000000000"]}]' \
165      '["u3", {"u": ["uuid","00100000-0000-0000-0000-000000000000"]}]' \
166      '["u4", {"u": ["uuid","00010000-0000-0000-0000-000000000000"]}]' \
167      '["u5", {"u": ["uuid","00001000-0000-0000-0000-000000000000"]}]' \
168      '["u6", {"u": ["uuid","00000100-0000-0000-0000-000000000000"]}]' \
169      '["u7", {"u": ["uuid","00000010-0000-0000-0000-000000000000"]}]' \
170      '["u8", {"u": ["uuid","00000001-0000-0000-0000-000000000000"]}]' \
171      '["null6", {"u": ["uuid","00000000-c6db-4d22-970f-b41fabd20c4b"]}]']],
172   [[null == null2
173 null == null3
174 null == null4
175 null == null5
176 hash(null) == hash(null6)
177 null2 == null3
178 null2 == null4
179 null2 == null5
180 hash(null2) == hash(null6)
181 null3 == null4
182 null3 == null5
183 hash(null3) == hash(null6)
184 null4 == null5
185 hash(null4) == hash(null6)
186 hash(null5) == hash(null6)]])
187
188 OVSDB_CHECK_POSITIVE([row hashing (sets)],
189   [[compare-rows \
190     '{"columns":
191         {"i": {"type": {"key": "integer", "min": 0, "max": "unlimited"}},
192          "r": {"type": {"key": "real", "min": 0, "max": "unlimited"}},
193          "b": {"type": {"key": "boolean", "min": 0, "max": "unlimited"}},
194          "s": {"type": {"key": "string", "min": 0, "max": "unlimited"}},
195          "u": {"type": {"key": "uuid", "min": 0, "max": "unlimited"}}}}' \
196     '["null0", {"i": ["set", []]}]' \
197     '["i0", {"i": ["set", [0]]}]' \
198     '["i01", {"i": ["set", [0, 1]]}]' \
199     '["i012", {"i": ["set", [0, 1, 2]]}]' \
200     '["i021", {"i": ["set", [0, 2, 1]]}]' \
201     '["i201", {"i": ["set", [2, 0, 1]]}]' \
202     '["i102", {"i": ["set", [1, 0, 2]]}]' \
203     '["i120", {"i": ["set", [1, 2, 0]]}]' \
204     '["i210", {"i": ["set", [2, 1, 0]]}]' \
205     '["r0", {"r": ["set", [0]]}]' \
206     '["r01", {"r": ["set", [0, 1]]}]' \
207     '["r012", {"r": ["set", [0, 1, 2]]}]' \
208     '["r201", {"r": ["set", [2, 0, 1]]}]' \
209     '["null1", {"b": ["set", []]}]' \
210     '["b0", {"b": ["set", [false]]}]' \
211     '["b1", {"b": ["set", [true]]}]' \
212     '["b01", {"b": ["set", [false, true]]}]' \
213     '["b10", {"b": ["set", [true, false]]}]' \
214     '["null2", {"s": ["set", []]}]' \
215     '["sa", {"s": ["set", ["a"]]}]' \
216     '["sb", {"s": ["set", ["b"]]}]' \
217     '["sab", {"s": ["set", ["a", "b"]]}]' \
218     '["sba", {"s": ["set", ["b", "a"]]}]']],
219   [[null0 == null1
220 null0 == null2
221 i012 == i021
222 i012 == i201
223 i012 == i102
224 i012 == i120
225 i012 == i210
226 i021 == i201
227 i021 == i102
228 i021 == i120
229 i021 == i210
230 i201 == i102
231 i201 == i120
232 i201 == i210
233 i102 == i120
234 i102 == i210
235 i120 == i210
236 r012 == r201
237 null1 == null2
238 b01 == b10
239 sab == sba]])
240
241 OVSDB_CHECK_POSITIVE([row hashing (maps)],
242   [[compare-rows \
243     '{"columns":
244         {"ii": {"type": {"key": "integer", "value": "integer", 
245                          "min": 0, "max": "unlimited"}},
246          "rr": {"type": {"key": "real", "value": "real",
247                          "min": 0, "max": "unlimited"}},
248          "bb": {"type": {"key": "boolean", "value": "boolean",
249                          "min": 0, "max": "unlimited"}},
250          "ss": {"type": {"key": "string", "value": "string",
251                          "min": 0, "max": "unlimited"}}}}' \
252     '["null", {}]' \
253     '["ii0", {"ii": ["map", [[0, 0]]]}]' \
254     '["ii1", {"ii": ["map", [[0, 1]]]}]' \
255     '["ii00", {"ii": ["map", [[0, 0], [1, 0]]]}]' \
256     '["ii01", {"ii": ["map", [[0, 0], [1, 1]]]}]' \
257     '["ii10", {"ii": ["map", [[0, 1], [1, 0]]]}]' \
258     '["ii11", {"ii": ["map", [[0, 1], [1, 1]]]}]' \
259     '["rr0", {"rr": ["map", [[0, 0]]]}]' \
260     '["rr0", {"rr": ["map", [[0, 1]]]}]' \
261     '["rr00", {"rr": ["map", [[0, 0], [1, 0]]]}]' \
262     '["rr01", {"rr": ["map", [[0, 0], [1, 1]]]}]' \
263     '["rr10", {"rr": ["map", [[0, 1], [1, 0]]]}]' \
264     '["rr11", {"rr": ["map", [[0, 1], [1, 1]]]}]' \
265     '["bb0", {"bb": ["map", [[false, false]]]}]' \
266     '["bb1", {"bb": ["map", [[false, true]]]}]' \
267     '["bb00", {"bb": ["map", [[false, false], [true, false]]]}]' \
268     '["bb01", {"bb": ["map", [[false, false], [true, true]]]}]' \
269     '["bb10", {"bb": ["map", [[false, true], [true, false]]]}]' \
270     '["bb11", {"bb": ["map", [[false, true], [true, true]]]}]' \
271     '["ss0", {"ss": ["map", [["a", "a"]]]}]' \
272     '["ss1", {"ss": ["map", [["a", "b"]]]}]' \
273     '["ss00", {"ss": ["map", [["a", "a"], ["b", "a"]]]}]' \
274     '["ss01", {"ss": ["map", [["a", "a"], ["b", "b"]]]}]' \
275     '["ss10", {"ss": ["map", [["a", "b"], ["b", "a"]]]}]' \
276     '["ss11", {"ss": ["map", [["a", "b"], ["b", "b"]]]}]'; echo
277 ]], [[]])