]> git.proxmox.com Git - ovs.git/blob - tests/ovsdb-idl.at
ovsdb-server: Improve logging for referential integrity violations.
[ovs.git] / tests / ovsdb-idl.at
1 AT_BANNER([OVSDB -- interface description language (IDL)])
2
3 # OVSDB_CHECK_IDL(TITLE, [PRE-IDL-TXN], TRANSACTIONS, OUTPUT, [KEYWORDS])
4 #
5 # Creates a database with a schema derived from idltest.ovsidl, runs
6 # each PRE-IDL-TXN (if any), starts an ovsdb-server on that database,
7 # and runs "test-ovsdb idl" passing each of the TRANSACTIONS along.
8 #
9 # Checks that the overall output is OUTPUT. Before comparison, the
10 # output is sorted (using "sort") and UUIDs in the output are replaced
11 # by markers of the form <N> where N is a number. The first unique
12 # UUID is replaced by <0>, the next by <1>, and so on. If a given
13 # UUID appears more than once it is always replaced by the same
14 # marker.
15 #
16 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
17 m4_define([OVSDB_CHECK_IDL],
18 [AT_SETUP([$1])
19 AT_KEYWORDS([ovsdb server idl positive $5])
20 AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema],
21 [0], [stdout], [ignore])
22 AT_CHECK([ovsdb-server '-vPATTERN:console:ovsdb-server|%c|%m' --detach --pidfile=$PWD/pid --remote=punix:socket --unixctl=$PWD/unixctl db], [0], [ignore], [ignore])
23 m4_if([$2], [], [],
24 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore], [kill `cat pid`])])
25 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl unix:socket $3],
26 [0], [stdout], [ignore], [kill `cat pid`])
27 AT_CHECK([sort stdout | perl $srcdir/uuidfilt.pl], [0], [$4], [],
28 [kill `cat pid`])
29 OVSDB_SERVER_SHUTDOWN
30 AT_CLEANUP])
31
32 OVSDB_CHECK_IDL([simple idl, initially empty, no ops],
33 [],
34 [],
35 [000: empty
36 001: done
37 ])
38
39 OVSDB_CHECK_IDL([simple idl, initially empty, various ops],
40 [],
41 [['["idltest",
42 {"op": "insert",
43 "table": "simple",
44 "row": {"i": 1,
45 "r": 2.0,
46 "b": true,
47 "s": "mystring",
48 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
49 "ia": ["set", [1, 2, 3]],
50 "ra": ["set", [-0.5]],
51 "ba": ["set", [true, false]],
52 "sa": ["set", ["abc", "def"]],
53 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
54 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
55 {"op": "insert",
56 "table": "simple",
57 "row": {}}]' \
58 '["idltest",
59 {"op": "update",
60 "table": "simple",
61 "where": [],
62 "row": {"b": true}}]' \
63 '["idltest",
64 {"op": "update",
65 "table": "simple",
66 "where": [],
67 "row": {"r": 123.5}}]' \
68 '["idltest",
69 {"op": "insert",
70 "table": "simple",
71 "row": {"i": -1,
72 "r": 125,
73 "b": false,
74 "s": "",
75 "ia": ["set", [1]],
76 "ra": ["set", [1.5]],
77 "ba": ["set", [false]],
78 "sa": ["set", []],
79 "ua": ["set", []]}}]' \
80 '["idltest",
81 {"op": "update",
82 "table": "simple",
83 "where": [["i", "<", 1]],
84 "row": {"s": "newstring"}}]' \
85 '["idltest",
86 {"op": "delete",
87 "table": "simple",
88 "where": [["i", "==", 0]]}]' \
89 'reconnect']],
90 [[000: empty
91 001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
92 002: i=0 r=0 b=false s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
93 002: i=1 r=2 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[false true] sa=[abc def] ua=[<4> <5>] uuid=<0>
94 003: {"error":null,"result":[{"count":2}]}
95 004: i=0 r=0 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
96 004: i=1 r=2 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[false true] sa=[abc def] ua=[<4> <5>] uuid=<0>
97 005: {"error":null,"result":[{"count":2}]}
98 006: i=0 r=123.5 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
99 006: i=1 r=123.5 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[false true] sa=[abc def] ua=[<4> <5>] uuid=<0>
100 007: {"error":null,"result":[{"uuid":["uuid","<6>"]}]}
101 008: i=-1 r=125 b=false s= u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
102 008: i=0 r=123.5 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
103 008: i=1 r=123.5 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[false true] sa=[abc def] ua=[<4> <5>] uuid=<0>
104 009: {"error":null,"result":[{"count":2}]}
105 010: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
106 010: i=0 r=123.5 b=true s=newstring u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
107 010: i=1 r=123.5 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[false true] sa=[abc def] ua=[<4> <5>] uuid=<0>
108 011: {"error":null,"result":[{"count":1}]}
109 012: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
110 012: i=1 r=123.5 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[false true] sa=[abc def] ua=[<4> <5>] uuid=<0>
111 013: reconnect
112 014: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
113 014: i=1 r=123.5 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[false true] sa=[abc def] ua=[<4> <5>] uuid=<0>
114 015: done
115 ]])
116
117 OVSDB_CHECK_IDL([simple idl, initially populated],
118 [['["idltest",
119 {"op": "insert",
120 "table": "simple",
121 "row": {"i": 1,
122 "r": 2.0,
123 "b": true,
124 "s": "mystring",
125 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
126 "ia": ["set", [1, 2, 3]],
127 "ra": ["set", [-0.5]],
128 "ba": ["set", [true, false]],
129 "sa": ["set", ["abc", "def"]],
130 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
131 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
132 {"op": "insert",
133 "table": "simple",
134 "row": {}}]']],
135 [['["idltest",
136 {"op": "update",
137 "table": "simple",
138 "where": [],
139 "row": {"b": true}}]']],
140 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
141 000: i=1 r=2 b=true s=mystring u=<2> ia=[1 2 3] ra=[-0.5] ba=[false true] sa=[abc def] ua=[<3> <4>] uuid=<5>
142 001: {"error":null,"result":[{"count":2}]}
143 002: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
144 002: i=1 r=2 b=true s=mystring u=<2> ia=[1 2 3] ra=[-0.5] ba=[false true] sa=[abc def] ua=[<3> <4>] uuid=<5>
145 003: done
146 ]])
147
148 OVSDB_CHECK_IDL([simple idl, writing via IDL],
149 [['["idltest",
150 {"op": "insert",
151 "table": "simple",
152 "row": {"i": 1,
153 "r": 2.0,
154 "b": true,
155 "s": "mystring",
156 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
157 "ia": ["set", [1, 2, 3]],
158 "ra": ["set", [-0.5]],
159 "ba": ["set", [true, false]],
160 "sa": ["set", ["abc", "def"]],
161 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
162 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
163 {"op": "insert",
164 "table": "simple",
165 "row": {}}]']],
166 [['set 0 b 1, set 1 r 3.5' \
167 'insert 2, delete 1']],
168 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
169 000: i=1 r=2 b=true s=mystring u=<2> ia=[1 2 3] ra=[-0.5] ba=[false true] sa=[abc def] ua=[<3> <4>] uuid=<5>
170 001: commit, status=success
171 002: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
172 002: i=1 r=3.5 b=true s=mystring u=<2> ia=[1 2 3] ra=[-0.5] ba=[false true] sa=[abc def] ua=[<3> <4>] uuid=<5>
173 003: commit, status=success
174 004: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
175 004: i=2 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<6>
176 005: done
177 ]])
178
179 OVSDB_CHECK_IDL([simple idl, increment operation],
180 [['["idltest",
181 {"op": "insert",
182 "table": "simple",
183 "row": {}}]']],
184 [['set 0 r 2.0, increment simple i']],
185 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
186 001: commit, status=success, increment=1
187 002: i=1 r=2 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
188 003: done
189 ]])
190
191 OVSDB_CHECK_IDL([self-linking idl, consistent ops],
192 [],
193 [['["idltest",
194 {"op": "insert",
195 "table": "link1",
196 "row": {"i": 0, "k": ["named-uuid", "self"]},
197 "uuid-name": "self"}]' \
198 '["idltest",
199 {"op": "insert",
200 "table": "link1",
201 "row": {"i": 1, "k": ["named-uuid", "row2"]},
202 "uuid-name": "row1"},
203 {"op": "insert",
204 "table": "link1",
205 "row": {"i": 2, "k": ["named-uuid", "row1"]},
206 "uuid-name": "row2"}]' \
207 '["idltest",
208 {"op": "update",
209 "table": "link1",
210 "where": [["i", "==", 1]],
211 "row": {"k": ["uuid", "#1#"]}}]' \
212 '["idltest",
213 {"op": "update",
214 "table": "link1",
215 "where": [],
216 "row": {"k": ["uuid", "#0#"]}}]']],
217 [[000: empty
218 001: {"error":null,"result":[{"uuid":["uuid","<0>"]}]}
219 002: i=0 k=0 ka=[] l2= uuid=<0>
220 003: {"error":null,"result":[{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]}]}
221 004: i=0 k=0 ka=[] l2= uuid=<0>
222 004: i=1 k=2 ka=[] l2= uuid=<1>
223 004: i=2 k=1 ka=[] l2= uuid=<2>
224 005: {"error":null,"result":[{"count":1}]}
225 006: i=0 k=0 ka=[] l2= uuid=<0>
226 006: i=1 k=1 ka=[] l2= uuid=<1>
227 006: i=2 k=1 ka=[] l2= uuid=<2>
228 007: {"error":null,"result":[{"count":3}]}
229 008: i=0 k=0 ka=[] l2= uuid=<0>
230 008: i=1 k=0 ka=[] l2= uuid=<1>
231 008: i=2 k=0 ka=[] l2= uuid=<2>
232 009: done
233 ]])
234
235 OVSDB_CHECK_IDL([self-linking idl, inconsistent ops],
236 [],
237 [['["idltest",
238 {"op": "insert",
239 "table": "link1",
240 "row": {"i": 0, "k": ["uuid", "cf197cc5-c8c9-42f5-82d5-c71a9f2cb96b"]}}]' \
241 '+["idltest",
242 {"op": "insert",
243 "table": "link1",
244 "uuid-name": "one",
245 "row": {"i": 1, "k": ["named-uuid", "one"]}},
246 {"op": "insert",
247 "table": "link1",
248 "row": {"i": 2, "k": ["named-uuid", "one"]}}]' \
249 '["idltest",
250 {"op": "update",
251 "table": "link1",
252 "where": [],
253 "row": {"k": ["uuid", "c2fca39a-e69a-42a4-9c56-5eca85839ce9"]}}]' \
254 '+["idltest",
255 {"op": "delete",
256 "table": "link1",
257 "where": [["_uuid", "==", ["uuid", "#1#"]]]}]' \
258 '+["idltest",
259 {"op": "delete",
260 "table": "link1",
261 "where": [["_uuid", "==", ["uuid", "#2#"]]]}]' \
262 '["idltest",
263 {"op": "delete",
264 "table": "link1",
265 "where": []}]' \
266 ]],
267 [[000: empty
268 001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"details":"Table link1 column k row <0> references nonexistent row <1> in table link1.","error":"referential integrity violation"}]}
269 002: {"error":null,"result":[{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]}
270 003: i=1 k=1 ka=[] l2= uuid=<2>
271 003: i=2 k=1 ka=[] l2= uuid=<3>
272 004: {"error":null,"result":[{"count":2},{"details":"Table link1 column k row <2> references nonexistent row <4> in table link1.","error":"referential integrity violation"}]}
273 005: {"error":null,"result":[{"count":1},{"details":"cannot delete link1 row <2> because of 1 remaining reference(s)","error":"referential integrity violation"}]}
274 006: {"error":null,"result":[{"count":1}]}
275 007: i=1 k=1 ka=[] l2= uuid=<2>
276 008: {"error":null,"result":[{"count":1}]}
277 009: empty
278 010: done
279 ]])
280
281 OVSDB_CHECK_IDL([self-linking idl, sets],
282 [],
283 [['["idltest",
284 {"op": "insert",
285 "table": "link1",
286 "row": {"i": 0, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i0"]]]},
287 "uuid-name": "i0"},
288 {"op": "insert",
289 "table": "link1",
290 "row": {"i": 1, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i1"]]]},
291 "uuid-name": "i1"},
292 {"op": "insert",
293 "table": "link1",
294 "row": {"i": 2, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i2"]]]},
295 "uuid-name": "i2"},
296 {"op": "insert",
297 "table": "link1",
298 "row": {"i": 3, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i3"]]]},
299 "uuid-name": "i3"}]' \
300 '["idltest",
301 {"op": "update",
302 "table": "link1",
303 "where": [],
304 "row": {"ka": ["set", [["uuid", "#0#"], ["uuid", "#1#"], ["uuid", "#2#"], ["uuid", "#3#"]]]}}]' \
305 '["idltest",
306 {"op": "update",
307 "table": "link1",
308 "where": [["i", "==", 2]],
309 "row": {"ka": ["set", [["uuid", "#0#"], ["uuid", "88702e78-845b-4a6e-ad08-cf68922ae84a"], ["uuid", "#2#"]]]}}]' \
310 '+["idltest",
311 {"op": "delete",
312 "table": "link1",
313 "where": []}]']],
314 [[000: empty
315 001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]}
316 002: i=0 k=0 ka=[0] l2= uuid=<0>
317 002: i=1 k=0 ka=[1] l2= uuid=<1>
318 002: i=2 k=0 ka=[2] l2= uuid=<2>
319 002: i=3 k=0 ka=[3] l2= uuid=<3>
320 003: {"error":null,"result":[{"count":4}]}
321 004: i=0 k=0 ka=[0 1 2 3] l2= uuid=<0>
322 004: i=1 k=0 ka=[0 1 2 3] l2= uuid=<1>
323 004: i=2 k=0 ka=[0 1 2 3] l2= uuid=<2>
324 004: i=3 k=0 ka=[0 1 2 3] l2= uuid=<3>
325 005: {"error":null,"result":[{"count":1},{"details":"Table link1 column ka row <2> references nonexistent row <4> in table link1.","error":"referential integrity violation"}]}
326 006: {"error":null,"result":[{"count":4}]}
327 007: empty
328 008: done
329 ]])
330
331 OVSDB_CHECK_IDL([external-linking idl, consistent ops],
332 [],
333 [['["idltest",
334 {"op": "insert",
335 "table": "link2",
336 "row": {"i": 0},
337 "uuid-name": "row0"},
338 {"op": "insert",
339 "table": "link1",
340 "row": {"i": 1, "k": ["named-uuid", "row1"], "l2": ["set", [["named-uuid", "row0"]]]},
341 "uuid-name": "row1"}]']],
342 [[000: empty
343 001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
344 002: i=0 l1= uuid=<0>
345 002: i=1 k=1 ka=[] l2=0 uuid=<1>
346 003: done
347 ]])