]> git.proxmox.com Git - mirror_ovs.git/blame - tests/ovsdb-idl.at
ovsdb: Loosen requirements for automatically compacting databases.
[mirror_ovs.git] / tests / ovsdb-idl.at
CommitLineData
c3bb4bd7
BP
1AT_BANNER([OVSDB -- interface description language (IDL)])
2
56120500
BP
3m4_divert_text([PREPARE_TESTS], [
4# ovsdb_start_idltest [REMOTE] [SCHEMA]
5#
6# Creates a database using SCHEMA (default: idltest.ovsschema) and
7# starts a database server listening on punix:socket and REMOTE (if
8# specified).
9ovsdb_start_idltest () {
10 ovsdb-tool create db ${2:-$abs_srcdir/idltest.ovsschema} || return $?
11 ovsdb-server -vconsole:warn --log-file --detach --no-chdir --pidfile --remote=punix:socket ${1:+--remote=$1} db || return $?
12 on_exit 'kill `cat ovsdb-server.pid`'
13}
14])
15
8cdf0349
BP
16# OVSDB_CHECK_IDL_C(TITLE, [PRE-IDL-TXN], TRANSACTIONS, OUTPUT, [KEYWORDS],
17# [FILTER])
c3bb4bd7
BP
18#
19# Creates a database with a schema derived from idltest.ovsidl, runs
20# each PRE-IDL-TXN (if any), starts an ovsdb-server on that database,
21# and runs "test-ovsdb idl" passing each of the TRANSACTIONS along.
22#
23# Checks that the overall output is OUTPUT. Before comparison, the
24# output is sorted (using "sort") and UUIDs in the output are replaced
25# by markers of the form <N> where N is a number. The first unique
26# UUID is replaced by <0>, the next by <1>, and so on. If a given
27# UUID appears more than once it is always replaced by the same
254604d8
BP
28# marker. If FILTER is supplied then the output is also filtered
29# through the specified program.
c3bb4bd7
BP
30#
31# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
8cdf0349
BP
32m4_define([OVSDB_CHECK_IDL_C],
33 [AT_SETUP([$1 - C])
c3bb4bd7 34 AT_KEYWORDS([ovsdb server idl positive $5])
56120500 35 AT_CHECK([ovsdb_start_idltest])
c3bb4bd7 36 m4_if([$2], [], [],
7427f2a4 37 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
8cdf0349 38 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl unix:socket $3],
7427f2a4 39 [0], [stdout], [ignore])
c724bd67 40 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 41 [0], [$4])
028cbd99 42 OVSDB_SERVER_SHUTDOWN
c3bb4bd7
BP
43 AT_CLEANUP])
44
8cdf0349 45# same as OVSDB_CHECK_IDL but uses the Python IDL implementation.
963f66b5
RB
46m4_define([OVSDB_CHECK_IDL_PYN],
47 [AT_SETUP([$1])
48 AT_SKIP_IF([test $7 = no])
8cdf0349 49 AT_KEYWORDS([ovsdb server idl positive Python $5])
56120500 50 AT_CHECK([ovsdb_start_idltest])
8cdf0349 51 m4_if([$2], [], [],
7427f2a4 52 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
963f66b5 53 AT_CHECK([$8 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema unix:socket $3],
7427f2a4 54 [0], [stdout], [ignore])
c724bd67 55 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 56 [0], [$4])
8cdf0349
BP
57 OVSDB_SERVER_SHUTDOWN
58 AT_CLEANUP])
59
963f66b5
RB
60m4_define([OVSDB_CHECK_IDL_PY],
61 [OVSDB_CHECK_IDL_PYN([$1 - Python2], [$2], [$3], [$4], [$5], [$6],
62 [$HAVE_PYTHON], [$PYTHON])
63 OVSDB_CHECK_IDL_PYN([$1 - Python3], [$2], [$3], [$4], [$5], [$6],
64 [$HAVE_PYTHON3], [$PYTHON3])])
65
66m4_define([OVSDB_CHECK_IDL_REGISTER_COLUMNS_PYN],
67 [AT_SETUP([$1 - register_columns])
68 AT_SKIP_IF([test $7 = no])
01dc1516 69 AT_KEYWORDS([ovsdb server idl positive Python register_columns $5])
56120500 70 AT_CHECK([ovsdb_start_idltest])
01dc1516 71 m4_if([$2], [], [],
7427f2a4 72 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
963f66b5 73 AT_CHECK([$8 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema unix:socket ?simple:b,ba,i,ia,r,ra,s,sa,u,ua?link1:i,k,ka,l2?link2:i,l1 $3],
7427f2a4 74 [0], [stdout], [ignore])
c724bd67 75 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 76 [0], [$4])
01dc1516
SA
77 OVSDB_SERVER_SHUTDOWN
78 AT_CLEANUP])
79
963f66b5
RB
80m4_define([OVSDB_CHECK_IDL_REGISTER_COLUMNS_PY],
81 [OVSDB_CHECK_IDL_REGISTER_COLUMNS_PYN([$1 - Python2], [$2], [$3], [$4], [$5], [$6],
82 [$HAVE_PYTHON], [$PYTHON])
83 OVSDB_CHECK_IDL_REGISTER_COLUMNS_PYN([$1 - Python3], [$2], [$3], [$4], [$5], [$6],
84 [$HAVE_PYTHON3], [$PYTHON3])])
85
e06d06a7 86# same as OVSDB_CHECK_IDL but uses the Python IDL implementation with tcp
963f66b5
RB
87m4_define([OVSDB_CHECK_IDL_TCP_PYN],
88 [AT_SETUP([$1 - tcp])
89 AT_SKIP_IF([test $7 = no])
e06d06a7 90 AT_KEYWORDS([ovsdb server idl positive Python with tcp socket $5])
56120500 91 AT_CHECK([ovsdb_start_idltest "ptcp:0:127.0.0.1"])
fb28ef2d 92 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
1e04fcc8 93
e06d06a7 94 m4_if([$2], [], [],
7427f2a4 95 [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT $2], [0], [ignore], [ignore])])
963f66b5 96 AT_CHECK([$8 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema tcp:127.0.0.1:$TCP_PORT $3],
7427f2a4 97 [0], [stdout], [ignore])
c724bd67 98 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 99 [0], [$4])
e06d06a7
IY
100 OVSDB_SERVER_SHUTDOWN
101 AT_CLEANUP])
102
963f66b5
RB
103m4_define([OVSDB_CHECK_IDL_TCP_PY],
104 [OVSDB_CHECK_IDL_TCP_PYN([$1 - Python2], [$2], [$3], [$4], [$5], [$6],
105 [$HAVE_PYTHON], [$PYTHON])
106 OVSDB_CHECK_IDL_TCP_PYN([$1 - Python3], [$2], [$3], [$4], [$5], [$6],
107 [$HAVE_PYTHON3], [$PYTHON3])])
108
e731d71b 109# same as OVSDB_CHECK_IDL but uses the Python IDL implementation with tcp6
963f66b5
RB
110m4_define([OVSDB_CHECK_IDL_TCP6_PYN],
111 [AT_SETUP([$1 - tcp6])
112 AT_SKIP_IF([test $7 = no])
7b9d1b65 113 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
4819b3a5 114 AT_SKIP_IF([test $HAVE_IPV6 = no])
e731d71b 115 AT_KEYWORDS([ovsdb server idl positive Python with tcp6 socket $5])
56120500 116 AT_CHECK([ovsdb_start_idltest "ptcp:0:[[::1]]"])
fb28ef2d 117 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
e731d71b
AS
118 echo "TCP_PORT=$TCP_PORT"
119
120 m4_if([$2], [], [],
7427f2a4 121 [AT_CHECK([ovsdb-client transact "tcp:[[::1]]:$TCP_PORT" $2], [0], [ignore], [ignore])])
963f66b5 122 AT_CHECK([$8 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema tcp:[[::1]]:$TCP_PORT $3],
7427f2a4 123 [0], [stdout], [ignore])
c724bd67 124 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 125 [0], [$4])
e731d71b
AS
126 OVSDB_SERVER_SHUTDOWN
127 AT_CLEANUP])
128
963f66b5
RB
129m4_define([OVSDB_CHECK_IDL_TCP6_PY],
130 [OVSDB_CHECK_IDL_TCP6_PYN([$1 - Python2], [$2], [$3], [$4], [$5], [$6],
131 [$HAVE_PYTHON], [$PYTHON])
132 OVSDB_CHECK_IDL_TCP6_PYN([$1 - Python3], [$2], [$3], [$4], [$5], [$6],
133 [$HAVE_PYTHON3], [$PYTHON3])])
134
8cdf0349
BP
135m4_define([OVSDB_CHECK_IDL],
136 [OVSDB_CHECK_IDL_C($@)
e06d06a7 137 OVSDB_CHECK_IDL_PY($@)
01dc1516 138 OVSDB_CHECK_IDL_REGISTER_COLUMNS_PY($@)
e731d71b
AS
139 OVSDB_CHECK_IDL_TCP_PY($@)
140 OVSDB_CHECK_IDL_TCP6_PY($@)])
8cdf0349 141
af358237
OBY
142# This test uses the Python IDL implementation with passive tcp
143m4_define([OVSDB_CHECK_IDL_PASSIVE_TCP_PY],
144 [AT_SETUP([$1 - Python ptcp])
145 AT_SKIP_IF([test $HAVE_PYTHON = no])
146 AT_KEYWORDS([ovsdb server idl positive Python with tcp socket $5])
af358237 147 # find free TCP port
56120500 148 AT_CHECK([ovsdb_start_idltest "ptcp:0:127.0.0.1"])
af358237 149 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
7427f2a4 150 OVSDB_SERVER_SHUTDOWN
56120500 151 rm -f db
af358237
OBY
152
153 # start OVSDB server in passive mode
56120500 154 AT_CHECK([ovsdb_start_idltest "tcp:127.0.0.1:$TCP_PORT"])
af358237 155 AT_CHECK([$PYTHON $srcdir/test-ovsdb.py -t10 idl_passive $srcdir/idltest.ovsschema ptcp:127.0.0.1:$TCP_PORT $3],
7427f2a4 156 [0], [stdout], [ignore])
c724bd67 157 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4
DDP
158 [0], [$4])
159 OVSDB_SERVER_SHUTDOWN
af358237
OBY
160 AT_CLEANUP
161 ])
162
163OVSDB_CHECK_IDL_PASSIVE_TCP_PY([simple passive idl, initially empty, select empty],
164 [],
165 [['["idltest",{"op":"select","table":"link1","where":[]}]']],
166 [[000: empty
167001: {"error":null,"result":[{"rows":[]}]}
168002: done
169]])
170
c3bb4bd7
BP
171OVSDB_CHECK_IDL([simple idl, initially empty, no ops],
172 [],
173 [],
174 [000: empty
175001: done
176])
177
178OVSDB_CHECK_IDL([simple idl, initially empty, various ops],
179 [],
9cb53f26
BP
180 [['["idltest",
181 {"op": "insert",
c3bb4bd7
BP
182 "table": "simple",
183 "row": {"i": 1,
184 "r": 2.0,
185 "b": true,
186 "s": "mystring",
187 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
188 "ia": ["set", [1, 2, 3]],
189 "ra": ["set", [-0.5]],
7fae24e6 190 "ba": ["set", [true]],
8cdf0349 191 "sa": ["set", ["abc", "def"]],
c3bb4bd7
BP
192 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
193 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
194 {"op": "insert",
195 "table": "simple",
196 "row": {}}]' \
9cb53f26
BP
197 '["idltest",
198 {"op": "update",
c3bb4bd7
BP
199 "table": "simple",
200 "where": [],
201 "row": {"b": true}}]' \
9cb53f26
BP
202 '["idltest",
203 {"op": "update",
c3bb4bd7
BP
204 "table": "simple",
205 "where": [],
206 "row": {"r": 123.5}}]' \
9cb53f26
BP
207 '["idltest",
208 {"op": "insert",
c3bb4bd7
BP
209 "table": "simple",
210 "row": {"i": -1,
211 "r": 125,
212 "b": false,
213 "s": "",
214 "ia": ["set", [1]],
215 "ra": ["set", [1.5]],
216 "ba": ["set", [false]],
8cdf0349 217 "sa": ["set", []],
c3bb4bd7 218 "ua": ["set", []]}}]' \
9cb53f26
BP
219 '["idltest",
220 {"op": "update",
c3bb4bd7
BP
221 "table": "simple",
222 "where": [["i", "<", 1]],
223 "row": {"s": "newstring"}}]' \
9cb53f26
BP
224 '["idltest",
225 {"op": "delete",
c3bb4bd7
BP
226 "table": "simple",
227 "where": [["i", "==", 0]]}]' \
228 'reconnect']],
229 [[000: empty
230001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
231002: i=0 r=0 b=false s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 232002: 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>
c3bb4bd7
BP
233003: {"error":null,"result":[{"count":2}]}
234004: i=0 r=0 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 235004: 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>
c3bb4bd7
BP
236005: {"error":null,"result":[{"count":2}]}
237006: i=0 r=123.5 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 238006: 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>
c3bb4bd7
BP
239007: {"error":null,"result":[{"uuid":["uuid","<6>"]}]}
240008: i=-1 r=125 b=false s= u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
241008: i=0 r=123.5 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 242008: 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>
c3bb4bd7
BP
243009: {"error":null,"result":[{"count":2}]}
244010: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
245010: i=0 r=123.5 b=true s=newstring u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 246010: 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>
c3bb4bd7
BP
247011: {"error":null,"result":[{"count":1}]}
248012: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
7fae24e6 249012: 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>
c3bb4bd7
BP
250013: reconnect
251014: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
7fae24e6 252014: 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>
c3bb4bd7
BP
253015: done
254]])
255
256OVSDB_CHECK_IDL([simple idl, initially populated],
9cb53f26
BP
257 [['["idltest",
258 {"op": "insert",
c3bb4bd7
BP
259 "table": "simple",
260 "row": {"i": 1,
261 "r": 2.0,
262 "b": true,
263 "s": "mystring",
264 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
265 "ia": ["set", [1, 2, 3]],
266 "ra": ["set", [-0.5]],
7fae24e6 267 "ba": ["set", [true]],
8cdf0349 268 "sa": ["set", ["abc", "def"]],
c3bb4bd7
BP
269 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
270 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
271 {"op": "insert",
272 "table": "simple",
273 "row": {}}]']],
9cb53f26
BP
274 [['["idltest",
275 {"op": "update",
c3bb4bd7
BP
276 "table": "simple",
277 "where": [],
278 "row": {"b": true}}]']],
279 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 280000: 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>
c3bb4bd7
BP
281001: {"error":null,"result":[{"count":2}]}
282002: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 283002: 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>
c3bb4bd7
BP
284003: done
285]])
286
475281c0 287OVSDB_CHECK_IDL([simple idl, writing via IDL],
9cb53f26
BP
288 [['["idltest",
289 {"op": "insert",
475281c0
BP
290 "table": "simple",
291 "row": {"i": 1,
292 "r": 2.0,
293 "b": true,
294 "s": "mystring",
295 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
296 "ia": ["set", [1, 2, 3]],
297 "ra": ["set", [-0.5]],
7fae24e6 298 "ba": ["set", [true]],
8cdf0349 299 "sa": ["set", ["abc", "def"]],
475281c0
BP
300 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
301 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
302 {"op": "insert",
303 "table": "simple",
304 "row": {}}]']],
a91c6104
BP
305 [['verify 0 b, verify 1 r, set 0 b 1, set 1 r 3.5' \
306 'insert 2, verify 2 i, verify 1 b, delete 1']],
475281c0 307 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 308000: 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>
475281c0
BP
309001: commit, status=success
310002: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 311002: 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>
475281c0
BP
312003: commit, status=success
313004: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
314004: i=2 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<6>
315005: done
316]])
317
e7164d96
LR
318OVSDB_CHECK_IDL([simple idl, writing via IDL with unicode],
319 [['["idltest",
320 {"op": "insert",
321 "table": "simple",
322 "row": {"s": "(╯°□°)╯︵ ┻━┻"}}]']],
323 [['set 0 b 1, insert 1, set 1 s "¯\_(ツ)_/¯"']],
324 [[000: i=0 r=0 b=false s=(╯°□°)╯︵ ┻━┻ u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
325001: commit, status=success
326002: i=0 r=0 b=true s=(╯°□°)╯︵ ┻━┻ u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
327002: i=1 r=0 b=false s="¯\_(ツ)_/¯" u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
328003: done
329]])
330
a91c6104
BP
331OVSDB_CHECK_IDL([simple idl, handling verification failure],
332 [['["idltest",
333 {"op": "insert",
334 "table": "simple",
335 "row": {"i": 1,
336 "r": 2.0}},
337 {"op": "insert",
338 "table": "simple",
339 "row": {}}]']],
340 [['set 0 b 1' \
341 '+["idltest",
342 {"op": "update",
343 "table": "simple",
344 "where": [["i", "==", 1]],
345 "row": {"r": 5.0}}]' \
346 '+verify 1 r, set 1 r 3' \
347 'verify 1 r, set 1 r 3' \
348 ]],
349 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
350000: i=1 r=2 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
351001: commit, status=success
352002: {"error":null,"result":[{"count":1}]}
94fbe1aa 353003: commit, status=try again
a91c6104
BP
354004: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
355004: i=1 r=5 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
356005: commit, status=success
357006: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
358006: i=1 r=3 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
359007: done
360]])
361
b54e22e9 362OVSDB_CHECK_IDL([simple idl, increment operation],
9cb53f26
BP
363 [['["idltest",
364 {"op": "insert",
b54e22e9
BP
365 "table": "simple",
366 "row": {}}]']],
94fbe1aa 367 [['set 0 r 2.0, increment 0']],
b54e22e9
BP
368 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
369001: commit, status=success, increment=1
370002: i=1 r=2 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
371003: done
372]])
373
2096903b
BP
374OVSDB_CHECK_IDL([simple idl, aborting],
375 [['["idltest",
376 {"op": "insert",
377 "table": "simple",
378 "row": {}}]']],
379 [['set 0 r 2.0, abort' \
380'+set 0 b 1']],
381 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
382001: commit, status=aborted
383002: commit, status=success
384003: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
385004: done
386]])
387
388OVSDB_CHECK_IDL([simple idl, destroy without commit or abort],
389 [['["idltest",
390 {"op": "insert",
391 "table": "simple",
392 "row": {}}]']],
393 [['set 0 r 2.0, destroy' \
394'+set 0 b 1']],
395 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
396001: destroy
397002: commit, status=success
398003: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
399004: done
400]])
401
16ebb90e
LS
402OVSDB_CHECK_IDL([simple idl, conditional, false condition],
403 [['["idltest",
404 {"op": "insert",
405 "table": "simple",
406 "row": {"i": 1,
407 "r": 2.0,
408 "b": true}}]']],
0164e367
BP
409 [['condition simple []' \
410 'condition simple [true]']],
16ebb90e
LS
411 [[000: change conditions
412001: empty
413002: change conditions
414003: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
415004: done
416]])
417
418OVSDB_CHECK_IDL([simple idl, conditional, true condition],
419 [['["idltest",
420 {"op": "insert",
421 "table": "simple",
422 "row": {"i": 1,
423 "r": 2.0,
424 "b": true}}]']],
0164e367
BP
425 [['condition simple []' \
426 'condition simple [true]']],
16ebb90e
LS
427 [[000: change conditions
428001: empty
429002: change conditions
430003: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
431004: done
432]])
433
434OVSDB_CHECK_IDL([simple idl, conditional, multiple clauses in condition],
435 [['["idltest",
436 {"op": "insert",
437 "table": "simple",
438 "row": {"i": 1,
439 "r": 2.0,
440 "b": true}},
441 {"op": "insert",
442 "table": "simple",
443 "row": {"i": 2,
444 "r": 3.0,
445 "b": true}}]']],
0164e367
BP
446 [['condition simple []' \
447 'condition simple [["i","==",1],["i","==",2]]']],
16ebb90e
LS
448 [[000: change conditions
449001: empty
450002: change conditions
451003: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
452003: i=2 r=3 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
453004: done
454]])
455
456OVSDB_CHECK_IDL([simple idl, conditional, modify as insert due to condition],
457 [['["idltest",
458 {"op": "insert",
459 "table": "simple",
460 "row": {"i": 1,
461 "r": 2.0,
462 "b": true}}]']],
0164e367
BP
463 [['condition simple []' \
464 'condition simple [["i","==",1]]']],
16ebb90e
LS
465 [[000: change conditions
466001: empty
467002: change conditions
468003: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
469004: done
470]])
471
472OVSDB_CHECK_IDL([simple idl, conditional, modify as delete due to condition],
473 [['["idltest",
474 {"op": "insert",
475 "table": "simple",
476 "row": {"i": 1,
477 "r": 2.0,
478 "b": true}}]']],
0164e367
BP
479 [['condition simple []' \
480 'condition simple [["i","==",1],["i","==",2]]' \
481 'condition simple [["i","==",2]]' \
16ebb90e
LS
482 '["idltest",
483 {"op": "insert",
484 "table": "simple",
485 "row": {"i": 2,
486 "r": 3.0,
487 "b": true}}]']],
488 [[000: change conditions
489001: empty
490002: change conditions
491003: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
492004: change conditions
493005: empty
494006: {"error":null,"result":[{"uuid":["uuid","<2>"]}]}
495007: i=2 r=3 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
496008: done
497]])
498
499OVSDB_CHECK_IDL([simple idl, conditional, multiple tables],
500 [['["idltest",
501 {"op": "insert",
502 "table": "simple",
503 "row": {"i": 1,
504 "r": 2.0,
505 "b": true}},
506 {"op": "insert",
507 "table": "link1",
508 "row": {"i": 0, "k": ["named-uuid", "self"]},
509 "uuid-name": "self"},
510 {"op": "insert",
511 "table": "link2",
512 "row": {"i": 2},
513 "uuid-name": "row0"}]']],
0164e367
BP
514 [['condition simple [];link1 [];link2 []' \
515 'condition simple [["i","==",1]]' \
516 'condition link1 [["i","==",0]]' \
517 'condition link2 [["i","==",3]]' \
16ebb90e
LS
518 '+["idltest",
519 {"op": "insert",
520 "table": "link2",
521 "row": {"i": 3},
522 "uuid-name": "row0"}]']],
523 [[000: change conditions
524001: empty
525002: change conditions
526003: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
527004: change conditions
528005: i=0 k=0 ka=[] l2= uuid=<2>
529005: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
530006: change conditions
531007: {"error":null,"result":[{"uuid":["uuid","<3>"]}]}
532008: i=0 k=0 ka=[] l2= uuid=<2>
533008: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
534008: i=3 l1= uuid=<3>
535009: done
536]])
537
c3bb4bd7
BP
538OVSDB_CHECK_IDL([self-linking idl, consistent ops],
539 [],
9cb53f26
BP
540 [['["idltest",
541 {"op": "insert",
e9011ac8 542 "table": "link1",
c3bb4bd7
BP
543 "row": {"i": 0, "k": ["named-uuid", "self"]},
544 "uuid-name": "self"}]' \
9cb53f26
BP
545 '["idltest",
546 {"op": "insert",
e9011ac8 547 "table": "link1",
2d2d6d4a 548 "row": {"i": 1, "k": ["named-uuid", "row2"]},
c3bb4bd7
BP
549 "uuid-name": "row1"},
550 {"op": "insert",
e9011ac8 551 "table": "link1",
c3bb4bd7 552 "row": {"i": 2, "k": ["named-uuid", "row1"]},
2d2d6d4a 553 "uuid-name": "row2"}]' \
9cb53f26
BP
554 '["idltest",
555 {"op": "update",
e9011ac8 556 "table": "link1",
c3bb4bd7
BP
557 "where": [["i", "==", 1]],
558 "row": {"k": ["uuid", "#1#"]}}]' \
9cb53f26
BP
559 '["idltest",
560 {"op": "update",
e9011ac8 561 "table": "link1",
c3bb4bd7
BP
562 "where": [],
563 "row": {"k": ["uuid", "#0#"]}}]']],
564 [[000: empty
565001: {"error":null,"result":[{"uuid":["uuid","<0>"]}]}
e9011ac8 566002: i=0 k=0 ka=[] l2= uuid=<0>
fbf925e4 567003: {"error":null,"result":[{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]}]}
e9011ac8
BP
568004: i=0 k=0 ka=[] l2= uuid=<0>
569004: i=1 k=2 ka=[] l2= uuid=<1>
570004: i=2 k=1 ka=[] l2= uuid=<2>
c3bb4bd7 571005: {"error":null,"result":[{"count":1}]}
e9011ac8
BP
572006: i=0 k=0 ka=[] l2= uuid=<0>
573006: i=1 k=1 ka=[] l2= uuid=<1>
574006: i=2 k=1 ka=[] l2= uuid=<2>
c3bb4bd7 575007: {"error":null,"result":[{"count":3}]}
e9011ac8
BP
576008: i=0 k=0 ka=[] l2= uuid=<0>
577008: i=1 k=0 ka=[] l2= uuid=<1>
578008: i=2 k=0 ka=[] l2= uuid=<2>
c3bb4bd7
BP
579009: done
580]])
581
582OVSDB_CHECK_IDL([self-linking idl, inconsistent ops],
583 [],
9cb53f26
BP
584 [['["idltest",
585 {"op": "insert",
e9011ac8 586 "table": "link1",
c3bb4bd7 587 "row": {"i": 0, "k": ["uuid", "cf197cc5-c8c9-42f5-82d5-c71a9f2cb96b"]}}]' \
9cb53f26
BP
588 '+["idltest",
589 {"op": "insert",
e9011ac8 590 "table": "link1",
0d0f05b9
BP
591 "uuid-name": "one",
592 "row": {"i": 1, "k": ["named-uuid", "one"]}},
593 {"op": "insert",
594 "table": "link1",
595 "row": {"i": 2, "k": ["named-uuid", "one"]}}]' \
9cb53f26
BP
596 '["idltest",
597 {"op": "update",
e9011ac8 598 "table": "link1",
c3bb4bd7
BP
599 "where": [],
600 "row": {"k": ["uuid", "c2fca39a-e69a-42a4-9c56-5eca85839ce9"]}}]' \
9cb53f26
BP
601 '+["idltest",
602 {"op": "delete",
e9011ac8 603 "table": "link1",
0d0f05b9 604 "where": [["_uuid", "==", ["uuid", "#1#"]]]}]' \
9cb53f26
BP
605 '+["idltest",
606 {"op": "delete",
e9011ac8 607 "table": "link1",
0d0f05b9 608 "where": [["_uuid", "==", ["uuid", "#2#"]]]}]' \
9cb53f26
BP
609 '["idltest",
610 {"op": "delete",
0d0f05b9
BP
611 "table": "link1",
612 "where": []}]' \
c3bb4bd7
BP
613]],
614 [[000: empty
97f7803b 615001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"details":"Table link1 column k row <0> references nonexistent row <1> in table link1.","error":"referential integrity violation"}]}
0d0f05b9
BP
616002: {"error":null,"result":[{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]}
617003: i=1 k=1 ka=[] l2= uuid=<2>
618003: i=2 k=1 ka=[] l2= uuid=<3>
254604d8 619004: {"error":null,"result":[{"count":2},{"details":"Table link1 column k row <x> references nonexistent row <4> in table link1.","error":"referential integrity violation"}]}
0d0f05b9
BP
620005: {"error":null,"result":[{"count":1},{"details":"cannot delete link1 row <2> because of 1 remaining reference(s)","error":"referential integrity violation"}]}
621006: {"error":null,"result":[{"count":1}]}
622007: i=1 k=1 ka=[] l2= uuid=<2>
623008: {"error":null,"result":[{"count":1}]}
624009: empty
625010: done
254604d8
BP
626]],
627 [],
628 [[sed -e '/004:/s/row <[23]> references/row <x> references/']])
c3bb4bd7
BP
629
630OVSDB_CHECK_IDL([self-linking idl, sets],
631 [],
9cb53f26
BP
632 [['["idltest",
633 {"op": "insert",
e9011ac8 634 "table": "link1",
0d0f05b9 635 "row": {"i": 0, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i0"]]]},
c3bb4bd7
BP
636 "uuid-name": "i0"},
637 {"op": "insert",
e9011ac8 638 "table": "link1",
0d0f05b9 639 "row": {"i": 1, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i1"]]]},
c3bb4bd7
BP
640 "uuid-name": "i1"},
641 {"op": "insert",
e9011ac8 642 "table": "link1",
0d0f05b9 643 "row": {"i": 2, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i2"]]]},
c3bb4bd7
BP
644 "uuid-name": "i2"},
645 {"op": "insert",
e9011ac8 646 "table": "link1",
0d0f05b9 647 "row": {"i": 3, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i3"]]]},
c3bb4bd7 648 "uuid-name": "i3"}]' \
9cb53f26
BP
649 '["idltest",
650 {"op": "update",
e9011ac8 651 "table": "link1",
c3bb4bd7
BP
652 "where": [],
653 "row": {"ka": ["set", [["uuid", "#0#"], ["uuid", "#1#"], ["uuid", "#2#"], ["uuid", "#3#"]]]}}]' \
9cb53f26
BP
654 '["idltest",
655 {"op": "update",
e9011ac8 656 "table": "link1",
97f7803b
BP
657 "where": [["i", "==", 2]],
658 "row": {"ka": ["set", [["uuid", "#0#"], ["uuid", "88702e78-845b-4a6e-ad08-cf68922ae84a"], ["uuid", "#2#"]]]}}]' \
9cb53f26
BP
659 '+["idltest",
660 {"op": "delete",
0d0f05b9
BP
661 "table": "link1",
662 "where": []}]']],
c3bb4bd7
BP
663 [[000: empty
664001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]}
0d0f05b9
BP
665002: i=0 k=0 ka=[0] l2= uuid=<0>
666002: i=1 k=0 ka=[1] l2= uuid=<1>
667002: i=2 k=0 ka=[2] l2= uuid=<2>
668002: i=3 k=0 ka=[3] l2= uuid=<3>
c3bb4bd7 669003: {"error":null,"result":[{"count":4}]}
0d0f05b9
BP
670004: i=0 k=0 ka=[0 1 2 3] l2= uuid=<0>
671004: i=1 k=0 ka=[0 1 2 3] l2= uuid=<1>
672004: i=2 k=0 ka=[0 1 2 3] l2= uuid=<2>
673004: i=3 k=0 ka=[0 1 2 3] l2= uuid=<3>
97f7803b 674005: {"error":null,"result":[{"count":1},{"details":"Table link1 column ka row <2> references nonexistent row <4> in table link1.","error":"referential integrity violation"}]}
0d0f05b9
BP
675006: {"error":null,"result":[{"count":4}]}
676007: empty
677008: done
c3bb4bd7
BP
678]])
679
e9011ac8
BP
680OVSDB_CHECK_IDL([external-linking idl, consistent ops],
681 [],
9cb53f26
BP
682 [['["idltest",
683 {"op": "insert",
e9011ac8
BP
684 "table": "link2",
685 "row": {"i": 0},
686 "uuid-name": "row0"},
687 {"op": "insert",
688 "table": "link1",
0d0f05b9 689 "row": {"i": 1, "k": ["named-uuid", "row1"], "l2": ["set", [["named-uuid", "row0"]]]},
e9011ac8
BP
690 "uuid-name": "row1"}]']],
691 [[000: empty
692001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
693002: i=0 l1= uuid=<0>
0d0f05b9 694002: i=1 k=1 ka=[] l2=0 uuid=<1>
e9011ac8
BP
695003: done
696]])
225b582a
IY
697
698OVSDB_CHECK_IDL_PY([external-linking idl, insert ops],
699 [],
700 [['linktest']],
701 [[000: empty
702001: commit, status=success
703002: i=1 k=1 ka=[1] l2= uuid=<0>
704002: i=2 k=1 ka=[1 2] l2= uuid=<1>
705003: done
706]])
3b4c362f
IY
707
708OVSDB_CHECK_IDL_PY([getattr idl, insert ops],
709 [],
710 [['getattrtest']],
711 [[000: empty
712001: commit, status=success
713002: i=2 k=2 ka=[] l2= uuid=<0>
714003: done
715]])
d18e52e3 716
d7d417fc
TW
717OVSDB_CHECK_IDL_PY([row-from-json idl, whats this],
718 [['["idltest",
719 {"op": "insert",
720 "table": "simple",
721 "row": {"i": 1}},
722 {"op": "insert",
723 "table": "simple",
724 "row": {}}]']],
725 [['notifytest insert 2, notifytest set 1 b 1, notifytest delete 0']],
726 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
727000: i=1 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
728001: commit, status=success, events=create|2|None, delete|0|None, update|1|b
729002: i=1 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
730002: i=2 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>
731003: done
732]])
733
d18e52e3
BP
734AT_SETUP([idl handling of missing tables and columns - C])
735AT_KEYWORDS([ovsdb server idl positive])
d18e52e3
BP
736
737# idltest2.ovsschema is the same as idltest.ovsschema, except that
738# table link2 and column l2 have been deleted. But the IDL still
739# expects them to be there, so this test checks that it properly
740# tolerates them being missing.
56120500 741AT_CHECK([ovsdb_start_idltest "" "$abs_srcdir/idltest2.ovsschema"])
d18e52e3
BP
742AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl unix:socket ['["idltest",
743 {"op": "insert",
744 "table": "link1",
745 "row": {"i": 0, "k": ["named-uuid", "self"]},
746 "uuid-name": "self"}]' \
747 '["idltest",
748 {"op": "insert",
749 "table": "link1",
750 "row": {"i": 1, "k": ["named-uuid", "row2"]},
751 "uuid-name": "row1"},
752 {"op": "insert",
753 "table": "link1",
754 "row": {"i": 2, "k": ["named-uuid", "row1"]},
755 "uuid-name": "row2"}]' \
756 '["idltest",
757 {"op": "update",
758 "table": "link1",
759 "where": [["i", "==", 1]],
760 "row": {"k": ["uuid", "#1#"]}}]' \
761 '["idltest",
762 {"op": "update",
763 "table": "link1",
764 "where": [],
765 "row": {"k": ["uuid", "#0#"]}}]']],
7427f2a4 766 [0], [stdout], [stderr])
c724bd67 767AT_CHECK([sort stdout | uuidfilt], [0],
d18e52e3
BP
768 [[000: empty
769001: {"error":null,"result":[{"uuid":["uuid","<0>"]}]}
770002: i=0 k=0 ka=[] l2= uuid=<0>
771003: {"error":null,"result":[{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]}]}
772004: i=0 k=0 ka=[] l2= uuid=<0>
773004: i=1 k=2 ka=[] l2= uuid=<1>
774004: i=2 k=1 ka=[] l2= uuid=<2>
775005: {"error":null,"result":[{"count":1}]}
776006: i=0 k=0 ka=[] l2= uuid=<0>
777006: i=1 k=1 ka=[] l2= uuid=<1>
778006: i=2 k=1 ka=[] l2= uuid=<2>
779007: {"error":null,"result":[{"count":3}]}
780008: i=0 k=0 ka=[] l2= uuid=<0>
781008: i=1 k=0 ka=[] l2= uuid=<1>
782008: i=2 k=0 ka=[] l2= uuid=<2>
783009: done
7427f2a4 784]])
d18e52e3
BP
785
786# Check that ovsdb-idl figured out that table link2 and column l2 are missing.
787AT_CHECK([grep ovsdb_idl stderr | sort], [0], [dnl
788test-ovsdb|ovsdb_idl|idltest database lacks link2 table (database needs upgrade?)
789test-ovsdb|ovsdb_idl|link1 table in idltest database lacks l2 column (database needs upgrade?)
790])
791
792# Check that ovsdb-idl sent on "monitor" request and that it didn't
793# mention that table or column, and (for paranoia) that it did mention another
794# table and column.
c383f3bf 795AT_CHECK([grep -c '"monitor\|monitor_cond"' stderr], [0], [1
d18e52e3 796])
c383f3bf
LS
797AT_CHECK([grep '"monitor\|monitor_cond"' stderr | grep link2], [1])
798AT_CHECK([grep '"monitor\|monitor_cond"' stderr | grep l2], [1])
799AT_CHECK([grep '"monitor\|monitor_cond"' stderr | grep -c '"link1"'], [0], [1
d18e52e3 800])
c383f3bf 801AT_CHECK([grep '"monitor\|monitor_cond"' stderr | grep -c '"ua"'], [0], [1
d18e52e3
BP
802])
803OVSDB_SERVER_SHUTDOWN
804AT_CLEANUP
80c12152
SA
805
806m4_define([OVSDB_CHECK_IDL_FETCH_COLUMNS_PY],
807 [AT_SETUP([$1 - Python fetch])
808 AT_SKIP_IF([test $HAVE_PYTHON = no])
809 AT_KEYWORDS([ovsdb server idl positive Python increment fetch $6])
56120500 810 AT_CHECK([ovsdb_start_idltest])
80c12152 811 m4_if([$2], [], [],
7427f2a4 812 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
80c12152 813 AT_CHECK([$PYTHON $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema unix:socket [$3] $4],
7427f2a4 814 [0], [stdout], [ignore])
c724bd67 815 AT_CHECK([sort stdout | uuidfilt]m4_if([$7],,, [[| $7]]),
7427f2a4 816 [0], [$5])
80c12152
SA
817 OVSDB_SERVER_SHUTDOWN
818 AT_CLEANUP])
819
820m4_define([OVSDB_CHECK_IDL_FETCH_COLUMNS],
821 [OVSDB_CHECK_IDL_FETCH_COLUMNS_PY($@)])
822
823OVSDB_CHECK_IDL_FETCH_COLUMNS([simple idl, initially populated],
824 [['["idltest",
825 {"op": "insert",
826 "table": "simple",
827 "row": {"i": 1,
828 "r": 2.0,
829 "b": true,
830 "s": "mystring",
831 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
832 "ia": ["set", [1, 2, 3]],
833 "ra": ["set", [-0.5]],
834 "ba": ["set", [true]],
835 "sa": ["set", ["abc", "def"]],
836 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
837 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
838 {"op": "insert",
839 "table": "simple",
840 "row": {}}]']],
841 [?simple:i,r!],
842 ['fetch 0 r'],
843 [[000: i=0 uuid=<0>
844000: i=1 uuid=<1>
845001: commit, status=success
846002: i=0 r=0 uuid=<0>
847002: i=1 uuid=<1>
848003: done
849]])
932104f4 850
897c8064
LS
851m4_define([OVSDB_CHECK_IDL_WO_MONITOR_COND_PY],
852 [AT_SETUP([$1 - Python])
853 AT_SKIP_IF([test $HAVE_PYTHON = no])
854 AT_KEYWORDS([ovsdb server idl Python monitor $4])
56120500
BP
855 AT_CHECK([ovsdb_start_idltest])
856 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/disable-monitor-cond])
897c8064
LS
857 AT_CHECK([$PYTHON $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema unix:socket $2],
858 [0], [stdout], [ignore], [kill `cat pid`])
c724bd67 859 AT_CHECK([sort stdout | uuidfilt]m4_if([$5],,, [[| $5]]),
897c8064
LS
860 [0], [$3], [], [kill `cat pid`])
861 OVSDB_SERVER_SHUTDOWN
862 AT_CLEANUP])
863
864
865m4_define([OVSDB_CHECK_IDL_WO_MONITOR_COND],
866 [OVSDB_CHECK_IDL_WO_MONITOR_COND_PY($@)])
867
868
869OVSDB_CHECK_IDL_WO_MONITOR_COND([simple idl disable monitor-cond],
870 [['["idltest",
871 {"op": "insert",
872 "table": "simple",
873 "row": {"i": 1,
874 "r": 2.0,
875 "b": true,
876 "s": "mystring",
877 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
878 "ia": ["set", [1, 2, 3]],
879 "ra": ["set", [-0.5]],
880 "ba": ["set", [true]],
881 "sa": ["set", ["abc", "def"]],
882 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
883 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
884 {"op": "insert",
885 "table": "simple",
886 "row": {}}]' \
887 '["idltest",
888 {"op": "update",
889 "table": "simple",
890 "where": [],
891 "row": {"b": true}}]' \
892 '["idltest",
893 {"op": "update",
894 "table": "simple",
895 "where": [],
896 "row": {"r": 123.5}}]' \
897 '["idltest",
898 {"op": "insert",
899 "table": "simple",
900 "row": {"i": -1,
901 "r": 125,
902 "b": false,
903 "s": "",
904 "ia": ["set", [1]],
905 "ra": ["set", [1.5]],
906 "ba": ["set", [false]],
907 "sa": ["set", []],
908 "ua": ["set", []]}}]' \
909 '["idltest",
910 {"op": "update",
911 "table": "simple",
912 "where": [["i", "<", 1]],
913 "row": {"s": "newstring"}}]' \
914 '["idltest",
915 {"op": "delete",
916 "table": "simple",
917 "where": [["i", "==", 0]]}]' \
918 'reconnect']],
919 [[000: empty
920001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
921002: i=0 r=0 b=false s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
922002: 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>
923003: {"error":null,"result":[{"count":2}]}
924004: i=0 r=0 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
925004: 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>
926005: {"error":null,"result":[{"count":2}]}
927006: i=0 r=123.5 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
928006: 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>
929007: {"error":null,"result":[{"uuid":["uuid","<6>"]}]}
930008: i=-1 r=125 b=false s= u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
931008: i=0 r=123.5 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
932008: 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>
933009: {"error":null,"result":[{"count":2}]}
934010: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
935010: i=0 r=123.5 b=true s=newstring u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
936010: 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>
937011: {"error":null,"result":[{"count":1}]}
938012: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
939012: 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>
940013: reconnect
941014: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
942014: 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>
943015: done
944]])
945
932104f4
SA
946m4_define([OVSDB_CHECK_IDL_TRACK_C],
947 [AT_SETUP([$1 - C])
948 AT_KEYWORDS([ovsdb server idl tracking positive $5])
56120500 949 AT_CHECK([ovsdb_start_idltest])
932104f4 950 m4_if([$2], [], [],
7427f2a4 951 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
932104f4 952 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl unix:socket $3],
7427f2a4 953 [0], [stdout], [ignore])
c724bd67 954 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 955 [0], [$4])
932104f4
SA
956 OVSDB_SERVER_SHUTDOWN
957 AT_CLEANUP])
958
959m4_define([OVSDB_CHECK_IDL_TRACK],
960 [OVSDB_CHECK_IDL_TRACK_C($@)])
961
962OVSDB_CHECK_IDL_TRACK([track, simple idl, initially populated],
963 [['["idltest",
964 {"op": "insert",
965 "table": "simple",
966 "row": {"i": 1,
967 "r": 2.0,
968 "b": true,
969 "s": "mystring",
970 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
971 "ia": ["set", [1, 2, 3]],
972 "ra": ["set", [-0.5]],
973 "ba": ["set", [true]],
974 "sa": ["set", ["abc", "def"]],
975 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
976 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
977 {"op": "insert",
978 "table": "simple",
979 "row": {}}]']],
980 [['["idltest",
981 {"op": "update",
982 "table": "simple",
983 "where": [],
984 "row": {"b": true}}]']],
985 [[000: i=1 r=2 b=true s=mystring u=<0> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<1> <2>] uuid=<3>
32d37ce8 986000: updated columns: b ba i ia r ra s sa u ua
932104f4
SA
987001: {"error":null,"result":[{"count":2}]}
988002: i=0 r=0 b=true s= u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<5>
989002: i=1 r=2 b=true s=mystring u=<0> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<1> <2>] uuid=<3>
32d37ce8 990002: updated columns: b
932104f4
SA
991003: done
992]])
993
994OVSDB_CHECK_IDL_TRACK([track, simple idl, initially empty, various ops],
995 [],
996 [['["idltest",
997 {"op": "insert",
998 "table": "simple",
999 "row": {"i": 1,
1000 "r": 2.0,
1001 "b": true,
1002 "s": "mystring",
1003 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
1004 "ia": ["set", [1, 2, 3]],
1005 "ra": ["set", [-0.5]],
1006 "ba": ["set", [true]],
1007 "sa": ["set", ["abc", "def"]],
1008 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
1009 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
1010 {"op": "insert",
1011 "table": "simple",
1012 "row": {}}]' \
1013 '["idltest",
1014 {"op": "update",
1015 "table": "simple",
1016 "where": [],
1017 "row": {"b": true}}]' \
1018 '["idltest",
1019 {"op": "update",
1020 "table": "simple",
1021 "where": [],
1022 "row": {"r": 123.5}}]' \
1023 '["idltest",
1024 {"op": "insert",
1025 "table": "simple",
1026 "row": {"i": -1,
1027 "r": 125,
1028 "b": false,
1029 "s": "",
1030 "ia": ["set", [1]],
1031 "ra": ["set", [1.5]],
1032 "ba": ["set", [false]],
1033 "sa": ["set", []],
1034 "ua": ["set", []]}}]' \
1035 '["idltest",
1036 {"op": "update",
1037 "table": "simple",
1038 "where": [["i", "<", 1]],
1039 "row": {"s": "newstring"}}]' \
1040 '["idltest",
1041 {"op": "delete",
1042 "table": "simple",
1043 "where": [["i", "==", 0]]}]' \
1044 'reconnect']],
1045 [[000: empty
1046001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
1047002: 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=<0>
32d37ce8 1048002: updated columns: b ba i ia r ra s sa u ua
932104f4
SA
1049003: {"error":null,"result":[{"count":2}]}
1050004: i=0 r=0 b=true s= u=<5> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
32d37ce8 1051004: updated columns: b
932104f4
SA
1052005: {"error":null,"result":[{"count":2}]}
1053006: i=0 r=123.5 b=true s= u=<5> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
1054006: i=1 r=123.5 b=true s=mystring u=<2> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<3> <4>] uuid=<0>
32d37ce8
SA
1055006: updated columns: r
1056006: updated columns: r
932104f4
SA
1057007: {"error":null,"result":[{"uuid":["uuid","<6>"]}]}
1058008: i=-1 r=125 b=false s= u=<5> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
32d37ce8 1059008: updated columns: ba i ia r ra
932104f4
SA
1060009: {"error":null,"result":[{"count":2}]}
1061010: i=-1 r=125 b=false s=newstring u=<5> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
1062010: i=0 r=123.5 b=true s=newstring u=<5> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
32d37ce8
SA
1063010: updated columns: s
1064010: updated columns: s
932104f4
SA
1065011: {"error":null,"result":[{"count":1}]}
1066012: ##deleted## uuid=<1>
1067013: reconnect
1068014: i=-1 r=125 b=false s=newstring u=<5> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
1069014: i=1 r=123.5 b=true s=mystring u=<2> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<3> <4>] uuid=<0>
32d37ce8
SA
1070014: updated columns: b ba i ia r ra s sa u ua
1071014: updated columns: ba i ia r ra s
932104f4
SA
1072015: done
1073]])
7251075c
EA
1074
1075m4_define([OVSDB_CHECK_IDL_PARTIAL_UPDATE_MAP_COLUMN],
1076 [AT_SETUP([$1 - C])
1077 AT_KEYWORDS([ovsdb server idl partial update map column positive $5])
56120500 1078 AT_CHECK([ovsdb_start_idltest])
7251075c 1079 m4_if([$2], [], [],
7427f2a4 1080 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
7251075c 1081 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-partial-update-map-column unix:socket $3],
7427f2a4 1082 [0], [stdout], [ignore])
c724bd67 1083 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 1084 [0], [$4])
7251075c
EA
1085 OVSDB_SERVER_SHUTDOWN
1086 AT_CLEANUP])
1087
1088OVSDB_CHECK_IDL_PARTIAL_UPDATE_MAP_COLUMN([map, simple2 idl-partial-update-map-column, initially populated],
1089[['["idltest", {"op":"insert", "table":"simple2",
1090 "row":{"name":"myString1","smap":["map",[["key1","value1"],["key2","value2"]]]} }]']
1091],
1092[],
1093[[000: Getting records
1094001: name=myString1 smap=[[key1 : value1],[key2 : value2]] imap=[]
1095002: After insert element
1096003: name=String2 smap=[[key1 : myList1],[key2 : value2]] imap=[[3 : myids2]]
1097004: After insert duplicated element
1098005: name=String2 smap=[[key1 : myList1],[key2 : value2]] imap=[[3 : myids2]]
1099006: After delete element
1100007: name=String2 smap=[[key2 : value2]] imap=[[3 : myids2]]
1101008: After trying to delete a deleted element
1102009: name=String2 smap=[[key2 : value2]] imap=[[3 : myids2]]
1103010: End test
1104]])
a7261bf7 1105
a59912a0
RM
1106OVSDB_CHECK_IDL_PY([partial-map idl],
1107[['["idltest", {"op":"insert", "table":"simple2",
330b9c9c 1108 "row":{"name":"myString1","smap":["map",[["key1","value1"],["key2","value2"]]]} }]']
a59912a0 1109],
2d54d801 1110 [?simple2:name,smap,imap 'partialmapinsertelement' 'partialmapinsertmultipleelements' 'partialmapdelelements' 'partialmapmutatenew'],
330b9c9c 1111[[000: name=myString1 smap=[(key1 value1) (key2 value2)] imap=[]
a59912a0 1112001: commit, status=success
330b9c9c 1113002: name=String2 smap=[(key1 myList1) (key2 value2)] imap=[(3 myids2)]
a59912a0 1114003: commit, status=success
2d54d801 1115004: name=String2 smap=[(key1 myList1) (key2 myList2) (key3 myList3) (key4 myList4)] imap=[(3 myids2)]
330b9c9c
AB
1116005: commit, status=success
1117006: name=String2 smap=[(key2 myList2)] imap=[(3 myids2)]
2d54d801
AB
1118007: commit, status=success
1119008: name=String2 smap=[(key2 myList2)] imap=[(3 myids2)]
1120008: name=String2New smap=[(key1 newList1) (key2 newList2)] imap=[]
1121009: done
a59912a0
RM
1122]])
1123
f1ab6e06
RM
1124m4_define([OVSDB_CHECK_IDL_PARTIAL_UPDATE_SET_COLUMN],
1125 [AT_SETUP([$1 - C])
1126 AT_KEYWORDS([ovsdb server idl partial update set column positive $5])
56120500 1127 AT_CHECK([ovsdb_start_idltest])
f1ab6e06
RM
1128 m4_if([$2], [], [],
1129 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
1130 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-partial-update-set-column unix:socket $3],
1131 [0], [stdout], [ignore])
c724bd67 1132 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
f1ab6e06
RM
1133 [0], [$4])
1134 OVSDB_SERVER_SHUTDOWN
1135 AT_CLEANUP])
1136
1137OVSDB_CHECK_IDL_PARTIAL_UPDATE_SET_COLUMN([set, simple3 idl-partial-update-set-column, initially populated],
1138[['["idltest", {"op":"insert", "table":"simple3",
1139 "row":{"name":"mySet1","uset":["set", [[ "uuid", "0005b872-f9e5-43be-ae02-3184b9680e75" ], [ "uuid", "000d2f6a-76af-412f-b59d-e7bcd3e84eff" ]]]} }]']
1140],
1141[],
1142[[000: Getting records
1143001: name=mySet1 uset=[[<0>],[<1>]] uref=[]
1144002: After rename+add new value
1145003: name=String2 uset=[[<0>],[<1>],[<2>]] uref=[]
1146004: After add new value
1147005: name=String2 uset=[[<0>],[<1>],[<2>],[<3>]] uref=[]
1148006: After delete value
1149007: name=String2 uset=[[<0>],[<1>],[<3>]] uref=[]
1150008: After trying to delete a deleted value
1151009: name=String2 uset=[[<0>],[<1>],[<3>]] uref=[]
1152010: After add to other table + set of strong ref
1153011: name=String2 uset=[[<0>],[<1>],[<3>]] uref=[[<4>]]
1154012: End test
1155]])
1156
a59912a0 1157OVSDB_CHECK_IDL_PY([partial-set idl],
b3220c67
AB
1158[['["idltest", {"op":"insert", "table":"simple3", "uuid-name":"newrow",
1159 "row":{"name":"mySet1","uset":["set", [[ "uuid", "0005b872-f9e5-43be-ae02-3184b9680e75" ]]]} },
1160 {"op":"insert", "table":"simple4", "row":{"name":"seed"}},
1161 {"op":"mutate", "table":"simple3", "where":[["_uuid", "==", ["named-uuid", "newrow"]]],
1162 "mutations": [["uset", "insert", ["set", [["uuid", "000d2f6a-76af-412f-b59d-e7bcd3e84eff"]]]]]}]']
a59912a0 1163],
2d54d801 1164 ['partialrenamesetadd' 'partialduplicateadd' 'partialsetdel' 'partialsetref' 'partialsetoverrideops' 'partialsetadddelete' 'partialsetmutatenew'],
a59912a0
RM
1165[[000: name=mySet1 uset=[<0> <1>]
1166001: commit, status=success
1167002: name=String2 uset=[<0> <1> <2>]
1168003: commit, status=success
1169004: name=String2 uset=[<0> <1> <2> <3>]
1170005: commit, status=success
1171006: name=String2 uset=[<0> <1> <3>]
1172007: commit, status=success
1173008: name=String2 uset=[<0> <1> <3>]
330b9c9c
AB
1174009: commit, status=success
1175010: name=String2 uset=[<3>]
b3220c67 1176011: commit, status=success
2d54d801
AB
1177012: name=String2 uset=[<4> <5>]
1178013: commit, status=success
1179014: name=String2 uset=[<4> <5>]
1180014: name=String3 uset=[<6>]
1181015: done
a59912a0
RM
1182]])
1183
a7261bf7
NS
1184m4_define([OVSDB_CHECK_IDL_NOTIFY_PY],
1185 [AT_SETUP([$1 - Python])
1186 AT_SKIP_IF([test $HAVE_PYTHON = no])
1187 AT_KEYWORDS([ovsdb server idl Python notify $4])
56120500 1188 AT_CHECK([ovsdb_start_idltest])
a7261bf7
NS
1189 AT_CHECK([$PYTHON $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema unix:socket $2],
1190 [0], [stdout], [ignore], [kill `cat pid`])
c724bd67 1191 AT_CHECK([sort stdout | uuidfilt]m4_if([$5],,, [[| $5]]),
a7261bf7
NS
1192 [0], [$3], [], [kill `cat pid`])
1193 OVSDB_SERVER_SHUTDOWN
1194 AT_CLEANUP])
1195
d90ed7d6
NS
1196# This test uses the Python IDL implementation with ssl
1197m4_define([OVSDB_CHECK_IDL_NOTIFY_SSL_PY],
1198 [AT_SETUP([$1 - SSL])
1e96502f 1199 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
d90ed7d6 1200 AT_SKIP_IF([test $HAVE_PYTHON = no])
ca9c2c56 1201 $PYTHON -c "import OpenSSL.SSL"
d90ed7d6
NS
1202 SSL_PRESENT=$?
1203 AT_SKIP_IF([test $SSL_PRESENT != 0])
1204 AT_KEYWORDS([ovsdb server idl Python notify - ssl socket])
1205 AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema],
1206 [0], [stdout], [ignore])
1207 PKIDIR=$abs_top_builddir/tests
56120500
BP
1208 AT_CHECK([ovsdb-server -vconsole:warn --log-file --detach --no-chdir \
1209 --pidfile \
d90ed7d6
NS
1210 --private-key=$PKIDIR/testpki-privkey2.pem \
1211 --certificate=$PKIDIR/testpki-cert2.pem \
1212 --ca-cert=$PKIDIR/testpki-cacert.pem \
56120500
BP
1213 --remote=pssl:0:127.0.0.1 db])
1214 on_exit 'kill `cat ovsdb-server.pid`'
d90ed7d6
NS
1215 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
1216 AT_CHECK([$PYTHON $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema \
1217 ssl:127.0.0.1:$TCP_PORT $PKIDIR/testpki-privkey.pem \
1218 $PKIDIR/testpki-cert.pem $PKIDIR/testpki-cacert.pem $2],
1219 [0], [stdout], [ignore], [kill `cat pid`])
c724bd67 1220 AT_CHECK([sort stdout | uuidfilt]m4_if([$5],,, [[| $5]]),
d90ed7d6
NS
1221 [0], [$3], [], [kill `cat pid`])
1222 OVSDB_SERVER_SHUTDOWN
1223 AT_CLEANUP])
a7261bf7
NS
1224
1225m4_define([OVSDB_CHECK_IDL_NOTIFY],
d90ed7d6
NS
1226 [OVSDB_CHECK_IDL_NOTIFY_PY($@)
1227 OVSDB_CHECK_IDL_NOTIFY_SSL_PY($@)])
a7261bf7
NS
1228
1229OVSDB_CHECK_IDL_NOTIFY([simple idl verify notify],
1230 [['track-notify' \
1231 '["idltest",
1232 {"op": "insert",
1233 "table": "simple",
1234 "row": {"i": 1,
1235 "r": 2.0,
1236 "b": true,
1237 "s": "mystring",
1238 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
1239 "ia": ["set", [1, 2, 3]],
1240 "ra": ["set", [-0.5]],
1241 "ba": ["set", [true]],
1242 "sa": ["set", ["abc", "def"]],
1243 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
1244 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
1245 {"op": "insert",
1246 "table": "simple",
1247 "row": {}}]' \
1248 '["idltest",
1249 {"op": "update",
1250 "table": "simple",
1251 "where": [],
1252 "row": {"b": false}}]' \
1253 '["idltest",
1254 {"op": "update",
1255 "table": "simple",
1256 "where": [],
1257 "row": {"r": 123.5}}]' \
1258 '["idltest",
1259 {"op": "insert",
1260 "table": "simple",
1261 "row": {"i": -1,
1262 "r": 125,
1263 "b": false,
1264 "s": "",
1265 "ia": ["set", [1]],
1266 "ra": ["set", [1.5]],
1267 "ba": ["set", [false]],
1268 "sa": ["set", []],
1269 "ua": ["set", []]}}]' \
1270 '["idltest",
1271 {"op": "update",
1272 "table": "simple",
1273 "where": [["i", "<", 1]],
1274 "row": {"s": "newstring"}}]' \
1275 '["idltest",
1276 {"op": "delete",
1277 "table": "simple",
1278 "where": [["i", "==", 0]]}]' \
1279 'reconnect']],
1280 [[000: empty
1281001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
1282002: event:create, row={i=0 r=0 b=false s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>}, updates=None
1283002: event:create, row={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>}, updates=None
1284002: i=0 r=0 b=false s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
1285002: 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>
1286003: {"error":null,"result":[{"count":2}]}
1287004: event:update, row={i=1 r=2 b=false s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<4> <5>] uuid=<0>}, updates={b=true uuid=<0>}
1288004: i=0 r=0 b=false s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
1289004: i=1 r=2 b=false s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<4> <5>] uuid=<0>
1290005: {"error":null,"result":[{"count":2}]}
1291006: event:update, row={i=0 r=123.5 b=false s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>}, updates={r=0 uuid=<1>}
1292006: event:update, row={i=1 r=123.5 b=false s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<4> <5>] uuid=<0>}, updates={r=2 uuid=<0>}
1293006: i=0 r=123.5 b=false s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
1294006: i=1 r=123.5 b=false s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<4> <5>] uuid=<0>
1295007: {"error":null,"result":[{"uuid":["uuid","<6>"]}]}
1296008: event:create, row={i=-1 r=125 b=false s= u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>}, updates=None
1297008: i=-1 r=125 b=false s= u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
1298008: i=0 r=123.5 b=false s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
1299008: i=1 r=123.5 b=false s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<4> <5>] uuid=<0>
1300009: {"error":null,"result":[{"count":2}]}
1301010: event:update, row={i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>}, updates={s= uuid=<6>}
1302010: event:update, row={i=0 r=123.5 b=false s=newstring u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>}, updates={s= uuid=<1>}
1303010: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
1304010: i=0 r=123.5 b=false s=newstring u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
1305010: i=1 r=123.5 b=false s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<4> <5>] uuid=<0>
1306011: {"error":null,"result":[{"count":1}]}
1307012: event:delete, row={i=0 r=123.5 b=false s=newstring u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>}, updates=None
1308012: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
1309012: i=1 r=123.5 b=false s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<4> <5>] uuid=<0>
1310013: reconnect
1311014: event:create, row={i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>}, updates=None
1312014: event:create, row={i=1 r=123.5 b=false s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<4> <5>] uuid=<0>}, updates=None
1313014: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
1314014: i=1 r=123.5 b=false s=mystring u=<3> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<4> <5>] uuid=<0>
1315015: done
1316]])
0a8606ee
LR
1317
1318# Tests to verify the functionality of the one column compound index.
1319# It tests index for one column string and integer indexes.
1320# The run of test-ovsdb generates the output of the display of data using the different indexes defined in
1321# the program.
1322# Then, some at_checks are used to verify the correctness of the corresponding index as well as the existence
1323# of all the rows involved in the test.
1324m4_define([OVSDB_CHECK_IDL_COMPOUND_INDEX_SINGLE_COLUMN_C],
1325 [AT_SETUP([$1 - C])
1326 AT_KEYWORDS([ovsdb server idl compound_index_single_column compound_index positive $5])
1327 AT_CHECK([ovsdb_start_idltest])
1328 m4_if([$2], [], [],
1329 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore], [kill `cat pid`])])
1330# Generate the data to be tested.
1331 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-compound-index unix:socket $3],
1332 [0], [stdout], [ignore], [kill `cat pid`])
1333# Filter the rows of data that corresponds to the string index eliminating the extra columns of data.
1334# This is done to verifiy that the output data is in the correct and expected order.
1335 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: s=.*' | sed -e 's/ i=.*//g']],
1336 [0], [$4], [], [kill `cat pid`])
1337# Here, the data is filtered and sorted in order to have all the rows in the index and be
1338# able to determined that all the involved rows are present.
1339 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: s=.*' | sort -k 1,1n -k 2,2 -k 3,3]],
1340 [0], [$5], [], [kill `cat pid`])
1341# Filter the rows of data that corresponds to the integer index eliminating the extra columns of data.
1342# This is done to verifiy that the output data is in the correct and expected order.
1343 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: i=.*' | sed -e 's/ s=.*//g']],
1344 [0], [$6], [], [kill `cat pid`])
1345# Here again, the data is filtered and sorted in order to have all the rows in the index and be
1346# able to determined that all the involved rows are present.
1347 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: i=.*' | sort -k 1,1n -k 2,2 -k 3,3]],
1348 [0], [$7], [], [kill `cat pid`])
1349 OVSDB_SERVER_SHUTDOWN
1350 AT_CLEANUP])
1351
1352OVSDB_CHECK_IDL_COMPOUND_INDEX_SINGLE_COLUMN_C([Compound_index, single column test ],
1353 [['["idltest",
1354 {"op": "insert", "table": "simple", "row": {"s":"List000", "i": 1, "b":true, "r":101.0}},
1355 {"op": "insert", "table": "simple", "row": {"s":"List000", "i": 2, "b":false, "r":102.0}},
1356 {"op": "insert", "table": "simple", "row": {"s":"List000", "i": 10, "b":true, "r":110.0}},
1357 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 1, "b":false, "r":110.0}},
1358 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 2, "b":true, "r":120.0}},
1359 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 2, "b":true, "r":122.0}},
1360 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 4, "b":true, "r":130.0}},
1361 {"op": "insert", "table": "simple", "row": {"s":"List005", "i": 5, "b":true, "r":130.0}},
1362 {"op": "insert", "table": "simple", "row": {"s":"List020", "i": 20, "b":true, "r":220.0}},
1363 {"op": "insert", "table": "simple", "row": {"s":"List020", "i": 19, "b":true, "r":219.0}}
1364 ]']],
1365 [idl_compound_index_single_column],
1366 [001: s=List000
1367001: s=List000
1368001: s=List000
1369001: s=List001
1370001: s=List001
1371001: s=List001
1372001: s=List001
1373001: s=List005
1374001: s=List020
1375001: s=List020
1376003: s=List001
1377003: s=List001
1378003: s=List001
1379003: s=List001
1380],
1381[001: s=List000 i=1 b=True r=101.000000
1382001: s=List000 i=10 b=True r=110.000000
1383001: s=List000 i=2 b=False r=102.000000
1384001: s=List001 i=1 b=False r=110.000000
1385001: s=List001 i=2 b=True r=120.000000
1386001: s=List001 i=2 b=True r=122.000000
1387001: s=List001 i=4 b=True r=130.000000
1388001: s=List005 i=5 b=True r=130.000000
1389001: s=List020 i=19 b=True r=219.000000
1390001: s=List020 i=20 b=True r=220.000000
1391003: s=List001 i=1 b=False r=110.000000
1392003: s=List001 i=2 b=True r=120.000000
1393003: s=List001 i=2 b=True r=122.000000
1394003: s=List001 i=4 b=True r=130.000000
1395],
1396[002: i=1
1397002: i=1
1398002: i=2
1399002: i=2
1400002: i=2
1401002: i=4
1402002: i=5
1403002: i=10
1404002: i=19
1405002: i=20
1406004: i=5
1407005: i=4
1408005: i=5
1409006: i=5
1410006: i=10
1411006: i=19
1412006: i=20
1413006: i=54
1414007: i=1
1415007: i=1
1416007: i=2
1417007: i=2
1418007: i=2
1419007: i=5
1420007: i=10
1421007: i=19
1422007: i=20
1423007: i=54
1424],
1425[002: i=1 s=List000 b=True r=101.000000
1426002: i=1 s=List001 b=False r=110.000000
1427002: i=10 s=List000 b=True r=110.000000
1428002: i=19 s=List020 b=True r=219.000000
1429002: i=2 s=List000 b=False r=102.000000
1430002: i=2 s=List001 b=True r=120.000000
1431002: i=2 s=List001 b=True r=122.000000
1432002: i=20 s=List020 b=True r=220.000000
1433002: i=4 s=List001 b=True r=130.000000
1434002: i=5 s=List005 b=True r=130.000000
1435004: i=5 s=List005 b=True r=130.000000
1436005: i=4 s=List001 b=True r=130.000000
1437005: i=5 s=List005 b=True r=130.000000
1438006: i=10 s=List000 b=True r=110.000000
1439006: i=19 s=List020 b=True r=219.000000
1440006: i=20 s=List020 b=True r=220.000000
1441006: i=5 s=List005 b=True r=130.000000
1442006: i=54 s=Lista054 b=False r=0.000000
1443007: i=1 s=List000 b=True r=101.000000
1444007: i=1 s=List001 b=False r=110.000000
1445007: i=10 s=List000 b=True r=110.000000
1446007: i=19 s=List020 b=True r=219.000000
1447007: i=2 s=List000 b=False r=102.000000
1448007: i=2 s=List001 b=True r=120.000000
1449007: i=2 s=List001 b=True r=122.000000
1450007: i=20 s=List020 b=True r=220.000000
1451007: i=5 s=List005 b=True r=130.000000
1452007: i=54 s=Lista054 b=False r=0.000000
1453])
1454
1455# Tests to verify the functionality of two column compound index.
1456# It tests index for two columns using string and integer fields.
1457# The run of test-ovsdb generates the output of the display of data using the different indexes defined in
1458# the program.
1459# Then, some at_checks are used to verify the correctness of the corresponding index as well as the existence
1460# of all the rows involved in the test.
1461m4_define([OVSDB_CHECK_IDL_COMPOUND_INDEX_DOUBLE_COLUMN_C],
1462 [AT_SETUP([$1 - C])
1463 AT_KEYWORDS([ovsdb server idl compound_index_double_column compound_index positive $5])
1464 AT_CHECK([ovsdb_start_idltest])
1465 m4_if([$2], [], [],
1466 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore], [kill `cat pid`])])
1467# Generate the data to be tested.
1468 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-compound-index unix:socket $3],
1469 [0], [stdout], [ignore], [kill `cat pid`])
1470# Filter the rows of data that corresponds to the string-integer index eliminating the extra columns of data.
1471# This is done to verifiy that the output data is in the correct and expected order.
1472 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: s=.*' | sed -e 's/ b=.*//g']],
1473 [0], [$4], [], [kill `cat pid`])
1474# Here, the data is filtered and sorted in order to have all the rows in the index and be
1475# able to determined that all the involved rows are present.
1476 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: s=.*' | sort -k 1,1n -k 2,2 -k 3,3]],
1477 [0], [$5], [], [kill `cat pid`])
1478# Filter the rows of data that corresponds to the integer index eliminating the extra columns of data.
1479# This is done to verifiy that the output data is in the correct and expected order.
1480 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: i=.*' | sed -e 's/ b=.*//g']],
1481 [0], [$6], [], [kill `cat pid`])
1482# Here again, the data is filtered and sorted in order to have all the rows in the index and be
1483# able to determined that all the involved rows are present.
1484 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: i=.*' | sort -k 1,1n -k 2,2 -k 3,3]],
1485 [0], [$7], [], [kill `cat pid`])
1486 OVSDB_SERVER_SHUTDOWN
1487 AT_CLEANUP])
1488
1489OVSDB_CHECK_IDL_COMPOUND_INDEX_DOUBLE_COLUMN_C([Compound_index, double column test ],
1490 [['["idltest",
1491 {"op": "insert", "table": "simple", "row": {"s":"List000", "i": 1, "b":true, "r":101.0}},
1492 {"op": "insert", "table": "simple", "row": {"s":"List000", "i": 2, "b":false, "r":102.0}},
1493 {"op": "insert", "table": "simple", "row": {"s":"List000", "i": 10, "b":true, "r":110.0}},
1494 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 1, "b":false, "r":110.0}},
1495 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 2, "b":true, "r":120.0}},
1496 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 2, "b":true, "r":122.0}},
1497 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 4, "b":true, "r":130.0}},
1498 {"op": "insert", "table": "simple", "row": {"s":"List005", "i": 5, "b":true, "r":130.0}},
1499 {"op": "insert", "table": "simple", "row": {"s":"List020", "i": 20, "b":true, "r":220.0}},
1500 {"op": "insert", "table": "simple", "row": {"s":"List020", "i": 19, "b":true, "r":219.0}}
1501 ]']],
1502 [idl_compound_index_double_column],
1503 [001: s=List000 i=1
1504001: s=List000 i=2
1505001: s=List000 i=10
1506001: s=List001 i=1
1507001: s=List001 i=2
1508001: s=List001 i=2
1509001: s=List001 i=4
1510001: s=List005 i=5
1511001: s=List020 i=19
1512001: s=List020 i=20
1513002: s=List000 i=10
1514002: s=List000 i=2
1515002: s=List000 i=1
1516002: s=List001 i=4
1517002: s=List001 i=2
1518002: s=List001 i=2
1519002: s=List001 i=1
1520002: s=List005 i=5
1521002: s=List020 i=20
1522002: s=List020 i=19
1523003: s=List000 i=10
1524004: s=List001 i=1
1525004: s=List001 i=2
1526004: s=List001 i=2
1527004: s=List001 i=4
1528004: s=List005 i=5
1529],
1530 [001: s=List000 i=1 b=True r=101.000000
1531001: s=List000 i=10 b=True r=110.000000
1532001: s=List000 i=2 b=False r=102.000000
1533001: s=List001 i=1 b=False r=110.000000
1534001: s=List001 i=2 b=True r=120.000000
1535001: s=List001 i=2 b=True r=122.000000
1536001: s=List001 i=4 b=True r=130.000000
1537001: s=List005 i=5 b=True r=130.000000
1538001: s=List020 i=19 b=True r=219.000000
1539001: s=List020 i=20 b=True r=220.000000
1540002: s=List000 i=1 b=True r=101.000000
1541002: s=List000 i=10 b=True r=110.000000
1542002: s=List000 i=2 b=False r=102.000000
1543002: s=List001 i=1 b=False r=110.000000
1544002: s=List001 i=2 b=True r=120.000000
1545002: s=List001 i=2 b=True r=122.000000
1546002: s=List001 i=4 b=True r=130.000000
1547002: s=List005 i=5 b=True r=130.000000
1548002: s=List020 i=19 b=True r=219.000000
1549002: s=List020 i=20 b=True r=220.000000
1550003: s=List000 i=10 b=True r=110.000000
1551004: s=List001 i=1 b=False r=110.000000
1552004: s=List001 i=2 b=True r=120.000000
1553004: s=List001 i=2 b=True r=122.000000
1554004: s=List001 i=4 b=True r=130.000000
1555004: s=List005 i=5 b=True r=130.000000
1556],
1557 [005: i=1 s=List000
1558005: i=1 s=List001
1559005: i=2 s=List000
1560005: i=2 s=List001
1561005: i=2 s=List001
1562005: i=4 s=List001
1563005: i=5 s=List005
1564005: i=10 s=List000
1565005: i=19 s=List020
1566005: i=20 s=List020
1567006: i=20 s=List020
1568006: i=19 s=List020
1569006: i=10 s=List000
1570006: i=5 s=List005
1571006: i=4 s=List001
1572006: i=2 s=List000
1573006: i=2 s=List001
1574006: i=2 s=List001
1575006: i=1 s=List000
1576006: i=1 s=List001
1577],
1578 [005: i=1 s=List000 b=True r=101.000000
1579005: i=1 s=List001 b=False r=110.000000
1580005: i=10 s=List000 b=True r=110.000000
1581005: i=19 s=List020 b=True r=219.000000
1582005: i=2 s=List000 b=False r=102.000000
1583005: i=2 s=List001 b=True r=120.000000
1584005: i=2 s=List001 b=True r=122.000000
1585005: i=20 s=List020 b=True r=220.000000
1586005: i=4 s=List001 b=True r=130.000000
1587005: i=5 s=List005 b=True r=130.000000
1588006: i=1 s=List000 b=True r=101.000000
1589006: i=1 s=List001 b=False r=110.000000
1590006: i=10 s=List000 b=True r=110.000000
1591006: i=19 s=List020 b=True r=219.000000
1592006: i=2 s=List000 b=False r=102.000000
1593006: i=2 s=List001 b=True r=120.000000
1594006: i=2 s=List001 b=True r=122.000000
1595006: i=20 s=List020 b=True r=220.000000
1596006: i=4 s=List001 b=True r=130.000000
1597006: i=5 s=List005 b=True r=130.000000
1598])
3cc1634f
HZ
1599
1600m4_define([OVSDB_CHECK_IDL_COMPOUND_INDEX_WITH_REF],
1601 [AT_SETUP([$1 - C])
1602 AT_KEYWORDS([ovsdb server idl compound_index compound_index_with_ref positive $5])
1603 AT_CHECK([ovsdb_start_idltest])
1604 m4_if([$2], [], [],
1605 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
1606 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-compound-index-with-ref unix:socket $3],
1607 [0], [stdout], [ignore])
c724bd67 1608 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
3cc1634f
HZ
1609 [0], [$4])
1610 OVSDB_SERVER_SHUTDOWN
1611 AT_CLEANUP])
1612
1613OVSDB_CHECK_IDL_COMPOUND_INDEX_WITH_REF([set, simple3 idl-compound-index-with-ref, initially populated],
1614[],
1615[],
1616[[000: After add to other table + set of strong ref
1617001: name= uset=[] uref=[[<0>]]
1618002: check simple4: not empty
1619003: Query using index with reference
1620004: name= uset=[] uref=[[<0>]]
1621005: After delete
1622007: check simple4: empty
1623008: End test
1624]])