]> git.proxmox.com Git - ovs.git/blame - tests/ovsdb-data.at
ovs-vsctl: Add --if-exists option to "get" command, for map columns.
[ovs.git] / tests / ovsdb-data.at
CommitLineData
f85f8ebb
BP
1AT_BANNER([OVSDB -- atoms])
2
3OVSDB_CHECK_POSITIVE([integer atom],
4 [[parse-atoms '["integer"]' \
5 '[0]' \
6 '[-1]' \
7 '[1e3]' \
8 '[9223372036854775807]' \
9 '[-9223372036854775808]' ]],
10 [0
11-1
121000
139223372036854775807
14-9223372036854775808])
15
16OVSDB_CHECK_POSITIVE([real atom],
17 [[parse-atoms '["real"]' \
18 '[0]' \
19 '[0.0]' \
20 '[-0.0]' \
21 '[-1.25]' \
22 '[1e3]' \
23 '[1e37]' \
24 '[0.00390625]' ]],
25 [0
260
270
28-1.25
291000
301e+37
310.00390625])
32
33OVSDB_CHECK_POSITIVE([boolean atom],
34 [[parse-atoms '["boolean"]' '[true]' '[false]' ]],
35 [true
36false])
37
38OVSDB_CHECK_POSITIVE([string atom],
39 [[parse-atoms '["string"]' '[""]' '["true"]' '["\"\\\/\b\f\n\r\t"]']],
40 [""
41"true"
42"\"\\/\b\f\n\r\t"])
43
44OVSDB_CHECK_POSITIVE([uuid atom],
45 [[parse-atoms '["uuid"]' '["uuid", "550e8400-e29b-41d4-a716-446655440000"]']],
46 [[["uuid","550e8400-e29b-41d4-a716-446655440000"]]])
47
48OVSDB_CHECK_POSITIVE([integer atom sorting],
49 [[sort-atoms '["integer"]' '[55,0,-1,2,1]']],
50 [[[-1,0,1,2,55]]])
51
52OVSDB_CHECK_POSITIVE([real atom sorting],
53 [[sort-atoms '["real"]' '[1.25,1.23,0.0,-0.0,-1e99]']],
54 [[[-1e+99,0,0,1.23,1.25]]])
55
56OVSDB_CHECK_POSITIVE([boolean atom sorting],
57 [[sort-atoms '["boolean"]' '[true,false,true,false,false]']],
58 [[[false,false,false,true,true]]])
59
60OVSDB_CHECK_POSITIVE([string atom sorting],
61 [[sort-atoms '["string"]' '["abd","abc","\b","xxx"]']],
62 [[["\b","abc","abd","xxx"]]])
63
64OVSDB_CHECK_POSITIVE([uuid atom sorting],
65 [[sort-atoms '["uuid"]' '[
66 ["uuid", "00000000-0000-0000-0000-000000000001"],
67 ["uuid", "00000000-1000-0000-0000-000000000000"],
68 ["uuid", "00000000-0000-1000-0000-000000000000"],
69 ["uuid", "00010000-0000-0000-0000-000000000000"],
70 ["uuid", "00000000-0000-0000-0000-000000000100"],
71 ["uuid", "00000000-0000-0000-0000-000100000000"],
72 ["uuid", "00000000-0000-0010-0000-000000000000"],
73 ["uuid", "00000100-0000-0000-0000-000000000000"],
74 ["uuid", "00000000-0000-0001-0000-000000000000"],
75 ["uuid", "00000000-0000-0000-0000-000001000000"],
76 ["uuid", "01000000-0000-0000-0000-000000000000"],
77 ["uuid", "00000000-0000-0000-0000-000000001000"],
78 ["uuid", "00000000-0000-0000-0000-000010000000"],
79 ["uuid", "00000000-0000-0000-0000-010000000000"],
80 ["uuid", "00000000-0000-0100-0000-000000000000"],
81 ["uuid", "10000000-0000-0000-0000-000000000000"],
82 ["uuid", "00000000-0000-0000-0000-000000000010"],
83 ["uuid", "00000000-0100-0000-0000-000000000000"],
84 ["uuid", "00000000-0000-0000-0100-000000000000"],
85 ["uuid", "00000000-0000-0000-0001-000000000000"],
86 ["uuid", "00000010-0000-0000-0000-000000000000"],
87 ["uuid", "00000000-0000-0000-0010-000000000000"],
88 ["uuid", "00000000-0000-0000-0000-000000010000"],
89 ["uuid", "00000000-0000-0000-1000-000000000000"],
90 ["uuid", "00000000-0000-0000-0000-100000000000"],
91 ["uuid", "00000000-0000-0000-0000-001000000000"],
92 ["uuid", "00000000-0000-0000-0000-000000100000"],
93 ["uuid", "00000000-0000-0000-0000-000000000000"],
94 ["uuid", "00000000-0010-0000-0000-000000000000"],
95 ["uuid", "00100000-0000-0000-0000-000000000000"],
96 ["uuid", "00000000-0001-0000-0000-000000000000"],
97 ["uuid", "00000001-0000-0000-0000-000000000000"],
98 ["uuid", "00001000-0000-0000-0000-000000000000"]]']],
99 [[[["uuid","00000000-0000-0000-0000-000000000000"],["uuid","00000000-0000-0000-0000-000000000001"],["uuid","00000000-0000-0000-0000-000000000010"],["uuid","00000000-0000-0000-0000-000000000100"],["uuid","00000000-0000-0000-0000-000000001000"],["uuid","00000000-0000-0000-0000-000000010000"],["uuid","00000000-0000-0000-0000-000000100000"],["uuid","00000000-0000-0000-0000-000001000000"],["uuid","00000000-0000-0000-0000-000010000000"],["uuid","00000000-0000-0000-0000-000100000000"],["uuid","00000000-0000-0000-0000-001000000000"],["uuid","00000000-0000-0000-0000-010000000000"],["uuid","00000000-0000-0000-0000-100000000000"],["uuid","00000000-0000-0000-0001-000000000000"],["uuid","00000000-0000-0000-0010-000000000000"],["uuid","00000000-0000-0000-0100-000000000000"],["uuid","00000000-0000-0000-1000-000000000000"],["uuid","00000000-0000-0001-0000-000000000000"],["uuid","00000000-0000-0010-0000-000000000000"],["uuid","00000000-0000-0100-0000-000000000000"],["uuid","00000000-0000-1000-0000-000000000000"],["uuid","00000000-0001-0000-0000-000000000000"],["uuid","00000000-0010-0000-0000-000000000000"],["uuid","00000000-0100-0000-0000-000000000000"],["uuid","00000000-1000-0000-0000-000000000000"],["uuid","00000001-0000-0000-0000-000000000000"],["uuid","00000010-0000-0000-0000-000000000000"],["uuid","00000100-0000-0000-0000-000000000000"],["uuid","00001000-0000-0000-0000-000000000000"],["uuid","00010000-0000-0000-0000-000000000000"],["uuid","00100000-0000-0000-0000-000000000000"],["uuid","01000000-0000-0000-0000-000000000000"],["uuid","10000000-0000-0000-0000-000000000000"]]]])
100
101OVSDB_CHECK_NEGATIVE([real not acceptable integer atom],
102 [[parse-atoms '["integer"]' '[0.5]' ]],
103 [expected integer])
104
105OVSDB_CHECK_NEGATIVE([string "true" not acceptable boolean atom],
106 [[parse-atoms '["boolean"]' '["true"]' ]],
107 [expected boolean])
108
109OVSDB_CHECK_NEGATIVE([integer not acceptable string atom],
110 [[parse-atoms '["string"]' '[1]']],
111 [expected string])
112
113OVSDB_CHECK_NEGATIVE([uuid atom must be expressed as array],
114 [[parse-atoms '["uuid"]' '["550e8400-e29b-41d4-a716-446655440000"]']],
115 [[expected ["uuid", <string>]]])
116
117AT_BANNER([OSVDB -- simple data])
118
119OVSDB_CHECK_POSITIVE([integer datum],
120 [[parse-data '["integer"]' '[0]' '[1]' '[-1]']],
121 [0
1221
123-1])
124
125OVSDB_CHECK_POSITIVE([real datum],
126 [[parse-data '["real"]' '[0]' '[1.0]' '[-1.25]']],
127 [0
1281
129-1.25])
130
131OVSDB_CHECK_POSITIVE([boolean datum],
132 [[parse-data '["boolean"]' '[true]' '[false]' ]],
133 [true
134false])
135
136OVSDB_CHECK_POSITIVE([string datum],
137 [[parse-data '["string"]' '[""]' '["true"]' '["\"\\\/\b\f\n\r\t"]']],
138 [""
139"true"
140"\"\\/\b\f\n\r\t"])
141
142AT_BANNER([OVSDB -- set data])
143
144OVSDB_CHECK_POSITIVE([optional boolean],
145 [[parse-data '{"key": "boolean", "min": 0}' \
146 '["set", [true]]' \
147 '["set", [false]]' \
148 '["set", []]']],
149 [[["set",[true]]
150["set",[false]]
151["set",[]]]],
152 [set])
153
154OVSDB_CHECK_POSITIVE([set of 0 or more integers],
155 [[parse-data '{"key": "integer", "min": 0, "max": "unlimited"}' \
156 '["set", [0]]' \
157 '["set", [0, 1]]' \
158 '["set", [0, 1, 2]]' \
159 '["set", [0, 1, 2, 3, 4, 5]]' \
160 '["set", [0, 1, 2, 3, 4, 5, 6, 7, 8]]' \
161 '["set", [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]']],
162 [[["set",[0]]
163["set",[0,1]]
164["set",[0,1,2]]
165["set",[0,1,2,3,4,5]]
166["set",[0,1,2,3,4,5,6,7,8]]
167["set",[0,1,2,3,4,5,6,7,8,9,10]]]])
168
169OVSDB_CHECK_POSITIVE([set of 1 to 3 uuids],
170 [[parse-data '{"key": "uuid", "min": 1, "max": 3}' \
171 '["set", [["uuid", "550e8400-e29b-41d4-a716-446655440000"]]]' \
172 '["set", [["uuid", "c5051240-30ff-43ed-b4b9-93cf3f050813"],
173 ["uuid", "90558331-09af-4d2f-a572-509cad2e9088"],
174 ["uuid", "550e8400-e29b-41d4-a716-446655440000"]]]']],
175 [[["set",[["uuid","550e8400-e29b-41d4-a716-446655440000"]]]
176["set",[["uuid","550e8400-e29b-41d4-a716-446655440000"],["uuid","90558331-09af-4d2f-a572-509cad2e9088"],["uuid","c5051240-30ff-43ed-b4b9-93cf3f050813"]]]]])
177
178OVSDB_CHECK_POSITIVE([set of 0 to 3 strings],
179 [[parse-data '{"key": "string", "min": 0, "max": 3}' \
180 '["set", []]' \
181 '["set", ["a relatively long string"]]' \
182 '["set", ["short string", "a relatively long string"]]' \
183 '["set", ["zzz", "short string", "a relatively long string"]]']],
184 [[["set",[]]
185["set",["a relatively long string"]]
186["set",["a relatively long string","short string"]]
187["set",["a relatively long string","short string","zzz"]]]])
188
189OVSDB_CHECK_NEGATIVE([duplicate boolean not allowed in set],
190 [[parse-data '{"key": "boolean", "max": 5}' '["set", [true, true]]']],
191 [ovsdb error: set contains duplicate])
192
193OVSDB_CHECK_NEGATIVE([duplicate integer not allowed in set],
194 [[parse-data '{"key": "integer", "max": 5}' '["set", [1, 2, 3, 1]]']],
195 [ovsdb error: set contains duplicate])
196
197OVSDB_CHECK_NEGATIVE([duplicate real not allowed in set],
198 [[parse-data '{"key": "real", "max": 5}' '["set", [0.0, -0.0]]']],
199 [ovsdb error: set contains duplicate])
200
201OVSDB_CHECK_NEGATIVE([duplicate string not allowed in set],
202 [[parse-data '{"key": "string", "max": 5}' '["set", ["asdf", "ASDF", "asdf"]]']],
203 [ovsdb error: set contains duplicate])
204
205OVSDB_CHECK_NEGATIVE([duplicate uuid not allowed in set],
206 [[parse-data '{"key": "uuid", "max": 5}' \
207 '["set", [["uuid", "7ef21525-0088-4a28-a418-5518413e43ea"],
208 ["uuid", "355ad037-f1da-40aa-b47c-ff9c7e8c6a38"],
209 ["uuid", "7ef21525-0088-4a28-a418-5518413e43ea"]]]']],
210 [ovsdb error: set contains duplicate])
211
212AT_BANNER([OVSDB -- map data])
213
214OVSDB_CHECK_POSITIVE([map of 1 integer to boolean],
215 [[parse-data '{"key": "integer", "value": "boolean"}' \
216 '["map", [[1, true]]]']],
217 [[["map",[[1,true]]]]])
218
219OVSDB_CHECK_POSITIVE([map of at least 1 integer to boolean],
220 [[parse-data '{"key": "integer", "value": "boolean", "max": "unlimited"}' \
221 '["map", [[1, true]]]' \
222 '["map", [[0, true], [1, false], [2, true], [3, true], [4, true]]]' \
223 '["map", [[3, false], [0, true], [4, false]]]']],
224 [[["map",[[1,true]]]
225["map",[[0,true],[1,false],[2,true],[3,true],[4,true]]]
226["map",[[0,true],[3,false],[4,false]]]]])
227
228OVSDB_CHECK_POSITIVE([map of 1 boolean to integer],
229 [[parse-data '{"key": "boolean", "value": "integer"}' \
230 '["map", [[true, 1]]]']],
231 [[["map",[[true,1]]]]])
232
31a763d7
BP
233OVSDB_CHECK_POSITIVE([map of 1 uuid to real],
234 [[parse-data '{"key": "uuid", "value": "real", "min": 1, "max": 5}' \
f85f8ebb
BP
235 '["map", [[["uuid", "cad8542b-6ee1-486b-971b-7dcbf6e14979"], 1.0],
236 [["uuid", "6b94b968-2702-4f64-9457-314a34d69b8c"], 2.0],
237 [["uuid", "d2c4a168-24de-47eb-a8a3-c1abfc814979"], 3.0],
238 [["uuid", "25bfa475-d072-4f60-8be1-00f48643e9cb"], 4.0],
239 [["uuid", "1c92b8ca-d5e4-4628-a85d-1dc2d099a99a"], 5.0]]]']],
240 [[["map",[[["uuid","1c92b8ca-d5e4-4628-a85d-1dc2d099a99a"],5],[["uuid","25bfa475-d072-4f60-8be1-00f48643e9cb"],4],[["uuid","6b94b968-2702-4f64-9457-314a34d69b8c"],2],[["uuid","cad8542b-6ee1-486b-971b-7dcbf6e14979"],1],[["uuid","d2c4a168-24de-47eb-a8a3-c1abfc814979"],3]]]]])
241
242OVSDB_CHECK_POSITIVE([map of 10 string to string],
31a763d7 243 [[parse-data '{"key": "string", "value": "string", "min": 1, "max": 10}' \
f85f8ebb
BP
244 '["map", [["2 gills", "1 chopin"],
245 ["2 chopins", "1 pint"],
246 ["2 pints", "1 quart"],
247 ["2 quarts", "1 pottle"],
248 ["2 pottles", "1 gallon"],
249 ["2 gallons", "1 peck"],
250 ["2 pecks", "1 demibushel"],
251 ["2 demibushel", "1 firkin"],
252 ["2 firkins", "1 kilderkin"],
253 ["2 kilderkins", "1 barrel"]]]']],
254 [[["map",[["2 chopins","1 pint"],["2 demibushel","1 firkin"],["2 firkins","1 kilderkin"],["2 gallons","1 peck"],["2 gills","1 chopin"],["2 kilderkins","1 barrel"],["2 pecks","1 demibushel"],["2 pints","1 quart"],["2 pottles","1 gallon"],["2 quarts","1 pottle"]]]]])
255
256OVSDB_CHECK_NEGATIVE([duplicate integer key not allowed in map],
257 [[parse-data '{"key": "integer", "value": "boolean", "max": 5}' \
258 '["map", [[1, true], [2, false], [1, false]]]']],
259 [ovsdb error: map contains duplicate key])