]> git.proxmox.com Git - ovs.git/blame - tests/ovsdb-idl.at
Require Python 3 and remove support for Python 2.
[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}
c39751e4
TE
14
15# ovsdb_cluster_start_idltest [REMOTE] [SCHEMA]
16#
17# Creates a database using SCHEMA (default: idltest.ovsschema) and
18# starts a database cluster listening on punix:socket and REMOTE (if
19# specified).
20ovsdb_cluster_start_idltest () {
21 local n=$1
22 ovsdb-tool create-cluster s1.db $abs_srcdir/idltest.ovsschema unix:s1.raft || return $?
23 cid=`ovsdb-tool db-cid s1.db`
24 schema_name=`ovsdb-tool schema-name $abs_srcdir/idltest.ovsschema`
25 for i in `seq 2 $n`; do
26 ovsdb-tool join-cluster s$i.db $schema_name unix:s$i.raft unix:s1.raft || return $?
27 done
28 for i in `seq $n`; do
29 ovsdb-server -vraft -vconsole:warn --detach --no-chdir --log-file=s$i.log --pidfile=s$i.pid --unixctl=s$i --remote=punix:s$i.ovsdb ${2:+--remote=$2} s$i.db || return $?
30 done
31 on_exit 'kill `cat s*.pid`'
32}
33
34# ovsdb_cluster_leader [REMOTES] [DATABASE]
35#
36# Returns the leader of the DATABASE cluster.
37ovsdb_cluster_leader () {
38 remotes=$(echo $1 | tr "," "\n")
39 for remote in $remotes; do
40 ovsdb-client dump $remote _Server Database name leader | grep $2 | grep -q true
41 if [[ $? == 0 ]]; then
42 port=$(echo $remote | cut -d':' -f 3)
43 log=$(grep --include=s\*.log -rlnw -e "listening on port $port" ./)
44 pid=$(echo $log | sed 's/\(.*\.\)log/\1pid/' )
45 echo "${remote}|${pid}"
46 return
47 fi
48 done
49}])
56120500 50
8cdf0349
BP
51# OVSDB_CHECK_IDL_C(TITLE, [PRE-IDL-TXN], TRANSACTIONS, OUTPUT, [KEYWORDS],
52# [FILTER])
c3bb4bd7
BP
53#
54# Creates a database with a schema derived from idltest.ovsidl, runs
55# each PRE-IDL-TXN (if any), starts an ovsdb-server on that database,
56# and runs "test-ovsdb idl" passing each of the TRANSACTIONS along.
57#
58# Checks that the overall output is OUTPUT. Before comparison, the
59# output is sorted (using "sort") and UUIDs in the output are replaced
60# by markers of the form <N> where N is a number. The first unique
61# UUID is replaced by <0>, the next by <1>, and so on. If a given
62# UUID appears more than once it is always replaced by the same
254604d8
BP
63# marker. If FILTER is supplied then the output is also filtered
64# through the specified program.
c3bb4bd7
BP
65#
66# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
8cdf0349
BP
67m4_define([OVSDB_CHECK_IDL_C],
68 [AT_SETUP([$1 - C])
c3bb4bd7 69 AT_KEYWORDS([ovsdb server idl positive $5])
56120500 70 AT_CHECK([ovsdb_start_idltest])
c3bb4bd7 71 m4_if([$2], [], [],
7427f2a4 72 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
8cdf0349 73 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl unix:socket $3],
7427f2a4 74 [0], [stdout], [ignore])
c724bd67 75 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 76 [0], [$4])
028cbd99 77 OVSDB_SERVER_SHUTDOWN
c3bb4bd7
BP
78 AT_CLEANUP])
79
b481a4cc
IM
80# same as OVSDB_CHECK_IDL but uses tcp.
81m4_define([OVSDB_CHECK_IDL_TCP_C],
82 [AT_SETUP([$1 - C - tcp])
83 AT_KEYWORDS([ovsdb server idl positive tcp socket $5])
84 AT_CHECK([ovsdb_start_idltest "ptcp:0:127.0.0.1"])
85 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
86
87 m4_if([$2], [], [],
88 [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT $2], [0], [ignore], [ignore])])
89 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl tcp:127.0.0.1:$TCP_PORT $3],
90 [0], [stdout], [ignore])
91 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
92 [0], [$4])
93 OVSDB_SERVER_SHUTDOWN
94 AT_CLEANUP])
95
96# same as OVSDB_CHECK_IDL but uses tcp6.
97m4_define([OVSDB_CHECK_IDL_TCP6_C],
98 [AT_SETUP([$1 - C - tcp6])
99 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
100 AT_SKIP_IF([test $HAVE_IPV6 = no])
101 AT_KEYWORDS([ovsdb server idl positive tcp6 socket $5])
102 AT_CHECK([ovsdb_start_idltest "ptcp:0:[[::1]]"])
103 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
104
105 m4_if([$2], [], [],
106 [AT_CHECK([ovsdb-client transact tcp:[[::1]]:$TCP_PORT $2], [0], [ignore], [ignore])])
107 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl tcp:[[::1]]:$TCP_PORT $3],
108 [0], [stdout], [ignore])
109 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
110 [0], [$4])
111 OVSDB_SERVER_SHUTDOWN
112 AT_CLEANUP])
113
8cdf0349 114# same as OVSDB_CHECK_IDL but uses the Python IDL implementation.
1ca0323e
BP
115m4_define([OVSDB_CHECK_IDL_PY],
116 [AT_SETUP([$1 - Python3])
8cdf0349 117 AT_KEYWORDS([ovsdb server idl positive Python $5])
56120500 118 AT_CHECK([ovsdb_start_idltest])
8cdf0349 119 m4_if([$2], [], [],
7427f2a4 120 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
1ca0323e 121 AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema unix:socket $3],
7427f2a4 122 [0], [stdout], [ignore])
c724bd67 123 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 124 [0], [$4])
8cdf0349
BP
125 OVSDB_SERVER_SHUTDOWN
126 AT_CLEANUP])
127
1ca0323e
BP
128m4_define([OVSDB_CHECK_IDL_REGISTER_COLUMNS_PY],
129 [AT_SETUP([$1 - Python3 - register_columns])
01dc1516 130 AT_KEYWORDS([ovsdb server idl positive Python register_columns $5])
56120500 131 AT_CHECK([ovsdb_start_idltest])
01dc1516 132 m4_if([$2], [], [],
7427f2a4 133 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
1ca0323e 134 AT_CHECK([$PYTHON3 $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?singleton:name $3],
7427f2a4 135 [0], [stdout], [ignore])
c724bd67 136 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 137 [0], [$4])
01dc1516
SA
138 OVSDB_SERVER_SHUTDOWN
139 AT_CLEANUP])
140
e06d06a7 141# same as OVSDB_CHECK_IDL but uses the Python IDL implementation with tcp
1ca0323e
BP
142m4_define([OVSDB_CHECK_IDL_TCP_PY],
143 [AT_SETUP([$1 - Python3 - tcp])
e06d06a7 144 AT_KEYWORDS([ovsdb server idl positive Python with tcp socket $5])
56120500 145 AT_CHECK([ovsdb_start_idltest "ptcp:0:127.0.0.1"])
fb28ef2d 146 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
1e04fcc8 147
e06d06a7 148 m4_if([$2], [], [],
7427f2a4 149 [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT $2], [0], [ignore], [ignore])])
1ca0323e 150 AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema tcp:127.0.0.1:$TCP_PORT $3],
7427f2a4 151 [0], [stdout], [ignore])
c724bd67 152 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 153 [0], [$4])
e06d06a7
IY
154 OVSDB_SERVER_SHUTDOWN
155 AT_CLEANUP])
156
31e434fc
NS
157# same as OVSDB_CHECK_IDL but uses the Python IDL implementation with tcp
158# with multiple remotes with only one remote reachable
1ca0323e
BP
159m4_define([OVSDB_CHECK_IDL_TCP_MULTIPLE_REMOTES_PY],
160 [AT_SETUP([$1 - Python3 (multiple remotes) - tcp])
31e434fc
NS
161 AT_KEYWORDS([ovsdb server idl positive Python with tcp socket $5])
162 AT_CHECK([ovsdb_start_idltest "ptcp:0:127.0.0.1"])
163 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
fe495d0c
IM
164 WRONG_PORT_1=$((TCP_PORT + 101))
165 WRONG_PORT_2=$((TCP_PORT + 102))
31e434fc
NS
166 remote=tcp:127.0.0.1:$WRONG_PORT_1,tcp:127.0.0.1:$TCP_PORT,tcp:127.0.0.1:$WRONG_PORT_2
167 m4_if([$2], [], [],
168 [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT $2], [0], [ignore], [ignore])])
1ca0323e 169 AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py -t20 idl $srcdir/idltest.ovsschema $remote $3],
31e434fc
NS
170 [0], [stdout], [ignore])
171 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
172 [0], [$4])
173 OVSDB_SERVER_SHUTDOWN
174 AT_CLEANUP])
175
e731d71b 176# same as OVSDB_CHECK_IDL but uses the Python IDL implementation with tcp6
1ca0323e
BP
177m4_define([OVSDB_CHECK_IDL_TCP6_PY],
178 [AT_SETUP([$1 - Python3 - tcp6])
7b9d1b65 179 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
4819b3a5 180 AT_SKIP_IF([test $HAVE_IPV6 = no])
e731d71b 181 AT_KEYWORDS([ovsdb server idl positive Python with tcp6 socket $5])
56120500 182 AT_CHECK([ovsdb_start_idltest "ptcp:0:[[::1]]"])
fb28ef2d 183 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
e731d71b
AS
184 echo "TCP_PORT=$TCP_PORT"
185
186 m4_if([$2], [], [],
7427f2a4 187 [AT_CHECK([ovsdb-client transact "tcp:[[::1]]:$TCP_PORT" $2], [0], [ignore], [ignore])])
1ca0323e 188 AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema tcp:[[::1]]:$TCP_PORT $3],
7427f2a4 189 [0], [stdout], [ignore])
c724bd67 190 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 191 [0], [$4])
e731d71b
AS
192 OVSDB_SERVER_SHUTDOWN
193 AT_CLEANUP])
194
1ca0323e
BP
195m4_define([OVSDB_CHECK_IDL_TCP6_MULTIPLE_REMOTES_PY],
196 [AT_SETUP([$1 - Python3 - tcp6])
31e434fc
NS
197 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
198 AT_SKIP_IF([test $HAVE_IPV6 = no])
199 AT_KEYWORDS([ovsdb server idl positive Python with tcp6 socket $5])
200 AT_CHECK([ovsdb_start_idltest "ptcp:0:[[::1]]"])
201 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
fe495d0c
IM
202 WRONG_PORT_1=$((TCP_PORT + 101))
203 WRONG_PORT_2=$((TCP_PORT + 102))
31e434fc
NS
204 remote="tcp:[[::1]]:$WRONG_PORT_1,tcp:[[::1]]:$TCP_PORT,tcp:[[::1]]:$WRONG_PORT_2"
205 m4_if([$2], [], [],
206 [AT_CHECK([ovsdb-client transact "tcp:[[::1]]:$TCP_PORT" $2], [0], [ignore], [ignore])])
1ca0323e 207 AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py -t20 idl $srcdir/idltest.ovsschema $remote $3],
31e434fc
NS
208 [0], [stdout], [ignore])
209 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
210 [0], [$4])
211 OVSDB_SERVER_SHUTDOWN
212 AT_CLEANUP])
213
61845323 214# same as OVSDB_CHECK_IDL but uses the Python IDL implementation with SSL
1ca0323e
BP
215m4_define([OVSDB_CHECK_IDL_SSL_PY],
216 [AT_SETUP([$1 - Python3 - SSL])
61845323 217 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
1ca0323e 218 $PYTHON3 -c "import OpenSSL.SSL"
61845323
JS
219 SSL_PRESENT=$?
220 AT_SKIP_IF([test $SSL_PRESENT != 0])
221 AT_KEYWORDS([ovsdb server idl positive Python with ssl socket $5])
222 AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema],
223 [0], [stdout], [ignore])
224 PKIDIR=$abs_top_builddir/tests
225 AT_CHECK([ovsdb-server -vconsole:warn --log-file --detach --no-chdir \
226 --pidfile \
227 --private-key=$PKIDIR/testpki-privkey2.pem \
228 --certificate=$PKIDIR/testpki-cert2.pem \
229 --ca-cert=$PKIDIR/testpki-cacert.pem \
230 --remote=pssl:0:127.0.0.1 db])
231 on_exit 'kill `cat ovsdb-server.pid`'
232 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
233 m4_if([$2], [], [],
234 [AT_CHECK([ovsdb-client \
235 --private-key=$PKIDIR/testpki-privkey2.pem \
236 --certificate=$PKIDIR/testpki-cert2.pem \
237 --ca-cert=$PKIDIR/testpki-cacert.pem \
238 transact "ssl:127.0.0.1:$TCP_PORT" $2], [0], [ignore], [ignore])])
1ca0323e 239 AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema \
61845323
JS
240 ssl:127.0.0.1:$TCP_PORT $PKIDIR/testpki-privkey.pem \
241 $PKIDIR/testpki-cert.pem $PKIDIR/testpki-cacert.pem $3],
242 [0], [stdout], [ignore])
243 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
244 [0], [$4])
245 OVSDB_SERVER_SHUTDOWN
246 AT_CLEANUP])
247
8cdf0349
BP
248m4_define([OVSDB_CHECK_IDL],
249 [OVSDB_CHECK_IDL_C($@)
b481a4cc
IM
250 OVSDB_CHECK_IDL_TCP_C($@)
251 OVSDB_CHECK_IDL_TCP6_C($@)
e06d06a7 252 OVSDB_CHECK_IDL_PY($@)
01dc1516 253 OVSDB_CHECK_IDL_REGISTER_COLUMNS_PY($@)
e731d71b 254 OVSDB_CHECK_IDL_TCP_PY($@)
31e434fc 255 OVSDB_CHECK_IDL_TCP_MULTIPLE_REMOTES_PY($@)
61845323 256 OVSDB_CHECK_IDL_TCP6_PY($@)
31e434fc 257 OVSDB_CHECK_IDL_TCP6_MULTIPLE_REMOTES_PY($@)
61845323 258 OVSDB_CHECK_IDL_SSL_PY($@)])
8cdf0349 259
af358237 260# This test uses the Python IDL implementation with passive tcp
1ca0323e
BP
261m4_define([OVSDB_CHECK_IDL_PASSIVE_TCP_PY],
262 [AT_SETUP([$1 - Python3 - ptcp])
af358237 263 AT_KEYWORDS([ovsdb server idl positive Python with tcp socket $5])
af358237 264 # find free TCP port
56120500 265 AT_CHECK([ovsdb_start_idltest "ptcp:0:127.0.0.1"])
af358237 266 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
7427f2a4 267 OVSDB_SERVER_SHUTDOWN
56120500 268 rm -f db
af358237
OBY
269
270 # start OVSDB server in passive mode
56120500 271 AT_CHECK([ovsdb_start_idltest "tcp:127.0.0.1:$TCP_PORT"])
1ca0323e 272 AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py -t10 idl_passive $srcdir/idltest.ovsschema ptcp:127.0.0.1:$TCP_PORT $3],
7427f2a4 273 [0], [stdout], [ignore])
c724bd67 274 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4
DDP
275 [0], [$4])
276 OVSDB_SERVER_SHUTDOWN
af358237
OBY
277 AT_CLEANUP
278 ])
279
280OVSDB_CHECK_IDL_PASSIVE_TCP_PY([simple passive idl, initially empty, select empty],
281 [],
282 [['["idltest",{"op":"select","table":"link1","where":[]}]']],
283 [[000: empty
284001: {"error":null,"result":[{"rows":[]}]}
285002: done
286]])
287
c3bb4bd7
BP
288OVSDB_CHECK_IDL([simple idl, initially empty, no ops],
289 [],
290 [],
291 [000: empty
292001: done
293])
294
295OVSDB_CHECK_IDL([simple idl, initially empty, various ops],
296 [],
9cb53f26
BP
297 [['["idltest",
298 {"op": "insert",
c3bb4bd7
BP
299 "table": "simple",
300 "row": {"i": 1,
301 "r": 2.0,
302 "b": true,
303 "s": "mystring",
304 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
305 "ia": ["set", [1, 2, 3]],
306 "ra": ["set", [-0.5]],
7fae24e6 307 "ba": ["set", [true]],
8cdf0349 308 "sa": ["set", ["abc", "def"]],
c3bb4bd7
BP
309 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
310 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
311 {"op": "insert",
312 "table": "simple",
313 "row": {}}]' \
9cb53f26
BP
314 '["idltest",
315 {"op": "update",
c3bb4bd7
BP
316 "table": "simple",
317 "where": [],
318 "row": {"b": true}}]' \
9cb53f26
BP
319 '["idltest",
320 {"op": "update",
c3bb4bd7
BP
321 "table": "simple",
322 "where": [],
323 "row": {"r": 123.5}}]' \
9cb53f26
BP
324 '["idltest",
325 {"op": "insert",
c3bb4bd7
BP
326 "table": "simple",
327 "row": {"i": -1,
328 "r": 125,
329 "b": false,
330 "s": "",
331 "ia": ["set", [1]],
332 "ra": ["set", [1.5]],
333 "ba": ["set", [false]],
8cdf0349 334 "sa": ["set", []],
c3bb4bd7 335 "ua": ["set", []]}}]' \
9cb53f26
BP
336 '["idltest",
337 {"op": "update",
c3bb4bd7
BP
338 "table": "simple",
339 "where": [["i", "<", 1]],
340 "row": {"s": "newstring"}}]' \
9cb53f26
BP
341 '["idltest",
342 {"op": "delete",
c3bb4bd7
BP
343 "table": "simple",
344 "where": [["i", "==", 0]]}]' \
345 'reconnect']],
346 [[000: empty
347001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
348002: i=0 r=0 b=false s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 349002: 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
350003: {"error":null,"result":[{"count":2}]}
351004: i=0 r=0 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 352004: 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
353005: {"error":null,"result":[{"count":2}]}
354006: i=0 r=123.5 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 355006: 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
356007: {"error":null,"result":[{"uuid":["uuid","<6>"]}]}
357008: i=-1 r=125 b=false s= u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
358008: i=0 r=123.5 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 359008: 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
360009: {"error":null,"result":[{"count":2}]}
361010: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
362010: i=0 r=123.5 b=true s=newstring u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 363010: 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
364011: {"error":null,"result":[{"count":1}]}
365012: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
7fae24e6 366012: 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
367013: reconnect
368014: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
7fae24e6 369014: 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
370015: done
371]])
372
373OVSDB_CHECK_IDL([simple idl, initially populated],
9cb53f26
BP
374 [['["idltest",
375 {"op": "insert",
c3bb4bd7
BP
376 "table": "simple",
377 "row": {"i": 1,
378 "r": 2.0,
379 "b": true,
380 "s": "mystring",
381 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
382 "ia": ["set", [1, 2, 3]],
383 "ra": ["set", [-0.5]],
7fae24e6 384 "ba": ["set", [true]],
8cdf0349 385 "sa": ["set", ["abc", "def"]],
c3bb4bd7
BP
386 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
387 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
388 {"op": "insert",
389 "table": "simple",
390 "row": {}}]']],
9cb53f26
BP
391 [['["idltest",
392 {"op": "update",
c3bb4bd7
BP
393 "table": "simple",
394 "where": [],
395 "row": {"b": true}}]']],
396 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 397000: 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
398001: {"error":null,"result":[{"count":2}]}
399002: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 400002: 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
401003: done
402]])
403
475281c0 404OVSDB_CHECK_IDL([simple idl, writing via IDL],
9cb53f26
BP
405 [['["idltest",
406 {"op": "insert",
475281c0
BP
407 "table": "simple",
408 "row": {"i": 1,
409 "r": 2.0,
410 "b": true,
411 "s": "mystring",
412 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
413 "ia": ["set", [1, 2, 3]],
414 "ra": ["set", [-0.5]],
7fae24e6 415 "ba": ["set", [true]],
8cdf0349 416 "sa": ["set", ["abc", "def"]],
475281c0
BP
417 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
418 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
419 {"op": "insert",
420 "table": "simple",
421 "row": {}}]']],
a91c6104
BP
422 [['verify 0 b, verify 1 r, set 0 b 1, set 1 r 3.5' \
423 'insert 2, verify 2 i, verify 1 b, delete 1']],
475281c0 424 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 425000: 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
426001: commit, status=success
427002: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 428002: 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
429003: commit, status=success
430004: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
431004: i=2 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<6>
432005: done
433]])
434
e7164d96
LR
435OVSDB_CHECK_IDL([simple idl, writing via IDL with unicode],
436 [['["idltest",
437 {"op": "insert",
438 "table": "simple",
439 "row": {"s": "(╯°□°)╯︵ ┻━┻"}}]']],
440 [['set 0 b 1, insert 1, set 1 s "¯\_(ツ)_/¯"']],
441 [[000: i=0 r=0 b=false s=(╯°□°)╯︵ ┻━┻ u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
442001: commit, status=success
443002: i=0 r=0 b=true s=(╯°□°)╯︵ ┻━┻ u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
444002: i=1 r=0 b=false s="¯\_(ツ)_/¯" u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
445003: done
446]])
447
1ca0323e
BP
448m4_define([OVSDB_CHECK_IDL_PY_WITH_EXPOUT],
449 [AT_SETUP([$1 - Python3])
980211b7
GL
450 AT_KEYWORDS([ovsdb server idl positive Python $5])
451 AT_CHECK([ovsdb_start_idltest])
452 m4_if([$2], [], [],
453 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
1ca0323e 454 AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema unix:socket $3],
980211b7
GL
455 [0], [stdout], [ignore])
456 echo "$4" > expout
457 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
458 [0], [expout])
459 OVSDB_SERVER_SHUTDOWN
460 AT_CLEANUP])
461
980211b7
GL
462OVSDB_CHECK_IDL_PY_WITH_EXPOUT([simple idl, writing large data via IDL with unicode],
463 [['["idltest",
464 {"op": "insert",
465 "table": "simple",
466 "row": {"s": "'$(printf "测试超过四千零九十六个字节的中文字符串以使解码出现问题。%.0s" {1..50})'"}}]']],
467 [['set 0 b 1, insert 1, set 1 s '$(printf "测试超过四千零九十六个字节的中文字符串以使解码出现问题。%.0s" {1..100})'']],
468 [[000: i=0 r=0 b=false s=$(printf "测试超过四千零九十六个字节的中文字符串以使解码出现问题。%.0s" {1..50}) u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
469001: commit, status=success
470002: i=0 r=0 b=true s=$(printf "测试超过四千零九十六个字节的中文字符串以使解码出现问题。%.0s" {1..50}) u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
471002: i=1 r=0 b=false s=$(printf "测试超过四千零九十六个字节的中文字符串以使解码出现问题。%.0s" {1..100}) u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
472003: done]])
473
a91c6104
BP
474OVSDB_CHECK_IDL([simple idl, handling verification failure],
475 [['["idltest",
476 {"op": "insert",
477 "table": "simple",
478 "row": {"i": 1,
479 "r": 2.0}},
480 {"op": "insert",
481 "table": "simple",
482 "row": {}}]']],
483 [['set 0 b 1' \
484 '+["idltest",
485 {"op": "update",
486 "table": "simple",
487 "where": [["i", "==", 1]],
488 "row": {"r": 5.0}}]' \
489 '+verify 1 r, set 1 r 3' \
490 'verify 1 r, set 1 r 3' \
491 ]],
492 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
493000: i=1 r=2 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
494001: commit, status=success
495002: {"error":null,"result":[{"count":1}]}
94fbe1aa 496003: commit, status=try again
a91c6104
BP
497004: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
498004: i=1 r=5 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
499005: commit, status=success
500006: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
501006: i=1 r=3 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
502007: done
503]])
504
b54e22e9 505OVSDB_CHECK_IDL([simple idl, increment operation],
9cb53f26
BP
506 [['["idltest",
507 {"op": "insert",
b54e22e9
BP
508 "table": "simple",
509 "row": {}}]']],
94fbe1aa 510 [['set 0 r 2.0, increment 0']],
b54e22e9
BP
511 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
512001: commit, status=success, increment=1
513002: i=1 r=2 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
514003: done
515]])
516
2096903b
BP
517OVSDB_CHECK_IDL([simple idl, aborting],
518 [['["idltest",
519 {"op": "insert",
520 "table": "simple",
521 "row": {}}]']],
522 [['set 0 r 2.0, abort' \
523'+set 0 b 1']],
524 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
525001: commit, status=aborted
526002: commit, status=success
527003: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
528004: done
529]])
530
531OVSDB_CHECK_IDL([simple idl, destroy without commit or abort],
532 [['["idltest",
533 {"op": "insert",
534 "table": "simple",
535 "row": {}}]']],
536 [['set 0 r 2.0, destroy' \
537'+set 0 b 1']],
538 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
539001: destroy
540002: commit, status=success
541003: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
542004: done
543]])
544
16ebb90e
LS
545OVSDB_CHECK_IDL([simple idl, conditional, false condition],
546 [['["idltest",
547 {"op": "insert",
548 "table": "simple",
549 "row": {"i": 1,
550 "r": 2.0,
551 "b": true}}]']],
0164e367
BP
552 [['condition simple []' \
553 'condition simple [true]']],
16ebb90e
LS
554 [[000: change conditions
555001: empty
556002: change conditions
557003: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
558004: done
559]])
560
561OVSDB_CHECK_IDL([simple idl, conditional, true condition],
562 [['["idltest",
563 {"op": "insert",
564 "table": "simple",
565 "row": {"i": 1,
566 "r": 2.0,
567 "b": true}}]']],
0164e367
BP
568 [['condition simple []' \
569 'condition simple [true]']],
16ebb90e
LS
570 [[000: change conditions
571001: empty
572002: change conditions
573003: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
574004: done
575]])
576
577OVSDB_CHECK_IDL([simple idl, conditional, multiple clauses in condition],
578 [['["idltest",
579 {"op": "insert",
580 "table": "simple",
581 "row": {"i": 1,
582 "r": 2.0,
583 "b": true}},
584 {"op": "insert",
585 "table": "simple",
586 "row": {"i": 2,
587 "r": 3.0,
588 "b": true}}]']],
0164e367
BP
589 [['condition simple []' \
590 'condition simple [["i","==",1],["i","==",2]]']],
16ebb90e
LS
591 [[000: change conditions
592001: empty
593002: change conditions
594003: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
595003: i=2 r=3 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
596004: done
597]])
598
599OVSDB_CHECK_IDL([simple idl, conditional, modify as insert due to condition],
600 [['["idltest",
601 {"op": "insert",
602 "table": "simple",
603 "row": {"i": 1,
604 "r": 2.0,
605 "b": true}}]']],
0164e367
BP
606 [['condition simple []' \
607 'condition simple [["i","==",1]]']],
16ebb90e
LS
608 [[000: change conditions
609001: empty
610002: change conditions
611003: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
612004: done
613]])
614
615OVSDB_CHECK_IDL([simple idl, conditional, modify as delete due to condition],
616 [['["idltest",
617 {"op": "insert",
618 "table": "simple",
619 "row": {"i": 1,
620 "r": 2.0,
621 "b": true}}]']],
0164e367
BP
622 [['condition simple []' \
623 'condition simple [["i","==",1],["i","==",2]]' \
624 'condition simple [["i","==",2]]' \
16ebb90e
LS
625 '["idltest",
626 {"op": "insert",
627 "table": "simple",
628 "row": {"i": 2,
629 "r": 3.0,
630 "b": true}}]']],
631 [[000: change conditions
632001: empty
633002: change conditions
634003: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
635004: change conditions
636005: empty
637006: {"error":null,"result":[{"uuid":["uuid","<2>"]}]}
638007: i=2 r=3 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
639008: done
640]])
641
642OVSDB_CHECK_IDL([simple idl, conditional, multiple tables],
643 [['["idltest",
644 {"op": "insert",
645 "table": "simple",
646 "row": {"i": 1,
647 "r": 2.0,
648 "b": true}},
649 {"op": "insert",
650 "table": "link1",
651 "row": {"i": 0, "k": ["named-uuid", "self"]},
652 "uuid-name": "self"},
653 {"op": "insert",
654 "table": "link2",
655 "row": {"i": 2},
656 "uuid-name": "row0"}]']],
0164e367
BP
657 [['condition simple [];link1 [];link2 []' \
658 'condition simple [["i","==",1]]' \
659 'condition link1 [["i","==",0]]' \
660 'condition link2 [["i","==",3]]' \
16ebb90e
LS
661 '+["idltest",
662 {"op": "insert",
663 "table": "link2",
664 "row": {"i": 3},
665 "uuid-name": "row0"}]']],
666 [[000: change conditions
667001: empty
668002: change conditions
669003: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
670004: change conditions
671005: i=0 k=0 ka=[] l2= uuid=<2>
672005: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
673006: change conditions
674007: {"error":null,"result":[{"uuid":["uuid","<3>"]}]}
675008: i=0 k=0 ka=[] l2= uuid=<2>
676008: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
677008: i=3 l1= uuid=<3>
678009: done
679]])
680
c3bb4bd7
BP
681OVSDB_CHECK_IDL([self-linking idl, consistent ops],
682 [],
9cb53f26
BP
683 [['["idltest",
684 {"op": "insert",
e9011ac8 685 "table": "link1",
c3bb4bd7
BP
686 "row": {"i": 0, "k": ["named-uuid", "self"]},
687 "uuid-name": "self"}]' \
9cb53f26
BP
688 '["idltest",
689 {"op": "insert",
e9011ac8 690 "table": "link1",
2d2d6d4a 691 "row": {"i": 1, "k": ["named-uuid", "row2"]},
c3bb4bd7
BP
692 "uuid-name": "row1"},
693 {"op": "insert",
e9011ac8 694 "table": "link1",
c3bb4bd7 695 "row": {"i": 2, "k": ["named-uuid", "row1"]},
2d2d6d4a 696 "uuid-name": "row2"}]' \
9cb53f26
BP
697 '["idltest",
698 {"op": "update",
e9011ac8 699 "table": "link1",
c3bb4bd7
BP
700 "where": [["i", "==", 1]],
701 "row": {"k": ["uuid", "#1#"]}}]' \
9cb53f26
BP
702 '["idltest",
703 {"op": "update",
e9011ac8 704 "table": "link1",
c3bb4bd7
BP
705 "where": [],
706 "row": {"k": ["uuid", "#0#"]}}]']],
707 [[000: empty
708001: {"error":null,"result":[{"uuid":["uuid","<0>"]}]}
e9011ac8 709002: i=0 k=0 ka=[] l2= uuid=<0>
fbf925e4 710003: {"error":null,"result":[{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]}]}
e9011ac8
BP
711004: i=0 k=0 ka=[] l2= uuid=<0>
712004: i=1 k=2 ka=[] l2= uuid=<1>
713004: i=2 k=1 ka=[] l2= uuid=<2>
c3bb4bd7 714005: {"error":null,"result":[{"count":1}]}
e9011ac8
BP
715006: i=0 k=0 ka=[] l2= uuid=<0>
716006: i=1 k=1 ka=[] l2= uuid=<1>
717006: i=2 k=1 ka=[] l2= uuid=<2>
c3bb4bd7 718007: {"error":null,"result":[{"count":3}]}
e9011ac8
BP
719008: i=0 k=0 ka=[] l2= uuid=<0>
720008: i=1 k=0 ka=[] l2= uuid=<1>
721008: i=2 k=0 ka=[] l2= uuid=<2>
c3bb4bd7
BP
722009: done
723]])
724
725OVSDB_CHECK_IDL([self-linking idl, inconsistent ops],
726 [],
9cb53f26
BP
727 [['["idltest",
728 {"op": "insert",
e9011ac8 729 "table": "link1",
c3bb4bd7 730 "row": {"i": 0, "k": ["uuid", "cf197cc5-c8c9-42f5-82d5-c71a9f2cb96b"]}}]' \
9cb53f26
BP
731 '+["idltest",
732 {"op": "insert",
e9011ac8 733 "table": "link1",
0d0f05b9
BP
734 "uuid-name": "one",
735 "row": {"i": 1, "k": ["named-uuid", "one"]}},
736 {"op": "insert",
737 "table": "link1",
738 "row": {"i": 2, "k": ["named-uuid", "one"]}}]' \
9cb53f26
BP
739 '["idltest",
740 {"op": "update",
e9011ac8 741 "table": "link1",
c3bb4bd7
BP
742 "where": [],
743 "row": {"k": ["uuid", "c2fca39a-e69a-42a4-9c56-5eca85839ce9"]}}]' \
9cb53f26
BP
744 '+["idltest",
745 {"op": "delete",
e9011ac8 746 "table": "link1",
0d0f05b9 747 "where": [["_uuid", "==", ["uuid", "#1#"]]]}]' \
9cb53f26
BP
748 '+["idltest",
749 {"op": "delete",
e9011ac8 750 "table": "link1",
0d0f05b9 751 "where": [["_uuid", "==", ["uuid", "#2#"]]]}]' \
9cb53f26
BP
752 '["idltest",
753 {"op": "delete",
0d0f05b9
BP
754 "table": "link1",
755 "where": []}]' \
c3bb4bd7
BP
756]],
757 [[000: empty
97f7803b 758001: {"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
759002: {"error":null,"result":[{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]}
760003: i=1 k=1 ka=[] l2= uuid=<2>
761003: i=2 k=1 ka=[] l2= uuid=<3>
254604d8 762004: {"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
763005: {"error":null,"result":[{"count":1},{"details":"cannot delete link1 row <2> because of 1 remaining reference(s)","error":"referential integrity violation"}]}
764006: {"error":null,"result":[{"count":1}]}
765007: i=1 k=1 ka=[] l2= uuid=<2>
766008: {"error":null,"result":[{"count":1}]}
767009: empty
768010: done
254604d8
BP
769]],
770 [],
771 [[sed -e '/004:/s/row <[23]> references/row <x> references/']])
c3bb4bd7
BP
772
773OVSDB_CHECK_IDL([self-linking idl, sets],
774 [],
9cb53f26
BP
775 [['["idltest",
776 {"op": "insert",
e9011ac8 777 "table": "link1",
0d0f05b9 778 "row": {"i": 0, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i0"]]]},
c3bb4bd7
BP
779 "uuid-name": "i0"},
780 {"op": "insert",
e9011ac8 781 "table": "link1",
0d0f05b9 782 "row": {"i": 1, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i1"]]]},
c3bb4bd7
BP
783 "uuid-name": "i1"},
784 {"op": "insert",
e9011ac8 785 "table": "link1",
0d0f05b9 786 "row": {"i": 2, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i2"]]]},
c3bb4bd7
BP
787 "uuid-name": "i2"},
788 {"op": "insert",
e9011ac8 789 "table": "link1",
0d0f05b9 790 "row": {"i": 3, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i3"]]]},
c3bb4bd7 791 "uuid-name": "i3"}]' \
9cb53f26
BP
792 '["idltest",
793 {"op": "update",
e9011ac8 794 "table": "link1",
c3bb4bd7
BP
795 "where": [],
796 "row": {"ka": ["set", [["uuid", "#0#"], ["uuid", "#1#"], ["uuid", "#2#"], ["uuid", "#3#"]]]}}]' \
9cb53f26
BP
797 '["idltest",
798 {"op": "update",
e9011ac8 799 "table": "link1",
97f7803b
BP
800 "where": [["i", "==", 2]],
801 "row": {"ka": ["set", [["uuid", "#0#"], ["uuid", "88702e78-845b-4a6e-ad08-cf68922ae84a"], ["uuid", "#2#"]]]}}]' \
9cb53f26
BP
802 '+["idltest",
803 {"op": "delete",
0d0f05b9
BP
804 "table": "link1",
805 "where": []}]']],
c3bb4bd7
BP
806 [[000: empty
807001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]}
0d0f05b9
BP
808002: i=0 k=0 ka=[0] l2= uuid=<0>
809002: i=1 k=0 ka=[1] l2= uuid=<1>
810002: i=2 k=0 ka=[2] l2= uuid=<2>
811002: i=3 k=0 ka=[3] l2= uuid=<3>
c3bb4bd7 812003: {"error":null,"result":[{"count":4}]}
0d0f05b9
BP
813004: i=0 k=0 ka=[0 1 2 3] l2= uuid=<0>
814004: i=1 k=0 ka=[0 1 2 3] l2= uuid=<1>
815004: i=2 k=0 ka=[0 1 2 3] l2= uuid=<2>
816004: i=3 k=0 ka=[0 1 2 3] l2= uuid=<3>
97f7803b 817005: {"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
818006: {"error":null,"result":[{"count":4}]}
819007: empty
820008: done
c3bb4bd7
BP
821]])
822
e9011ac8
BP
823OVSDB_CHECK_IDL([external-linking idl, consistent ops],
824 [],
9cb53f26
BP
825 [['["idltest",
826 {"op": "insert",
e9011ac8
BP
827 "table": "link2",
828 "row": {"i": 0},
829 "uuid-name": "row0"},
830 {"op": "insert",
831 "table": "link1",
0d0f05b9 832 "row": {"i": 1, "k": ["named-uuid", "row1"], "l2": ["set", [["named-uuid", "row0"]]]},
e9011ac8
BP
833 "uuid-name": "row1"}]']],
834 [[000: empty
835001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
836002: i=0 l1= uuid=<0>
0d0f05b9 837002: i=1 k=1 ka=[] l2=0 uuid=<1>
e9011ac8
BP
838003: done
839]])
225b582a 840
079ace1f
MM
841OVSDB_CHECK_IDL([singleton idl, constraints],
842 [],
843 [['["idltest",
844 {"op": "insert",
845 "table": "singleton",
846 "row": {"name": "foo"}}]' \
847 '["idltest",
848 {"op": "insert",
849 "table": "singleton",
850 "row": {"name": "bar"}}]' \
851 '+["idltest",
852 {"op": "delete",
853 "table": "singleton",
854 "where": [["_uuid", "==", ["uuid", "#0#"]]]},
855 {"op": "insert",
856 "table": "singleton",
857 "row": {"name": "bar"}}]']],
858 [[000: empty
859001: {"error":null,"result":[{"uuid":["uuid","<0>"]}]}
860002: name=foo uuid=<0>
861003: {"error":null,"result":[{"uuid":["uuid","<1>"]},{"details":"transaction causes \"singleton\" table to contain 2 rows, greater than the schema-defined limit of 1 row(s)","error":"constraint violation"}]}
862004: {"error":null,"result":[{"count":1},{"uuid":["uuid","<2>"]}]}
863005: name=bar uuid=<2>
864006: done
865]])
866
225b582a
IY
867OVSDB_CHECK_IDL_PY([external-linking idl, insert ops],
868 [],
869 [['linktest']],
870 [[000: empty
871001: commit, status=success
872002: i=1 k=1 ka=[1] l2= uuid=<0>
873002: i=2 k=1 ka=[1 2] l2= uuid=<1>
874003: done
875]])
3b4c362f
IY
876
877OVSDB_CHECK_IDL_PY([getattr idl, insert ops],
878 [],
879 [['getattrtest']],
880 [[000: empty
881001: commit, status=success
882002: i=2 k=2 ka=[] l2= uuid=<0>
883003: done
884]])
d18e52e3 885
d7d417fc
TW
886OVSDB_CHECK_IDL_PY([row-from-json idl, whats this],
887 [['["idltest",
888 {"op": "insert",
889 "table": "simple",
890 "row": {"i": 1}},
891 {"op": "insert",
892 "table": "simple",
893 "row": {}}]']],
894 [['notifytest insert 2, notifytest set 1 b 1, notifytest delete 0']],
895 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
896000: i=1 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
897001: commit, status=success, events=create|2|None, delete|0|None, update|1|b
898002: i=1 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
899002: i=2 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>
900003: done
901]])
902
d18e52e3
BP
903AT_SETUP([idl handling of missing tables and columns - C])
904AT_KEYWORDS([ovsdb server idl positive])
d18e52e3
BP
905
906# idltest2.ovsschema is the same as idltest.ovsschema, except that
907# table link2 and column l2 have been deleted. But the IDL still
908# expects them to be there, so this test checks that it properly
909# tolerates them being missing.
56120500 910AT_CHECK([ovsdb_start_idltest "" "$abs_srcdir/idltest2.ovsschema"])
d18e52e3
BP
911AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl unix:socket ['["idltest",
912 {"op": "insert",
913 "table": "link1",
914 "row": {"i": 0, "k": ["named-uuid", "self"]},
915 "uuid-name": "self"}]' \
916 '["idltest",
917 {"op": "insert",
918 "table": "link1",
919 "row": {"i": 1, "k": ["named-uuid", "row2"]},
920 "uuid-name": "row1"},
921 {"op": "insert",
922 "table": "link1",
923 "row": {"i": 2, "k": ["named-uuid", "row1"]},
924 "uuid-name": "row2"}]' \
925 '["idltest",
926 {"op": "update",
927 "table": "link1",
928 "where": [["i", "==", 1]],
929 "row": {"k": ["uuid", "#1#"]}}]' \
930 '["idltest",
931 {"op": "update",
932 "table": "link1",
933 "where": [],
934 "row": {"k": ["uuid", "#0#"]}}]']],
5a0e4aec 935 [0], [stdout], [stderr])
c724bd67 936AT_CHECK([sort stdout | uuidfilt], [0],
d18e52e3
BP
937 [[000: empty
938001: {"error":null,"result":[{"uuid":["uuid","<0>"]}]}
939002: i=0 k=0 ka=[] l2= uuid=<0>
940003: {"error":null,"result":[{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]}]}
941004: i=0 k=0 ka=[] l2= uuid=<0>
942004: i=1 k=2 ka=[] l2= uuid=<1>
943004: i=2 k=1 ka=[] l2= uuid=<2>
944005: {"error":null,"result":[{"count":1}]}
945006: i=0 k=0 ka=[] l2= uuid=<0>
946006: i=1 k=1 ka=[] l2= uuid=<1>
947006: i=2 k=1 ka=[] l2= uuid=<2>
948007: {"error":null,"result":[{"count":3}]}
949008: i=0 k=0 ka=[] l2= uuid=<0>
950008: i=1 k=0 ka=[] l2= uuid=<1>
951008: i=2 k=0 ka=[] l2= uuid=<2>
952009: done
7427f2a4 953]])
d18e52e3
BP
954
955# Check that ovsdb-idl figured out that table link2 and column l2 are missing.
956AT_CHECK([grep ovsdb_idl stderr | sort], [0], [dnl
957test-ovsdb|ovsdb_idl|idltest database lacks link2 table (database needs upgrade?)
079ace1f 958test-ovsdb|ovsdb_idl|idltest database lacks singleton table (database needs upgrade?)
d18e52e3
BP
959test-ovsdb|ovsdb_idl|link1 table in idltest database lacks l2 column (database needs upgrade?)
960])
961
962# Check that ovsdb-idl sent on "monitor" request and that it didn't
963# mention that table or column, and (for paranoia) that it did mention another
964# table and column.
1b1d2e6d 965AT_CHECK([grep -c '"monitor\|monitor_cond"' stderr], [0], [2
d18e52e3 966])
c383f3bf
LS
967AT_CHECK([grep '"monitor\|monitor_cond"' stderr | grep link2], [1])
968AT_CHECK([grep '"monitor\|monitor_cond"' stderr | grep l2], [1])
969AT_CHECK([grep '"monitor\|monitor_cond"' stderr | grep -c '"link1"'], [0], [1
d18e52e3 970])
c383f3bf 971AT_CHECK([grep '"monitor\|monitor_cond"' stderr | grep -c '"ua"'], [0], [1
d18e52e3
BP
972])
973OVSDB_SERVER_SHUTDOWN
974AT_CLEANUP
80c12152 975
1ca0323e
BP
976m4_define([OVSDB_CHECK_IDL_FETCH_COLUMNS_PY],
977 [AT_SETUP([$1 - Python3 - fetch])
80c12152 978 AT_KEYWORDS([ovsdb server idl positive Python increment fetch $6])
56120500 979 AT_CHECK([ovsdb_start_idltest])
80c12152 980 m4_if([$2], [], [],
7427f2a4 981 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
1ca0323e 982 AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema unix:socket [$3] $4],
7427f2a4 983 [0], [stdout], [ignore])
c724bd67 984 AT_CHECK([sort stdout | uuidfilt]m4_if([$7],,, [[| $7]]),
7427f2a4 985 [0], [$5])
80c12152
SA
986 OVSDB_SERVER_SHUTDOWN
987 AT_CLEANUP])
988
989m4_define([OVSDB_CHECK_IDL_FETCH_COLUMNS],
990 [OVSDB_CHECK_IDL_FETCH_COLUMNS_PY($@)])
991
992OVSDB_CHECK_IDL_FETCH_COLUMNS([simple idl, initially populated],
993 [['["idltest",
994 {"op": "insert",
995 "table": "simple",
996 "row": {"i": 1,
997 "r": 2.0,
998 "b": true,
999 "s": "mystring",
1000 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
1001 "ia": ["set", [1, 2, 3]],
1002 "ra": ["set", [-0.5]],
1003 "ba": ["set", [true]],
1004 "sa": ["set", ["abc", "def"]],
1005 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
1006 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
1007 {"op": "insert",
1008 "table": "simple",
1009 "row": {}}]']],
1010 [?simple:i,r!],
1011 ['fetch 0 r'],
1012 [[000: i=0 uuid=<0>
1013000: i=1 uuid=<1>
1014001: commit, status=success
1015002: i=0 r=0 uuid=<0>
1016002: i=1 uuid=<1>
1017003: done
1018]])
932104f4 1019
1ca0323e
BP
1020m4_define([OVSDB_CHECK_IDL_WO_MONITOR_COND_PY],
1021 [AT_SETUP([$1 - Python3])
897c8064 1022 AT_KEYWORDS([ovsdb server idl Python monitor $4])
56120500
BP
1023 AT_CHECK([ovsdb_start_idltest])
1024 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/disable-monitor-cond])
1ca0323e 1025 AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema unix:socket $2],
7ef00082 1026 [0], [stdout], [ignore])
c724bd67 1027 AT_CHECK([sort stdout | uuidfilt]m4_if([$5],,, [[| $5]]),
7ef00082 1028 [0], [$3])
897c8064
LS
1029 OVSDB_SERVER_SHUTDOWN
1030 AT_CLEANUP])
1031
897c8064
LS
1032m4_define([OVSDB_CHECK_IDL_WO_MONITOR_COND],
1033 [OVSDB_CHECK_IDL_WO_MONITOR_COND_PY($@)])
1034
1035
1036OVSDB_CHECK_IDL_WO_MONITOR_COND([simple idl disable monitor-cond],
1037 [['["idltest",
1038 {"op": "insert",
1039 "table": "simple",
1040 "row": {"i": 1,
1041 "r": 2.0,
1042 "b": true,
1043 "s": "mystring",
1044 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
1045 "ia": ["set", [1, 2, 3]],
1046 "ra": ["set", [-0.5]],
1047 "ba": ["set", [true]],
1048 "sa": ["set", ["abc", "def"]],
1049 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
1050 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
1051 {"op": "insert",
1052 "table": "simple",
1053 "row": {}}]' \
1054 '["idltest",
1055 {"op": "update",
1056 "table": "simple",
1057 "where": [],
1058 "row": {"b": true}}]' \
1059 '["idltest",
1060 {"op": "update",
1061 "table": "simple",
1062 "where": [],
1063 "row": {"r": 123.5}}]' \
1064 '["idltest",
1065 {"op": "insert",
1066 "table": "simple",
1067 "row": {"i": -1,
1068 "r": 125,
1069 "b": false,
1070 "s": "",
1071 "ia": ["set", [1]],
1072 "ra": ["set", [1.5]],
1073 "ba": ["set", [false]],
1074 "sa": ["set", []],
1075 "ua": ["set", []]}}]' \
1076 '["idltest",
1077 {"op": "update",
1078 "table": "simple",
1079 "where": [["i", "<", 1]],
1080 "row": {"s": "newstring"}}]' \
1081 '["idltest",
1082 {"op": "delete",
1083 "table": "simple",
1084 "where": [["i", "==", 0]]}]' \
1085 'reconnect']],
1086 [[000: empty
1087001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
1088002: i=0 r=0 b=false s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
1089002: 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>
1090003: {"error":null,"result":[{"count":2}]}
1091004: i=0 r=0 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
1092004: 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>
1093005: {"error":null,"result":[{"count":2}]}
1094006: i=0 r=123.5 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
1095006: 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>
1096007: {"error":null,"result":[{"uuid":["uuid","<6>"]}]}
1097008: i=-1 r=125 b=false s= u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
1098008: i=0 r=123.5 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
1099008: 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>
1100009: {"error":null,"result":[{"count":2}]}
1101010: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
1102010: i=0 r=123.5 b=true s=newstring u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
1103010: 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>
1104011: {"error":null,"result":[{"count":1}]}
1105012: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
1106012: 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>
1107013: reconnect
1108014: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
1109014: 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>
1110015: done
1111]])
1112
932104f4
SA
1113m4_define([OVSDB_CHECK_IDL_TRACK_C],
1114 [AT_SETUP([$1 - C])
1115 AT_KEYWORDS([ovsdb server idl tracking positive $5])
56120500 1116 AT_CHECK([ovsdb_start_idltest])
932104f4 1117 m4_if([$2], [], [],
7427f2a4 1118 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
932104f4 1119 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl unix:socket $3],
7427f2a4 1120 [0], [stdout], [ignore])
c724bd67 1121 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 1122 [0], [$4])
932104f4
SA
1123 OVSDB_SERVER_SHUTDOWN
1124 AT_CLEANUP])
1125
1126m4_define([OVSDB_CHECK_IDL_TRACK],
1127 [OVSDB_CHECK_IDL_TRACK_C($@)])
1128
1129OVSDB_CHECK_IDL_TRACK([track, simple idl, initially populated],
1130 [['["idltest",
1131 {"op": "insert",
1132 "table": "simple",
1133 "row": {"i": 1,
1134 "r": 2.0,
1135 "b": true,
1136 "s": "mystring",
1137 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
1138 "ia": ["set", [1, 2, 3]],
1139 "ra": ["set", [-0.5]],
1140 "ba": ["set", [true]],
1141 "sa": ["set", ["abc", "def"]],
1142 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
1143 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
1144 {"op": "insert",
1145 "table": "simple",
1146 "row": {}}]']],
1147 [['["idltest",
1148 {"op": "update",
1149 "table": "simple",
1150 "where": [],
1151 "row": {"b": true}}]']],
1152 [[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 1153000: updated columns: b ba i ia r ra s sa u ua
932104f4
SA
1154001: {"error":null,"result":[{"count":2}]}
1155002: i=0 r=0 b=true s= u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<5>
1156002: 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 1157002: updated columns: b
932104f4
SA
1158003: done
1159]])
1160
1161OVSDB_CHECK_IDL_TRACK([track, simple idl, initially empty, various ops],
1162 [],
1163 [['["idltest",
1164 {"op": "insert",
1165 "table": "simple",
1166 "row": {"i": 1,
1167 "r": 2.0,
1168 "b": true,
1169 "s": "mystring",
1170 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
1171 "ia": ["set", [1, 2, 3]],
1172 "ra": ["set", [-0.5]],
1173 "ba": ["set", [true]],
1174 "sa": ["set", ["abc", "def"]],
1175 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
1176 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
1177 {"op": "insert",
1178 "table": "simple",
1179 "row": {}}]' \
1180 '["idltest",
1181 {"op": "update",
1182 "table": "simple",
1183 "where": [],
1184 "row": {"b": true}}]' \
1185 '["idltest",
1186 {"op": "update",
1187 "table": "simple",
1188 "where": [],
1189 "row": {"r": 123.5}}]' \
1190 '["idltest",
1191 {"op": "insert",
1192 "table": "simple",
1193 "row": {"i": -1,
1194 "r": 125,
1195 "b": false,
1196 "s": "",
1197 "ia": ["set", [1]],
1198 "ra": ["set", [1.5]],
1199 "ba": ["set", [false]],
1200 "sa": ["set", []],
1201 "ua": ["set", []]}}]' \
1202 '["idltest",
1203 {"op": "update",
1204 "table": "simple",
1205 "where": [["i", "<", 1]],
1206 "row": {"s": "newstring"}}]' \
1207 '["idltest",
1208 {"op": "delete",
1209 "table": "simple",
1210 "where": [["i", "==", 0]]}]' \
1211 'reconnect']],
1212 [[000: empty
1213001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
1214002: 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 1215002: updated columns: b ba i ia r ra s sa u ua
932104f4
SA
1216003: {"error":null,"result":[{"count":2}]}
1217004: i=0 r=0 b=true s= u=<5> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
32d37ce8 1218004: updated columns: b
932104f4
SA
1219005: {"error":null,"result":[{"count":2}]}
1220006: i=0 r=123.5 b=true s= u=<5> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
1221006: 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
1222006: updated columns: r
1223006: updated columns: r
932104f4
SA
1224007: {"error":null,"result":[{"uuid":["uuid","<6>"]}]}
1225008: i=-1 r=125 b=false s= u=<5> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
32d37ce8 1226008: updated columns: ba i ia r ra
932104f4
SA
1227009: {"error":null,"result":[{"count":2}]}
1228010: i=-1 r=125 b=false s=newstring u=<5> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
1229010: i=0 r=123.5 b=true s=newstring u=<5> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
32d37ce8
SA
1230010: updated columns: s
1231010: updated columns: s
932104f4
SA
1232011: {"error":null,"result":[{"count":1}]}
1233012: ##deleted## uuid=<1>
1234013: reconnect
1235014: i=-1 r=125 b=false s=newstring u=<5> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
1236014: 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
1237014: updated columns: b ba i ia r ra s sa u ua
1238014: updated columns: ba i ia r ra s
932104f4
SA
1239015: done
1240]])
7251075c
EA
1241
1242m4_define([OVSDB_CHECK_IDL_PARTIAL_UPDATE_MAP_COLUMN],
1243 [AT_SETUP([$1 - C])
1244 AT_KEYWORDS([ovsdb server idl partial update map column positive $5])
56120500 1245 AT_CHECK([ovsdb_start_idltest])
7251075c 1246 m4_if([$2], [], [],
7427f2a4 1247 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
7251075c 1248 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-partial-update-map-column unix:socket $3],
7427f2a4 1249 [0], [stdout], [ignore])
c724bd67 1250 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 1251 [0], [$4])
7251075c
EA
1252 OVSDB_SERVER_SHUTDOWN
1253 AT_CLEANUP])
1254
1255OVSDB_CHECK_IDL_PARTIAL_UPDATE_MAP_COLUMN([map, simple2 idl-partial-update-map-column, initially populated],
1256[['["idltest", {"op":"insert", "table":"simple2",
1257 "row":{"name":"myString1","smap":["map",[["key1","value1"],["key2","value2"]]]} }]']
1258],
1259[],
1260[[000: Getting records
1261001: name=myString1 smap=[[key1 : value1],[key2 : value2]] imap=[]
1262002: After insert element
1263003: name=String2 smap=[[key1 : myList1],[key2 : value2]] imap=[[3 : myids2]]
1264004: After insert duplicated element
1265005: name=String2 smap=[[key1 : myList1],[key2 : value2]] imap=[[3 : myids2]]
1266006: After delete element
1267007: name=String2 smap=[[key2 : value2]] imap=[[3 : myids2]]
1268008: After trying to delete a deleted element
1269009: name=String2 smap=[[key2 : value2]] imap=[[3 : myids2]]
1270010: End test
1271]])
a7261bf7 1272
a59912a0
RM
1273OVSDB_CHECK_IDL_PY([partial-map idl],
1274[['["idltest", {"op":"insert", "table":"simple2",
330b9c9c 1275 "row":{"name":"myString1","smap":["map",[["key1","value1"],["key2","value2"]]]} }]']
a59912a0 1276],
2d54d801 1277 [?simple2:name,smap,imap 'partialmapinsertelement' 'partialmapinsertmultipleelements' 'partialmapdelelements' 'partialmapmutatenew'],
330b9c9c 1278[[000: name=myString1 smap=[(key1 value1) (key2 value2)] imap=[]
a59912a0 1279001: commit, status=success
330b9c9c 1280002: name=String2 smap=[(key1 myList1) (key2 value2)] imap=[(3 myids2)]
a59912a0 1281003: commit, status=success
2d54d801 1282004: name=String2 smap=[(key1 myList1) (key2 myList2) (key3 myList3) (key4 myList4)] imap=[(3 myids2)]
330b9c9c
AB
1283005: commit, status=success
1284006: name=String2 smap=[(key2 myList2)] imap=[(3 myids2)]
2d54d801
AB
1285007: commit, status=success
1286008: name=String2 smap=[(key2 myList2)] imap=[(3 myids2)]
1287008: name=String2New smap=[(key1 newList1) (key2 newList2)] imap=[]
1288009: done
a59912a0
RM
1289]])
1290
f1ab6e06
RM
1291m4_define([OVSDB_CHECK_IDL_PARTIAL_UPDATE_SET_COLUMN],
1292 [AT_SETUP([$1 - C])
1293 AT_KEYWORDS([ovsdb server idl partial update set column positive $5])
56120500 1294 AT_CHECK([ovsdb_start_idltest])
f1ab6e06
RM
1295 m4_if([$2], [], [],
1296 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
1297 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-partial-update-set-column unix:socket $3],
1298 [0], [stdout], [ignore])
c724bd67 1299 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
f1ab6e06
RM
1300 [0], [$4])
1301 OVSDB_SERVER_SHUTDOWN
1302 AT_CLEANUP])
1303
1304OVSDB_CHECK_IDL_PARTIAL_UPDATE_SET_COLUMN([set, simple3 idl-partial-update-set-column, initially populated],
1305[['["idltest", {"op":"insert", "table":"simple3",
1306 "row":{"name":"mySet1","uset":["set", [[ "uuid", "0005b872-f9e5-43be-ae02-3184b9680e75" ], [ "uuid", "000d2f6a-76af-412f-b59d-e7bcd3e84eff" ]]]} }]']
1307],
1308[],
1309[[000: Getting records
1310001: name=mySet1 uset=[[<0>],[<1>]] uref=[]
1311002: After rename+add new value
1312003: name=String2 uset=[[<0>],[<1>],[<2>]] uref=[]
1313004: After add new value
1314005: name=String2 uset=[[<0>],[<1>],[<2>],[<3>]] uref=[]
1315006: After delete value
1316007: name=String2 uset=[[<0>],[<1>],[<3>]] uref=[]
1317008: After trying to delete a deleted value
1318009: name=String2 uset=[[<0>],[<1>],[<3>]] uref=[]
1319010: After add to other table + set of strong ref
1320011: name=String2 uset=[[<0>],[<1>],[<3>]] uref=[[<4>]]
1321012: End test
1322]])
1323
a59912a0 1324OVSDB_CHECK_IDL_PY([partial-set idl],
b3220c67
AB
1325[['["idltest", {"op":"insert", "table":"simple3", "uuid-name":"newrow",
1326 "row":{"name":"mySet1","uset":["set", [[ "uuid", "0005b872-f9e5-43be-ae02-3184b9680e75" ]]]} },
1327 {"op":"insert", "table":"simple4", "row":{"name":"seed"}},
1328 {"op":"mutate", "table":"simple3", "where":[["_uuid", "==", ["named-uuid", "newrow"]]],
1329 "mutations": [["uset", "insert", ["set", [["uuid", "000d2f6a-76af-412f-b59d-e7bcd3e84eff"]]]]]}]']
a59912a0 1330],
2d54d801 1331 ['partialrenamesetadd' 'partialduplicateadd' 'partialsetdel' 'partialsetref' 'partialsetoverrideops' 'partialsetadddelete' 'partialsetmutatenew'],
a59912a0
RM
1332[[000: name=mySet1 uset=[<0> <1>]
1333001: commit, status=success
1334002: name=String2 uset=[<0> <1> <2>]
1335003: commit, status=success
1336004: name=String2 uset=[<0> <1> <2> <3>]
1337005: commit, status=success
1338006: name=String2 uset=[<0> <1> <3>]
1339007: commit, status=success
1340008: name=String2 uset=[<0> <1> <3>]
330b9c9c
AB
1341009: commit, status=success
1342010: name=String2 uset=[<3>]
b3220c67 1343011: commit, status=success
2d54d801
AB
1344012: name=String2 uset=[<4> <5>]
1345013: commit, status=success
1346014: name=String2 uset=[<4> <5>]
1347014: name=String3 uset=[<6>]
1348015: done
a59912a0
RM
1349]])
1350
a7261bf7 1351m4_define([OVSDB_CHECK_IDL_NOTIFY],
1ca0323e
BP
1352 [OVSDB_CHECK_IDL_PY([$1], [], [$2], [$3], [notify $4], [$5])
1353 OVSDB_CHECK_IDL_SSL_PY([$1], [], [$2], [$3], [notify $4], [$5])])
a7261bf7
NS
1354
1355OVSDB_CHECK_IDL_NOTIFY([simple idl verify notify],
1356 [['track-notify' \
1357 '["idltest",
1358 {"op": "insert",
1359 "table": "simple",
1360 "row": {"i": 1,
1361 "r": 2.0,
1362 "b": true,
1363 "s": "mystring",
1364 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
1365 "ia": ["set", [1, 2, 3]],
1366 "ra": ["set", [-0.5]],
1367 "ba": ["set", [true]],
1368 "sa": ["set", ["abc", "def"]],
1369 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
1370 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
1371 {"op": "insert",
1372 "table": "simple",
1373 "row": {}}]' \
1374 '["idltest",
1375 {"op": "update",
1376 "table": "simple",
1377 "where": [],
1378 "row": {"b": false}}]' \
1379 '["idltest",
1380 {"op": "update",
1381 "table": "simple",
1382 "where": [],
1383 "row": {"r": 123.5}}]' \
1384 '["idltest",
1385 {"op": "insert",
1386 "table": "simple",
1387 "row": {"i": -1,
1388 "r": 125,
1389 "b": false,
1390 "s": "",
1391 "ia": ["set", [1]],
1392 "ra": ["set", [1.5]],
1393 "ba": ["set", [false]],
1394 "sa": ["set", []],
1395 "ua": ["set", []]}}]' \
1396 '["idltest",
1397 {"op": "update",
1398 "table": "simple",
1399 "where": [["i", "<", 1]],
1400 "row": {"s": "newstring"}}]' \
1401 '["idltest",
1402 {"op": "delete",
1403 "table": "simple",
1404 "where": [["i", "==", 0]]}]' \
1405 'reconnect']],
1406 [[000: empty
c39751e4
TE
1407000: event:create, row={uuid=<0>}, updates=None
1408000: event:create, row={uuid=<1>}, updates=None
1409001: {"error":null,"result":[{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]}
1410002: event:create, row={i=0 r=0 b=false s= u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>}, updates=None
1411002: event:create, row={i=1 r=2 b=true s=mystring u=<5> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<6> <7>] uuid=<2>}, updates=None
1412002: i=0 r=0 b=false s= u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>
1413002: i=1 r=2 b=true s=mystring u=<5> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<6> <7>] uuid=<2>
a7261bf7 1414003: {"error":null,"result":[{"count":2}]}
c39751e4
TE
1415004: event:update, row={i=1 r=2 b=false s=mystring u=<5> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<6> <7>] uuid=<2>}, updates={b=true uuid=<2>}
1416004: i=0 r=0 b=false s= u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>
1417004: i=1 r=2 b=false s=mystring u=<5> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<6> <7>] uuid=<2>
a7261bf7 1418005: {"error":null,"result":[{"count":2}]}
c39751e4
TE
1419006: event:update, row={i=0 r=123.5 b=false s= u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>}, updates={r=0 uuid=<3>}
1420006: event:update, row={i=1 r=123.5 b=false s=mystring u=<5> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<6> <7>] uuid=<2>}, updates={r=2 uuid=<2>}
1421006: i=0 r=123.5 b=false s= u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>
1422006: i=1 r=123.5 b=false s=mystring u=<5> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<6> <7>] uuid=<2>
1423007: {"error":null,"result":[{"uuid":["uuid","<8>"]}]}
1424008: event:create, row={i=-1 r=125 b=false s= u=<4> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<8>}, updates=None
1425008: i=-1 r=125 b=false s= u=<4> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<8>
1426008: i=0 r=123.5 b=false s= u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>
1427008: i=1 r=123.5 b=false s=mystring u=<5> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<6> <7>] uuid=<2>
a7261bf7 1428009: {"error":null,"result":[{"count":2}]}
c39751e4
TE
1429010: event:update, row={i=-1 r=125 b=false s=newstring u=<4> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<8>}, updates={s= uuid=<8>}
1430010: event:update, row={i=0 r=123.5 b=false s=newstring u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>}, updates={s= uuid=<3>}
1431010: i=-1 r=125 b=false s=newstring u=<4> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<8>
1432010: i=0 r=123.5 b=false s=newstring u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>
1433010: i=1 r=123.5 b=false s=mystring u=<5> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<6> <7>] uuid=<2>
a7261bf7 1434011: {"error":null,"result":[{"count":1}]}
c39751e4
TE
1435012: event:delete, row={i=0 r=123.5 b=false s=newstring u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>}, updates=None
1436012: i=-1 r=125 b=false s=newstring u=<4> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<8>
1437012: i=1 r=123.5 b=false s=mystring u=<5> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<6> <7>] uuid=<2>
a7261bf7 1438013: reconnect
c39751e4
TE
1439014: event:create, row={i=-1 r=125 b=false s=newstring u=<4> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<8>}, updates=None
1440014: event:create, row={i=1 r=123.5 b=false s=mystring u=<5> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<6> <7>] uuid=<2>}, updates=None
1441014: event:create, row={uuid=<0>}, updates=None
1442014: event:create, row={uuid=<1>}, updates=None
1443014: i=-1 r=125 b=false s=newstring u=<4> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<8>
1444014: i=1 r=123.5 b=false s=mystring u=<5> ia=[1 2 3] ra=[-0.5] ba=[true] sa=[abc def] ua=[<6> <7>] uuid=<2>
a7261bf7
NS
1445015: done
1446]])
0a8606ee
LR
1447
1448# Tests to verify the functionality of the one column compound index.
1449# It tests index for one column string and integer indexes.
1450# The run of test-ovsdb generates the output of the display of data using the different indexes defined in
1451# the program.
1452# Then, some at_checks are used to verify the correctness of the corresponding index as well as the existence
1453# of all the rows involved in the test.
1454m4_define([OVSDB_CHECK_IDL_COMPOUND_INDEX_SINGLE_COLUMN_C],
1455 [AT_SETUP([$1 - C])
1456 AT_KEYWORDS([ovsdb server idl compound_index_single_column compound_index positive $5])
1457 AT_CHECK([ovsdb_start_idltest])
1458 m4_if([$2], [], [],
7ef00082 1459 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
0a8606ee
LR
1460# Generate the data to be tested.
1461 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-compound-index unix:socket $3],
7ef00082 1462 [0], [stdout], [ignore])
0a8606ee
LR
1463# Filter the rows of data that corresponds to the string index eliminating the extra columns of data.
1464# This is done to verifiy that the output data is in the correct and expected order.
1465 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: s=.*' | sed -e 's/ i=.*//g']],
7ef00082 1466 [0], [$4])
0a8606ee
LR
1467# Here, the data is filtered and sorted in order to have all the rows in the index and be
1468# able to determined that all the involved rows are present.
1469 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: s=.*' | sort -k 1,1n -k 2,2 -k 3,3]],
7ef00082 1470 [0], [$5])
0a8606ee
LR
1471# Filter the rows of data that corresponds to the integer index eliminating the extra columns of data.
1472# This is done to verifiy that the output data is in the correct and expected order.
1473 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: i=.*' | sed -e 's/ s=.*//g']],
7ef00082 1474 [0], [$6])
0a8606ee
LR
1475# Here again, the data is filtered and sorted in order to have all the rows in the index and be
1476# able to determined that all the involved rows are present.
1477 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: i=.*' | sort -k 1,1n -k 2,2 -k 3,3]],
7ef00082 1478 [0], [$7])
0a8606ee
LR
1479 OVSDB_SERVER_SHUTDOWN
1480 AT_CLEANUP])
1481
1482OVSDB_CHECK_IDL_COMPOUND_INDEX_SINGLE_COLUMN_C([Compound_index, single column test ],
1483 [['["idltest",
1484 {"op": "insert", "table": "simple", "row": {"s":"List000", "i": 1, "b":true, "r":101.0}},
1485 {"op": "insert", "table": "simple", "row": {"s":"List000", "i": 2, "b":false, "r":102.0}},
1486 {"op": "insert", "table": "simple", "row": {"s":"List000", "i": 10, "b":true, "r":110.0}},
1487 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 1, "b":false, "r":110.0}},
1488 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 2, "b":true, "r":120.0}},
1489 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 2, "b":true, "r":122.0}},
1490 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 4, "b":true, "r":130.0}},
1491 {"op": "insert", "table": "simple", "row": {"s":"List005", "i": 5, "b":true, "r":130.0}},
1492 {"op": "insert", "table": "simple", "row": {"s":"List020", "i": 20, "b":true, "r":220.0}},
1493 {"op": "insert", "table": "simple", "row": {"s":"List020", "i": 19, "b":true, "r":219.0}}
1494 ]']],
1495 [idl_compound_index_single_column],
1496 [001: s=List000
1497001: s=List000
1498001: s=List000
1499001: s=List001
1500001: s=List001
1501001: s=List001
1502001: s=List001
1503001: s=List005
1504001: s=List020
1505001: s=List020
1506003: s=List001
1507003: s=List001
1508003: s=List001
1509003: s=List001
1510],
1511[001: s=List000 i=1 b=True r=101.000000
1512001: s=List000 i=10 b=True r=110.000000
1513001: s=List000 i=2 b=False r=102.000000
1514001: s=List001 i=1 b=False r=110.000000
1515001: s=List001 i=2 b=True r=120.000000
1516001: s=List001 i=2 b=True r=122.000000
1517001: s=List001 i=4 b=True r=130.000000
1518001: s=List005 i=5 b=True r=130.000000
1519001: s=List020 i=19 b=True r=219.000000
1520001: s=List020 i=20 b=True r=220.000000
1521003: s=List001 i=1 b=False r=110.000000
1522003: s=List001 i=2 b=True r=120.000000
1523003: s=List001 i=2 b=True r=122.000000
1524003: s=List001 i=4 b=True r=130.000000
1525],
1526[002: i=1
1527002: i=1
1528002: i=2
1529002: i=2
1530002: i=2
1531002: i=4
1532002: i=5
1533002: i=10
1534002: i=19
1535002: i=20
1536004: i=5
1537005: i=4
1538005: i=5
1539006: i=5
1540006: i=10
1541006: i=19
1542006: i=20
1543006: i=54
0a8606ee 1544007: i=5
0a8606ee
LR
1545007: i=19
1546007: i=20
d0bde286 1547007: i=30
0a8606ee 1548007: i=54
d0bde286
HZ
1549008: i=1
1550008: i=1
1551008: i=2
1552008: i=2
1553008: i=2
1554008: i=5
1555008: i=19
1556008: i=20
1557008: i=30
1558008: i=54
0a8606ee
LR
1559],
1560[002: i=1 s=List000 b=True r=101.000000
1561002: i=1 s=List001 b=False r=110.000000
1562002: i=10 s=List000 b=True r=110.000000
1563002: i=19 s=List020 b=True r=219.000000
1564002: i=2 s=List000 b=False r=102.000000
1565002: i=2 s=List001 b=True r=120.000000
1566002: i=2 s=List001 b=True r=122.000000
1567002: i=20 s=List020 b=True r=220.000000
1568002: i=4 s=List001 b=True r=130.000000
1569002: i=5 s=List005 b=True r=130.000000
1570004: i=5 s=List005 b=True r=130.000000
1571005: i=4 s=List001 b=True r=130.000000
1572005: i=5 s=List005 b=True r=130.000000
1573006: i=10 s=List000 b=True r=110.000000
1574006: i=19 s=List020 b=True r=219.000000
1575006: i=20 s=List020 b=True r=220.000000
1576006: i=5 s=List005 b=True r=130.000000
1577006: i=54 s=Lista054 b=False r=0.000000
0a8606ee 1578007: i=19 s=List020 b=True r=219.000000
0a8606ee 1579007: i=20 s=List020 b=True r=220.000000
d0bde286 1580007: i=30 s=List000 b=True r=110.000000
0a8606ee
LR
1581007: i=5 s=List005 b=True r=130.000000
1582007: i=54 s=Lista054 b=False r=0.000000
d0bde286
HZ
1583008: i=1 s=List000 b=True r=101.000000
1584008: i=1 s=List001 b=False r=110.000000
1585008: i=19 s=List020 b=True r=219.000000
1586008: i=2 s=List000 b=False r=102.000000
1587008: i=2 s=List001 b=True r=120.000000
1588008: i=2 s=List001 b=True r=122.000000
1589008: i=20 s=List020 b=True r=220.000000
1590008: i=30 s=List000 b=True r=110.000000
1591008: i=5 s=List005 b=True r=130.000000
1592008: i=54 s=Lista054 b=False r=0.000000
0a8606ee
LR
1593])
1594
1595# Tests to verify the functionality of two column compound index.
1596# It tests index for two columns using string and integer fields.
1597# The run of test-ovsdb generates the output of the display of data using the different indexes defined in
1598# the program.
1599# Then, some at_checks are used to verify the correctness of the corresponding index as well as the existence
1600# of all the rows involved in the test.
1601m4_define([OVSDB_CHECK_IDL_COMPOUND_INDEX_DOUBLE_COLUMN_C],
1602 [AT_SETUP([$1 - C])
1603 AT_KEYWORDS([ovsdb server idl compound_index_double_column compound_index positive $5])
1604 AT_CHECK([ovsdb_start_idltest])
1605 m4_if([$2], [], [],
7ef00082 1606 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
0a8606ee
LR
1607# Generate the data to be tested.
1608 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-compound-index unix:socket $3],
7ef00082 1609 [0], [stdout], [ignore])
0a8606ee
LR
1610# Filter the rows of data that corresponds to the string-integer index eliminating the extra columns of data.
1611# This is done to verifiy that the output data is in the correct and expected order.
1612 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: s=.*' | sed -e 's/ b=.*//g']],
7ef00082 1613 [0], [$4])
0a8606ee
LR
1614# Here, the data is filtered and sorted in order to have all the rows in the index and be
1615# able to determined that all the involved rows are present.
1616 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: s=.*' | sort -k 1,1n -k 2,2 -k 3,3]],
7ef00082 1617 [0], [$5])
0a8606ee
LR
1618# Filter the rows of data that corresponds to the integer index eliminating the extra columns of data.
1619# This is done to verifiy that the output data is in the correct and expected order.
1620 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: i=.*' | sed -e 's/ b=.*//g']],
7ef00082 1621 [0], [$6])
0a8606ee
LR
1622# Here again, the data is filtered and sorted in order to have all the rows in the index and be
1623# able to determined that all the involved rows are present.
1624 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: i=.*' | sort -k 1,1n -k 2,2 -k 3,3]],
7ef00082 1625 [0], [$7])
0a8606ee
LR
1626 OVSDB_SERVER_SHUTDOWN
1627 AT_CLEANUP])
1628
1629OVSDB_CHECK_IDL_COMPOUND_INDEX_DOUBLE_COLUMN_C([Compound_index, double column test ],
1630 [['["idltest",
1631 {"op": "insert", "table": "simple", "row": {"s":"List000", "i": 1, "b":true, "r":101.0}},
1632 {"op": "insert", "table": "simple", "row": {"s":"List000", "i": 2, "b":false, "r":102.0}},
1633 {"op": "insert", "table": "simple", "row": {"s":"List000", "i": 10, "b":true, "r":110.0}},
1634 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 1, "b":false, "r":110.0}},
1635 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 2, "b":true, "r":120.0}},
1636 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 2, "b":true, "r":122.0}},
1637 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 4, "b":true, "r":130.0}},
1638 {"op": "insert", "table": "simple", "row": {"s":"List005", "i": 5, "b":true, "r":130.0}},
1639 {"op": "insert", "table": "simple", "row": {"s":"List020", "i": 20, "b":true, "r":220.0}},
1640 {"op": "insert", "table": "simple", "row": {"s":"List020", "i": 19, "b":true, "r":219.0}}
1641 ]']],
1642 [idl_compound_index_double_column],
1643 [001: s=List000 i=1
1644001: s=List000 i=2
1645001: s=List000 i=10
1646001: s=List001 i=1
1647001: s=List001 i=2
1648001: s=List001 i=2
1649001: s=List001 i=4
1650001: s=List005 i=5
1651001: s=List020 i=19
1652001: s=List020 i=20
1653002: s=List000 i=10
1654002: s=List000 i=2
1655002: s=List000 i=1
1656002: s=List001 i=4
1657002: s=List001 i=2
1658002: s=List001 i=2
1659002: s=List001 i=1
1660002: s=List005 i=5
1661002: s=List020 i=20
1662002: s=List020 i=19
1663003: s=List000 i=10
1664004: s=List001 i=1
1665004: s=List001 i=2
1666004: s=List001 i=2
1667004: s=List001 i=4
1668004: s=List005 i=5
1669],
1670 [001: s=List000 i=1 b=True r=101.000000
1671001: s=List000 i=10 b=True r=110.000000
1672001: s=List000 i=2 b=False r=102.000000
1673001: s=List001 i=1 b=False r=110.000000
1674001: s=List001 i=2 b=True r=120.000000
1675001: s=List001 i=2 b=True r=122.000000
1676001: s=List001 i=4 b=True r=130.000000
1677001: s=List005 i=5 b=True r=130.000000
1678001: s=List020 i=19 b=True r=219.000000
1679001: s=List020 i=20 b=True r=220.000000
1680002: s=List000 i=1 b=True r=101.000000
1681002: s=List000 i=10 b=True r=110.000000
1682002: s=List000 i=2 b=False r=102.000000
1683002: s=List001 i=1 b=False r=110.000000
1684002: s=List001 i=2 b=True r=120.000000
1685002: s=List001 i=2 b=True r=122.000000
1686002: s=List001 i=4 b=True r=130.000000
1687002: s=List005 i=5 b=True r=130.000000
1688002: s=List020 i=19 b=True r=219.000000
1689002: s=List020 i=20 b=True r=220.000000
1690003: s=List000 i=10 b=True r=110.000000
1691004: s=List001 i=1 b=False r=110.000000
1692004: s=List001 i=2 b=True r=120.000000
1693004: s=List001 i=2 b=True r=122.000000
1694004: s=List001 i=4 b=True r=130.000000
1695004: s=List005 i=5 b=True r=130.000000
1696],
1697 [005: i=1 s=List000
1698005: i=1 s=List001
1699005: i=2 s=List000
1700005: i=2 s=List001
1701005: i=2 s=List001
1702005: i=4 s=List001
1703005: i=5 s=List005
1704005: i=10 s=List000
1705005: i=19 s=List020
1706005: i=20 s=List020
1707006: i=20 s=List020
1708006: i=19 s=List020
1709006: i=10 s=List000
1710006: i=5 s=List005
1711006: i=4 s=List001
1712006: i=2 s=List000
1713006: i=2 s=List001
1714006: i=2 s=List001
1715006: i=1 s=List000
1716006: i=1 s=List001
1717],
1718 [005: i=1 s=List000 b=True r=101.000000
1719005: i=1 s=List001 b=False r=110.000000
1720005: i=10 s=List000 b=True r=110.000000
1721005: i=19 s=List020 b=True r=219.000000
1722005: i=2 s=List000 b=False r=102.000000
1723005: i=2 s=List001 b=True r=120.000000
1724005: i=2 s=List001 b=True r=122.000000
1725005: i=20 s=List020 b=True r=220.000000
1726005: i=4 s=List001 b=True r=130.000000
1727005: i=5 s=List005 b=True r=130.000000
1728006: i=1 s=List000 b=True r=101.000000
1729006: i=1 s=List001 b=False r=110.000000
1730006: i=10 s=List000 b=True r=110.000000
1731006: i=19 s=List020 b=True r=219.000000
1732006: i=2 s=List000 b=False r=102.000000
1733006: i=2 s=List001 b=True r=120.000000
1734006: i=2 s=List001 b=True r=122.000000
1735006: i=20 s=List020 b=True r=220.000000
1736006: i=4 s=List001 b=True r=130.000000
1737006: i=5 s=List005 b=True r=130.000000
1738])
3cc1634f
HZ
1739
1740m4_define([OVSDB_CHECK_IDL_COMPOUND_INDEX_WITH_REF],
1741 [AT_SETUP([$1 - C])
1742 AT_KEYWORDS([ovsdb server idl compound_index compound_index_with_ref positive $5])
1743 AT_CHECK([ovsdb_start_idltest])
1744 m4_if([$2], [], [],
1745 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
1746 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-compound-index-with-ref unix:socket $3],
1747 [0], [stdout], [ignore])
c724bd67 1748 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
3cc1634f
HZ
1749 [0], [$4])
1750 OVSDB_SERVER_SHUTDOWN
1751 AT_CLEANUP])
1752
1753OVSDB_CHECK_IDL_COMPOUND_INDEX_WITH_REF([set, simple3 idl-compound-index-with-ref, initially populated],
1754[],
1755[],
1756[[000: After add to other table + set of strong ref
1757001: name= uset=[] uref=[[<0>]]
1758002: check simple4: not empty
1759003: Query using index with reference
1760004: name= uset=[] uref=[[<0>]]
1761005: After delete
1762007: check simple4: empty
1763008: End test
1764]])
c1aa16d1 1765
cfef5ae8
IM
1766m4_define([CHECK_STREAM_OPEN_BLOCK],
1767 [AT_SETUP([Check Stream open block - C - $1])
1768 AT_SKIP_IF([test "$1" = "tcp6" && test "$IS_WIN32" = "yes"])
1769 AT_SKIP_IF([test "$1" = "tcp6" && test "$HAVE_IPV6" = "no"])
1770 AT_KEYWORDS([Check Stream open block $1])
1771 AT_CHECK([ovsdb_start_idltest "ptcp:0:$2"])
1772 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
fe495d0c 1773 WRONG_PORT=$(($TCP_PORT + 101))
cfef5ae8
IM
1774 AT_CHECK([test-stream tcp:$2:$TCP_PORT], [0], [ignore])
1775 AT_CHECK([test-stream tcp:$2:$WRONG_PORT], [1], [ignore], [ignore])
1776 OVSDB_SERVER_SHUTDOWN
1777 AT_CHECK([test-stream tcp:$2:$TCP_PORT], [1], [ignore], [ignore])
1778 AT_CLEANUP])
1779
1780CHECK_STREAM_OPEN_BLOCK([tcp], [127.0.0.1])
1781CHECK_STREAM_OPEN_BLOCK([tcp6], [[[::1]]])
1782
c1aa16d1 1783m4_define([CHECK_STREAM_OPEN_BLOCK_PY],
1ca0323e 1784 [AT_SETUP([$1 - Python3])
c1aa16d1
NS
1785 AT_KEYWORDS([Check PY Stream open block - $3])
1786 AT_CHECK([ovsdb_start_idltest "ptcp:0:127.0.0.1"])
1787 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
fe495d0c 1788 WRONG_PORT=$(($TCP_PORT + 101))
c1aa16d1
NS
1789 AT_CHECK([$3 $srcdir/test-stream.py tcp:127.0.0.1:$TCP_PORT], [0], [ignore])
1790 AT_CHECK([$3 $srcdir/test-stream.py tcp:127.0.0.1:$WRONG_PORT], [1], [ignore])
1791 OVSDB_SERVER_SHUTDOWN
1792 AT_CHECK([$3 $srcdir/test-stream.py tcp:127.0.0.1:$TCP_PORT], [1], [ignore])
1793 AT_CLEANUP])
1794
c39751e4
TE
1795# same as OVSDB_CHECK_IDL but uses Python IDL implementation with tcp
1796# with multiple remotes to assert the idl connects to the leader of the Raft cluster
1ca0323e
BP
1797m4_define([OVSDB_CHECK_IDL_LEADER_ONLY_PY],
1798 [AT_SETUP([$1 - Python3 (leader only)])
c39751e4
TE
1799 AT_KEYWORDS([ovsdb server idl Python leader_only with tcp socket])
1800 m4_define([LPBK],[127.0.0.1])
1801 AT_CHECK([ovsdb_cluster_start_idltest $2 "ptcp:0:"LPBK])
1802 PARSE_LISTENING_PORT([s2.log], [TCP_PORT_1])
1803 PARSE_LISTENING_PORT([s3.log], [TCP_PORT_2])
1804 PARSE_LISTENING_PORT([s1.log], [TCP_PORT_3])
1805 remotes=tcp:LPBK:$TCP_PORT_1,tcp:LPBK:$TCP_PORT_2,tcp:LPBK:$TCP_PORT_3
1806 pids=$(cat s2.pid s3.pid s1.pid | tr '\n' ',')
1807 echo $pids
1ca0323e 1808 AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py -t30 idl-cluster $srcdir/idltest.ovsschema $remotes $pids $3],
c39751e4
TE
1809 [0], [stdout], [ignore])
1810 remote=$(ovsdb_cluster_leader $remotes "idltest")
1811 leader=$(echo $remote | cut -d'|' -f 1)
1812 AT_CHECK([grep -F -- "${leader}" stdout], [0], [ignore])
1813 AT_CLEANUP])
1814
c39751e4
TE
1815OVSDB_CHECK_IDL_LEADER_ONLY_PY([Check Python IDL connects to leader], 3, ['remote'])
1816OVSDB_CHECK_IDL_LEADER_ONLY_PY([Check Python IDL reconnects to leader], 3, ['remote' '+remotestop' 'remote'])