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