]> git.proxmox.com Git - ovs.git/blame - tests/ovsdb-idl.at
Fix ovs-dpctl-top by removing 3 wrong hunks in py3-compat.patch.
[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 14
c39751e4
TE
15# ovsdb_cluster_leader [REMOTES] [DATABASE]
16#
17# Returns the leader of the DATABASE cluster.
18ovsdb_cluster_leader () {
19 remotes=$(echo $1 | tr "," "\n")
20 for remote in $remotes; do
21 ovsdb-client dump $remote _Server Database name leader | grep $2 | grep -q true
22 if [[ $? == 0 ]]; then
23 port=$(echo $remote | cut -d':' -f 3)
24 log=$(grep --include=s\*.log -rlnw -e "listening on port $port" ./)
25 pid=$(echo $log | sed 's/\(.*\.\)log/\1pid/' )
26 echo "${remote}|${pid}"
27 return
28 fi
29 done
30}])
56120500 31
5198e8a0
FL
32# OVSDB_CLUSTER_START_IDLTEST([N], [REMOTE])
33#
34# Creates a clustered database using idltest.ovsschema and starts a database
35# cluster of N servers listening on punix:socket and REMOTE (if specified).
36m4_define([OVSDB_CLUSTER_START_IDLTEST],
37 [n=$1
38 AT_CHECK([ovsdb-tool create-cluster s1.db \
39 $abs_srcdir/idltest.ovsschema unix:s1.raft])
40 cid=$(ovsdb-tool db-cid s1.db)
41 schema_name=$(ovsdb-tool schema-name $abs_srcdir/idltest.ovsschema)
42 for i in $(seq 2 $n); do
43 AT_CHECK([ovsdb-tool join-cluster s$i.db \
44 $schema_name unix:s$i.raft unix:s1.raft])
45 done
6edb0dd3 46 on_exit 'kill $(cat s*.pid)'
5198e8a0
FL
47 for i in $(seq $n); do
48 AT_CHECK([ovsdb-server -vraft -vconsole:warn --detach --no-chdir \
49 --log-file=s$i.log --pidfile=s$i.pid --unixctl=s$i \
50 --remote=punix:s$i.ovsdb \
51 m4_if([$2], [], [], [--remote=$2]) s$i.db])
52 done
5198e8a0
FL
53
54 for i in $(seq $n); do
55 OVS_WAIT_UNTIL([ovs-appctl -t $(pwd)/s$i cluster/status ${schema_name} \
56 | grep -q 'Status: cluster member'])
57 done
58])
59
60
8cdf0349
BP
61# OVSDB_CHECK_IDL_C(TITLE, [PRE-IDL-TXN], TRANSACTIONS, OUTPUT, [KEYWORDS],
62# [FILTER])
c3bb4bd7
BP
63#
64# Creates a database with a schema derived from idltest.ovsidl, runs
65# each PRE-IDL-TXN (if any), starts an ovsdb-server on that database,
66# and runs "test-ovsdb idl" passing each of the TRANSACTIONS along.
67#
68# Checks that the overall output is OUTPUT. Before comparison, the
69# output is sorted (using "sort") and UUIDs in the output are replaced
70# by markers of the form <N> where N is a number. The first unique
71# UUID is replaced by <0>, the next by <1>, and so on. If a given
72# UUID appears more than once it is always replaced by the same
254604d8
BP
73# marker. If FILTER is supplied then the output is also filtered
74# through the specified program.
c3bb4bd7
BP
75#
76# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
8cdf0349
BP
77m4_define([OVSDB_CHECK_IDL_C],
78 [AT_SETUP([$1 - C])
c3bb4bd7 79 AT_KEYWORDS([ovsdb server idl positive $5])
56120500 80 AT_CHECK([ovsdb_start_idltest])
c3bb4bd7 81 m4_if([$2], [], [],
7427f2a4 82 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
8cdf0349 83 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl unix:socket $3],
7427f2a4 84 [0], [stdout], [ignore])
c724bd67 85 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 86 [0], [$4])
028cbd99 87 OVSDB_SERVER_SHUTDOWN
c3bb4bd7
BP
88 AT_CLEANUP])
89
b481a4cc
IM
90# same as OVSDB_CHECK_IDL but uses tcp.
91m4_define([OVSDB_CHECK_IDL_TCP_C],
92 [AT_SETUP([$1 - C - tcp])
93 AT_KEYWORDS([ovsdb server idl positive tcp socket $5])
94 AT_CHECK([ovsdb_start_idltest "ptcp:0:127.0.0.1"])
95 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
96
97 m4_if([$2], [], [],
98 [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT $2], [0], [ignore], [ignore])])
99 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl tcp:127.0.0.1:$TCP_PORT $3],
100 [0], [stdout], [ignore])
101 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
102 [0], [$4])
103 OVSDB_SERVER_SHUTDOWN
104 AT_CLEANUP])
105
106# same as OVSDB_CHECK_IDL but uses tcp6.
107m4_define([OVSDB_CHECK_IDL_TCP6_C],
108 [AT_SETUP([$1 - C - tcp6])
109 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
110 AT_SKIP_IF([test $HAVE_IPV6 = no])
111 AT_KEYWORDS([ovsdb server idl positive tcp6 socket $5])
112 AT_CHECK([ovsdb_start_idltest "ptcp:0:[[::1]]"])
113 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
114
115 m4_if([$2], [], [],
116 [AT_CHECK([ovsdb-client transact tcp:[[::1]]:$TCP_PORT $2], [0], [ignore], [ignore])])
117 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl tcp:[[::1]]:$TCP_PORT $3],
118 [0], [stdout], [ignore])
119 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
120 [0], [$4])
121 OVSDB_SERVER_SHUTDOWN
122 AT_CLEANUP])
123
8cdf0349 124# same as OVSDB_CHECK_IDL but uses the Python IDL implementation.
1ca0323e
BP
125m4_define([OVSDB_CHECK_IDL_PY],
126 [AT_SETUP([$1 - Python3])
8cdf0349 127 AT_KEYWORDS([ovsdb server idl positive Python $5])
56120500 128 AT_CHECK([ovsdb_start_idltest])
8cdf0349 129 m4_if([$2], [], [],
7427f2a4 130 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
1ca0323e 131 AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema unix:socket $3],
7427f2a4 132 [0], [stdout], [ignore])
c724bd67 133 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 134 [0], [$4])
8cdf0349
BP
135 OVSDB_SERVER_SHUTDOWN
136 AT_CLEANUP])
137
1ca0323e
BP
138m4_define([OVSDB_CHECK_IDL_REGISTER_COLUMNS_PY],
139 [AT_SETUP([$1 - Python3 - register_columns])
01dc1516 140 AT_KEYWORDS([ovsdb server idl positive Python register_columns $5])
56120500 141 AT_CHECK([ovsdb_start_idltest])
01dc1516 142 m4_if([$2], [], [],
7427f2a4 143 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
1ca0323e 144 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 145 [0], [stdout], [ignore])
c724bd67 146 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 147 [0], [$4])
01dc1516
SA
148 OVSDB_SERVER_SHUTDOWN
149 AT_CLEANUP])
150
e06d06a7 151# same as OVSDB_CHECK_IDL but uses the Python IDL implementation with tcp
1ca0323e
BP
152m4_define([OVSDB_CHECK_IDL_TCP_PY],
153 [AT_SETUP([$1 - Python3 - tcp])
e06d06a7 154 AT_KEYWORDS([ovsdb server idl positive Python with tcp socket $5])
56120500 155 AT_CHECK([ovsdb_start_idltest "ptcp:0:127.0.0.1"])
fb28ef2d 156 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
1e04fcc8 157
e06d06a7 158 m4_if([$2], [], [],
7427f2a4 159 [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT $2], [0], [ignore], [ignore])])
1ca0323e 160 AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema tcp:127.0.0.1:$TCP_PORT $3],
7427f2a4 161 [0], [stdout], [ignore])
c724bd67 162 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 163 [0], [$4])
e06d06a7
IY
164 OVSDB_SERVER_SHUTDOWN
165 AT_CLEANUP])
166
31e434fc
NS
167# same as OVSDB_CHECK_IDL but uses the Python IDL implementation with tcp
168# with multiple remotes with only one remote reachable
1ca0323e
BP
169m4_define([OVSDB_CHECK_IDL_TCP_MULTIPLE_REMOTES_PY],
170 [AT_SETUP([$1 - Python3 (multiple remotes) - tcp])
31e434fc
NS
171 AT_KEYWORDS([ovsdb server idl positive Python with tcp socket $5])
172 AT_CHECK([ovsdb_start_idltest "ptcp:0:127.0.0.1"])
173 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
fe495d0c
IM
174 WRONG_PORT_1=$((TCP_PORT + 101))
175 WRONG_PORT_2=$((TCP_PORT + 102))
31e434fc
NS
176 remote=tcp:127.0.0.1:$WRONG_PORT_1,tcp:127.0.0.1:$TCP_PORT,tcp:127.0.0.1:$WRONG_PORT_2
177 m4_if([$2], [], [],
178 [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT $2], [0], [ignore], [ignore])])
1ca0323e 179 AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py -t20 idl $srcdir/idltest.ovsschema $remote $3],
31e434fc
NS
180 [0], [stdout], [ignore])
181 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
182 [0], [$4])
183 OVSDB_SERVER_SHUTDOWN
184 AT_CLEANUP])
185
e731d71b 186# same as OVSDB_CHECK_IDL but uses the Python IDL implementation with tcp6
1ca0323e
BP
187m4_define([OVSDB_CHECK_IDL_TCP6_PY],
188 [AT_SETUP([$1 - Python3 - tcp6])
7b9d1b65 189 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
4819b3a5 190 AT_SKIP_IF([test $HAVE_IPV6 = no])
e731d71b 191 AT_KEYWORDS([ovsdb server idl positive Python with tcp6 socket $5])
56120500 192 AT_CHECK([ovsdb_start_idltest "ptcp:0:[[::1]]"])
fb28ef2d 193 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
e731d71b
AS
194 echo "TCP_PORT=$TCP_PORT"
195
196 m4_if([$2], [], [],
7427f2a4 197 [AT_CHECK([ovsdb-client transact "tcp:[[::1]]:$TCP_PORT" $2], [0], [ignore], [ignore])])
1ca0323e 198 AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema tcp:[[::1]]:$TCP_PORT $3],
7427f2a4 199 [0], [stdout], [ignore])
c724bd67 200 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 201 [0], [$4])
e731d71b
AS
202 OVSDB_SERVER_SHUTDOWN
203 AT_CLEANUP])
204
1ca0323e
BP
205m4_define([OVSDB_CHECK_IDL_TCP6_MULTIPLE_REMOTES_PY],
206 [AT_SETUP([$1 - Python3 - tcp6])
31e434fc
NS
207 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
208 AT_SKIP_IF([test $HAVE_IPV6 = no])
209 AT_KEYWORDS([ovsdb server idl positive Python with tcp6 socket $5])
210 AT_CHECK([ovsdb_start_idltest "ptcp:0:[[::1]]"])
211 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
fe495d0c
IM
212 WRONG_PORT_1=$((TCP_PORT + 101))
213 WRONG_PORT_2=$((TCP_PORT + 102))
31e434fc
NS
214 remote="tcp:[[::1]]:$WRONG_PORT_1,tcp:[[::1]]:$TCP_PORT,tcp:[[::1]]:$WRONG_PORT_2"
215 m4_if([$2], [], [],
216 [AT_CHECK([ovsdb-client transact "tcp:[[::1]]:$TCP_PORT" $2], [0], [ignore], [ignore])])
1ca0323e 217 AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py -t20 idl $srcdir/idltest.ovsschema $remote $3],
31e434fc
NS
218 [0], [stdout], [ignore])
219 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
220 [0], [$4])
221 OVSDB_SERVER_SHUTDOWN
222 AT_CLEANUP])
223
61845323 224# same as OVSDB_CHECK_IDL but uses the Python IDL implementation with SSL
1ca0323e
BP
225m4_define([OVSDB_CHECK_IDL_SSL_PY],
226 [AT_SETUP([$1 - Python3 - SSL])
61845323 227 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
1ca0323e 228 $PYTHON3 -c "import OpenSSL.SSL"
61845323
JS
229 SSL_PRESENT=$?
230 AT_SKIP_IF([test $SSL_PRESENT != 0])
231 AT_KEYWORDS([ovsdb server idl positive Python with ssl socket $5])
232 AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema],
233 [0], [stdout], [ignore])
234 PKIDIR=$abs_top_builddir/tests
235 AT_CHECK([ovsdb-server -vconsole:warn --log-file --detach --no-chdir \
236 --pidfile \
237 --private-key=$PKIDIR/testpki-privkey2.pem \
238 --certificate=$PKIDIR/testpki-cert2.pem \
239 --ca-cert=$PKIDIR/testpki-cacert.pem \
240 --remote=pssl:0:127.0.0.1 db])
241 on_exit 'kill `cat ovsdb-server.pid`'
242 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
243 m4_if([$2], [], [],
244 [AT_CHECK([ovsdb-client \
245 --private-key=$PKIDIR/testpki-privkey2.pem \
246 --certificate=$PKIDIR/testpki-cert2.pem \
247 --ca-cert=$PKIDIR/testpki-cacert.pem \
248 transact "ssl:127.0.0.1:$TCP_PORT" $2], [0], [ignore], [ignore])])
1ca0323e 249 AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema \
61845323
JS
250 ssl:127.0.0.1:$TCP_PORT $PKIDIR/testpki-privkey.pem \
251 $PKIDIR/testpki-cert.pem $PKIDIR/testpki-cacert.pem $3],
252 [0], [stdout], [ignore])
253 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
254 [0], [$4])
255 OVSDB_SERVER_SHUTDOWN
256 AT_CLEANUP])
257
8cdf0349
BP
258m4_define([OVSDB_CHECK_IDL],
259 [OVSDB_CHECK_IDL_C($@)
b481a4cc
IM
260 OVSDB_CHECK_IDL_TCP_C($@)
261 OVSDB_CHECK_IDL_TCP6_C($@)
e06d06a7 262 OVSDB_CHECK_IDL_PY($@)
01dc1516 263 OVSDB_CHECK_IDL_REGISTER_COLUMNS_PY($@)
e731d71b 264 OVSDB_CHECK_IDL_TCP_PY($@)
31e434fc 265 OVSDB_CHECK_IDL_TCP_MULTIPLE_REMOTES_PY($@)
61845323 266 OVSDB_CHECK_IDL_TCP6_PY($@)
31e434fc 267 OVSDB_CHECK_IDL_TCP6_MULTIPLE_REMOTES_PY($@)
61845323 268 OVSDB_CHECK_IDL_SSL_PY($@)])
8cdf0349 269
af358237 270# This test uses the Python IDL implementation with passive tcp
1ca0323e
BP
271m4_define([OVSDB_CHECK_IDL_PASSIVE_TCP_PY],
272 [AT_SETUP([$1 - Python3 - ptcp])
af358237 273 AT_KEYWORDS([ovsdb server idl positive Python with tcp socket $5])
af358237 274 # find free TCP port
56120500 275 AT_CHECK([ovsdb_start_idltest "ptcp:0:127.0.0.1"])
af358237 276 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
7427f2a4 277 OVSDB_SERVER_SHUTDOWN
56120500 278 rm -f db
af358237
OBY
279
280 # start OVSDB server in passive mode
56120500 281 AT_CHECK([ovsdb_start_idltest "tcp:127.0.0.1:$TCP_PORT"])
1ca0323e 282 AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py -t10 idl_passive $srcdir/idltest.ovsschema ptcp:127.0.0.1:$TCP_PORT $3],
7427f2a4 283 [0], [stdout], [ignore])
c724bd67 284 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4
DDP
285 [0], [$4])
286 OVSDB_SERVER_SHUTDOWN
af358237
OBY
287 AT_CLEANUP
288 ])
289
290OVSDB_CHECK_IDL_PASSIVE_TCP_PY([simple passive idl, initially empty, select empty],
291 [],
292 [['["idltest",{"op":"select","table":"link1","where":[]}]']],
293 [[000: empty
294001: {"error":null,"result":[{"rows":[]}]}
295002: done
296]])
297
c3bb4bd7
BP
298OVSDB_CHECK_IDL([simple idl, initially empty, no ops],
299 [],
300 [],
301 [000: empty
302001: done
303])
304
305OVSDB_CHECK_IDL([simple idl, initially empty, various ops],
306 [],
9cb53f26
BP
307 [['["idltest",
308 {"op": "insert",
c3bb4bd7
BP
309 "table": "simple",
310 "row": {"i": 1,
311 "r": 2.0,
312 "b": true,
313 "s": "mystring",
314 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
315 "ia": ["set", [1, 2, 3]],
316 "ra": ["set", [-0.5]],
7fae24e6 317 "ba": ["set", [true]],
8cdf0349 318 "sa": ["set", ["abc", "def"]],
c3bb4bd7
BP
319 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
320 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
321 {"op": "insert",
322 "table": "simple",
323 "row": {}}]' \
9cb53f26
BP
324 '["idltest",
325 {"op": "update",
c3bb4bd7
BP
326 "table": "simple",
327 "where": [],
328 "row": {"b": true}}]' \
9cb53f26
BP
329 '["idltest",
330 {"op": "update",
c3bb4bd7
BP
331 "table": "simple",
332 "where": [],
333 "row": {"r": 123.5}}]' \
9cb53f26
BP
334 '["idltest",
335 {"op": "insert",
c3bb4bd7
BP
336 "table": "simple",
337 "row": {"i": -1,
338 "r": 125,
339 "b": false,
340 "s": "",
341 "ia": ["set", [1]],
342 "ra": ["set", [1.5]],
343 "ba": ["set", [false]],
8cdf0349 344 "sa": ["set", []],
c3bb4bd7 345 "ua": ["set", []]}}]' \
9cb53f26
BP
346 '["idltest",
347 {"op": "update",
c3bb4bd7
BP
348 "table": "simple",
349 "where": [["i", "<", 1]],
350 "row": {"s": "newstring"}}]' \
9cb53f26
BP
351 '["idltest",
352 {"op": "delete",
c3bb4bd7
BP
353 "table": "simple",
354 "where": [["i", "==", 0]]}]' \
355 'reconnect']],
356 [[000: empty
357001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
358002: i=0 r=0 b=false s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 359002: 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
360003: {"error":null,"result":[{"count":2}]}
361004: i=0 r=0 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 362004: 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
363005: {"error":null,"result":[{"count":2}]}
364006: i=0 r=123.5 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 365006: 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
366007: {"error":null,"result":[{"uuid":["uuid","<6>"]}]}
367008: i=-1 r=125 b=false s= u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
368008: i=0 r=123.5 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 369008: 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
370009: {"error":null,"result":[{"count":2}]}
371010: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
372010: i=0 r=123.5 b=true s=newstring u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 373010: 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
374011: {"error":null,"result":[{"count":1}]}
375012: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
7fae24e6 376012: 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
377013: reconnect
378014: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
7fae24e6 379014: 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
380015: done
381]])
382
383OVSDB_CHECK_IDL([simple idl, initially populated],
9cb53f26
BP
384 [['["idltest",
385 {"op": "insert",
c3bb4bd7
BP
386 "table": "simple",
387 "row": {"i": 1,
388 "r": 2.0,
389 "b": true,
390 "s": "mystring",
391 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
392 "ia": ["set", [1, 2, 3]],
393 "ra": ["set", [-0.5]],
7fae24e6 394 "ba": ["set", [true]],
8cdf0349 395 "sa": ["set", ["abc", "def"]],
c3bb4bd7
BP
396 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
397 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
398 {"op": "insert",
399 "table": "simple",
400 "row": {}}]']],
9cb53f26
BP
401 [['["idltest",
402 {"op": "update",
c3bb4bd7
BP
403 "table": "simple",
404 "where": [],
405 "row": {"b": true}}]']],
406 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 407000: 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
408001: {"error":null,"result":[{"count":2}]}
409002: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 410002: 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
411003: done
412]])
413
475281c0 414OVSDB_CHECK_IDL([simple idl, writing via IDL],
9cb53f26
BP
415 [['["idltest",
416 {"op": "insert",
475281c0
BP
417 "table": "simple",
418 "row": {"i": 1,
419 "r": 2.0,
420 "b": true,
421 "s": "mystring",
422 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
423 "ia": ["set", [1, 2, 3]],
424 "ra": ["set", [-0.5]],
7fae24e6 425 "ba": ["set", [true]],
8cdf0349 426 "sa": ["set", ["abc", "def"]],
475281c0
BP
427 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
428 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
429 {"op": "insert",
430 "table": "simple",
431 "row": {}}]']],
a91c6104
BP
432 [['verify 0 b, verify 1 r, set 0 b 1, set 1 r 3.5' \
433 'insert 2, verify 2 i, verify 1 b, delete 1']],
475281c0 434 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 435000: 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
436001: commit, status=success
437002: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 438002: 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
439003: commit, status=success
440004: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
441004: i=2 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<6>
442005: done
443]])
444
e7164d96
LR
445OVSDB_CHECK_IDL([simple idl, writing via IDL with unicode],
446 [['["idltest",
447 {"op": "insert",
448 "table": "simple",
449 "row": {"s": "(╯°□°)╯︵ ┻━┻"}}]']],
450 [['set 0 b 1, insert 1, set 1 s "¯\_(ツ)_/¯"']],
451 [[000: i=0 r=0 b=false s=(╯°□°)╯︵ ┻━┻ u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
452001: commit, status=success
453002: i=0 r=0 b=true s=(╯°□°)╯︵ ┻━┻ u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
454002: i=1 r=0 b=false s="¯\_(ツ)_/¯" u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
455003: done
456]])
457
1ca0323e
BP
458m4_define([OVSDB_CHECK_IDL_PY_WITH_EXPOUT],
459 [AT_SETUP([$1 - Python3])
980211b7
GL
460 AT_KEYWORDS([ovsdb server idl positive Python $5])
461 AT_CHECK([ovsdb_start_idltest])
462 m4_if([$2], [], [],
463 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
1ca0323e 464 AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema unix:socket $3],
980211b7
GL
465 [0], [stdout], [ignore])
466 echo "$4" > expout
467 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
468 [0], [expout])
469 OVSDB_SERVER_SHUTDOWN
470 AT_CLEANUP])
471
980211b7
GL
472OVSDB_CHECK_IDL_PY_WITH_EXPOUT([simple idl, writing large data via IDL with unicode],
473 [['["idltest",
474 {"op": "insert",
475 "table": "simple",
476 "row": {"s": "'$(printf "测试超过四千零九十六个字节的中文字符串以使解码出现问题。%.0s" {1..50})'"}}]']],
477 [['set 0 b 1, insert 1, set 1 s '$(printf "测试超过四千零九十六个字节的中文字符串以使解码出现问题。%.0s" {1..100})'']],
478 [[000: i=0 r=0 b=false s=$(printf "测试超过四千零九十六个字节的中文字符串以使解码出现问题。%.0s" {1..50}) u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
479001: commit, status=success
480002: i=0 r=0 b=true s=$(printf "测试超过四千零九十六个字节的中文字符串以使解码出现问题。%.0s" {1..50}) u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
481002: i=1 r=0 b=false s=$(printf "测试超过四千零九十六个字节的中文字符串以使解码出现问题。%.0s" {1..100}) u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
482003: done]])
483
a91c6104
BP
484OVSDB_CHECK_IDL([simple idl, handling verification failure],
485 [['["idltest",
486 {"op": "insert",
487 "table": "simple",
488 "row": {"i": 1,
489 "r": 2.0}},
490 {"op": "insert",
491 "table": "simple",
492 "row": {}}]']],
493 [['set 0 b 1' \
494 '+["idltest",
495 {"op": "update",
496 "table": "simple",
497 "where": [["i", "==", 1]],
498 "row": {"r": 5.0}}]' \
499 '+verify 1 r, set 1 r 3' \
500 'verify 1 r, set 1 r 3' \
501 ]],
502 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
503000: i=1 r=2 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
504001: commit, status=success
505002: {"error":null,"result":[{"count":1}]}
94fbe1aa 506003: commit, status=try again
a91c6104
BP
507004: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
508004: i=1 r=5 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
509005: commit, status=success
510006: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
511006: i=1 r=3 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
512007: done
513]])
514
b54e22e9 515OVSDB_CHECK_IDL([simple idl, increment operation],
9cb53f26
BP
516 [['["idltest",
517 {"op": "insert",
b54e22e9
BP
518 "table": "simple",
519 "row": {}}]']],
94fbe1aa 520 [['set 0 r 2.0, increment 0']],
b54e22e9
BP
521 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
522001: commit, status=success, increment=1
523002: i=1 r=2 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
524003: done
525]])
526
2096903b
BP
527OVSDB_CHECK_IDL([simple idl, aborting],
528 [['["idltest",
529 {"op": "insert",
530 "table": "simple",
531 "row": {}}]']],
532 [['set 0 r 2.0, abort' \
533'+set 0 b 1']],
534 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
535001: commit, status=aborted
536002: commit, status=success
537003: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
538004: done
539]])
540
541OVSDB_CHECK_IDL([simple idl, destroy without commit or abort],
542 [['["idltest",
543 {"op": "insert",
544 "table": "simple",
545 "row": {}}]']],
546 [['set 0 r 2.0, destroy' \
547'+set 0 b 1']],
548 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
549001: destroy
550002: commit, status=success
551003: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
552004: done
553]])
554
16ebb90e
LS
555OVSDB_CHECK_IDL([simple idl, conditional, false condition],
556 [['["idltest",
557 {"op": "insert",
558 "table": "simple",
559 "row": {"i": 1,
560 "r": 2.0,
561 "b": true}}]']],
0164e367
BP
562 [['condition simple []' \
563 'condition simple [true]']],
16ebb90e
LS
564 [[000: change conditions
565001: empty
566002: change conditions
567003: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
568004: done
569]])
570
571OVSDB_CHECK_IDL([simple idl, conditional, true condition],
572 [['["idltest",
573 {"op": "insert",
574 "table": "simple",
575 "row": {"i": 1,
576 "r": 2.0,
577 "b": true}}]']],
0164e367
BP
578 [['condition simple []' \
579 'condition simple [true]']],
16ebb90e
LS
580 [[000: change conditions
581001: empty
582002: change conditions
583003: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
584004: done
585]])
586
587OVSDB_CHECK_IDL([simple idl, conditional, multiple clauses in condition],
588 [['["idltest",
589 {"op": "insert",
590 "table": "simple",
591 "row": {"i": 1,
592 "r": 2.0,
593 "b": true}},
594 {"op": "insert",
595 "table": "simple",
596 "row": {"i": 2,
597 "r": 3.0,
598 "b": true}}]']],
0164e367
BP
599 [['condition simple []' \
600 'condition simple [["i","==",1],["i","==",2]]']],
16ebb90e
LS
601 [[000: change conditions
602001: empty
603002: change conditions
604003: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
605003: i=2 r=3 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
606004: done
607]])
608
609OVSDB_CHECK_IDL([simple idl, conditional, modify as insert due to condition],
610 [['["idltest",
611 {"op": "insert",
612 "table": "simple",
613 "row": {"i": 1,
614 "r": 2.0,
615 "b": true}}]']],
0164e367
BP
616 [['condition simple []' \
617 'condition simple [["i","==",1]]']],
16ebb90e
LS
618 [[000: change conditions
619001: empty
620002: change conditions
621003: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
622004: done
623]])
624
625OVSDB_CHECK_IDL([simple idl, conditional, modify as delete due to condition],
626 [['["idltest",
627 {"op": "insert",
628 "table": "simple",
629 "row": {"i": 1,
630 "r": 2.0,
631 "b": true}}]']],
0164e367
BP
632 [['condition simple []' \
633 'condition simple [["i","==",1],["i","==",2]]' \
634 'condition simple [["i","==",2]]' \
16ebb90e
LS
635 '["idltest",
636 {"op": "insert",
637 "table": "simple",
638 "row": {"i": 2,
639 "r": 3.0,
640 "b": true}}]']],
641 [[000: change conditions
642001: empty
643002: change conditions
644003: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
645004: change conditions
646005: empty
647006: {"error":null,"result":[{"uuid":["uuid","<2>"]}]}
648007: i=2 r=3 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
649008: done
650]])
651
652OVSDB_CHECK_IDL([simple idl, conditional, multiple tables],
653 [['["idltest",
654 {"op": "insert",
655 "table": "simple",
656 "row": {"i": 1,
657 "r": 2.0,
658 "b": true}},
659 {"op": "insert",
660 "table": "link1",
661 "row": {"i": 0, "k": ["named-uuid", "self"]},
662 "uuid-name": "self"},
663 {"op": "insert",
664 "table": "link2",
665 "row": {"i": 2},
666 "uuid-name": "row0"}]']],
0164e367
BP
667 [['condition simple [];link1 [];link2 []' \
668 'condition simple [["i","==",1]]' \
669 'condition link1 [["i","==",0]]' \
670 'condition link2 [["i","==",3]]' \
16ebb90e
LS
671 '+["idltest",
672 {"op": "insert",
673 "table": "link2",
674 "row": {"i": 3},
675 "uuid-name": "row0"}]']],
676 [[000: change conditions
677001: empty
678002: change conditions
679003: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
680004: change conditions
681005: i=0 k=0 ka=[] l2= uuid=<2>
682005: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
683006: change conditions
684007: {"error":null,"result":[{"uuid":["uuid","<3>"]}]}
685008: i=0 k=0 ka=[] l2= uuid=<2>
686008: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
687008: i=3 l1= uuid=<3>
688009: done
689]])
690
c3bb4bd7
BP
691OVSDB_CHECK_IDL([self-linking idl, consistent ops],
692 [],
9cb53f26
BP
693 [['["idltest",
694 {"op": "insert",
e9011ac8 695 "table": "link1",
c3bb4bd7
BP
696 "row": {"i": 0, "k": ["named-uuid", "self"]},
697 "uuid-name": "self"}]' \
9cb53f26
BP
698 '["idltest",
699 {"op": "insert",
e9011ac8 700 "table": "link1",
2d2d6d4a 701 "row": {"i": 1, "k": ["named-uuid", "row2"]},
c3bb4bd7
BP
702 "uuid-name": "row1"},
703 {"op": "insert",
e9011ac8 704 "table": "link1",
c3bb4bd7 705 "row": {"i": 2, "k": ["named-uuid", "row1"]},
2d2d6d4a 706 "uuid-name": "row2"}]' \
9cb53f26
BP
707 '["idltest",
708 {"op": "update",
e9011ac8 709 "table": "link1",
c3bb4bd7
BP
710 "where": [["i", "==", 1]],
711 "row": {"k": ["uuid", "#1#"]}}]' \
9cb53f26
BP
712 '["idltest",
713 {"op": "update",
e9011ac8 714 "table": "link1",
c3bb4bd7
BP
715 "where": [],
716 "row": {"k": ["uuid", "#0#"]}}]']],
717 [[000: empty
718001: {"error":null,"result":[{"uuid":["uuid","<0>"]}]}
e9011ac8 719002: i=0 k=0 ka=[] l2= uuid=<0>
fbf925e4 720003: {"error":null,"result":[{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]}]}
e9011ac8
BP
721004: i=0 k=0 ka=[] l2= uuid=<0>
722004: i=1 k=2 ka=[] l2= uuid=<1>
723004: i=2 k=1 ka=[] l2= uuid=<2>
c3bb4bd7 724005: {"error":null,"result":[{"count":1}]}
e9011ac8
BP
725006: i=0 k=0 ka=[] l2= uuid=<0>
726006: i=1 k=1 ka=[] l2= uuid=<1>
727006: i=2 k=1 ka=[] l2= uuid=<2>
c3bb4bd7 728007: {"error":null,"result":[{"count":3}]}
e9011ac8
BP
729008: i=0 k=0 ka=[] l2= uuid=<0>
730008: i=1 k=0 ka=[] l2= uuid=<1>
731008: i=2 k=0 ka=[] l2= uuid=<2>
c3bb4bd7
BP
732009: done
733]])
734
735OVSDB_CHECK_IDL([self-linking idl, inconsistent ops],
736 [],
9cb53f26
BP
737 [['["idltest",
738 {"op": "insert",
e9011ac8 739 "table": "link1",
c3bb4bd7 740 "row": {"i": 0, "k": ["uuid", "cf197cc5-c8c9-42f5-82d5-c71a9f2cb96b"]}}]' \
9cb53f26
BP
741 '+["idltest",
742 {"op": "insert",
e9011ac8 743 "table": "link1",
0d0f05b9
BP
744 "uuid-name": "one",
745 "row": {"i": 1, "k": ["named-uuid", "one"]}},
746 {"op": "insert",
747 "table": "link1",
748 "row": {"i": 2, "k": ["named-uuid", "one"]}}]' \
9cb53f26
BP
749 '["idltest",
750 {"op": "update",
e9011ac8 751 "table": "link1",
c3bb4bd7
BP
752 "where": [],
753 "row": {"k": ["uuid", "c2fca39a-e69a-42a4-9c56-5eca85839ce9"]}}]' \
9cb53f26
BP
754 '+["idltest",
755 {"op": "delete",
e9011ac8 756 "table": "link1",
0d0f05b9 757 "where": [["_uuid", "==", ["uuid", "#1#"]]]}]' \
9cb53f26
BP
758 '+["idltest",
759 {"op": "delete",
e9011ac8 760 "table": "link1",
0d0f05b9 761 "where": [["_uuid", "==", ["uuid", "#2#"]]]}]' \
9cb53f26
BP
762 '["idltest",
763 {"op": "delete",
0d0f05b9
BP
764 "table": "link1",
765 "where": []}]' \
c3bb4bd7
BP
766]],
767 [[000: empty
97f7803b 768001: {"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
769002: {"error":null,"result":[{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]}
770003: i=1 k=1 ka=[] l2= uuid=<2>
771003: i=2 k=1 ka=[] l2= uuid=<3>
254604d8 772004: {"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
773005: {"error":null,"result":[{"count":1},{"details":"cannot delete link1 row <2> because of 1 remaining reference(s)","error":"referential integrity violation"}]}
774006: {"error":null,"result":[{"count":1}]}
775007: i=1 k=1 ka=[] l2= uuid=<2>
776008: {"error":null,"result":[{"count":1}]}
777009: empty
778010: done
254604d8
BP
779]],
780 [],
781 [[sed -e '/004:/s/row <[23]> references/row <x> references/']])
c3bb4bd7
BP
782
783OVSDB_CHECK_IDL([self-linking idl, sets],
784 [],
9cb53f26
BP
785 [['["idltest",
786 {"op": "insert",
e9011ac8 787 "table": "link1",
0d0f05b9 788 "row": {"i": 0, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i0"]]]},
c3bb4bd7
BP
789 "uuid-name": "i0"},
790 {"op": "insert",
e9011ac8 791 "table": "link1",
0d0f05b9 792 "row": {"i": 1, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i1"]]]},
c3bb4bd7
BP
793 "uuid-name": "i1"},
794 {"op": "insert",
e9011ac8 795 "table": "link1",
0d0f05b9 796 "row": {"i": 2, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i2"]]]},
c3bb4bd7
BP
797 "uuid-name": "i2"},
798 {"op": "insert",
e9011ac8 799 "table": "link1",
0d0f05b9 800 "row": {"i": 3, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i3"]]]},
c3bb4bd7 801 "uuid-name": "i3"}]' \
9cb53f26
BP
802 '["idltest",
803 {"op": "update",
e9011ac8 804 "table": "link1",
c3bb4bd7
BP
805 "where": [],
806 "row": {"ka": ["set", [["uuid", "#0#"], ["uuid", "#1#"], ["uuid", "#2#"], ["uuid", "#3#"]]]}}]' \
9cb53f26
BP
807 '["idltest",
808 {"op": "update",
e9011ac8 809 "table": "link1",
97f7803b
BP
810 "where": [["i", "==", 2]],
811 "row": {"ka": ["set", [["uuid", "#0#"], ["uuid", "88702e78-845b-4a6e-ad08-cf68922ae84a"], ["uuid", "#2#"]]]}}]' \
9cb53f26
BP
812 '+["idltest",
813 {"op": "delete",
0d0f05b9
BP
814 "table": "link1",
815 "where": []}]']],
c3bb4bd7
BP
816 [[000: empty
817001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]}
0d0f05b9
BP
818002: i=0 k=0 ka=[0] l2= uuid=<0>
819002: i=1 k=0 ka=[1] l2= uuid=<1>
820002: i=2 k=0 ka=[2] l2= uuid=<2>
821002: i=3 k=0 ka=[3] l2= uuid=<3>
c3bb4bd7 822003: {"error":null,"result":[{"count":4}]}
0d0f05b9
BP
823004: i=0 k=0 ka=[0 1 2 3] l2= uuid=<0>
824004: i=1 k=0 ka=[0 1 2 3] l2= uuid=<1>
825004: i=2 k=0 ka=[0 1 2 3] l2= uuid=<2>
826004: i=3 k=0 ka=[0 1 2 3] l2= uuid=<3>
97f7803b 827005: {"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
828006: {"error":null,"result":[{"count":4}]}
829007: empty
830008: done
c3bb4bd7
BP
831]])
832
e9011ac8
BP
833OVSDB_CHECK_IDL([external-linking idl, consistent ops],
834 [],
9cb53f26
BP
835 [['["idltest",
836 {"op": "insert",
e9011ac8
BP
837 "table": "link2",
838 "row": {"i": 0},
839 "uuid-name": "row0"},
840 {"op": "insert",
841 "table": "link1",
0d0f05b9 842 "row": {"i": 1, "k": ["named-uuid", "row1"], "l2": ["set", [["named-uuid", "row0"]]]},
e9011ac8
BP
843 "uuid-name": "row1"}]']],
844 [[000: empty
845001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
846002: i=0 l1= uuid=<0>
0d0f05b9 847002: i=1 k=1 ka=[] l2=0 uuid=<1>
e9011ac8
BP
848003: done
849]])
225b582a 850
079ace1f
MM
851OVSDB_CHECK_IDL([singleton idl, constraints],
852 [],
853 [['["idltest",
854 {"op": "insert",
855 "table": "singleton",
856 "row": {"name": "foo"}}]' \
857 '["idltest",
858 {"op": "insert",
859 "table": "singleton",
860 "row": {"name": "bar"}}]' \
861 '+["idltest",
862 {"op": "delete",
863 "table": "singleton",
864 "where": [["_uuid", "==", ["uuid", "#0#"]]]},
865 {"op": "insert",
866 "table": "singleton",
867 "row": {"name": "bar"}}]']],
868 [[000: empty
869001: {"error":null,"result":[{"uuid":["uuid","<0>"]}]}
870002: name=foo uuid=<0>
871003: {"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"}]}
872004: {"error":null,"result":[{"count":1},{"uuid":["uuid","<2>"]}]}
873005: name=bar uuid=<2>
874006: done
875]])
876
225b582a
IY
877OVSDB_CHECK_IDL_PY([external-linking idl, insert ops],
878 [],
879 [['linktest']],
880 [[000: empty
881001: commit, status=success
882002: i=1 k=1 ka=[1] l2= uuid=<0>
883002: i=2 k=1 ka=[1 2] l2= uuid=<1>
884003: done
885]])
3b4c362f
IY
886
887OVSDB_CHECK_IDL_PY([getattr idl, insert ops],
888 [],
889 [['getattrtest']],
890 [[000: empty
891001: commit, status=success
892002: i=2 k=2 ka=[] l2= uuid=<0>
893003: done
894]])
d18e52e3 895
d7d417fc
TW
896OVSDB_CHECK_IDL_PY([row-from-json idl, whats this],
897 [['["idltest",
898 {"op": "insert",
899 "table": "simple",
900 "row": {"i": 1}},
901 {"op": "insert",
902 "table": "simple",
903 "row": {}}]']],
904 [['notifytest insert 2, notifytest set 1 b 1, notifytest delete 0']],
905 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
906000: i=1 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
907001: commit, status=success, events=create|2|None, delete|0|None, update|1|b
908002: i=1 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
909002: i=2 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>
910003: done
911]])
912
d18e52e3
BP
913AT_SETUP([idl handling of missing tables and columns - C])
914AT_KEYWORDS([ovsdb server idl positive])
d18e52e3
BP
915
916# idltest2.ovsschema is the same as idltest.ovsschema, except that
917# table link2 and column l2 have been deleted. But the IDL still
918# expects them to be there, so this test checks that it properly
919# tolerates them being missing.
56120500 920AT_CHECK([ovsdb_start_idltest "" "$abs_srcdir/idltest2.ovsschema"])
d18e52e3
BP
921AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl unix:socket ['["idltest",
922 {"op": "insert",
923 "table": "link1",
924 "row": {"i": 0, "k": ["named-uuid", "self"]},
925 "uuid-name": "self"}]' \
926 '["idltest",
927 {"op": "insert",
928 "table": "link1",
929 "row": {"i": 1, "k": ["named-uuid", "row2"]},
930 "uuid-name": "row1"},
931 {"op": "insert",
932 "table": "link1",
933 "row": {"i": 2, "k": ["named-uuid", "row1"]},
934 "uuid-name": "row2"}]' \
935 '["idltest",
936 {"op": "update",
937 "table": "link1",
938 "where": [["i", "==", 1]],
939 "row": {"k": ["uuid", "#1#"]}}]' \
940 '["idltest",
941 {"op": "update",
942 "table": "link1",
943 "where": [],
944 "row": {"k": ["uuid", "#0#"]}}]']],
5a0e4aec 945 [0], [stdout], [stderr])
c724bd67 946AT_CHECK([sort stdout | uuidfilt], [0],
d18e52e3
BP
947 [[000: empty
948001: {"error":null,"result":[{"uuid":["uuid","<0>"]}]}
949002: i=0 k=0 ka=[] l2= uuid=<0>
950003: {"error":null,"result":[{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]}]}
951004: i=0 k=0 ka=[] l2= uuid=<0>
952004: i=1 k=2 ka=[] l2= uuid=<1>
953004: i=2 k=1 ka=[] l2= uuid=<2>
954005: {"error":null,"result":[{"count":1}]}
955006: i=0 k=0 ka=[] l2= uuid=<0>
956006: i=1 k=1 ka=[] l2= uuid=<1>
957006: i=2 k=1 ka=[] l2= uuid=<2>
958007: {"error":null,"result":[{"count":3}]}
959008: i=0 k=0 ka=[] l2= uuid=<0>
960008: i=1 k=0 ka=[] l2= uuid=<1>
961008: i=2 k=0 ka=[] l2= uuid=<2>
962009: done
7427f2a4 963]])
d18e52e3
BP
964
965# Check that ovsdb-idl figured out that table link2 and column l2 are missing.
966AT_CHECK([grep ovsdb_idl stderr | sort], [0], [dnl
f2cf6677 967test-ovsdb|ovsdb_idl|idltest database lacks indexed table (database needs upgrade?)
d18e52e3 968test-ovsdb|ovsdb_idl|idltest database lacks link2 table (database needs upgrade?)
9435b0b8 969test-ovsdb|ovsdb_idl|idltest database lacks simple5 table (database needs upgrade?)
f0d23f67 970test-ovsdb|ovsdb_idl|idltest database lacks simple6 table (database needs upgrade?)
079ace1f 971test-ovsdb|ovsdb_idl|idltest database lacks singleton table (database needs upgrade?)
d18e52e3
BP
972test-ovsdb|ovsdb_idl|link1 table in idltest database lacks l2 column (database needs upgrade?)
973])
974
975# Check that ovsdb-idl sent on "monitor" request and that it didn't
976# mention that table or column, and (for paranoia) that it did mention another
977# table and column.
1b1d2e6d 978AT_CHECK([grep -c '"monitor\|monitor_cond"' stderr], [0], [2
d18e52e3 979])
c383f3bf
LS
980AT_CHECK([grep '"monitor\|monitor_cond"' stderr | grep link2], [1])
981AT_CHECK([grep '"monitor\|monitor_cond"' stderr | grep l2], [1])
982AT_CHECK([grep '"monitor\|monitor_cond"' stderr | grep -c '"link1"'], [0], [1
d18e52e3 983])
c383f3bf 984AT_CHECK([grep '"monitor\|monitor_cond"' stderr | grep -c '"ua"'], [0], [1
d18e52e3
BP
985])
986OVSDB_SERVER_SHUTDOWN
987AT_CLEANUP
80c12152 988
1ca0323e
BP
989m4_define([OVSDB_CHECK_IDL_FETCH_COLUMNS_PY],
990 [AT_SETUP([$1 - Python3 - fetch])
80c12152 991 AT_KEYWORDS([ovsdb server idl positive Python increment fetch $6])
56120500 992 AT_CHECK([ovsdb_start_idltest])
80c12152 993 m4_if([$2], [], [],
7427f2a4 994 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
1ca0323e 995 AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema unix:socket [$3] $4],
7427f2a4 996 [0], [stdout], [ignore])
c724bd67 997 AT_CHECK([sort stdout | uuidfilt]m4_if([$7],,, [[| $7]]),
7427f2a4 998 [0], [$5])
80c12152
SA
999 OVSDB_SERVER_SHUTDOWN
1000 AT_CLEANUP])
1001
1002m4_define([OVSDB_CHECK_IDL_FETCH_COLUMNS],
1003 [OVSDB_CHECK_IDL_FETCH_COLUMNS_PY($@)])
1004
1005OVSDB_CHECK_IDL_FETCH_COLUMNS([simple idl, initially populated],
1006 [['["idltest",
1007 {"op": "insert",
1008 "table": "simple",
1009 "row": {"i": 1,
1010 "r": 2.0,
1011 "b": true,
1012 "s": "mystring",
1013 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
1014 "ia": ["set", [1, 2, 3]],
1015 "ra": ["set", [-0.5]],
1016 "ba": ["set", [true]],
1017 "sa": ["set", ["abc", "def"]],
1018 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
1019 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
1020 {"op": "insert",
1021 "table": "simple",
1022 "row": {}}]']],
1023 [?simple:i,r!],
1024 ['fetch 0 r'],
1025 [[000: i=0 uuid=<0>
1026000: i=1 uuid=<1>
1027001: commit, status=success
1028002: i=0 r=0 uuid=<0>
1029002: i=1 uuid=<1>
1030003: done
1031]])
932104f4 1032
1ca0323e
BP
1033m4_define([OVSDB_CHECK_IDL_WO_MONITOR_COND_PY],
1034 [AT_SETUP([$1 - Python3])
897c8064 1035 AT_KEYWORDS([ovsdb server idl Python monitor $4])
56120500
BP
1036 AT_CHECK([ovsdb_start_idltest])
1037 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/disable-monitor-cond])
1ca0323e 1038 AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema unix:socket $2],
7ef00082 1039 [0], [stdout], [ignore])
c724bd67 1040 AT_CHECK([sort stdout | uuidfilt]m4_if([$5],,, [[| $5]]),
7ef00082 1041 [0], [$3])
897c8064
LS
1042 OVSDB_SERVER_SHUTDOWN
1043 AT_CLEANUP])
1044
897c8064
LS
1045m4_define([OVSDB_CHECK_IDL_WO_MONITOR_COND],
1046 [OVSDB_CHECK_IDL_WO_MONITOR_COND_PY($@)])
1047
1048
1049OVSDB_CHECK_IDL_WO_MONITOR_COND([simple idl disable monitor-cond],
1050 [['["idltest",
1051 {"op": "insert",
1052 "table": "simple",
1053 "row": {"i": 1,
1054 "r": 2.0,
1055 "b": true,
1056 "s": "mystring",
1057 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
1058 "ia": ["set", [1, 2, 3]],
1059 "ra": ["set", [-0.5]],
1060 "ba": ["set", [true]],
1061 "sa": ["set", ["abc", "def"]],
1062 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
1063 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
1064 {"op": "insert",
1065 "table": "simple",
1066 "row": {}}]' \
1067 '["idltest",
1068 {"op": "update",
1069 "table": "simple",
1070 "where": [],
1071 "row": {"b": true}}]' \
1072 '["idltest",
1073 {"op": "update",
1074 "table": "simple",
1075 "where": [],
1076 "row": {"r": 123.5}}]' \
1077 '["idltest",
1078 {"op": "insert",
1079 "table": "simple",
1080 "row": {"i": -1,
1081 "r": 125,
1082 "b": false,
1083 "s": "",
1084 "ia": ["set", [1]],
1085 "ra": ["set", [1.5]],
1086 "ba": ["set", [false]],
1087 "sa": ["set", []],
1088 "ua": ["set", []]}}]' \
1089 '["idltest",
1090 {"op": "update",
1091 "table": "simple",
1092 "where": [["i", "<", 1]],
1093 "row": {"s": "newstring"}}]' \
1094 '["idltest",
1095 {"op": "delete",
1096 "table": "simple",
1097 "where": [["i", "==", 0]]}]' \
1098 'reconnect']],
1099 [[000: empty
1100001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
1101002: i=0 r=0 b=false s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
1102002: 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>
1103003: {"error":null,"result":[{"count":2}]}
1104004: i=0 r=0 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
1105004: 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>
1106005: {"error":null,"result":[{"count":2}]}
1107006: i=0 r=123.5 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
1108006: 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>
1109007: {"error":null,"result":[{"uuid":["uuid","<6>"]}]}
1110008: i=-1 r=125 b=false s= u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
1111008: i=0 r=123.5 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
1112008: 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>
1113009: {"error":null,"result":[{"count":2}]}
1114010: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
1115010: i=0 r=123.5 b=true s=newstring u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
1116010: 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>
1117011: {"error":null,"result":[{"count":1}]}
1118012: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
1119012: 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>
1120013: reconnect
1121014: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
1122014: 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>
1123015: done
1124]])
1125
932104f4
SA
1126m4_define([OVSDB_CHECK_IDL_TRACK_C],
1127 [AT_SETUP([$1 - C])
1128 AT_KEYWORDS([ovsdb server idl tracking positive $5])
56120500 1129 AT_CHECK([ovsdb_start_idltest])
932104f4 1130 m4_if([$2], [], [],
7427f2a4 1131 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
932104f4 1132 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl unix:socket $3],
7427f2a4 1133 [0], [stdout], [ignore])
c724bd67 1134 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 1135 [0], [$4])
932104f4
SA
1136 OVSDB_SERVER_SHUTDOWN
1137 AT_CLEANUP])
1138
1139m4_define([OVSDB_CHECK_IDL_TRACK],
1140 [OVSDB_CHECK_IDL_TRACK_C($@)])
1141
1142OVSDB_CHECK_IDL_TRACK([track, simple idl, initially populated],
1143 [['["idltest",
1144 {"op": "insert",
1145 "table": "simple",
1146 "row": {"i": 1,
1147 "r": 2.0,
1148 "b": true,
1149 "s": "mystring",
1150 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
1151 "ia": ["set", [1, 2, 3]],
1152 "ra": ["set", [-0.5]],
1153 "ba": ["set", [true]],
1154 "sa": ["set", ["abc", "def"]],
1155 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
1156 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
1157 {"op": "insert",
1158 "table": "simple",
1159 "row": {}}]']],
1160 [['["idltest",
1161 {"op": "update",
1162 "table": "simple",
1163 "where": [],
1164 "row": {"b": true}}]']],
1165 [[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>
12eb2f67 1166000: inserted row: uuid=<3>
32d37ce8 1167000: updated columns: b ba i ia r ra s sa u ua
932104f4
SA
1168001: {"error":null,"result":[{"count":2}]}
1169002: i=0 r=0 b=true s= u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<5>
1170002: 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 1171002: updated columns: b
932104f4
SA
1172003: done
1173]])
1174
f0d23f67
IM
1175dnl This test creates database with weak references and checks that orphan
1176dnl rows created for weak references are not available for iteration via
1177dnl list of tracked changes.
1178OVSDB_CHECK_IDL_TRACK([track, simple idl, initially populated, orphan weak references],
1179 [['["idltest",
1180 {"op": "insert",
1181 "table": "simple",
1182 "row": {"s": "row0_s"},
1183 "uuid-name": "weak_row0"},
1184 {"op": "insert",
1185 "table": "simple",
1186 "row": {"s": "row1_s"},
1187 "uuid-name": "weak_row1"},
1188 {"op": "insert",
1189 "table": "simple",
1190 "row": {"s": "row2_s"},
1191 "uuid-name": "weak_row2"},
1192 {"op": "insert",
1193 "table": "simple6",
1194 "row": {"name": "first_row",
1195 "weak_ref": ["set",
1196 [["named-uuid", "weak_row0"],
1197 ["named-uuid", "weak_row1"],
1198 ["named-uuid", "weak_row2"]]
1199 ]}}]']],
1200 [['condition simple []' \
1201 'condition simple [["s","==","row1_s"]]' \
1202 '["idltest",
1203 {"op": "update",
1204 "table": "simple6",
1205 "where": [],
1206 "row": {"name": "new_name"}}]' \
1207 '["idltest",
1208 {"op": "delete",
1209 "table": "simple6",
1210 "where": []}]']],
1211 [[000: change conditions
1212001: inserted row: uuid=<0>
1213001: name=first_row weak_ref=[] uuid=<0>
1214001: updated columns: name weak_ref
1215002: change conditions
1216003: i=0 r=0 b=false s=row1_s u=<1> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
1217003: inserted row: uuid=<2>
1218003: name=first_row weak_ref=[<2>] uuid=<0>
1219003: updated columns: s
1220004: {"error":null,"result":[{"count":1}]}
1221005: name=new_name weak_ref=[<2>] uuid=<0>
1222005: updated columns: name
1223006: {"error":null,"result":[{"count":1}]}
1224007: i=0 r=0 b=false s=row1_s u=<1> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
1225008: done
1226]])
1227
2407099c
DC
1228dnl This test creates database with weak references and checks that the
1229dnl content of orphaned rows created for weak references after monitor
1230dnl condition change are not leaked when the row is reinserted and deleted.
1231OVSDB_CHECK_IDL_TRACK([track, simple idl, initially populated, orphan rows, conditional],
1232 [['["idltest",
1233 {"op": "insert",
1234 "table": "simple",
1235 "row": {"s": "row0_s"},
1236 "uuid-name": "weak_row0"},
1237 {"op": "insert",
1238 "table": "simple",
1239 "row": {"s": "row1_s"},
1240 "uuid-name": "weak_row1"},
1241 {"op": "insert",
1242 "table": "simple6",
1243 "row": {"name": "first_row",
1244 "weak_ref": ["set",
1245 [["named-uuid", "weak_row0"]]
1246 ]}}]']],
1247 [['condition simple []' \
1248 'condition simple [["s","==","row0_s"]]' \
1249 'condition simple [["s","==","row1_s"]]' \
1250 'condition simple [["s","==","row0_s"]]' \
1251 '["idltest",
1252 {"op": "delete",
1253 "table": "simple6",
1254 "where": []}]']],
1255 [[000: change conditions
1256001: inserted row: uuid=<0>
1257001: name=first_row weak_ref=[] uuid=<0>
1258001: updated columns: name weak_ref
1259002: change conditions
1260003: i=0 r=0 b=false s=row0_s u=<1> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
1261003: inserted row: uuid=<2>
1262003: name=first_row weak_ref=[<2>] uuid=<0>
1263003: updated columns: s
1264004: change conditions
1265005: i=0 r=0 b=false s=row1_s u=<1> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>
1266005: inserted row: uuid=<3>
1267005: updated columns: s
1268006: change conditions
1269007: deleted row: uuid=<3>
1270007: i=0 r=0 b=false s=row0_s u=<1> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
1271007: i=0 r=0 b=false s=row1_s u=<1> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>
1272007: inserted row: uuid=<2>
1273007: name=first_row weak_ref=[<2>] uuid=<0>
1274007: updated columns: s
1275008: {"error":null,"result":[{"count":1}]}
1276009: i=0 r=0 b=false s=row0_s u=<1> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
1277010: done
1278]])
1279
932104f4
SA
1280OVSDB_CHECK_IDL_TRACK([track, simple idl, initially empty, various ops],
1281 [],
1282 [['["idltest",
1283 {"op": "insert",
1284 "table": "simple",
1285 "row": {"i": 1,
1286 "r": 2.0,
1287 "b": true,
1288 "s": "mystring",
1289 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
1290 "ia": ["set", [1, 2, 3]],
1291 "ra": ["set", [-0.5]],
1292 "ba": ["set", [true]],
1293 "sa": ["set", ["abc", "def"]],
1294 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
1295 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
1296 {"op": "insert",
1297 "table": "simple",
1298 "row": {}}]' \
1299 '["idltest",
1300 {"op": "update",
1301 "table": "simple",
1302 "where": [],
1303 "row": {"b": true}}]' \
1304 '["idltest",
1305 {"op": "update",
1306 "table": "simple",
1307 "where": [],
1308 "row": {"r": 123.5}}]' \
1309 '["idltest",
1310 {"op": "insert",
1311 "table": "simple",
1312 "row": {"i": -1,
1313 "r": 125,
1314 "b": false,
1315 "s": "",
1316 "ia": ["set", [1]],
1317 "ra": ["set", [1.5]],
1318 "ba": ["set", [false]],
1319 "sa": ["set", []],
1320 "ua": ["set", []]}}]' \
1321 '["idltest",
1322 {"op": "update",
1323 "table": "simple",
1324 "where": [["i", "<", 1]],
1325 "row": {"s": "newstring"}}]' \
1326 '["idltest",
1327 {"op": "delete",
1328 "table": "simple",
1329 "where": [["i", "==", 0]]}]' \
1330 'reconnect']],
1331 [[000: empty
1332001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
1333002: 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>
12eb2f67 1334002: inserted row: uuid=<0>
32d37ce8 1335002: updated columns: b ba i ia r ra s sa u ua
932104f4
SA
1336003: {"error":null,"result":[{"count":2}]}
1337004: i=0 r=0 b=true s= u=<5> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
32d37ce8 1338004: updated columns: b
932104f4
SA
1339005: {"error":null,"result":[{"count":2}]}
1340006: i=0 r=123.5 b=true s= u=<5> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
1341006: 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
1342006: updated columns: r
1343006: updated columns: r
932104f4
SA
1344007: {"error":null,"result":[{"uuid":["uuid","<6>"]}]}
1345008: i=-1 r=125 b=false s= u=<5> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
12eb2f67 1346008: inserted row: uuid=<6>
32d37ce8 1347008: updated columns: ba i ia r ra
932104f4
SA
1348009: {"error":null,"result":[{"count":2}]}
1349010: i=-1 r=125 b=false s=newstring u=<5> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
1350010: i=0 r=123.5 b=true s=newstring u=<5> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
32d37ce8
SA
1351010: updated columns: s
1352010: updated columns: s
932104f4 1353011: {"error":null,"result":[{"count":1}]}
12eb2f67 1354012: deleted row: uuid=<1>
f0d23f67 1355012: i=0 r=123.5 b=true s=newstring u=<5> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
932104f4
SA
1356013: reconnect
1357014: i=-1 r=125 b=false s=newstring u=<5> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
1358014: 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
1359014: updated columns: b ba i ia r ra s sa u ua
1360014: updated columns: ba i ia r ra s
932104f4
SA
1361015: done
1362]])
7251075c
EA
1363
1364m4_define([OVSDB_CHECK_IDL_PARTIAL_UPDATE_MAP_COLUMN],
1365 [AT_SETUP([$1 - C])
1366 AT_KEYWORDS([ovsdb server idl partial update map column positive $5])
56120500 1367 AT_CHECK([ovsdb_start_idltest])
7251075c 1368 m4_if([$2], [], [],
7427f2a4 1369 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
7251075c 1370 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-partial-update-map-column unix:socket $3],
7427f2a4 1371 [0], [stdout], [ignore])
c724bd67 1372 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 1373 [0], [$4])
7251075c
EA
1374 OVSDB_SERVER_SHUTDOWN
1375 AT_CLEANUP])
1376
1377OVSDB_CHECK_IDL_PARTIAL_UPDATE_MAP_COLUMN([map, simple2 idl-partial-update-map-column, initially populated],
1378[['["idltest", {"op":"insert", "table":"simple2",
1379 "row":{"name":"myString1","smap":["map",[["key1","value1"],["key2","value2"]]]} }]']
1380],
1381[],
1382[[000: Getting records
1383001: name=myString1 smap=[[key1 : value1],[key2 : value2]] imap=[]
1384002: After insert element
1385003: name=String2 smap=[[key1 : myList1],[key2 : value2]] imap=[[3 : myids2]]
1386004: After insert duplicated element
1387005: name=String2 smap=[[key1 : myList1],[key2 : value2]] imap=[[3 : myids2]]
1388006: After delete element
1389007: name=String2 smap=[[key2 : value2]] imap=[[3 : myids2]]
1390008: After trying to delete a deleted element
1391009: name=String2 smap=[[key2 : value2]] imap=[[3 : myids2]]
1392010: End test
1393]])
a7261bf7 1394
a59912a0
RM
1395OVSDB_CHECK_IDL_PY([partial-map idl],
1396[['["idltest", {"op":"insert", "table":"simple2",
330b9c9c 1397 "row":{"name":"myString1","smap":["map",[["key1","value1"],["key2","value2"]]]} }]']
a59912a0 1398],
2d54d801 1399 [?simple2:name,smap,imap 'partialmapinsertelement' 'partialmapinsertmultipleelements' 'partialmapdelelements' 'partialmapmutatenew'],
330b9c9c 1400[[000: name=myString1 smap=[(key1 value1) (key2 value2)] imap=[]
a59912a0 1401001: commit, status=success
330b9c9c 1402002: name=String2 smap=[(key1 myList1) (key2 value2)] imap=[(3 myids2)]
a59912a0 1403003: commit, status=success
2d54d801 1404004: name=String2 smap=[(key1 myList1) (key2 myList2) (key3 myList3) (key4 myList4)] imap=[(3 myids2)]
330b9c9c
AB
1405005: commit, status=success
1406006: name=String2 smap=[(key2 myList2)] imap=[(3 myids2)]
2d54d801
AB
1407007: commit, status=success
1408008: name=String2 smap=[(key2 myList2)] imap=[(3 myids2)]
1409008: name=String2New smap=[(key1 newList1) (key2 newList2)] imap=[]
1410009: done
a59912a0
RM
1411]])
1412
9435b0b8
TW
1413OVSDB_CHECK_IDL_PY([partial-map update set refmap idl],
1414[['["idltest", {"op":"insert", "table":"simple3", "row":{"name":"myString1"}},
1415 {"op":"insert", "table":"simple5", "row":{"name":"myString2"}}]']],
1416['partialmapmutateirefmap'],
1417[[000: name=myString1 uset=[]
1418000: name=myString2 irefmap=[]
1419001: commit, status=success
1420002: name=myString1 uset=[]
1421002: name=myString2 irefmap=[(1 <0>)]
1422003: done
1423]])
1424
f1ab6e06
RM
1425m4_define([OVSDB_CHECK_IDL_PARTIAL_UPDATE_SET_COLUMN],
1426 [AT_SETUP([$1 - C])
1427 AT_KEYWORDS([ovsdb server idl partial update set column positive $5])
56120500 1428 AT_CHECK([ovsdb_start_idltest])
f1ab6e06
RM
1429 m4_if([$2], [], [],
1430 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
1431 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-partial-update-set-column unix:socket $3],
1432 [0], [stdout], [ignore])
c724bd67 1433 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
f1ab6e06
RM
1434 [0], [$4])
1435 OVSDB_SERVER_SHUTDOWN
1436 AT_CLEANUP])
1437
1438OVSDB_CHECK_IDL_PARTIAL_UPDATE_SET_COLUMN([set, simple3 idl-partial-update-set-column, initially populated],
1439[['["idltest", {"op":"insert", "table":"simple3",
1440 "row":{"name":"mySet1","uset":["set", [[ "uuid", "0005b872-f9e5-43be-ae02-3184b9680e75" ], [ "uuid", "000d2f6a-76af-412f-b59d-e7bcd3e84eff" ]]]} }]']
1441],
1442[],
1443[[000: Getting records
1444001: name=mySet1 uset=[[<0>],[<1>]] uref=[]
1445002: After rename+add new value
1446003: name=String2 uset=[[<0>],[<1>],[<2>]] uref=[]
1447004: After add new value
1448005: name=String2 uset=[[<0>],[<1>],[<2>],[<3>]] uref=[]
1449006: After delete value
1450007: name=String2 uset=[[<0>],[<1>],[<3>]] uref=[]
1451008: After trying to delete a deleted value
1452009: name=String2 uset=[[<0>],[<1>],[<3>]] uref=[]
1453010: After add to other table + set of strong ref
1454011: name=String2 uset=[[<0>],[<1>],[<3>]] uref=[[<4>]]
1455012: End test
1456]])
1457
a59912a0 1458OVSDB_CHECK_IDL_PY([partial-set idl],
b3220c67
AB
1459[['["idltest", {"op":"insert", "table":"simple3", "uuid-name":"newrow",
1460 "row":{"name":"mySet1","uset":["set", [[ "uuid", "0005b872-f9e5-43be-ae02-3184b9680e75" ]]]} },
1461 {"op":"insert", "table":"simple4", "row":{"name":"seed"}},
1462 {"op":"mutate", "table":"simple3", "where":[["_uuid", "==", ["named-uuid", "newrow"]]],
1463 "mutations": [["uset", "insert", ["set", [["uuid", "000d2f6a-76af-412f-b59d-e7bcd3e84eff"]]]]]}]']
a59912a0 1464],
2d54d801 1465 ['partialrenamesetadd' 'partialduplicateadd' 'partialsetdel' 'partialsetref' 'partialsetoverrideops' 'partialsetadddelete' 'partialsetmutatenew'],
a59912a0
RM
1466[[000: name=mySet1 uset=[<0> <1>]
1467001: commit, status=success
1468002: name=String2 uset=[<0> <1> <2>]
1469003: commit, status=success
1470004: name=String2 uset=[<0> <1> <2> <3>]
1471005: commit, status=success
1472006: name=String2 uset=[<0> <1> <3>]
1473007: commit, status=success
1474008: name=String2 uset=[<0> <1> <3>]
330b9c9c
AB
1475009: commit, status=success
1476010: name=String2 uset=[<3>]
b3220c67 1477011: commit, status=success
2d54d801
AB
1478012: name=String2 uset=[<4> <5>]
1479013: commit, status=success
1480014: name=String2 uset=[<4> <5>]
1481014: name=String3 uset=[<6>]
1482015: done
a59912a0
RM
1483]])
1484
a7261bf7 1485m4_define([OVSDB_CHECK_IDL_NOTIFY],
1ca0323e
BP
1486 [OVSDB_CHECK_IDL_PY([$1], [], [$2], [$3], [notify $4], [$5])
1487 OVSDB_CHECK_IDL_SSL_PY([$1], [], [$2], [$3], [notify $4], [$5])])
a7261bf7
NS
1488
1489OVSDB_CHECK_IDL_NOTIFY([simple idl verify notify],
1490 [['track-notify' \
1491 '["idltest",
1492 {"op": "insert",
1493 "table": "simple",
1494 "row": {"i": 1,
1495 "r": 2.0,
1496 "b": true,
1497 "s": "mystring",
1498 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
1499 "ia": ["set", [1, 2, 3]],
1500 "ra": ["set", [-0.5]],
1501 "ba": ["set", [true]],
1502 "sa": ["set", ["abc", "def"]],
1503 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
1504 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
1505 {"op": "insert",
1506 "table": "simple",
1507 "row": {}}]' \
1508 '["idltest",
1509 {"op": "update",
1510 "table": "simple",
1511 "where": [],
1512 "row": {"b": false}}]' \
1513 '["idltest",
1514 {"op": "update",
1515 "table": "simple",
1516 "where": [],
1517 "row": {"r": 123.5}}]' \
1518 '["idltest",
1519 {"op": "insert",
1520 "table": "simple",
1521 "row": {"i": -1,
1522 "r": 125,
1523 "b": false,
1524 "s": "",
1525 "ia": ["set", [1]],
1526 "ra": ["set", [1.5]],
1527 "ba": ["set", [false]],
1528 "sa": ["set", []],
1529 "ua": ["set", []]}}]' \
1530 '["idltest",
1531 {"op": "update",
1532 "table": "simple",
1533 "where": [["i", "<", 1]],
1534 "row": {"s": "newstring"}}]' \
1535 '["idltest",
1536 {"op": "delete",
1537 "table": "simple",
1538 "where": [["i", "==", 0]]}]' \
1539 'reconnect']],
1540 [[000: empty
c39751e4
TE
1541000: event:create, row={uuid=<0>}, updates=None
1542000: event:create, row={uuid=<1>}, updates=None
1543001: {"error":null,"result":[{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]}
1544002: event:create, row={i=0 r=0 b=false s= u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>}, updates=None
1545002: 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
1546002: i=0 r=0 b=false s= u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>
1547002: 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 1548003: {"error":null,"result":[{"count":2}]}
c39751e4
TE
1549004: 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>}
1550004: i=0 r=0 b=false s= u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>
1551004: 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 1552005: {"error":null,"result":[{"count":2}]}
c39751e4
TE
1553006: 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>}
1554006: 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>}
1555006: i=0 r=123.5 b=false s= u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>
1556006: 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>
1557007: {"error":null,"result":[{"uuid":["uuid","<8>"]}]}
1558008: 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
1559008: i=-1 r=125 b=false s= u=<4> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<8>
1560008: i=0 r=123.5 b=false s= u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>
1561008: 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 1562009: {"error":null,"result":[{"count":2}]}
c39751e4
TE
1563010: 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>}
1564010: 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>}
1565010: i=-1 r=125 b=false s=newstring u=<4> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<8>
1566010: i=0 r=123.5 b=false s=newstring u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>
1567010: 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 1568011: {"error":null,"result":[{"count":1}]}
c39751e4
TE
1569012: event:delete, row={i=0 r=123.5 b=false s=newstring u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>}, updates=None
1570012: i=-1 r=125 b=false s=newstring u=<4> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<8>
1571012: 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 1572013: reconnect
c39751e4
TE
1573014: 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
1574014: 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
1575014: event:create, row={uuid=<0>}, updates=None
1576014: event:create, row={uuid=<1>}, updates=None
1577014: i=-1 r=125 b=false s=newstring u=<4> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<8>
1578014: 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
1579015: done
1580]])
0a8606ee
LR
1581
1582# Tests to verify the functionality of the one column compound index.
1583# It tests index for one column string and integer indexes.
1584# The run of test-ovsdb generates the output of the display of data using the different indexes defined in
1585# the program.
1586# Then, some at_checks are used to verify the correctness of the corresponding index as well as the existence
1587# of all the rows involved in the test.
1588m4_define([OVSDB_CHECK_IDL_COMPOUND_INDEX_SINGLE_COLUMN_C],
1589 [AT_SETUP([$1 - C])
1590 AT_KEYWORDS([ovsdb server idl compound_index_single_column compound_index positive $5])
1591 AT_CHECK([ovsdb_start_idltest])
1592 m4_if([$2], [], [],
7ef00082 1593 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
0a8606ee
LR
1594# Generate the data to be tested.
1595 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-compound-index unix:socket $3],
7ef00082 1596 [0], [stdout], [ignore])
0a8606ee
LR
1597# Filter the rows of data that corresponds to the string index eliminating the extra columns of data.
1598# This is done to verifiy that the output data is in the correct and expected order.
1599 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: s=.*' | sed -e 's/ i=.*//g']],
7ef00082 1600 [0], [$4])
0a8606ee
LR
1601# Here, the data is filtered and sorted in order to have all the rows in the index and be
1602# able to determined that all the involved rows are present.
1603 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: s=.*' | sort -k 1,1n -k 2,2 -k 3,3]],
7ef00082 1604 [0], [$5])
0a8606ee
LR
1605# Filter the rows of data that corresponds to the integer index eliminating the extra columns of data.
1606# This is done to verifiy that the output data is in the correct and expected order.
1607 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: i=.*' | sed -e 's/ s=.*//g']],
7ef00082 1608 [0], [$6])
0a8606ee
LR
1609# Here again, the data is filtered and sorted in order to have all the rows in the index and be
1610# able to determined that all the involved rows are present.
1611 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: i=.*' | sort -k 1,1n -k 2,2 -k 3,3]],
7ef00082 1612 [0], [$7])
0a8606ee
LR
1613 OVSDB_SERVER_SHUTDOWN
1614 AT_CLEANUP])
1615
1616OVSDB_CHECK_IDL_COMPOUND_INDEX_SINGLE_COLUMN_C([Compound_index, single column test ],
1617 [['["idltest",
1618 {"op": "insert", "table": "simple", "row": {"s":"List000", "i": 1, "b":true, "r":101.0}},
1619 {"op": "insert", "table": "simple", "row": {"s":"List000", "i": 2, "b":false, "r":102.0}},
1620 {"op": "insert", "table": "simple", "row": {"s":"List000", "i": 10, "b":true, "r":110.0}},
1621 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 1, "b":false, "r":110.0}},
1622 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 2, "b":true, "r":120.0}},
1623 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 2, "b":true, "r":122.0}},
1624 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 4, "b":true, "r":130.0}},
1625 {"op": "insert", "table": "simple", "row": {"s":"List005", "i": 5, "b":true, "r":130.0}},
1626 {"op": "insert", "table": "simple", "row": {"s":"List020", "i": 20, "b":true, "r":220.0}},
1627 {"op": "insert", "table": "simple", "row": {"s":"List020", "i": 19, "b":true, "r":219.0}}
1628 ]']],
1629 [idl_compound_index_single_column],
1630 [001: s=List000
1631001: s=List000
1632001: s=List000
1633001: s=List001
1634001: s=List001
1635001: s=List001
1636001: s=List001
1637001: s=List005
1638001: s=List020
1639001: s=List020
1640003: s=List001
1641003: s=List001
1642003: s=List001
1643003: s=List001
1644],
1645[001: s=List000 i=1 b=True r=101.000000
1646001: s=List000 i=10 b=True r=110.000000
1647001: s=List000 i=2 b=False r=102.000000
1648001: s=List001 i=1 b=False r=110.000000
1649001: s=List001 i=2 b=True r=120.000000
1650001: s=List001 i=2 b=True r=122.000000
1651001: s=List001 i=4 b=True r=130.000000
1652001: s=List005 i=5 b=True r=130.000000
1653001: s=List020 i=19 b=True r=219.000000
1654001: s=List020 i=20 b=True r=220.000000
1655003: s=List001 i=1 b=False r=110.000000
1656003: s=List001 i=2 b=True r=120.000000
1657003: s=List001 i=2 b=True r=122.000000
1658003: s=List001 i=4 b=True r=130.000000
1659],
1660[002: i=1
1661002: i=1
1662002: i=2
1663002: i=2
1664002: i=2
1665002: i=4
1666002: i=5
1667002: i=10
1668002: i=19
1669002: i=20
1670004: i=5
1671005: i=4
1672005: i=5
1673006: i=5
1674006: i=10
1675006: i=19
1676006: i=20
1677006: i=54
0a8606ee 1678007: i=5
0a8606ee
LR
1679007: i=19
1680007: i=20
d0bde286 1681007: i=30
0a8606ee 1682007: i=54
d0bde286
HZ
1683008: i=1
1684008: i=1
1685008: i=2
1686008: i=2
1687008: i=2
1688008: i=5
1689008: i=19
1690008: i=20
1691008: i=30
1692008: i=54
0a8606ee
LR
1693],
1694[002: i=1 s=List000 b=True r=101.000000
1695002: i=1 s=List001 b=False r=110.000000
1696002: i=10 s=List000 b=True r=110.000000
1697002: i=19 s=List020 b=True r=219.000000
1698002: i=2 s=List000 b=False r=102.000000
1699002: i=2 s=List001 b=True r=120.000000
1700002: i=2 s=List001 b=True r=122.000000
1701002: i=20 s=List020 b=True r=220.000000
1702002: i=4 s=List001 b=True r=130.000000
1703002: i=5 s=List005 b=True r=130.000000
1704004: i=5 s=List005 b=True r=130.000000
1705005: i=4 s=List001 b=True r=130.000000
1706005: i=5 s=List005 b=True r=130.000000
1707006: i=10 s=List000 b=True r=110.000000
1708006: i=19 s=List020 b=True r=219.000000
1709006: i=20 s=List020 b=True r=220.000000
1710006: i=5 s=List005 b=True r=130.000000
1711006: i=54 s=Lista054 b=False r=0.000000
0a8606ee 1712007: i=19 s=List020 b=True r=219.000000
0a8606ee 1713007: i=20 s=List020 b=True r=220.000000
d0bde286 1714007: i=30 s=List000 b=True r=110.000000
0a8606ee
LR
1715007: i=5 s=List005 b=True r=130.000000
1716007: i=54 s=Lista054 b=False r=0.000000
d0bde286
HZ
1717008: i=1 s=List000 b=True r=101.000000
1718008: i=1 s=List001 b=False r=110.000000
1719008: i=19 s=List020 b=True r=219.000000
1720008: i=2 s=List000 b=False r=102.000000
1721008: i=2 s=List001 b=True r=120.000000
1722008: i=2 s=List001 b=True r=122.000000
1723008: i=20 s=List020 b=True r=220.000000
1724008: i=30 s=List000 b=True r=110.000000
1725008: i=5 s=List005 b=True r=130.000000
1726008: i=54 s=Lista054 b=False r=0.000000
0a8606ee
LR
1727])
1728
1729# Tests to verify the functionality of two column compound index.
1730# It tests index for two columns using string and integer fields.
1731# The run of test-ovsdb generates the output of the display of data using the different indexes defined in
1732# the program.
1733# Then, some at_checks are used to verify the correctness of the corresponding index as well as the existence
1734# of all the rows involved in the test.
1735m4_define([OVSDB_CHECK_IDL_COMPOUND_INDEX_DOUBLE_COLUMN_C],
1736 [AT_SETUP([$1 - C])
1737 AT_KEYWORDS([ovsdb server idl compound_index_double_column compound_index positive $5])
1738 AT_CHECK([ovsdb_start_idltest])
1739 m4_if([$2], [], [],
7ef00082 1740 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
0a8606ee
LR
1741# Generate the data to be tested.
1742 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-compound-index unix:socket $3],
7ef00082 1743 [0], [stdout], [ignore])
0a8606ee
LR
1744# Filter the rows of data that corresponds to the string-integer index eliminating the extra columns of data.
1745# This is done to verifiy that the output data is in the correct and expected order.
1746 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: s=.*' | sed -e 's/ b=.*//g']],
7ef00082 1747 [0], [$4])
0a8606ee
LR
1748# Here, the data is filtered and sorted in order to have all the rows in the index and be
1749# able to determined that all the involved rows are present.
1750 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: s=.*' | sort -k 1,1n -k 2,2 -k 3,3]],
7ef00082 1751 [0], [$5])
0a8606ee
LR
1752# Filter the rows of data that corresponds to the integer index eliminating the extra columns of data.
1753# This is done to verifiy that the output data is in the correct and expected order.
1754 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: i=.*' | sed -e 's/ b=.*//g']],
7ef00082 1755 [0], [$6])
0a8606ee
LR
1756# Here again, the data is filtered and sorted in order to have all the rows in the index and be
1757# able to determined that all the involved rows are present.
1758 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: i=.*' | sort -k 1,1n -k 2,2 -k 3,3]],
7ef00082 1759 [0], [$7])
0a8606ee
LR
1760 OVSDB_SERVER_SHUTDOWN
1761 AT_CLEANUP])
1762
1763OVSDB_CHECK_IDL_COMPOUND_INDEX_DOUBLE_COLUMN_C([Compound_index, double column test ],
1764 [['["idltest",
1765 {"op": "insert", "table": "simple", "row": {"s":"List000", "i": 1, "b":true, "r":101.0}},
1766 {"op": "insert", "table": "simple", "row": {"s":"List000", "i": 2, "b":false, "r":102.0}},
1767 {"op": "insert", "table": "simple", "row": {"s":"List000", "i": 10, "b":true, "r":110.0}},
1768 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 1, "b":false, "r":110.0}},
1769 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 2, "b":true, "r":120.0}},
1770 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 2, "b":true, "r":122.0}},
1771 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 4, "b":true, "r":130.0}},
1772 {"op": "insert", "table": "simple", "row": {"s":"List005", "i": 5, "b":true, "r":130.0}},
1773 {"op": "insert", "table": "simple", "row": {"s":"List020", "i": 20, "b":true, "r":220.0}},
1774 {"op": "insert", "table": "simple", "row": {"s":"List020", "i": 19, "b":true, "r":219.0}}
1775 ]']],
1776 [idl_compound_index_double_column],
1777 [001: s=List000 i=1
1778001: s=List000 i=2
1779001: s=List000 i=10
1780001: s=List001 i=1
1781001: s=List001 i=2
1782001: s=List001 i=2
1783001: s=List001 i=4
1784001: s=List005 i=5
1785001: s=List020 i=19
1786001: s=List020 i=20
1787002: s=List000 i=10
1788002: s=List000 i=2
1789002: s=List000 i=1
1790002: s=List001 i=4
1791002: s=List001 i=2
1792002: s=List001 i=2
1793002: s=List001 i=1
1794002: s=List005 i=5
1795002: s=List020 i=20
1796002: s=List020 i=19
1797003: s=List000 i=10
1798004: s=List001 i=1
1799004: s=List001 i=2
1800004: s=List001 i=2
1801004: s=List001 i=4
1802004: s=List005 i=5
1803],
1804 [001: s=List000 i=1 b=True r=101.000000
1805001: s=List000 i=10 b=True r=110.000000
1806001: s=List000 i=2 b=False r=102.000000
1807001: s=List001 i=1 b=False r=110.000000
1808001: s=List001 i=2 b=True r=120.000000
1809001: s=List001 i=2 b=True r=122.000000
1810001: s=List001 i=4 b=True r=130.000000
1811001: s=List005 i=5 b=True r=130.000000
1812001: s=List020 i=19 b=True r=219.000000
1813001: s=List020 i=20 b=True r=220.000000
1814002: s=List000 i=1 b=True r=101.000000
1815002: s=List000 i=10 b=True r=110.000000
1816002: s=List000 i=2 b=False r=102.000000
1817002: s=List001 i=1 b=False r=110.000000
1818002: s=List001 i=2 b=True r=120.000000
1819002: s=List001 i=2 b=True r=122.000000
1820002: s=List001 i=4 b=True r=130.000000
1821002: s=List005 i=5 b=True r=130.000000
1822002: s=List020 i=19 b=True r=219.000000
1823002: s=List020 i=20 b=True r=220.000000
1824003: s=List000 i=10 b=True r=110.000000
1825004: s=List001 i=1 b=False r=110.000000
1826004: s=List001 i=2 b=True r=120.000000
1827004: s=List001 i=2 b=True r=122.000000
1828004: s=List001 i=4 b=True r=130.000000
1829004: s=List005 i=5 b=True r=130.000000
1830],
1831 [005: i=1 s=List000
1832005: i=1 s=List001
1833005: i=2 s=List000
1834005: i=2 s=List001
1835005: i=2 s=List001
1836005: i=4 s=List001
1837005: i=5 s=List005
1838005: i=10 s=List000
1839005: i=19 s=List020
1840005: i=20 s=List020
1841006: i=20 s=List020
1842006: i=19 s=List020
1843006: i=10 s=List000
1844006: i=5 s=List005
1845006: i=4 s=List001
1846006: i=2 s=List000
1847006: i=2 s=List001
1848006: i=2 s=List001
1849006: i=1 s=List000
1850006: i=1 s=List001
1851],
1852 [005: i=1 s=List000 b=True r=101.000000
1853005: i=1 s=List001 b=False r=110.000000
1854005: i=10 s=List000 b=True r=110.000000
1855005: i=19 s=List020 b=True r=219.000000
1856005: i=2 s=List000 b=False r=102.000000
1857005: i=2 s=List001 b=True r=120.000000
1858005: i=2 s=List001 b=True r=122.000000
1859005: i=20 s=List020 b=True r=220.000000
1860005: i=4 s=List001 b=True r=130.000000
1861005: i=5 s=List005 b=True r=130.000000
1862006: i=1 s=List000 b=True r=101.000000
1863006: i=1 s=List001 b=False r=110.000000
1864006: i=10 s=List000 b=True r=110.000000
1865006: i=19 s=List020 b=True r=219.000000
1866006: i=2 s=List000 b=False r=102.000000
1867006: i=2 s=List001 b=True r=120.000000
1868006: i=2 s=List001 b=True r=122.000000
1869006: i=20 s=List020 b=True r=220.000000
1870006: i=4 s=List001 b=True r=130.000000
1871006: i=5 s=List005 b=True r=130.000000
1872])
3cc1634f
HZ
1873
1874m4_define([OVSDB_CHECK_IDL_COMPOUND_INDEX_WITH_REF],
1875 [AT_SETUP([$1 - C])
1876 AT_KEYWORDS([ovsdb server idl compound_index compound_index_with_ref positive $5])
1877 AT_CHECK([ovsdb_start_idltest])
1878 m4_if([$2], [], [],
1879 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
1880 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-compound-index-with-ref unix:socket $3],
1881 [0], [stdout], [ignore])
c724bd67 1882 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
3cc1634f
HZ
1883 [0], [$4])
1884 OVSDB_SERVER_SHUTDOWN
1885 AT_CLEANUP])
1886
1887OVSDB_CHECK_IDL_COMPOUND_INDEX_WITH_REF([set, simple3 idl-compound-index-with-ref, initially populated],
1888[],
1889[],
1890[[000: After add to other table + set of strong ref
1891001: name= uset=[] uref=[[<0>]]
1892002: check simple4: not empty
1893003: Query using index with reference
1894004: name= uset=[] uref=[[<0>]]
1895005: After delete
1896007: check simple4: empty
1897008: End test
1898]])
c1aa16d1 1899
cfef5ae8 1900m4_define([CHECK_STREAM_OPEN_BLOCK],
6fcef908
IM
1901 [AT_SETUP([Check stream open block - $1 - $3])
1902 AT_SKIP_IF([test "$3" = "tcp6" && test "$IS_WIN32" = "yes"])
1903 AT_SKIP_IF([test "$3" = "tcp6" && test "$HAVE_IPV6" = "no"])
1904 AT_KEYWORDS([ovsdb server stream open_block $3])
1905 AT_CHECK([ovsdb_start_idltest "ptcp:0:$4"])
cfef5ae8 1906 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
fe495d0c 1907 WRONG_PORT=$(($TCP_PORT + 101))
6fcef908
IM
1908 AT_CHECK([$2 tcp:$4:$TCP_PORT], [0], [ignore])
1909 AT_CHECK([$2 tcp:$4:$WRONG_PORT], [1], [ignore], [ignore])
cfef5ae8 1910 OVSDB_SERVER_SHUTDOWN
6fcef908 1911 AT_CHECK([$2 tcp:$4:$TCP_PORT], [1], [ignore], [ignore])
cfef5ae8
IM
1912 AT_CLEANUP])
1913
6fcef908
IM
1914CHECK_STREAM_OPEN_BLOCK([C], [test-stream], [tcp], [127.0.0.1])
1915CHECK_STREAM_OPEN_BLOCK([C], [test-stream], [tcp6], [[[::1]]])
1916CHECK_STREAM_OPEN_BLOCK([Python3], [$PYTHON3 $srcdir/test-stream.py],
1917 [tcp], [127.0.0.1])
1918CHECK_STREAM_OPEN_BLOCK([Python3], [$PYTHON3 $srcdir/test-stream.py],
1919 [tcp6], [[[::1]]])
c1aa16d1 1920
c39751e4
TE
1921# same as OVSDB_CHECK_IDL but uses Python IDL implementation with tcp
1922# with multiple remotes to assert the idl connects to the leader of the Raft cluster
1ca0323e
BP
1923m4_define([OVSDB_CHECK_IDL_LEADER_ONLY_PY],
1924 [AT_SETUP([$1 - Python3 (leader only)])
804ef1a7 1925 AT_SKIP_IF([test "$IS_ARM64" = "yes"])
c39751e4
TE
1926 AT_KEYWORDS([ovsdb server idl Python leader_only with tcp socket])
1927 m4_define([LPBK],[127.0.0.1])
5198e8a0 1928 OVSDB_CLUSTER_START_IDLTEST([$2], ["ptcp:0:"LPBK])
c39751e4
TE
1929 PARSE_LISTENING_PORT([s2.log], [TCP_PORT_1])
1930 PARSE_LISTENING_PORT([s3.log], [TCP_PORT_2])
1931 PARSE_LISTENING_PORT([s1.log], [TCP_PORT_3])
1932 remotes=tcp:LPBK:$TCP_PORT_1,tcp:LPBK:$TCP_PORT_2,tcp:LPBK:$TCP_PORT_3
1933 pids=$(cat s2.pid s3.pid s1.pid | tr '\n' ',')
1934 echo $pids
1ca0323e 1935 AT_CHECK([$PYTHON3 $srcdir/test-ovsdb.py -t30 idl-cluster $srcdir/idltest.ovsschema $remotes $pids $3],
c39751e4
TE
1936 [0], [stdout], [ignore])
1937 remote=$(ovsdb_cluster_leader $remotes "idltest")
1938 leader=$(echo $remote | cut -d'|' -f 1)
1939 AT_CHECK([grep -F -- "${leader}" stdout], [0], [ignore])
1940 AT_CLEANUP])
1941
c39751e4
TE
1942OVSDB_CHECK_IDL_LEADER_ONLY_PY([Check Python IDL connects to leader], 3, ['remote'])
1943OVSDB_CHECK_IDL_LEADER_ONLY_PY([Check Python IDL reconnects to leader], 3, ['remote' '+remotestop' 'remote'])
ae25f8c8
DC
1944
1945# same as OVSDB_CHECK_IDL but uses C IDL implementation with tcp
1946# with multiple remotes.
1947m4_define([OVSDB_CHECK_CLUSTER_IDL_C],
1948 [AT_SETUP([$1 - C - tcp])
1949 AT_KEYWORDS([ovsdb server idl positive tcp socket $5])
1950 m4_define([LPBK],[127.0.0.1])
5198e8a0 1951 OVSDB_CLUSTER_START_IDLTEST([$2], ["ptcp:0:"LPBK])
ae25f8c8
DC
1952 PARSE_LISTENING_PORT([s1.log], [TCP_PORT_1])
1953 PARSE_LISTENING_PORT([s2.log], [TCP_PORT_2])
1954 PARSE_LISTENING_PORT([s3.log], [TCP_PORT_3])
1955 remotes=tcp:LPBK:$TCP_PORT_1,tcp:LPBK:$TCP_PORT_2,tcp:LPBK:$TCP_PORT_3
1956
1957 m4_if([$3], [], [],
1958 [AT_CHECK([ovsdb-client transact $remotes $3], [0], [ignore], [ignore])])
1959 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl tcp:LPBK:$TCP_PORT_1 $4],
1960 [0], [stdout], [ignore])
1961 AT_CHECK([sort stdout | uuidfilt]m4_if([$7],,, [[| $7]]),
1962 [0], [$5])
1963 AT_CLEANUP])
1964
1965# Checks that monitor_cond_since works fine when disconnects happen
1966# with cond_change requests in flight (i.e., IDL is properly updated).
1967OVSDB_CHECK_CLUSTER_IDL_C([simple idl, monitor_cond_since, cluster disconnect],
1968 3,
1969 [['["idltest",
1970 {"op": "insert",
1971 "table": "simple",
1972 "row": {"i": 1,
1973 "r": 1.0,
1974 "b": true}},
1975 {"op": "insert",
1976 "table": "simple",
1977 "row": {"i": 2,
1978 "r": 1.0,
1979 "b": true}}]']],
1980 [['condition simple []' \
1981 'condition simple [["i","==",2]]' \
1982 'condition simple [["i","==",1]]' \
1983 '+reconnect' \
1984 '["idltest",
1985 {"op": "update",
1986 "table": "simple",
1987 "where": [["i", "==", 1]],
1988 "row": {"r": 2.0 }}]']],
1989 [[000: change conditions
1990001: empty
1991002: change conditions
1992003: i=2 r=1 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
1993004: change conditions
1994005: reconnect
1995006: i=2 r=1 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
1996007: {"error":null,"result":[{"count":1}]}
1997008: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
1998009: done
1999]])