ovn: Implement action to copy one field into another.
[cascardo/ovs.git] / tests / ovsdb-idl.at
1 AT_BANNER([OVSDB -- interface description language (IDL)])
2
3 # OVSDB_CHECK_IDL_C(TITLE, [PRE-IDL-TXN], TRANSACTIONS, OUTPUT, [KEYWORDS],
4 #                   [FILTER])
5 #
6 # Creates a database with a schema derived from idltest.ovsidl, runs
7 # each PRE-IDL-TXN (if any), starts an ovsdb-server on that database,
8 # and runs "test-ovsdb idl" passing each of the TRANSACTIONS along.
9 #
10 # Checks that the overall output is OUTPUT.  Before comparison, the
11 # output is sorted (using "sort") and UUIDs in the output are replaced
12 # by markers of the form <N> where N is a number.  The first unique
13 # UUID is replaced by <0>, the next by <1>, and so on.  If a given
14 # UUID appears more than once it is always replaced by the same
15 # marker.  If FILTER is supplied then the output is also filtered
16 # through the specified program.
17 #
18 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
19 m4_define([OVSDB_CHECK_IDL_C],
20   [AT_SETUP([$1 - C])
21    AT_KEYWORDS([ovsdb server idl positive $5])
22    AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema],
23                   [0], [stdout], [ignore])
24    AT_CHECK([ovsdb-server '-vPATTERN:console:ovsdb-server|%c|%m' --detach --no-chdir --pidfile="`pwd`"/pid --remote=punix:socket --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
25    m4_if([$2], [], [],
26      [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore], [kill `cat pid`])])
27    AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl unix:socket $3],
28             [0], [stdout], [ignore], [kill `cat pid`])
29    AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]),
30             [0], [$4], [], [kill `cat pid`])
31    OVSDB_SERVER_SHUTDOWN
32    AT_CLEANUP])
33
34 # same as OVSDB_CHECK_IDL but uses the Python IDL implementation.
35 m4_define([OVSDB_CHECK_IDL_PY],
36   [AT_SETUP([$1 - Python])
37    AT_SKIP_IF([test $HAVE_PYTHON = no])
38    AT_KEYWORDS([ovsdb server idl positive Python $5])
39    AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema],
40                   [0], [stdout], [ignore])
41    AT_CHECK([ovsdb-server '-vPATTERN:console:ovsdb-server|%c|%m' --detach --no-chdir --pidfile="`pwd`"/pid --remote=punix:socket --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
42    m4_if([$2], [], [],
43      [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore], [kill `cat pid`])])
44    AT_CHECK([$PYTHON $srcdir/test-ovsdb.py  -t10 idl $srcdir/idltest.ovsschema unix:socket $3],
45             [0], [stdout], [ignore], [kill `cat pid`])
46    AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]),
47             [0], [$4], [], [kill `cat pid`])
48    OVSDB_SERVER_SHUTDOWN
49    AT_CLEANUP])
50
51 # same as OVSDB_CHECK_IDL but uses the Python IDL implementation with tcp
52 m4_define([OVSDB_CHECK_IDL_TCP_PY],
53   [AT_SETUP([$1 - Python tcp])
54    AT_SKIP_IF([test $HAVE_PYTHON = no])
55    AT_KEYWORDS([ovsdb server idl positive Python with tcp socket $5])
56    AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema],
57                   [0], [stdout], [ignore])
58    AT_CHECK([ovsdb-server --log-file '-vPATTERN:console:ovsdb-server|%c|%m' --detach --no-chdir --pidfile="`pwd`"/pid --remote=punix:socket --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
59    TCP_PORT=`parse_listening_port < ovsdb-server.log`
60
61    m4_if([$2], [], [],
62      [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT $2], [0], [ignore], [ignore], [kill `cat pid`])])
63    AT_CHECK([$PYTHON $srcdir/test-ovsdb.py  -t10 idl $srcdir/idltest.ovsschema tcp:127.0.0.1:$TCP_PORT $3],
64             [0], [stdout], [ignore], [kill `cat pid`])
65    AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]),
66             [0], [$4], [], [kill `cat pid`])
67    OVSDB_SERVER_SHUTDOWN
68    AT_CLEANUP])
69
70 # same as OVSDB_CHECK_IDL but uses the Python IDL implementation with tcp6
71 m4_define([OVSDB_CHECK_IDL_TCP6_PY],
72   [AT_SETUP([$1 - Python tcp6])
73    AT_SKIP_IF([test $HAVE_PYTHON = no])
74    AT_SKIP_IF([test $HAVE_IPV6 = no])
75    AT_KEYWORDS([ovsdb server idl positive Python with tcp6 socket $5])
76    AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema],
77                   [0], [stdout], [ignore])
78    AT_CHECK([ovsdb-server --log-file '-vPATTERN:console:ovsdb-server|%c|%m' --detach --no-chdir --pidfile="`pwd`"/pid --remote=ptcp:0:[[::1]] --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
79    TCP_PORT=`parse_listening_port < ovsdb-server.log`
80    echo "TCP_PORT=$TCP_PORT"
81
82    m4_if([$2], [], [],
83      [AT_CHECK([ovsdb-client transact "tcp:[[::1]]:$TCP_PORT" $2], [0], [ignore], [ignore], [kill `cat pid`])])
84    AT_CHECK([$PYTHON $srcdir/test-ovsdb.py  -t10 idl $srcdir/idltest.ovsschema tcp:[[::1]]:$TCP_PORT $3],
85             [0], [stdout], [ignore], [kill `cat pid`])
86    AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]),
87             [0], [$4], [], [kill `cat pid`])
88    OVSDB_SERVER_SHUTDOWN
89    AT_CLEANUP])
90
91 m4_define([OVSDB_CHECK_IDL],
92   [OVSDB_CHECK_IDL_C($@)
93    OVSDB_CHECK_IDL_PY($@)
94    OVSDB_CHECK_IDL_TCP_PY($@)
95    OVSDB_CHECK_IDL_TCP6_PY($@)])
96
97 OVSDB_CHECK_IDL([simple idl, initially empty, no ops],
98   [],
99   [],
100   [000: empty
101 001: done
102 ])
103
104 OVSDB_CHECK_IDL([simple idl, initially empty, various ops],
105   [],
106   [['["idltest",
107       {"op": "insert",
108        "table": "simple",
109        "row": {"i": 1,
110                "r": 2.0,
111                "b": true,
112                "s": "mystring",
113                "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
114                "ia": ["set", [1, 2, 3]],
115                "ra": ["set", [-0.5]],
116                "ba": ["set", [true]],
117                "sa": ["set", ["abc", "def"]],
118                "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
119                               ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
120       {"op": "insert",
121        "table": "simple",
122        "row": {}}]' \
123     '["idltest",
124       {"op": "update",
125        "table": "simple",
126        "where": [],
127        "row": {"b": true}}]' \
128     '["idltest",
129       {"op": "update",
130        "table": "simple",
131        "where": [],
132        "row": {"r": 123.5}}]' \
133     '["idltest",
134       {"op": "insert",
135        "table": "simple",
136        "row": {"i": -1,
137                "r": 125,
138                "b": false,
139                "s": "",
140                "ia": ["set", [1]],
141                "ra": ["set", [1.5]],
142                "ba": ["set", [false]],
143                "sa": ["set", []],
144                "ua": ["set", []]}}]' \
145     '["idltest",
146       {"op": "update",
147        "table": "simple",
148        "where": [["i", "<", 1]],
149        "row": {"s": "newstring"}}]' \
150     '["idltest",
151       {"op": "delete",
152        "table": "simple",
153        "where": [["i", "==", 0]]}]' \
154     'reconnect']],
155   [[000: empty
156 001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
157 002: i=0 r=0 b=false s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
158 002: i=1 r=2 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<4> <5>] uuid=<0>
159 003: {"error":null,"result":[{"count":2}]}
160 004: i=0 r=0 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
161 004: i=1 r=2 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<4> <5>] uuid=<0>
162 005: {"error":null,"result":[{"count":2}]}
163 006: i=0 r=123.5 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
164 006: i=1 r=123.5 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<4> <5>] uuid=<0>
165 007: {"error":null,"result":[{"uuid":["uuid","<6>"]}]}
166 008: i=-1 r=125 b=false s= u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
167 008: i=0 r=123.5 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
168 008: i=1 r=123.5 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<4> <5>] uuid=<0>
169 009: {"error":null,"result":[{"count":2}]}
170 010: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
171 010: i=0 r=123.5 b=true s=newstring u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
172 010: i=1 r=123.5 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<4> <5>] uuid=<0>
173 011: {"error":null,"result":[{"count":1}]}
174 012: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
175 012: i=1 r=123.5 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<4> <5>] uuid=<0>
176 013: reconnect
177 014: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
178 014: i=1 r=123.5 b=true s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<4> <5>] uuid=<0>
179 015: done
180 ]])
181
182 OVSDB_CHECK_IDL([simple idl, initially populated],
183   [['["idltest",
184       {"op": "insert",
185        "table": "simple",
186        "row": {"i": 1,
187                "r": 2.0,
188                "b": true,
189                "s": "mystring",
190                "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
191                "ia": ["set", [1, 2, 3]],
192                "ra": ["set", [-0.5]],
193                "ba": ["set", [true]],
194                "sa": ["set", ["abc", "def"]],
195                "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
196                               ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
197       {"op": "insert",
198        "table": "simple",
199        "row": {}}]']],
200   [['["idltest",
201       {"op": "update",
202        "table": "simple",
203        "where": [],
204        "row": {"b": true}}]']],
205   [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
206 000: i=1 r=2 b=true s=mystring u=<2> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<3> <4>] uuid=<5>
207 001: {"error":null,"result":[{"count":2}]}
208 002: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
209 002: i=1 r=2 b=true s=mystring u=<2> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<3> <4>] uuid=<5>
210 003: done
211 ]])
212
213 OVSDB_CHECK_IDL([simple idl, writing via IDL],
214   [['["idltest",
215       {"op": "insert",
216        "table": "simple",
217        "row": {"i": 1,
218                "r": 2.0,
219                "b": true,
220                "s": "mystring",
221                "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
222                "ia": ["set", [1, 2, 3]],
223                "ra": ["set", [-0.5]],
224                "ba": ["set", [true]],
225                "sa": ["set", ["abc", "def"]],
226                "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
227                               ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
228       {"op": "insert",
229        "table": "simple",
230        "row": {}}]']],
231   [['verify 0 b, verify 1 r, set 0 b 1, set 1 r 3.5' \
232     'insert 2, verify 2 i, verify 1 b, delete 1']],
233   [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
234 000: i=1 r=2 b=true s=mystring u=<2> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<3> <4>] uuid=<5>
235 001: commit, status=success
236 002: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
237 002: i=1 r=3.5 b=true s=mystring u=<2> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<3> <4>] uuid=<5>
238 003: commit, status=success
239 004: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
240 004: i=2 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<6>
241 005: done
242 ]])
243
244 OVSDB_CHECK_IDL([simple idl, handling verification failure],
245   [['["idltest",
246       {"op": "insert",
247        "table": "simple",
248        "row": {"i": 1,
249                "r": 2.0}},
250       {"op": "insert",
251        "table": "simple",
252        "row": {}}]']],
253   [['set 0 b 1' \
254     '+["idltest",
255        {"op": "update",
256         "table": "simple",
257         "where": [["i", "==", 1]],
258         "row": {"r": 5.0}}]' \
259     '+verify 1 r, set 1 r 3' \
260     'verify 1 r, set 1 r 3' \
261     ]],
262   [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
263 000: i=1 r=2 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
264 001: commit, status=success
265 002: {"error":null,"result":[{"count":1}]}
266 003: commit, status=try again
267 004: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
268 004: i=1 r=5 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
269 005: commit, status=success
270 006: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
271 006: i=1 r=3 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
272 007: done
273 ]])
274
275 OVSDB_CHECK_IDL([simple idl, increment operation],
276   [['["idltest",
277       {"op": "insert",
278        "table": "simple",
279        "row": {}}]']],
280   [['set 0 r 2.0, increment 0']],
281   [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
282 001: commit, status=success, increment=1
283 002: i=1 r=2 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
284 003: done
285 ]])
286
287 OVSDB_CHECK_IDL([simple idl, aborting],
288   [['["idltest",
289       {"op": "insert",
290        "table": "simple",
291        "row": {}}]']],
292   [['set 0 r 2.0, abort' \
293 '+set 0 b 1']],
294   [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
295 001: commit, status=aborted
296 002: commit, status=success
297 003: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
298 004: done
299 ]])
300
301 OVSDB_CHECK_IDL([simple idl, destroy without commit or abort],
302   [['["idltest",
303       {"op": "insert",
304        "table": "simple",
305        "row": {}}]']],
306   [['set 0 r 2.0, destroy' \
307 '+set 0 b 1']],
308   [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
309 001: destroy
310 002: commit, status=success
311 003: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
312 004: done
313 ]])
314
315 OVSDB_CHECK_IDL([self-linking idl, consistent ops],
316   [],
317   [['["idltest",
318       {"op": "insert",
319        "table": "link1",
320        "row": {"i": 0, "k": ["named-uuid", "self"]},
321        "uuid-name": "self"}]' \
322     '["idltest",
323       {"op": "insert",
324        "table": "link1",
325        "row": {"i": 1, "k": ["named-uuid", "row2"]},
326        "uuid-name": "row1"},
327       {"op": "insert",
328        "table": "link1",
329        "row": {"i": 2, "k": ["named-uuid", "row1"]},
330        "uuid-name": "row2"}]' \
331     '["idltest",
332       {"op": "update",
333        "table": "link1",
334        "where": [["i", "==", 1]],
335        "row": {"k": ["uuid", "#1#"]}}]' \
336     '["idltest",
337       {"op": "update",
338        "table": "link1",
339        "where": [],
340        "row": {"k": ["uuid", "#0#"]}}]']],
341   [[000: empty
342 001: {"error":null,"result":[{"uuid":["uuid","<0>"]}]}
343 002: i=0 k=0 ka=[] l2= uuid=<0>
344 003: {"error":null,"result":[{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]}]}
345 004: i=0 k=0 ka=[] l2= uuid=<0>
346 004: i=1 k=2 ka=[] l2= uuid=<1>
347 004: i=2 k=1 ka=[] l2= uuid=<2>
348 005: {"error":null,"result":[{"count":1}]}
349 006: i=0 k=0 ka=[] l2= uuid=<0>
350 006: i=1 k=1 ka=[] l2= uuid=<1>
351 006: i=2 k=1 ka=[] l2= uuid=<2>
352 007: {"error":null,"result":[{"count":3}]}
353 008: i=0 k=0 ka=[] l2= uuid=<0>
354 008: i=1 k=0 ka=[] l2= uuid=<1>
355 008: i=2 k=0 ka=[] l2= uuid=<2>
356 009: done
357 ]])
358
359 OVSDB_CHECK_IDL([self-linking idl, inconsistent ops],
360   [],
361   [['["idltest",
362       {"op": "insert",
363        "table": "link1",
364        "row": {"i": 0, "k": ["uuid", "cf197cc5-c8c9-42f5-82d5-c71a9f2cb96b"]}}]' \
365     '+["idltest",
366       {"op": "insert",
367        "table": "link1",
368        "uuid-name": "one",
369        "row": {"i": 1, "k": ["named-uuid", "one"]}},
370       {"op": "insert",
371        "table": "link1",
372        "row": {"i": 2, "k": ["named-uuid", "one"]}}]' \
373      '["idltest",
374       {"op": "update",
375        "table": "link1",
376        "where": [],
377        "row": {"k": ["uuid", "c2fca39a-e69a-42a4-9c56-5eca85839ce9"]}}]' \
378      '+["idltest",
379       {"op": "delete",
380        "table": "link1",
381        "where": [["_uuid", "==", ["uuid", "#1#"]]]}]' \
382      '+["idltest",
383       {"op": "delete",
384        "table": "link1",
385        "where": [["_uuid", "==", ["uuid", "#2#"]]]}]' \
386      '["idltest",
387       {"op": "delete",
388        "table": "link1",
389        "where": []}]' \
390 ]],
391   [[000: empty
392 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"}]}
393 002: {"error":null,"result":[{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]}
394 003: i=1 k=1 ka=[] l2= uuid=<2>
395 003: i=2 k=1 ka=[] l2= uuid=<3>
396 004: {"error":null,"result":[{"count":2},{"details":"Table link1 column k row <x> references nonexistent row <4> in table link1.","error":"referential integrity violation"}]}
397 005: {"error":null,"result":[{"count":1},{"details":"cannot delete link1 row <2> because of 1 remaining reference(s)","error":"referential integrity violation"}]}
398 006: {"error":null,"result":[{"count":1}]}
399 007: i=1 k=1 ka=[] l2= uuid=<2>
400 008: {"error":null,"result":[{"count":1}]}
401 009: empty
402 010: done
403 ]],
404   [],
405   [[sed -e '/004:/s/row <[23]> references/row <x> references/']])
406
407 OVSDB_CHECK_IDL([self-linking idl, sets],
408   [],
409   [['["idltest",
410       {"op": "insert",
411        "table": "link1",
412        "row": {"i": 0, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i0"]]]},
413        "uuid-name": "i0"},
414       {"op": "insert",
415        "table": "link1",
416        "row": {"i": 1, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i1"]]]},
417        "uuid-name": "i1"},
418       {"op": "insert",
419        "table": "link1",
420        "row": {"i": 2, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i2"]]]},
421        "uuid-name": "i2"},
422       {"op": "insert",
423        "table": "link1",
424        "row": {"i": 3, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i3"]]]},
425        "uuid-name": "i3"}]' \
426     '["idltest",
427       {"op": "update",
428        "table": "link1",
429        "where": [],
430        "row": {"ka": ["set", [["uuid", "#0#"], ["uuid", "#1#"], ["uuid", "#2#"], ["uuid", "#3#"]]]}}]' \
431     '["idltest",
432       {"op": "update",
433        "table": "link1",
434        "where": [["i", "==", 2]],
435        "row": {"ka": ["set", [["uuid", "#0#"], ["uuid", "88702e78-845b-4a6e-ad08-cf68922ae84a"], ["uuid", "#2#"]]]}}]' \
436     '+["idltest",
437       {"op": "delete",
438        "table": "link1",
439        "where": []}]']],
440   [[000: empty
441 001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]}
442 002: i=0 k=0 ka=[0] l2= uuid=<0>
443 002: i=1 k=0 ka=[1] l2= uuid=<1>
444 002: i=2 k=0 ka=[2] l2= uuid=<2>
445 002: i=3 k=0 ka=[3] l2= uuid=<3>
446 003: {"error":null,"result":[{"count":4}]}
447 004: i=0 k=0 ka=[0 1 2 3] l2= uuid=<0>
448 004: i=1 k=0 ka=[0 1 2 3] l2= uuid=<1>
449 004: i=2 k=0 ka=[0 1 2 3] l2= uuid=<2>
450 004: i=3 k=0 ka=[0 1 2 3] l2= uuid=<3>
451 005: {"error":null,"result":[{"count":1},{"details":"Table link1 column ka row <2> references nonexistent row <4> in table link1.","error":"referential integrity violation"}]}
452 006: {"error":null,"result":[{"count":4}]}
453 007: empty
454 008: done
455 ]])
456
457 OVSDB_CHECK_IDL([external-linking idl, consistent ops],
458   [],
459   [['["idltest",
460       {"op": "insert",
461        "table": "link2",
462        "row": {"i": 0},
463        "uuid-name": "row0"},
464       {"op": "insert",
465        "table": "link1",
466        "row": {"i": 1, "k": ["named-uuid", "row1"], "l2": ["set", [["named-uuid", "row0"]]]},
467        "uuid-name": "row1"}]']],
468   [[000: empty
469 001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
470 002: i=0 l1= uuid=<0>
471 002: i=1 k=1 ka=[] l2=0 uuid=<1>
472 003: done
473 ]])
474
475 OVSDB_CHECK_IDL_PY([external-linking idl, insert ops],
476   [],
477   [['linktest']],
478   [[000: empty
479 001: commit, status=success
480 002: i=1 k=1 ka=[1] l2= uuid=<0>
481 002: i=2 k=1 ka=[1 2] l2= uuid=<1>
482 003: done
483 ]])
484
485 OVSDB_CHECK_IDL_PY([getattr idl, insert ops],
486   [],
487   [['getattrtest']],
488   [[000: empty
489 001: commit, status=success
490 002: i=2 k=2 ka=[] l2= uuid=<0>
491 003: done
492 ]])
493
494 OVSDB_CHECK_IDL_PY([row-from-json idl, whats this],
495   [['["idltest",
496       {"op": "insert",
497        "table": "simple",
498        "row": {"i": 1}},
499       {"op": "insert",
500        "table": "simple",
501        "row": {}}]']],
502   [['notifytest insert 2, notifytest set 1 b 1, notifytest delete 0']],
503   [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
504 000: i=1 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
505 001: commit, status=success, events=create|2|None, delete|0|None, update|1|b
506 002: i=1 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
507 002: i=2 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>
508 003: done
509 ]])
510
511 AT_SETUP([idl handling of missing tables and columns - C])
512 AT_KEYWORDS([ovsdb server idl positive])
513
514 # idltest2.ovsschema is the same as idltest.ovsschema, except that
515 # table link2 and column l2 have been deleted.  But the IDL still
516 # expects them to be there, so this test checks that it properly
517 # tolerates them being missing.
518 AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest2.ovsschema],
519     [0], [stdout], [ignore])
520 AT_CHECK([ovsdb-server '-vPATTERN:console:ovsdb-server|%c|%m' --detach --no-chdir --pidfile="`pwd`"/pid --remote=punix:socket --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
521 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl unix:socket ['["idltest",
522       {"op": "insert",
523        "table": "link1",
524        "row": {"i": 0, "k": ["named-uuid", "self"]},
525        "uuid-name": "self"}]' \
526     '["idltest",
527       {"op": "insert",
528        "table": "link1",
529        "row": {"i": 1, "k": ["named-uuid", "row2"]},
530        "uuid-name": "row1"},
531       {"op": "insert",
532        "table": "link1",
533        "row": {"i": 2, "k": ["named-uuid", "row1"]},
534        "uuid-name": "row2"}]' \
535     '["idltest",
536       {"op": "update",
537        "table": "link1",
538        "where": [["i", "==", 1]],
539        "row": {"k": ["uuid", "#1#"]}}]' \
540     '["idltest",
541       {"op": "update",
542        "table": "link1",
543        "where": [],
544        "row": {"k": ["uuid", "#0#"]}}]']],
545          [0], [stdout], [stderr], [kill `cat pid`])
546 AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl], [0],
547     [[000: empty
548 001: {"error":null,"result":[{"uuid":["uuid","<0>"]}]}
549 002: i=0 k=0 ka=[] l2= uuid=<0>
550 003: {"error":null,"result":[{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]}]}
551 004: i=0 k=0 ka=[] l2= uuid=<0>
552 004: i=1 k=2 ka=[] l2= uuid=<1>
553 004: i=2 k=1 ka=[] l2= uuid=<2>
554 005: {"error":null,"result":[{"count":1}]}
555 006: i=0 k=0 ka=[] l2= uuid=<0>
556 006: i=1 k=1 ka=[] l2= uuid=<1>
557 006: i=2 k=1 ka=[] l2= uuid=<2>
558 007: {"error":null,"result":[{"count":3}]}
559 008: i=0 k=0 ka=[] l2= uuid=<0>
560 008: i=1 k=0 ka=[] l2= uuid=<1>
561 008: i=2 k=0 ka=[] l2= uuid=<2>
562 009: done
563 ]], [], [kill `cat pid`])
564
565 # Check that ovsdb-idl figured out that table link2 and column l2 are missing.
566 AT_CHECK([grep ovsdb_idl stderr | sort], [0], [dnl
567 test-ovsdb|ovsdb_idl|idltest database lacks link2 table (database needs upgrade?)
568 test-ovsdb|ovsdb_idl|link1 table in idltest database lacks l2 column (database needs upgrade?)
569 ])
570
571 # Check that ovsdb-idl sent on "monitor" request and that it didn't
572 # mention that table or column, and (for paranoia) that it did mention another
573 # table and column.
574 AT_CHECK([grep -c '"monitor"' stderr], [0], [1
575 ])
576 AT_CHECK([grep '"monitor"' stderr | grep link2], [1])
577 AT_CHECK([grep '"monitor"' stderr | grep l2], [1])
578 AT_CHECK([grep '"monitor"' stderr | grep -c '"link1"'], [0], [1
579 ])
580 AT_CHECK([grep '"monitor"' stderr | grep -c '"ua"'], [0], [1
581 ])
582 OVSDB_SERVER_SHUTDOWN
583 AT_CLEANUP