]> git.proxmox.com Git - mirror_ovs.git/blame - tests/ovsdb-idl.at
OVN: Always send prefix option in RAs
[mirror_ovs.git] / tests / ovsdb-idl.at
CommitLineData
c3bb4bd7
BP
1AT_BANNER([OVSDB -- interface description language (IDL)])
2
56120500
BP
3m4_divert_text([PREPARE_TESTS], [
4# ovsdb_start_idltest [REMOTE] [SCHEMA]
5#
6# Creates a database using SCHEMA (default: idltest.ovsschema) and
7# starts a database server listening on punix:socket and REMOTE (if
8# specified).
9ovsdb_start_idltest () {
10 ovsdb-tool create db ${2:-$abs_srcdir/idltest.ovsschema} || return $?
11 ovsdb-server -vconsole:warn --log-file --detach --no-chdir --pidfile --remote=punix:socket ${1:+--remote=$1} db || return $?
12 on_exit 'kill `cat ovsdb-server.pid`'
13}
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.
963f66b5
RB
115m4_define([OVSDB_CHECK_IDL_PYN],
116 [AT_SETUP([$1])
117 AT_SKIP_IF([test $7 = no])
8cdf0349 118 AT_KEYWORDS([ovsdb server idl positive Python $5])
56120500 119 AT_CHECK([ovsdb_start_idltest])
8cdf0349 120 m4_if([$2], [], [],
7427f2a4 121 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
e6703555 122 AT_CHECK([$8 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema unix:socket $3],
7427f2a4 123 [0], [stdout], [ignore])
c724bd67 124 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 125 [0], [$4])
8cdf0349
BP
126 OVSDB_SERVER_SHUTDOWN
127 AT_CLEANUP])
128
963f66b5 129m4_define([OVSDB_CHECK_IDL_PY],
e6703555 130 [OVSDB_CHECK_IDL_PYN([$1 - Python2], [$2], [$3], [$4], [$5], [$6],
9ec53312 131 [$HAVE_PYTHON2], [$PYTHON2])
e6703555
IM
132 OVSDB_CHECK_IDL_PYN([$1 - Python3], [$2], [$3], [$4], [$5], [$6],
133 [$HAVE_PYTHON3], [$PYTHON3])])
963f66b5
RB
134
135m4_define([OVSDB_CHECK_IDL_REGISTER_COLUMNS_PYN],
136 [AT_SETUP([$1 - register_columns])
137 AT_SKIP_IF([test $7 = no])
01dc1516 138 AT_KEYWORDS([ovsdb server idl positive Python register_columns $5])
56120500 139 AT_CHECK([ovsdb_start_idltest])
01dc1516 140 m4_if([$2], [], [],
7427f2a4 141 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
e6703555 142 AT_CHECK([$8 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema unix:socket ?simple:b,ba,i,ia,r,ra,s,sa,u,ua?link1:i,k,ka,l2?link2:i,l1?singleton:name $3],
7427f2a4 143 [0], [stdout], [ignore])
c724bd67 144 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 145 [0], [$4])
01dc1516
SA
146 OVSDB_SERVER_SHUTDOWN
147 AT_CLEANUP])
148
963f66b5 149m4_define([OVSDB_CHECK_IDL_REGISTER_COLUMNS_PY],
e6703555 150 [OVSDB_CHECK_IDL_REGISTER_COLUMNS_PYN([$1 - Python2], [$2], [$3], [$4], [$5], [$6],
9ec53312 151 [$HAVE_PYTHON2], [$PYTHON2])
e6703555
IM
152 OVSDB_CHECK_IDL_REGISTER_COLUMNS_PYN([$1 - Python3], [$2], [$3], [$4], [$5], [$6],
153 [$HAVE_PYTHON3], [$PYTHON3])])
963f66b5 154
e06d06a7 155# same as OVSDB_CHECK_IDL but uses the Python IDL implementation with tcp
963f66b5
RB
156m4_define([OVSDB_CHECK_IDL_TCP_PYN],
157 [AT_SETUP([$1 - tcp])
158 AT_SKIP_IF([test $7 = no])
e06d06a7 159 AT_KEYWORDS([ovsdb server idl positive Python with tcp socket $5])
56120500 160 AT_CHECK([ovsdb_start_idltest "ptcp:0:127.0.0.1"])
fb28ef2d 161 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
1e04fcc8 162
e06d06a7 163 m4_if([$2], [], [],
7427f2a4 164 [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT $2], [0], [ignore], [ignore])])
e6703555 165 AT_CHECK([$8 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema tcp:127.0.0.1:$TCP_PORT $3],
7427f2a4 166 [0], [stdout], [ignore])
c724bd67 167 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 168 [0], [$4])
e06d06a7
IY
169 OVSDB_SERVER_SHUTDOWN
170 AT_CLEANUP])
171
963f66b5 172m4_define([OVSDB_CHECK_IDL_TCP_PY],
e6703555 173 [OVSDB_CHECK_IDL_TCP_PYN([$1 - Python2], [$2], [$3], [$4], [$5], [$6],
9ec53312 174 [$HAVE_PYTHON2], [$PYTHON2])
e6703555
IM
175 OVSDB_CHECK_IDL_TCP_PYN([$1 - Python3], [$2], [$3], [$4], [$5], [$6],
176 [$HAVE_PYTHON3], [$PYTHON3])])
963f66b5 177
31e434fc
NS
178# same as OVSDB_CHECK_IDL but uses the Python IDL implementation with tcp
179# with multiple remotes with only one remote reachable
180m4_define([OVSDB_CHECK_IDL_TCP_MULTIPLE_REMOTES_PYN],
181 [AT_SETUP([$1 - tcp])
182 AT_SKIP_IF([test $7 = no])
183 AT_KEYWORDS([ovsdb server idl positive Python with tcp socket $5])
184 AT_CHECK([ovsdb_start_idltest "ptcp:0:127.0.0.1"])
185 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
fe495d0c
IM
186 WRONG_PORT_1=$((TCP_PORT + 101))
187 WRONG_PORT_2=$((TCP_PORT + 102))
31e434fc
NS
188 remote=tcp:127.0.0.1:$WRONG_PORT_1,tcp:127.0.0.1:$TCP_PORT,tcp:127.0.0.1:$WRONG_PORT_2
189 m4_if([$2], [], [],
190 [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT $2], [0], [ignore], [ignore])])
05e5030d 191 AT_CHECK([$8 $srcdir/test-ovsdb.py -t20 idl $srcdir/idltest.ovsschema $remote $3],
31e434fc
NS
192 [0], [stdout], [ignore])
193 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
194 [0], [$4])
195 OVSDB_SERVER_SHUTDOWN
196 AT_CLEANUP])
197
198m4_define([OVSDB_CHECK_IDL_TCP_MULTIPLE_REMOTES_PY],
e6703555 199 [OVSDB_CHECK_IDL_TCP_MULTIPLE_REMOTES_PYN([$1 - Python2 (multiple remotes)], [$2], [$3], [$4], [$5], [$6],
31e434fc 200 [$HAVE_PYTHON], [$PYTHON])
e6703555
IM
201 OVSDB_CHECK_IDL_TCP_MULTIPLE_REMOTES_PYN([$1 - Python3 (multiple remotes)], [$2], [$3], [$4], [$5], [$6],
202 [$HAVE_PYTHON3], [$PYTHON3])])
31e434fc 203
e731d71b 204# same as OVSDB_CHECK_IDL but uses the Python IDL implementation with tcp6
963f66b5
RB
205m4_define([OVSDB_CHECK_IDL_TCP6_PYN],
206 [AT_SETUP([$1 - tcp6])
207 AT_SKIP_IF([test $7 = no])
7b9d1b65 208 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
4819b3a5 209 AT_SKIP_IF([test $HAVE_IPV6 = no])
e731d71b 210 AT_KEYWORDS([ovsdb server idl positive Python with tcp6 socket $5])
56120500 211 AT_CHECK([ovsdb_start_idltest "ptcp:0:[[::1]]"])
fb28ef2d 212 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
e731d71b
AS
213 echo "TCP_PORT=$TCP_PORT"
214
215 m4_if([$2], [], [],
7427f2a4 216 [AT_CHECK([ovsdb-client transact "tcp:[[::1]]:$TCP_PORT" $2], [0], [ignore], [ignore])])
e6703555 217 AT_CHECK([$8 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema tcp:[[::1]]:$TCP_PORT $3],
7427f2a4 218 [0], [stdout], [ignore])
c724bd67 219 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 220 [0], [$4])
e731d71b
AS
221 OVSDB_SERVER_SHUTDOWN
222 AT_CLEANUP])
223
963f66b5 224m4_define([OVSDB_CHECK_IDL_TCP6_PY],
e6703555 225 [OVSDB_CHECK_IDL_TCP6_PYN([$1 - Python2], [$2], [$3], [$4], [$5], [$6],
9ec53312 226 [$HAVE_PYTHON2], [$PYTHON2])
e6703555
IM
227 OVSDB_CHECK_IDL_TCP6_PYN([$1 - Python3], [$2], [$3], [$4], [$5], [$6],
228 [$HAVE_PYTHON3], [$PYTHON3])])
963f66b5 229
31e434fc
NS
230m4_define([OVSDB_CHECK_IDL_TCP6_MULTIPLE_REMOTES_PYN],
231 [AT_SETUP([$1 - tcp6])
232 AT_SKIP_IF([test $7 = no])
233 AT_SKIP_IF([test "$IS_WIN32" = "yes"])
234 AT_SKIP_IF([test $HAVE_IPV6 = no])
235 AT_KEYWORDS([ovsdb server idl positive Python with tcp6 socket $5])
236 AT_CHECK([ovsdb_start_idltest "ptcp:0:[[::1]]"])
237 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
fe495d0c
IM
238 WRONG_PORT_1=$((TCP_PORT + 101))
239 WRONG_PORT_2=$((TCP_PORT + 102))
31e434fc
NS
240 remote="tcp:[[::1]]:$WRONG_PORT_1,tcp:[[::1]]:$TCP_PORT,tcp:[[::1]]:$WRONG_PORT_2"
241 m4_if([$2], [], [],
242 [AT_CHECK([ovsdb-client transact "tcp:[[::1]]:$TCP_PORT" $2], [0], [ignore], [ignore])])
05e5030d 243 AT_CHECK([$8 $srcdir/test-ovsdb.py -t20 idl $srcdir/idltest.ovsschema $remote $3],
31e434fc
NS
244 [0], [stdout], [ignore])
245 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
246 [0], [$4])
247 OVSDB_SERVER_SHUTDOWN
248 AT_CLEANUP])
249
250m4_define([OVSDB_CHECK_IDL_TCP6_MULTIPLE_REMOTES_PY],
e6703555 251 [OVSDB_CHECK_IDL_TCP6_MULTIPLE_REMOTES_PYN([$1 - Python2 (multiple remotes)], [$2], [$3], [$4], [$5], [$6],
31e434fc 252 [$HAVE_PYTHON], [$PYTHON])
e6703555
IM
253 OVSDB_CHECK_IDL_TCP6_MULTIPLE_REMOTES_PYN([$1 - Python3 (multiple remotes)], [$2], [$3], [$4], [$5], [$6],
254 [$HAVE_PYTHON3], [$PYTHON3])])
31e434fc 255
61845323
JS
256# same as OVSDB_CHECK_IDL but uses the Python IDL implementation with SSL
257m4_define([OVSDB_CHECK_IDL_SSL_PYN],
258 [AT_SETUP([$1 - SSL])
259 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
260 AT_SKIP_IF([test $7 = no])
261 $8 -c "import OpenSSL.SSL"
262 SSL_PRESENT=$?
263 AT_SKIP_IF([test $SSL_PRESENT != 0])
264 AT_KEYWORDS([ovsdb server idl positive Python with ssl socket $5])
265 AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema],
266 [0], [stdout], [ignore])
267 PKIDIR=$abs_top_builddir/tests
268 AT_CHECK([ovsdb-server -vconsole:warn --log-file --detach --no-chdir \
269 --pidfile \
270 --private-key=$PKIDIR/testpki-privkey2.pem \
271 --certificate=$PKIDIR/testpki-cert2.pem \
272 --ca-cert=$PKIDIR/testpki-cacert.pem \
273 --remote=pssl:0:127.0.0.1 db])
274 on_exit 'kill `cat ovsdb-server.pid`'
275 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
276 m4_if([$2], [], [],
277 [AT_CHECK([ovsdb-client \
278 --private-key=$PKIDIR/testpki-privkey2.pem \
279 --certificate=$PKIDIR/testpki-cert2.pem \
280 --ca-cert=$PKIDIR/testpki-cacert.pem \
281 transact "ssl:127.0.0.1:$TCP_PORT" $2], [0], [ignore], [ignore])])
e6703555 282 AT_CHECK([$8 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema \
61845323
JS
283 ssl:127.0.0.1:$TCP_PORT $PKIDIR/testpki-privkey.pem \
284 $PKIDIR/testpki-cert.pem $PKIDIR/testpki-cacert.pem $3],
285 [0], [stdout], [ignore])
286 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
287 [0], [$4])
288 OVSDB_SERVER_SHUTDOWN
289 AT_CLEANUP])
290
291m4_define([OVSDB_CHECK_IDL_SSL_PY],
e6703555 292 [OVSDB_CHECK_IDL_SSL_PYN([$1 - Python2], [$2], [$3], [$4], [$5], [$6],
61845323 293 [$HAVE_PYTHON], [$PYTHON])
e6703555
IM
294 OVSDB_CHECK_IDL_SSL_PYN([$1 - Python3], [$2], [$3], [$4], [$5], [$6],
295 [$HAVE_PYTHON3], [$PYTHON3])])
61845323 296
8cdf0349
BP
297m4_define([OVSDB_CHECK_IDL],
298 [OVSDB_CHECK_IDL_C($@)
b481a4cc
IM
299 OVSDB_CHECK_IDL_TCP_C($@)
300 OVSDB_CHECK_IDL_TCP6_C($@)
e06d06a7 301 OVSDB_CHECK_IDL_PY($@)
01dc1516 302 OVSDB_CHECK_IDL_REGISTER_COLUMNS_PY($@)
e731d71b 303 OVSDB_CHECK_IDL_TCP_PY($@)
31e434fc 304 OVSDB_CHECK_IDL_TCP_MULTIPLE_REMOTES_PY($@)
61845323 305 OVSDB_CHECK_IDL_TCP6_PY($@)
31e434fc 306 OVSDB_CHECK_IDL_TCP6_MULTIPLE_REMOTES_PY($@)
61845323 307 OVSDB_CHECK_IDL_SSL_PY($@)])
8cdf0349 308
af358237 309# This test uses the Python IDL implementation with passive tcp
f62a20d8
TR
310m4_define([OVSDB_CHECK_IDL_PASSIVE_TCP_PYN],
311 [AT_SETUP([$1 ptcp])
312 AT_SKIP_IF([test $7 = no])
af358237 313 AT_KEYWORDS([ovsdb server idl positive Python with tcp socket $5])
af358237 314 # find free TCP port
56120500 315 AT_CHECK([ovsdb_start_idltest "ptcp:0:127.0.0.1"])
af358237 316 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
7427f2a4 317 OVSDB_SERVER_SHUTDOWN
56120500 318 rm -f db
af358237
OBY
319
320 # start OVSDB server in passive mode
56120500 321 AT_CHECK([ovsdb_start_idltest "tcp:127.0.0.1:$TCP_PORT"])
e6703555 322 AT_CHECK([$8 $srcdir/test-ovsdb.py -t10 idl_passive $srcdir/idltest.ovsschema ptcp:127.0.0.1:$TCP_PORT $3],
7427f2a4 323 [0], [stdout], [ignore])
c724bd67 324 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4
DDP
325 [0], [$4])
326 OVSDB_SERVER_SHUTDOWN
af358237
OBY
327 AT_CLEANUP
328 ])
329
f62a20d8 330m4_define([OVSDB_CHECK_IDL_PASSIVE_TCP_PY],
e6703555 331 [OVSDB_CHECK_IDL_PASSIVE_TCP_PYN([$1 - Python2], [$2], [$3], [$4], [$5], [$6],
9ec53312 332 [$HAVE_PYTHON2], [$PYTHON2])
e6703555
IM
333 OVSDB_CHECK_IDL_PASSIVE_TCP_PYN([$1 - Python3], [$2], [$3], [$4], [$5], [$6],
334 [$HAVE_PYTHON3], [$PYTHON3])])
f62a20d8 335
af358237
OBY
336OVSDB_CHECK_IDL_PASSIVE_TCP_PY([simple passive idl, initially empty, select empty],
337 [],
338 [['["idltest",{"op":"select","table":"link1","where":[]}]']],
339 [[000: empty
340001: {"error":null,"result":[{"rows":[]}]}
341002: done
342]])
343
c3bb4bd7
BP
344OVSDB_CHECK_IDL([simple idl, initially empty, no ops],
345 [],
346 [],
347 [000: empty
348001: done
349])
350
351OVSDB_CHECK_IDL([simple idl, initially empty, various ops],
352 [],
9cb53f26
BP
353 [['["idltest",
354 {"op": "insert",
c3bb4bd7
BP
355 "table": "simple",
356 "row": {"i": 1,
357 "r": 2.0,
358 "b": true,
359 "s": "mystring",
360 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
361 "ia": ["set", [1, 2, 3]],
362 "ra": ["set", [-0.5]],
7fae24e6 363 "ba": ["set", [true]],
8cdf0349 364 "sa": ["set", ["abc", "def"]],
c3bb4bd7
BP
365 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
366 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
367 {"op": "insert",
368 "table": "simple",
369 "row": {}}]' \
9cb53f26
BP
370 '["idltest",
371 {"op": "update",
c3bb4bd7
BP
372 "table": "simple",
373 "where": [],
374 "row": {"b": true}}]' \
9cb53f26
BP
375 '["idltest",
376 {"op": "update",
c3bb4bd7
BP
377 "table": "simple",
378 "where": [],
379 "row": {"r": 123.5}}]' \
9cb53f26
BP
380 '["idltest",
381 {"op": "insert",
c3bb4bd7
BP
382 "table": "simple",
383 "row": {"i": -1,
384 "r": 125,
385 "b": false,
386 "s": "",
387 "ia": ["set", [1]],
388 "ra": ["set", [1.5]],
389 "ba": ["set", [false]],
8cdf0349 390 "sa": ["set", []],
c3bb4bd7 391 "ua": ["set", []]}}]' \
9cb53f26
BP
392 '["idltest",
393 {"op": "update",
c3bb4bd7
BP
394 "table": "simple",
395 "where": [["i", "<", 1]],
396 "row": {"s": "newstring"}}]' \
9cb53f26
BP
397 '["idltest",
398 {"op": "delete",
c3bb4bd7
BP
399 "table": "simple",
400 "where": [["i", "==", 0]]}]' \
401 'reconnect']],
402 [[000: empty
403001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
404002: i=0 r=0 b=false s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 405002: 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
406003: {"error":null,"result":[{"count":2}]}
407004: i=0 r=0 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 408004: 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
409005: {"error":null,"result":[{"count":2}]}
410006: i=0 r=123.5 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 411006: 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
412007: {"error":null,"result":[{"uuid":["uuid","<6>"]}]}
413008: i=-1 r=125 b=false s= u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
414008: i=0 r=123.5 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 415008: 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
416009: {"error":null,"result":[{"count":2}]}
417010: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
418010: i=0 r=123.5 b=true s=newstring u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 419010: 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
420011: {"error":null,"result":[{"count":1}]}
421012: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
7fae24e6 422012: 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
423013: reconnect
424014: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
7fae24e6 425014: 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
426015: done
427]])
428
429OVSDB_CHECK_IDL([simple idl, initially populated],
9cb53f26
BP
430 [['["idltest",
431 {"op": "insert",
c3bb4bd7
BP
432 "table": "simple",
433 "row": {"i": 1,
434 "r": 2.0,
435 "b": true,
436 "s": "mystring",
437 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
438 "ia": ["set", [1, 2, 3]],
439 "ra": ["set", [-0.5]],
7fae24e6 440 "ba": ["set", [true]],
8cdf0349 441 "sa": ["set", ["abc", "def"]],
c3bb4bd7
BP
442 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
443 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
444 {"op": "insert",
445 "table": "simple",
446 "row": {}}]']],
9cb53f26
BP
447 [['["idltest",
448 {"op": "update",
c3bb4bd7
BP
449 "table": "simple",
450 "where": [],
451 "row": {"b": true}}]']],
452 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 453000: 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
454001: {"error":null,"result":[{"count":2}]}
455002: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 456002: 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
457003: done
458]])
459
475281c0 460OVSDB_CHECK_IDL([simple idl, writing via IDL],
9cb53f26
BP
461 [['["idltest",
462 {"op": "insert",
475281c0
BP
463 "table": "simple",
464 "row": {"i": 1,
465 "r": 2.0,
466 "b": true,
467 "s": "mystring",
468 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
469 "ia": ["set", [1, 2, 3]],
470 "ra": ["set", [-0.5]],
7fae24e6 471 "ba": ["set", [true]],
8cdf0349 472 "sa": ["set", ["abc", "def"]],
475281c0
BP
473 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
474 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
475 {"op": "insert",
476 "table": "simple",
477 "row": {}}]']],
a91c6104
BP
478 [['verify 0 b, verify 1 r, set 0 b 1, set 1 r 3.5' \
479 'insert 2, verify 2 i, verify 1 b, delete 1']],
475281c0 480 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 481000: 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
482001: commit, status=success
483002: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
7fae24e6 484002: 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
485003: commit, status=success
486004: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
487004: i=2 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<6>
488005: done
489]])
490
e7164d96
LR
491OVSDB_CHECK_IDL([simple idl, writing via IDL with unicode],
492 [['["idltest",
493 {"op": "insert",
494 "table": "simple",
495 "row": {"s": "(╯°□°)╯︵ ┻━┻"}}]']],
496 [['set 0 b 1, insert 1, set 1 s "¯\_(ツ)_/¯"']],
497 [[000: i=0 r=0 b=false s=(╯°□°)╯︵ ┻━┻ u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
498001: commit, status=success
499002: i=0 r=0 b=true s=(╯°□°)╯︵ ┻━┻ u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
500002: i=1 r=0 b=false s="¯\_(ツ)_/¯" u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
501003: done
502]])
503
980211b7
GL
504m4_define([OVSDB_CHECK_IDL_PYN_WITH_EXPOUT],
505 [AT_SETUP([$1])
506 AT_SKIP_IF([test $7 = no])
507 AT_KEYWORDS([ovsdb server idl positive Python $5])
508 AT_CHECK([ovsdb_start_idltest])
509 m4_if([$2], [], [],
510 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
e6703555 511 AT_CHECK([$8 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema unix:socket $3],
980211b7
GL
512 [0], [stdout], [ignore])
513 echo "$4" > expout
514 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
515 [0], [expout])
516 OVSDB_SERVER_SHUTDOWN
517 AT_CLEANUP])
518
519m4_define([OVSDB_CHECK_IDL_PY_WITH_EXPOUT],
e6703555 520 [OVSDB_CHECK_IDL_PYN_WITH_EXPOUT([$1 - Python2], [$2], [$3], [$4], [$5], [$6],
9ec53312 521 [$HAVE_PYTHON2], [$PYTHON2])
e6703555
IM
522 OVSDB_CHECK_IDL_PYN_WITH_EXPOUT([$1 - Python3], [$2], [$3], [$4], [$5], [$6],
523 [$HAVE_PYTHON3], [$PYTHON3])])
980211b7
GL
524
525OVSDB_CHECK_IDL_PY_WITH_EXPOUT([simple idl, writing large data via IDL with unicode],
526 [['["idltest",
527 {"op": "insert",
528 "table": "simple",
529 "row": {"s": "'$(printf "测试超过四千零九十六个字节的中文字符串以使解码出现问题。%.0s" {1..50})'"}}]']],
530 [['set 0 b 1, insert 1, set 1 s '$(printf "测试超过四千零九十六个字节的中文字符串以使解码出现问题。%.0s" {1..100})'']],
531 [[000: i=0 r=0 b=false s=$(printf "测试超过四千零九十六个字节的中文字符串以使解码出现问题。%.0s" {1..50}) u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
532001: commit, status=success
533002: i=0 r=0 b=true s=$(printf "测试超过四千零九十六个字节的中文字符串以使解码出现问题。%.0s" {1..50}) u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
534002: i=1 r=0 b=false s=$(printf "测试超过四千零九十六个字节的中文字符串以使解码出现问题。%.0s" {1..100}) u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
535003: done]])
536
a91c6104
BP
537OVSDB_CHECK_IDL([simple idl, handling verification failure],
538 [['["idltest",
539 {"op": "insert",
540 "table": "simple",
541 "row": {"i": 1,
542 "r": 2.0}},
543 {"op": "insert",
544 "table": "simple",
545 "row": {}}]']],
546 [['set 0 b 1' \
547 '+["idltest",
548 {"op": "update",
549 "table": "simple",
550 "where": [["i", "==", 1]],
551 "row": {"r": 5.0}}]' \
552 '+verify 1 r, set 1 r 3' \
553 'verify 1 r, set 1 r 3' \
554 ]],
555 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
556000: i=1 r=2 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
557001: commit, status=success
558002: {"error":null,"result":[{"count":1}]}
94fbe1aa 559003: commit, status=try again
a91c6104
BP
560004: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
561004: i=1 r=5 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
562005: commit, status=success
563006: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
564006: i=1 r=3 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
565007: done
566]])
567
b54e22e9 568OVSDB_CHECK_IDL([simple idl, increment operation],
9cb53f26
BP
569 [['["idltest",
570 {"op": "insert",
b54e22e9
BP
571 "table": "simple",
572 "row": {}}]']],
94fbe1aa 573 [['set 0 r 2.0, increment 0']],
b54e22e9
BP
574 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
575001: commit, status=success, increment=1
576002: i=1 r=2 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
577003: done
578]])
579
2096903b
BP
580OVSDB_CHECK_IDL([simple idl, aborting],
581 [['["idltest",
582 {"op": "insert",
583 "table": "simple",
584 "row": {}}]']],
585 [['set 0 r 2.0, abort' \
586'+set 0 b 1']],
587 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
588001: commit, status=aborted
589002: commit, status=success
590003: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
591004: done
592]])
593
594OVSDB_CHECK_IDL([simple idl, destroy without commit or abort],
595 [['["idltest",
596 {"op": "insert",
597 "table": "simple",
598 "row": {}}]']],
599 [['set 0 r 2.0, destroy' \
600'+set 0 b 1']],
601 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
602001: destroy
603002: commit, status=success
604003: i=0 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
605004: done
606]])
607
16ebb90e
LS
608OVSDB_CHECK_IDL([simple idl, conditional, false condition],
609 [['["idltest",
610 {"op": "insert",
611 "table": "simple",
612 "row": {"i": 1,
613 "r": 2.0,
614 "b": true}}]']],
0164e367
BP
615 [['condition simple []' \
616 'condition simple [true]']],
16ebb90e
LS
617 [[000: change conditions
618001: empty
619002: change conditions
620003: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
621004: done
622]])
623
624OVSDB_CHECK_IDL([simple idl, conditional, true condition],
625 [['["idltest",
626 {"op": "insert",
627 "table": "simple",
628 "row": {"i": 1,
629 "r": 2.0,
630 "b": true}}]']],
0164e367
BP
631 [['condition simple []' \
632 'condition simple [true]']],
16ebb90e
LS
633 [[000: change conditions
634001: empty
635002: change conditions
636003: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
637004: done
638]])
639
640OVSDB_CHECK_IDL([simple idl, conditional, multiple clauses in condition],
641 [['["idltest",
642 {"op": "insert",
643 "table": "simple",
644 "row": {"i": 1,
645 "r": 2.0,
646 "b": true}},
647 {"op": "insert",
648 "table": "simple",
649 "row": {"i": 2,
650 "r": 3.0,
651 "b": true}}]']],
0164e367
BP
652 [['condition simple []' \
653 'condition simple [["i","==",1],["i","==",2]]']],
16ebb90e
LS
654 [[000: change conditions
655001: empty
656002: change conditions
657003: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
658003: i=2 r=3 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
659004: done
660]])
661
662OVSDB_CHECK_IDL([simple idl, conditional, modify as insert due to condition],
663 [['["idltest",
664 {"op": "insert",
665 "table": "simple",
666 "row": {"i": 1,
667 "r": 2.0,
668 "b": true}}]']],
0164e367
BP
669 [['condition simple []' \
670 'condition simple [["i","==",1]]']],
16ebb90e
LS
671 [[000: change conditions
672001: empty
673002: change conditions
674003: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
675004: done
676]])
677
678OVSDB_CHECK_IDL([simple idl, conditional, modify as delete due to condition],
679 [['["idltest",
680 {"op": "insert",
681 "table": "simple",
682 "row": {"i": 1,
683 "r": 2.0,
684 "b": true}}]']],
0164e367
BP
685 [['condition simple []' \
686 'condition simple [["i","==",1],["i","==",2]]' \
687 'condition simple [["i","==",2]]' \
16ebb90e
LS
688 '["idltest",
689 {"op": "insert",
690 "table": "simple",
691 "row": {"i": 2,
692 "r": 3.0,
693 "b": true}}]']],
694 [[000: change conditions
695001: empty
696002: change conditions
697003: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
698004: change conditions
699005: empty
700006: {"error":null,"result":[{"uuid":["uuid","<2>"]}]}
701007: i=2 r=3 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
702008: done
703]])
704
705OVSDB_CHECK_IDL([simple idl, conditional, multiple tables],
706 [['["idltest",
707 {"op": "insert",
708 "table": "simple",
709 "row": {"i": 1,
710 "r": 2.0,
711 "b": true}},
712 {"op": "insert",
713 "table": "link1",
714 "row": {"i": 0, "k": ["named-uuid", "self"]},
715 "uuid-name": "self"},
716 {"op": "insert",
717 "table": "link2",
718 "row": {"i": 2},
719 "uuid-name": "row0"}]']],
0164e367
BP
720 [['condition simple [];link1 [];link2 []' \
721 'condition simple [["i","==",1]]' \
722 'condition link1 [["i","==",0]]' \
723 'condition link2 [["i","==",3]]' \
16ebb90e
LS
724 '+["idltest",
725 {"op": "insert",
726 "table": "link2",
727 "row": {"i": 3},
728 "uuid-name": "row0"}]']],
729 [[000: change conditions
730001: empty
731002: change conditions
732003: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
733004: change conditions
734005: i=0 k=0 ka=[] l2= uuid=<2>
735005: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
736006: change conditions
737007: {"error":null,"result":[{"uuid":["uuid","<3>"]}]}
738008: i=0 k=0 ka=[] l2= uuid=<2>
739008: i=1 r=2 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
740008: i=3 l1= uuid=<3>
741009: done
742]])
743
c3bb4bd7
BP
744OVSDB_CHECK_IDL([self-linking idl, consistent ops],
745 [],
9cb53f26
BP
746 [['["idltest",
747 {"op": "insert",
e9011ac8 748 "table": "link1",
c3bb4bd7
BP
749 "row": {"i": 0, "k": ["named-uuid", "self"]},
750 "uuid-name": "self"}]' \
9cb53f26
BP
751 '["idltest",
752 {"op": "insert",
e9011ac8 753 "table": "link1",
2d2d6d4a 754 "row": {"i": 1, "k": ["named-uuid", "row2"]},
c3bb4bd7
BP
755 "uuid-name": "row1"},
756 {"op": "insert",
e9011ac8 757 "table": "link1",
c3bb4bd7 758 "row": {"i": 2, "k": ["named-uuid", "row1"]},
2d2d6d4a 759 "uuid-name": "row2"}]' \
9cb53f26
BP
760 '["idltest",
761 {"op": "update",
e9011ac8 762 "table": "link1",
c3bb4bd7
BP
763 "where": [["i", "==", 1]],
764 "row": {"k": ["uuid", "#1#"]}}]' \
9cb53f26
BP
765 '["idltest",
766 {"op": "update",
e9011ac8 767 "table": "link1",
c3bb4bd7
BP
768 "where": [],
769 "row": {"k": ["uuid", "#0#"]}}]']],
770 [[000: empty
771001: {"error":null,"result":[{"uuid":["uuid","<0>"]}]}
e9011ac8 772002: i=0 k=0 ka=[] l2= uuid=<0>
fbf925e4 773003: {"error":null,"result":[{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]}]}
e9011ac8
BP
774004: i=0 k=0 ka=[] l2= uuid=<0>
775004: i=1 k=2 ka=[] l2= uuid=<1>
776004: i=2 k=1 ka=[] l2= uuid=<2>
c3bb4bd7 777005: {"error":null,"result":[{"count":1}]}
e9011ac8
BP
778006: i=0 k=0 ka=[] l2= uuid=<0>
779006: i=1 k=1 ka=[] l2= uuid=<1>
780006: i=2 k=1 ka=[] l2= uuid=<2>
c3bb4bd7 781007: {"error":null,"result":[{"count":3}]}
e9011ac8
BP
782008: i=0 k=0 ka=[] l2= uuid=<0>
783008: i=1 k=0 ka=[] l2= uuid=<1>
784008: i=2 k=0 ka=[] l2= uuid=<2>
c3bb4bd7
BP
785009: done
786]])
787
788OVSDB_CHECK_IDL([self-linking idl, inconsistent ops],
789 [],
9cb53f26
BP
790 [['["idltest",
791 {"op": "insert",
e9011ac8 792 "table": "link1",
c3bb4bd7 793 "row": {"i": 0, "k": ["uuid", "cf197cc5-c8c9-42f5-82d5-c71a9f2cb96b"]}}]' \
9cb53f26
BP
794 '+["idltest",
795 {"op": "insert",
e9011ac8 796 "table": "link1",
0d0f05b9
BP
797 "uuid-name": "one",
798 "row": {"i": 1, "k": ["named-uuid", "one"]}},
799 {"op": "insert",
800 "table": "link1",
801 "row": {"i": 2, "k": ["named-uuid", "one"]}}]' \
9cb53f26
BP
802 '["idltest",
803 {"op": "update",
e9011ac8 804 "table": "link1",
c3bb4bd7
BP
805 "where": [],
806 "row": {"k": ["uuid", "c2fca39a-e69a-42a4-9c56-5eca85839ce9"]}}]' \
9cb53f26
BP
807 '+["idltest",
808 {"op": "delete",
e9011ac8 809 "table": "link1",
0d0f05b9 810 "where": [["_uuid", "==", ["uuid", "#1#"]]]}]' \
9cb53f26
BP
811 '+["idltest",
812 {"op": "delete",
e9011ac8 813 "table": "link1",
0d0f05b9 814 "where": [["_uuid", "==", ["uuid", "#2#"]]]}]' \
9cb53f26
BP
815 '["idltest",
816 {"op": "delete",
0d0f05b9
BP
817 "table": "link1",
818 "where": []}]' \
c3bb4bd7
BP
819]],
820 [[000: empty
97f7803b 821001: {"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
822002: {"error":null,"result":[{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]}
823003: i=1 k=1 ka=[] l2= uuid=<2>
824003: i=2 k=1 ka=[] l2= uuid=<3>
254604d8 825004: {"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
826005: {"error":null,"result":[{"count":1},{"details":"cannot delete link1 row <2> because of 1 remaining reference(s)","error":"referential integrity violation"}]}
827006: {"error":null,"result":[{"count":1}]}
828007: i=1 k=1 ka=[] l2= uuid=<2>
829008: {"error":null,"result":[{"count":1}]}
830009: empty
831010: done
254604d8
BP
832]],
833 [],
834 [[sed -e '/004:/s/row <[23]> references/row <x> references/']])
c3bb4bd7
BP
835
836OVSDB_CHECK_IDL([self-linking idl, sets],
837 [],
9cb53f26
BP
838 [['["idltest",
839 {"op": "insert",
e9011ac8 840 "table": "link1",
0d0f05b9 841 "row": {"i": 0, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i0"]]]},
c3bb4bd7
BP
842 "uuid-name": "i0"},
843 {"op": "insert",
e9011ac8 844 "table": "link1",
0d0f05b9 845 "row": {"i": 1, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i1"]]]},
c3bb4bd7
BP
846 "uuid-name": "i1"},
847 {"op": "insert",
e9011ac8 848 "table": "link1",
0d0f05b9 849 "row": {"i": 2, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i2"]]]},
c3bb4bd7
BP
850 "uuid-name": "i2"},
851 {"op": "insert",
e9011ac8 852 "table": "link1",
0d0f05b9 853 "row": {"i": 3, "k": ["named-uuid", "i0"], "ka": ["set", [["named-uuid", "i3"]]]},
c3bb4bd7 854 "uuid-name": "i3"}]' \
9cb53f26
BP
855 '["idltest",
856 {"op": "update",
e9011ac8 857 "table": "link1",
c3bb4bd7
BP
858 "where": [],
859 "row": {"ka": ["set", [["uuid", "#0#"], ["uuid", "#1#"], ["uuid", "#2#"], ["uuid", "#3#"]]]}}]' \
9cb53f26
BP
860 '["idltest",
861 {"op": "update",
e9011ac8 862 "table": "link1",
97f7803b
BP
863 "where": [["i", "==", 2]],
864 "row": {"ka": ["set", [["uuid", "#0#"], ["uuid", "88702e78-845b-4a6e-ad08-cf68922ae84a"], ["uuid", "#2#"]]]}}]' \
9cb53f26
BP
865 '+["idltest",
866 {"op": "delete",
0d0f05b9
BP
867 "table": "link1",
868 "where": []}]']],
c3bb4bd7
BP
869 [[000: empty
870001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]}
0d0f05b9
BP
871002: i=0 k=0 ka=[0] l2= uuid=<0>
872002: i=1 k=0 ka=[1] l2= uuid=<1>
873002: i=2 k=0 ka=[2] l2= uuid=<2>
874002: i=3 k=0 ka=[3] l2= uuid=<3>
c3bb4bd7 875003: {"error":null,"result":[{"count":4}]}
0d0f05b9
BP
876004: i=0 k=0 ka=[0 1 2 3] l2= uuid=<0>
877004: i=1 k=0 ka=[0 1 2 3] l2= uuid=<1>
878004: i=2 k=0 ka=[0 1 2 3] l2= uuid=<2>
879004: i=3 k=0 ka=[0 1 2 3] l2= uuid=<3>
97f7803b 880005: {"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
881006: {"error":null,"result":[{"count":4}]}
882007: empty
883008: done
c3bb4bd7
BP
884]])
885
e9011ac8
BP
886OVSDB_CHECK_IDL([external-linking idl, consistent ops],
887 [],
9cb53f26
BP
888 [['["idltest",
889 {"op": "insert",
e9011ac8
BP
890 "table": "link2",
891 "row": {"i": 0},
892 "uuid-name": "row0"},
893 {"op": "insert",
894 "table": "link1",
0d0f05b9 895 "row": {"i": 1, "k": ["named-uuid", "row1"], "l2": ["set", [["named-uuid", "row0"]]]},
e9011ac8
BP
896 "uuid-name": "row1"}]']],
897 [[000: empty
898001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
899002: i=0 l1= uuid=<0>
0d0f05b9 900002: i=1 k=1 ka=[] l2=0 uuid=<1>
e9011ac8
BP
901003: done
902]])
225b582a 903
079ace1f
MM
904OVSDB_CHECK_IDL([singleton idl, constraints],
905 [],
906 [['["idltest",
907 {"op": "insert",
908 "table": "singleton",
909 "row": {"name": "foo"}}]' \
910 '["idltest",
911 {"op": "insert",
912 "table": "singleton",
913 "row": {"name": "bar"}}]' \
914 '+["idltest",
915 {"op": "delete",
916 "table": "singleton",
917 "where": [["_uuid", "==", ["uuid", "#0#"]]]},
918 {"op": "insert",
919 "table": "singleton",
920 "row": {"name": "bar"}}]']],
921 [[000: empty
922001: {"error":null,"result":[{"uuid":["uuid","<0>"]}]}
923002: name=foo uuid=<0>
924003: {"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"}]}
925004: {"error":null,"result":[{"count":1},{"uuid":["uuid","<2>"]}]}
926005: name=bar uuid=<2>
927006: done
928]])
929
225b582a
IY
930OVSDB_CHECK_IDL_PY([external-linking idl, insert ops],
931 [],
932 [['linktest']],
933 [[000: empty
934001: commit, status=success
935002: i=1 k=1 ka=[1] l2= uuid=<0>
936002: i=2 k=1 ka=[1 2] l2= uuid=<1>
937003: done
938]])
3b4c362f
IY
939
940OVSDB_CHECK_IDL_PY([getattr idl, insert ops],
941 [],
942 [['getattrtest']],
943 [[000: empty
944001: commit, status=success
945002: i=2 k=2 ka=[] l2= uuid=<0>
946003: done
947]])
d18e52e3 948
d7d417fc
TW
949OVSDB_CHECK_IDL_PY([row-from-json idl, whats this],
950 [['["idltest",
951 {"op": "insert",
952 "table": "simple",
953 "row": {"i": 1}},
954 {"op": "insert",
955 "table": "simple",
956 "row": {}}]']],
957 [['notifytest insert 2, notifytest set 1 b 1, notifytest delete 0']],
958 [[000: i=0 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
959000: i=1 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
960001: commit, status=success, events=create|2|None, delete|0|None, update|1|b
961002: i=1 r=0 b=true s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<2>
962002: i=2 r=0 b=false s= u=<0> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>
963003: done
964]])
965
d18e52e3
BP
966AT_SETUP([idl handling of missing tables and columns - C])
967AT_KEYWORDS([ovsdb server idl positive])
d18e52e3
BP
968
969# idltest2.ovsschema is the same as idltest.ovsschema, except that
970# table link2 and column l2 have been deleted. But the IDL still
971# expects them to be there, so this test checks that it properly
972# tolerates them being missing.
56120500 973AT_CHECK([ovsdb_start_idltest "" "$abs_srcdir/idltest2.ovsschema"])
d18e52e3
BP
974AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl unix:socket ['["idltest",
975 {"op": "insert",
976 "table": "link1",
977 "row": {"i": 0, "k": ["named-uuid", "self"]},
978 "uuid-name": "self"}]' \
979 '["idltest",
980 {"op": "insert",
981 "table": "link1",
982 "row": {"i": 1, "k": ["named-uuid", "row2"]},
983 "uuid-name": "row1"},
984 {"op": "insert",
985 "table": "link1",
986 "row": {"i": 2, "k": ["named-uuid", "row1"]},
987 "uuid-name": "row2"}]' \
988 '["idltest",
989 {"op": "update",
990 "table": "link1",
991 "where": [["i", "==", 1]],
992 "row": {"k": ["uuid", "#1#"]}}]' \
993 '["idltest",
994 {"op": "update",
995 "table": "link1",
996 "where": [],
997 "row": {"k": ["uuid", "#0#"]}}]']],
5a0e4aec 998 [0], [stdout], [stderr])
c724bd67 999AT_CHECK([sort stdout | uuidfilt], [0],
d18e52e3
BP
1000 [[000: empty
1001001: {"error":null,"result":[{"uuid":["uuid","<0>"]}]}
1002002: i=0 k=0 ka=[] l2= uuid=<0>
1003003: {"error":null,"result":[{"uuid":["uuid","<1>"]},{"uuid":["uuid","<2>"]}]}
1004004: i=0 k=0 ka=[] l2= uuid=<0>
1005004: i=1 k=2 ka=[] l2= uuid=<1>
1006004: i=2 k=1 ka=[] l2= uuid=<2>
1007005: {"error":null,"result":[{"count":1}]}
1008006: i=0 k=0 ka=[] l2= uuid=<0>
1009006: i=1 k=1 ka=[] l2= uuid=<1>
1010006: i=2 k=1 ka=[] l2= uuid=<2>
1011007: {"error":null,"result":[{"count":3}]}
1012008: i=0 k=0 ka=[] l2= uuid=<0>
1013008: i=1 k=0 ka=[] l2= uuid=<1>
1014008: i=2 k=0 ka=[] l2= uuid=<2>
1015009: done
7427f2a4 1016]])
d18e52e3
BP
1017
1018# Check that ovsdb-idl figured out that table link2 and column l2 are missing.
1019AT_CHECK([grep ovsdb_idl stderr | sort], [0], [dnl
1020test-ovsdb|ovsdb_idl|idltest database lacks link2 table (database needs upgrade?)
079ace1f 1021test-ovsdb|ovsdb_idl|idltest database lacks singleton table (database needs upgrade?)
d18e52e3
BP
1022test-ovsdb|ovsdb_idl|link1 table in idltest database lacks l2 column (database needs upgrade?)
1023])
1024
1025# Check that ovsdb-idl sent on "monitor" request and that it didn't
1026# mention that table or column, and (for paranoia) that it did mention another
1027# table and column.
1b1d2e6d 1028AT_CHECK([grep -c '"monitor\|monitor_cond"' stderr], [0], [2
d18e52e3 1029])
c383f3bf
LS
1030AT_CHECK([grep '"monitor\|monitor_cond"' stderr | grep link2], [1])
1031AT_CHECK([grep '"monitor\|monitor_cond"' stderr | grep l2], [1])
1032AT_CHECK([grep '"monitor\|monitor_cond"' stderr | grep -c '"link1"'], [0], [1
d18e52e3 1033])
c383f3bf 1034AT_CHECK([grep '"monitor\|monitor_cond"' stderr | grep -c '"ua"'], [0], [1
d18e52e3
BP
1035])
1036OVSDB_SERVER_SHUTDOWN
1037AT_CLEANUP
80c12152 1038
f62a20d8
TR
1039m4_define([OVSDB_CHECK_IDL_FETCH_COLUMNS_PYN],
1040 [AT_SETUP([$1 fetch])
1041 AT_SKIP_IF([test $8 = no])
80c12152 1042 AT_KEYWORDS([ovsdb server idl positive Python increment fetch $6])
56120500 1043 AT_CHECK([ovsdb_start_idltest])
80c12152 1044 m4_if([$2], [], [],
7427f2a4 1045 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
e6703555 1046 AT_CHECK([$9 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema unix:socket [$3] $4],
7427f2a4 1047 [0], [stdout], [ignore])
c724bd67 1048 AT_CHECK([sort stdout | uuidfilt]m4_if([$7],,, [[| $7]]),
7427f2a4 1049 [0], [$5])
80c12152
SA
1050 OVSDB_SERVER_SHUTDOWN
1051 AT_CLEANUP])
1052
f62a20d8 1053m4_define([OVSDB_CHECK_IDL_FETCH_COLUMNS_PY],
e6703555 1054 [OVSDB_CHECK_IDL_FETCH_COLUMNS_PYN([$1 - Python2], [$2], [$3], [$4], [$5], [$6], [$7],
9ec53312 1055 [$HAVE_PYTHON2], [$PYTHON2])
e6703555
IM
1056 OVSDB_CHECK_IDL_FETCH_COLUMNS_PYN([$1 - Python3], [$2], [$3], [$4], [$5], [$6], [$7],
1057 [$HAVE_PYTHON3], [$PYTHON3])])
f62a20d8 1058
80c12152
SA
1059m4_define([OVSDB_CHECK_IDL_FETCH_COLUMNS],
1060 [OVSDB_CHECK_IDL_FETCH_COLUMNS_PY($@)])
1061
1062OVSDB_CHECK_IDL_FETCH_COLUMNS([simple idl, initially populated],
1063 [['["idltest",
1064 {"op": "insert",
1065 "table": "simple",
1066 "row": {"i": 1,
1067 "r": 2.0,
1068 "b": true,
1069 "s": "mystring",
1070 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
1071 "ia": ["set", [1, 2, 3]],
1072 "ra": ["set", [-0.5]],
1073 "ba": ["set", [true]],
1074 "sa": ["set", ["abc", "def"]],
1075 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
1076 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
1077 {"op": "insert",
1078 "table": "simple",
1079 "row": {}}]']],
1080 [?simple:i,r!],
1081 ['fetch 0 r'],
1082 [[000: i=0 uuid=<0>
1083000: i=1 uuid=<1>
1084001: commit, status=success
1085002: i=0 r=0 uuid=<0>
1086002: i=1 uuid=<1>
1087003: done
1088]])
932104f4 1089
f62a20d8
TR
1090m4_define([OVSDB_CHECK_IDL_WO_MONITOR_COND_PYN],
1091 [AT_SETUP([$1])
1092 AT_SKIP_IF([test $6 = no])
897c8064 1093 AT_KEYWORDS([ovsdb server idl Python monitor $4])
56120500
BP
1094 AT_CHECK([ovsdb_start_idltest])
1095 AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/disable-monitor-cond])
e6703555 1096 AT_CHECK([$7 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema unix:socket $2],
7ef00082 1097 [0], [stdout], [ignore])
c724bd67 1098 AT_CHECK([sort stdout | uuidfilt]m4_if([$5],,, [[| $5]]),
7ef00082 1099 [0], [$3])
897c8064
LS
1100 OVSDB_SERVER_SHUTDOWN
1101 AT_CLEANUP])
1102
f62a20d8 1103m4_define([OVSDB_CHECK_IDL_WO_MONITOR_COND_PY],
e6703555 1104 [OVSDB_CHECK_IDL_WO_MONITOR_COND_PYN([$1 - Python2], [$2], [$3], [$4], [$5],
9ec53312 1105 [$HAVE_PYTHON2], [$PYTHON2])
e6703555
IM
1106 OVSDB_CHECK_IDL_WO_MONITOR_COND_PYN([$1 - Python3], [$2], [$3], [$4], [$5],
1107 [$HAVE_PYTHON3], [$PYTHON3])])
f62a20d8 1108
897c8064
LS
1109
1110m4_define([OVSDB_CHECK_IDL_WO_MONITOR_COND],
1111 [OVSDB_CHECK_IDL_WO_MONITOR_COND_PY($@)])
1112
1113
1114OVSDB_CHECK_IDL_WO_MONITOR_COND([simple idl disable monitor-cond],
1115 [['["idltest",
1116 {"op": "insert",
1117 "table": "simple",
1118 "row": {"i": 1,
1119 "r": 2.0,
1120 "b": true,
1121 "s": "mystring",
1122 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
1123 "ia": ["set", [1, 2, 3]],
1124 "ra": ["set", [-0.5]],
1125 "ba": ["set", [true]],
1126 "sa": ["set", ["abc", "def"]],
1127 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
1128 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
1129 {"op": "insert",
1130 "table": "simple",
1131 "row": {}}]' \
1132 '["idltest",
1133 {"op": "update",
1134 "table": "simple",
1135 "where": [],
1136 "row": {"b": true}}]' \
1137 '["idltest",
1138 {"op": "update",
1139 "table": "simple",
1140 "where": [],
1141 "row": {"r": 123.5}}]' \
1142 '["idltest",
1143 {"op": "insert",
1144 "table": "simple",
1145 "row": {"i": -1,
1146 "r": 125,
1147 "b": false,
1148 "s": "",
1149 "ia": ["set", [1]],
1150 "ra": ["set", [1.5]],
1151 "ba": ["set", [false]],
1152 "sa": ["set", []],
1153 "ua": ["set", []]}}]' \
1154 '["idltest",
1155 {"op": "update",
1156 "table": "simple",
1157 "where": [["i", "<", 1]],
1158 "row": {"s": "newstring"}}]' \
1159 '["idltest",
1160 {"op": "delete",
1161 "table": "simple",
1162 "where": [["i", "==", 0]]}]' \
1163 'reconnect']],
1164 [[000: empty
1165001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
1166002: i=0 r=0 b=false s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
1167002: 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>
1168003: {"error":null,"result":[{"count":2}]}
1169004: i=0 r=0 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
1170004: 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>
1171005: {"error":null,"result":[{"count":2}]}
1172006: i=0 r=123.5 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
1173006: 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>
1174007: {"error":null,"result":[{"uuid":["uuid","<6>"]}]}
1175008: i=-1 r=125 b=false s= u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
1176008: i=0 r=123.5 b=true s= u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
1177008: 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>
1178009: {"error":null,"result":[{"count":2}]}
1179010: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
1180010: i=0 r=123.5 b=true s=newstring u=<2> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
1181010: 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>
1182011: {"error":null,"result":[{"count":1}]}
1183012: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
1184012: 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>
1185013: reconnect
1186014: i=-1 r=125 b=false s=newstring u=<2> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
1187014: 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>
1188015: done
1189]])
1190
932104f4
SA
1191m4_define([OVSDB_CHECK_IDL_TRACK_C],
1192 [AT_SETUP([$1 - C])
1193 AT_KEYWORDS([ovsdb server idl tracking positive $5])
56120500 1194 AT_CHECK([ovsdb_start_idltest])
932104f4 1195 m4_if([$2], [], [],
7427f2a4 1196 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
932104f4 1197 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl unix:socket $3],
7427f2a4 1198 [0], [stdout], [ignore])
c724bd67 1199 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 1200 [0], [$4])
932104f4
SA
1201 OVSDB_SERVER_SHUTDOWN
1202 AT_CLEANUP])
1203
1204m4_define([OVSDB_CHECK_IDL_TRACK],
1205 [OVSDB_CHECK_IDL_TRACK_C($@)])
1206
1207OVSDB_CHECK_IDL_TRACK([track, simple idl, initially populated],
1208 [['["idltest",
1209 {"op": "insert",
1210 "table": "simple",
1211 "row": {"i": 1,
1212 "r": 2.0,
1213 "b": true,
1214 "s": "mystring",
1215 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
1216 "ia": ["set", [1, 2, 3]],
1217 "ra": ["set", [-0.5]],
1218 "ba": ["set", [true]],
1219 "sa": ["set", ["abc", "def"]],
1220 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
1221 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
1222 {"op": "insert",
1223 "table": "simple",
1224 "row": {}}]']],
1225 [['["idltest",
1226 {"op": "update",
1227 "table": "simple",
1228 "where": [],
1229 "row": {"b": true}}]']],
1230 [[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 1231000: updated columns: b ba i ia r ra s sa u ua
932104f4
SA
1232001: {"error":null,"result":[{"count":2}]}
1233002: i=0 r=0 b=true s= u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<5>
1234002: 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 1235002: updated columns: b
932104f4
SA
1236003: done
1237]])
1238
1239OVSDB_CHECK_IDL_TRACK([track, simple idl, initially empty, various ops],
1240 [],
1241 [['["idltest",
1242 {"op": "insert",
1243 "table": "simple",
1244 "row": {"i": 1,
1245 "r": 2.0,
1246 "b": true,
1247 "s": "mystring",
1248 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
1249 "ia": ["set", [1, 2, 3]],
1250 "ra": ["set", [-0.5]],
1251 "ba": ["set", [true]],
1252 "sa": ["set", ["abc", "def"]],
1253 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
1254 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
1255 {"op": "insert",
1256 "table": "simple",
1257 "row": {}}]' \
1258 '["idltest",
1259 {"op": "update",
1260 "table": "simple",
1261 "where": [],
1262 "row": {"b": true}}]' \
1263 '["idltest",
1264 {"op": "update",
1265 "table": "simple",
1266 "where": [],
1267 "row": {"r": 123.5}}]' \
1268 '["idltest",
1269 {"op": "insert",
1270 "table": "simple",
1271 "row": {"i": -1,
1272 "r": 125,
1273 "b": false,
1274 "s": "",
1275 "ia": ["set", [1]],
1276 "ra": ["set", [1.5]],
1277 "ba": ["set", [false]],
1278 "sa": ["set", []],
1279 "ua": ["set", []]}}]' \
1280 '["idltest",
1281 {"op": "update",
1282 "table": "simple",
1283 "where": [["i", "<", 1]],
1284 "row": {"s": "newstring"}}]' \
1285 '["idltest",
1286 {"op": "delete",
1287 "table": "simple",
1288 "where": [["i", "==", 0]]}]' \
1289 'reconnect']],
1290 [[000: empty
1291001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
1292002: 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 1293002: updated columns: b ba i ia r ra s sa u ua
932104f4
SA
1294003: {"error":null,"result":[{"count":2}]}
1295004: i=0 r=0 b=true s= u=<5> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
32d37ce8 1296004: updated columns: b
932104f4
SA
1297005: {"error":null,"result":[{"count":2}]}
1298006: i=0 r=123.5 b=true s= u=<5> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
1299006: 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
1300006: updated columns: r
1301006: updated columns: r
932104f4
SA
1302007: {"error":null,"result":[{"uuid":["uuid","<6>"]}]}
1303008: i=-1 r=125 b=false s= u=<5> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
32d37ce8 1304008: updated columns: ba i ia r ra
932104f4
SA
1305009: {"error":null,"result":[{"count":2}]}
1306010: i=-1 r=125 b=false s=newstring u=<5> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
1307010: i=0 r=123.5 b=true s=newstring u=<5> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<1>
32d37ce8
SA
1308010: updated columns: s
1309010: updated columns: s
932104f4
SA
1310011: {"error":null,"result":[{"count":1}]}
1311012: ##deleted## uuid=<1>
1312013: reconnect
1313014: i=-1 r=125 b=false s=newstring u=<5> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<6>
1314014: 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
1315014: updated columns: b ba i ia r ra s sa u ua
1316014: updated columns: ba i ia r ra s
932104f4
SA
1317015: done
1318]])
7251075c
EA
1319
1320m4_define([OVSDB_CHECK_IDL_PARTIAL_UPDATE_MAP_COLUMN],
1321 [AT_SETUP([$1 - C])
1322 AT_KEYWORDS([ovsdb server idl partial update map column positive $5])
56120500 1323 AT_CHECK([ovsdb_start_idltest])
7251075c 1324 m4_if([$2], [], [],
7427f2a4 1325 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
7251075c 1326 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-partial-update-map-column unix:socket $3],
7427f2a4 1327 [0], [stdout], [ignore])
c724bd67 1328 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
7427f2a4 1329 [0], [$4])
7251075c
EA
1330 OVSDB_SERVER_SHUTDOWN
1331 AT_CLEANUP])
1332
1333OVSDB_CHECK_IDL_PARTIAL_UPDATE_MAP_COLUMN([map, simple2 idl-partial-update-map-column, initially populated],
1334[['["idltest", {"op":"insert", "table":"simple2",
1335 "row":{"name":"myString1","smap":["map",[["key1","value1"],["key2","value2"]]]} }]']
1336],
1337[],
1338[[000: Getting records
1339001: name=myString1 smap=[[key1 : value1],[key2 : value2]] imap=[]
1340002: After insert element
1341003: name=String2 smap=[[key1 : myList1],[key2 : value2]] imap=[[3 : myids2]]
1342004: After insert duplicated element
1343005: name=String2 smap=[[key1 : myList1],[key2 : value2]] imap=[[3 : myids2]]
1344006: After delete element
1345007: name=String2 smap=[[key2 : value2]] imap=[[3 : myids2]]
1346008: After trying to delete a deleted element
1347009: name=String2 smap=[[key2 : value2]] imap=[[3 : myids2]]
1348010: End test
1349]])
a7261bf7 1350
a59912a0
RM
1351OVSDB_CHECK_IDL_PY([partial-map idl],
1352[['["idltest", {"op":"insert", "table":"simple2",
330b9c9c 1353 "row":{"name":"myString1","smap":["map",[["key1","value1"],["key2","value2"]]]} }]']
a59912a0 1354],
2d54d801 1355 [?simple2:name,smap,imap 'partialmapinsertelement' 'partialmapinsertmultipleelements' 'partialmapdelelements' 'partialmapmutatenew'],
330b9c9c 1356[[000: name=myString1 smap=[(key1 value1) (key2 value2)] imap=[]
a59912a0 1357001: commit, status=success
330b9c9c 1358002: name=String2 smap=[(key1 myList1) (key2 value2)] imap=[(3 myids2)]
a59912a0 1359003: commit, status=success
2d54d801 1360004: name=String2 smap=[(key1 myList1) (key2 myList2) (key3 myList3) (key4 myList4)] imap=[(3 myids2)]
330b9c9c
AB
1361005: commit, status=success
1362006: name=String2 smap=[(key2 myList2)] imap=[(3 myids2)]
2d54d801
AB
1363007: commit, status=success
1364008: name=String2 smap=[(key2 myList2)] imap=[(3 myids2)]
1365008: name=String2New smap=[(key1 newList1) (key2 newList2)] imap=[]
1366009: done
a59912a0
RM
1367]])
1368
f1ab6e06
RM
1369m4_define([OVSDB_CHECK_IDL_PARTIAL_UPDATE_SET_COLUMN],
1370 [AT_SETUP([$1 - C])
1371 AT_KEYWORDS([ovsdb server idl partial update set column positive $5])
56120500 1372 AT_CHECK([ovsdb_start_idltest])
f1ab6e06
RM
1373 m4_if([$2], [], [],
1374 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
1375 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-partial-update-set-column unix:socket $3],
1376 [0], [stdout], [ignore])
c724bd67 1377 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
f1ab6e06
RM
1378 [0], [$4])
1379 OVSDB_SERVER_SHUTDOWN
1380 AT_CLEANUP])
1381
1382OVSDB_CHECK_IDL_PARTIAL_UPDATE_SET_COLUMN([set, simple3 idl-partial-update-set-column, initially populated],
1383[['["idltest", {"op":"insert", "table":"simple3",
1384 "row":{"name":"mySet1","uset":["set", [[ "uuid", "0005b872-f9e5-43be-ae02-3184b9680e75" ], [ "uuid", "000d2f6a-76af-412f-b59d-e7bcd3e84eff" ]]]} }]']
1385],
1386[],
1387[[000: Getting records
1388001: name=mySet1 uset=[[<0>],[<1>]] uref=[]
1389002: After rename+add new value
1390003: name=String2 uset=[[<0>],[<1>],[<2>]] uref=[]
1391004: After add new value
1392005: name=String2 uset=[[<0>],[<1>],[<2>],[<3>]] uref=[]
1393006: After delete value
1394007: name=String2 uset=[[<0>],[<1>],[<3>]] uref=[]
1395008: After trying to delete a deleted value
1396009: name=String2 uset=[[<0>],[<1>],[<3>]] uref=[]
1397010: After add to other table + set of strong ref
1398011: name=String2 uset=[[<0>],[<1>],[<3>]] uref=[[<4>]]
1399012: End test
1400]])
1401
a59912a0 1402OVSDB_CHECK_IDL_PY([partial-set idl],
b3220c67
AB
1403[['["idltest", {"op":"insert", "table":"simple3", "uuid-name":"newrow",
1404 "row":{"name":"mySet1","uset":["set", [[ "uuid", "0005b872-f9e5-43be-ae02-3184b9680e75" ]]]} },
1405 {"op":"insert", "table":"simple4", "row":{"name":"seed"}},
1406 {"op":"mutate", "table":"simple3", "where":[["_uuid", "==", ["named-uuid", "newrow"]]],
1407 "mutations": [["uset", "insert", ["set", [["uuid", "000d2f6a-76af-412f-b59d-e7bcd3e84eff"]]]]]}]']
a59912a0 1408],
2d54d801 1409 ['partialrenamesetadd' 'partialduplicateadd' 'partialsetdel' 'partialsetref' 'partialsetoverrideops' 'partialsetadddelete' 'partialsetmutatenew'],
a59912a0
RM
1410[[000: name=mySet1 uset=[<0> <1>]
1411001: commit, status=success
1412002: name=String2 uset=[<0> <1> <2>]
1413003: commit, status=success
1414004: name=String2 uset=[<0> <1> <2> <3>]
1415005: commit, status=success
1416006: name=String2 uset=[<0> <1> <3>]
1417007: commit, status=success
1418008: name=String2 uset=[<0> <1> <3>]
330b9c9c
AB
1419009: commit, status=success
1420010: name=String2 uset=[<3>]
b3220c67 1421011: commit, status=success
2d54d801
AB
1422012: name=String2 uset=[<4> <5>]
1423013: commit, status=success
1424014: name=String2 uset=[<4> <5>]
1425014: name=String3 uset=[<6>]
1426015: done
a59912a0
RM
1427]])
1428
f62a20d8 1429m4_define([OVSDB_CHECK_IDL_NOTIFY_PYN],
e6703555 1430 [OVSDB_CHECK_IDL_PYN([$1], [], [$2], [$3], [notify $4], [$5], [$6], [$7])])
a7261bf7 1431
f62a20d8
TR
1432m4_define([OVSDB_CHECK_IDL_NOTIFY_PY],
1433 [OVSDB_CHECK_IDL_NOTIFY_PYN([$1 - Python2], [$2], [$3], [$4], [$5],
9ec53312 1434 [$HAVE_PYTHON2], [$PYTHON2])
f62a20d8
TR
1435 OVSDB_CHECK_IDL_NOTIFY_PYN([$1 - Python3], [$2], [$3], [$4], [$5],
1436 [$HAVE_PYTHON3], [$PYTHON3])])
1437
d90ed7d6 1438# This test uses the Python IDL implementation with ssl
f62a20d8 1439m4_define([OVSDB_CHECK_IDL_NOTIFY_SSL_PYN],
e6703555 1440 [OVSDB_CHECK_IDL_SSL_PYN([$1], [], [$2], [$3], [notify $4], [$5], [$6], [$7])])
a7261bf7 1441
f62a20d8
TR
1442m4_define([OVSDB_CHECK_IDL_NOTIFY_SSL_PY],
1443 [OVSDB_CHECK_IDL_NOTIFY_SSL_PYN([$1 - Python2], [$2], [$3], [$4], [$5],
9ec53312 1444 [$HAVE_PYTHON2], [$PYTHON2])
f62a20d8
TR
1445 OVSDB_CHECK_IDL_NOTIFY_SSL_PYN([$1 - Python3], [$2], [$3], [$4], [$5],
1446 [$HAVE_PYTHON3], [$PYTHON3])])
1447
a7261bf7 1448m4_define([OVSDB_CHECK_IDL_NOTIFY],
d90ed7d6
NS
1449 [OVSDB_CHECK_IDL_NOTIFY_PY($@)
1450 OVSDB_CHECK_IDL_NOTIFY_SSL_PY($@)])
a7261bf7
NS
1451
1452OVSDB_CHECK_IDL_NOTIFY([simple idl verify notify],
1453 [['track-notify' \
1454 '["idltest",
1455 {"op": "insert",
1456 "table": "simple",
1457 "row": {"i": 1,
1458 "r": 2.0,
1459 "b": true,
1460 "s": "mystring",
1461 "u": ["uuid", "84f5c8f5-ac76-4dbc-a24f-8860eb407fc1"],
1462 "ia": ["set", [1, 2, 3]],
1463 "ra": ["set", [-0.5]],
1464 "ba": ["set", [true]],
1465 "sa": ["set", ["abc", "def"]],
1466 "ua": ["set", [["uuid", "69443985-7806-45e2-b35f-574a04e720f9"],
1467 ["uuid", "aad11ef0-816a-4b01-93e6-03b8b4256b98"]]]}},
1468 {"op": "insert",
1469 "table": "simple",
1470 "row": {}}]' \
1471 '["idltest",
1472 {"op": "update",
1473 "table": "simple",
1474 "where": [],
1475 "row": {"b": false}}]' \
1476 '["idltest",
1477 {"op": "update",
1478 "table": "simple",
1479 "where": [],
1480 "row": {"r": 123.5}}]' \
1481 '["idltest",
1482 {"op": "insert",
1483 "table": "simple",
1484 "row": {"i": -1,
1485 "r": 125,
1486 "b": false,
1487 "s": "",
1488 "ia": ["set", [1]],
1489 "ra": ["set", [1.5]],
1490 "ba": ["set", [false]],
1491 "sa": ["set", []],
1492 "ua": ["set", []]}}]' \
1493 '["idltest",
1494 {"op": "update",
1495 "table": "simple",
1496 "where": [["i", "<", 1]],
1497 "row": {"s": "newstring"}}]' \
1498 '["idltest",
1499 {"op": "delete",
1500 "table": "simple",
1501 "where": [["i", "==", 0]]}]' \
1502 'reconnect']],
1503 [[000: empty
c39751e4
TE
1504000: event:create, row={uuid=<0>}, updates=None
1505000: event:create, row={uuid=<1>}, updates=None
1506001: {"error":null,"result":[{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]}
1507002: event:create, row={i=0 r=0 b=false s= u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>}, updates=None
1508002: 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
1509002: i=0 r=0 b=false s= u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>
1510002: 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 1511003: {"error":null,"result":[{"count":2}]}
c39751e4
TE
1512004: 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>}
1513004: i=0 r=0 b=false s= u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>
1514004: 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 1515005: {"error":null,"result":[{"count":2}]}
c39751e4
TE
1516006: 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>}
1517006: 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>}
1518006: i=0 r=123.5 b=false s= u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>
1519006: 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>
1520007: {"error":null,"result":[{"uuid":["uuid","<8>"]}]}
1521008: 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
1522008: i=-1 r=125 b=false s= u=<4> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<8>
1523008: i=0 r=123.5 b=false s= u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>
1524008: 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 1525009: {"error":null,"result":[{"count":2}]}
c39751e4
TE
1526010: 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>}
1527010: 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>}
1528010: i=-1 r=125 b=false s=newstring u=<4> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<8>
1529010: i=0 r=123.5 b=false s=newstring u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>
1530010: 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 1531011: {"error":null,"result":[{"count":1}]}
c39751e4
TE
1532012: event:delete, row={i=0 r=123.5 b=false s=newstring u=<4> ia=[] ra=[] ba=[] sa=[] ua=[] uuid=<3>}, updates=None
1533012: i=-1 r=125 b=false s=newstring u=<4> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<8>
1534012: 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 1535013: reconnect
c39751e4
TE
1536014: 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
1537014: 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
1538014: event:create, row={uuid=<0>}, updates=None
1539014: event:create, row={uuid=<1>}, updates=None
1540014: i=-1 r=125 b=false s=newstring u=<4> ia=[1] ra=[1.5] ba=[false] sa=[] ua=[] uuid=<8>
1541014: 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
1542015: done
1543]])
0a8606ee
LR
1544
1545# Tests to verify the functionality of the one column compound index.
1546# It tests index for one column string and integer indexes.
1547# The run of test-ovsdb generates the output of the display of data using the different indexes defined in
1548# the program.
1549# Then, some at_checks are used to verify the correctness of the corresponding index as well as the existence
1550# of all the rows involved in the test.
1551m4_define([OVSDB_CHECK_IDL_COMPOUND_INDEX_SINGLE_COLUMN_C],
1552 [AT_SETUP([$1 - C])
1553 AT_KEYWORDS([ovsdb server idl compound_index_single_column compound_index positive $5])
1554 AT_CHECK([ovsdb_start_idltest])
1555 m4_if([$2], [], [],
7ef00082 1556 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
0a8606ee
LR
1557# Generate the data to be tested.
1558 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-compound-index unix:socket $3],
7ef00082 1559 [0], [stdout], [ignore])
0a8606ee
LR
1560# Filter the rows of data that corresponds to the string index eliminating the extra columns of data.
1561# This is done to verifiy that the output data is in the correct and expected order.
1562 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: s=.*' | sed -e 's/ i=.*//g']],
7ef00082 1563 [0], [$4])
0a8606ee
LR
1564# Here, the data is filtered and sorted in order to have all the rows in the index and be
1565# able to determined that all the involved rows are present.
1566 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: s=.*' | sort -k 1,1n -k 2,2 -k 3,3]],
7ef00082 1567 [0], [$5])
0a8606ee
LR
1568# Filter the rows of data that corresponds to the integer index eliminating the extra columns of data.
1569# This is done to verifiy that the output data is in the correct and expected order.
1570 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: i=.*' | sed -e 's/ s=.*//g']],
7ef00082 1571 [0], [$6])
0a8606ee
LR
1572# Here again, the data is filtered and sorted in order to have all the rows in the index and be
1573# able to determined that all the involved rows are present.
1574 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: i=.*' | sort -k 1,1n -k 2,2 -k 3,3]],
7ef00082 1575 [0], [$7])
0a8606ee
LR
1576 OVSDB_SERVER_SHUTDOWN
1577 AT_CLEANUP])
1578
1579OVSDB_CHECK_IDL_COMPOUND_INDEX_SINGLE_COLUMN_C([Compound_index, single column test ],
1580 [['["idltest",
1581 {"op": "insert", "table": "simple", "row": {"s":"List000", "i": 1, "b":true, "r":101.0}},
1582 {"op": "insert", "table": "simple", "row": {"s":"List000", "i": 2, "b":false, "r":102.0}},
1583 {"op": "insert", "table": "simple", "row": {"s":"List000", "i": 10, "b":true, "r":110.0}},
1584 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 1, "b":false, "r":110.0}},
1585 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 2, "b":true, "r":120.0}},
1586 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 2, "b":true, "r":122.0}},
1587 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 4, "b":true, "r":130.0}},
1588 {"op": "insert", "table": "simple", "row": {"s":"List005", "i": 5, "b":true, "r":130.0}},
1589 {"op": "insert", "table": "simple", "row": {"s":"List020", "i": 20, "b":true, "r":220.0}},
1590 {"op": "insert", "table": "simple", "row": {"s":"List020", "i": 19, "b":true, "r":219.0}}
1591 ]']],
1592 [idl_compound_index_single_column],
1593 [001: s=List000
1594001: s=List000
1595001: s=List000
1596001: s=List001
1597001: s=List001
1598001: s=List001
1599001: s=List001
1600001: s=List005
1601001: s=List020
1602001: s=List020
1603003: s=List001
1604003: s=List001
1605003: s=List001
1606003: s=List001
1607],
1608[001: s=List000 i=1 b=True r=101.000000
1609001: s=List000 i=10 b=True r=110.000000
1610001: s=List000 i=2 b=False r=102.000000
1611001: s=List001 i=1 b=False r=110.000000
1612001: s=List001 i=2 b=True r=120.000000
1613001: s=List001 i=2 b=True r=122.000000
1614001: s=List001 i=4 b=True r=130.000000
1615001: s=List005 i=5 b=True r=130.000000
1616001: s=List020 i=19 b=True r=219.000000
1617001: s=List020 i=20 b=True r=220.000000
1618003: s=List001 i=1 b=False r=110.000000
1619003: s=List001 i=2 b=True r=120.000000
1620003: s=List001 i=2 b=True r=122.000000
1621003: s=List001 i=4 b=True r=130.000000
1622],
1623[002: i=1
1624002: i=1
1625002: i=2
1626002: i=2
1627002: i=2
1628002: i=4
1629002: i=5
1630002: i=10
1631002: i=19
1632002: i=20
1633004: i=5
1634005: i=4
1635005: i=5
1636006: i=5
1637006: i=10
1638006: i=19
1639006: i=20
1640006: i=54
0a8606ee 1641007: i=5
0a8606ee
LR
1642007: i=19
1643007: i=20
d0bde286 1644007: i=30
0a8606ee 1645007: i=54
d0bde286
HZ
1646008: i=1
1647008: i=1
1648008: i=2
1649008: i=2
1650008: i=2
1651008: i=5
1652008: i=19
1653008: i=20
1654008: i=30
1655008: i=54
0a8606ee
LR
1656],
1657[002: i=1 s=List000 b=True r=101.000000
1658002: i=1 s=List001 b=False r=110.000000
1659002: i=10 s=List000 b=True r=110.000000
1660002: i=19 s=List020 b=True r=219.000000
1661002: i=2 s=List000 b=False r=102.000000
1662002: i=2 s=List001 b=True r=120.000000
1663002: i=2 s=List001 b=True r=122.000000
1664002: i=20 s=List020 b=True r=220.000000
1665002: i=4 s=List001 b=True r=130.000000
1666002: i=5 s=List005 b=True r=130.000000
1667004: i=5 s=List005 b=True r=130.000000
1668005: i=4 s=List001 b=True r=130.000000
1669005: i=5 s=List005 b=True r=130.000000
1670006: i=10 s=List000 b=True r=110.000000
1671006: i=19 s=List020 b=True r=219.000000
1672006: i=20 s=List020 b=True r=220.000000
1673006: i=5 s=List005 b=True r=130.000000
1674006: i=54 s=Lista054 b=False r=0.000000
0a8606ee 1675007: i=19 s=List020 b=True r=219.000000
0a8606ee 1676007: i=20 s=List020 b=True r=220.000000
d0bde286 1677007: i=30 s=List000 b=True r=110.000000
0a8606ee
LR
1678007: i=5 s=List005 b=True r=130.000000
1679007: i=54 s=Lista054 b=False r=0.000000
d0bde286
HZ
1680008: i=1 s=List000 b=True r=101.000000
1681008: i=1 s=List001 b=False r=110.000000
1682008: i=19 s=List020 b=True r=219.000000
1683008: i=2 s=List000 b=False r=102.000000
1684008: i=2 s=List001 b=True r=120.000000
1685008: i=2 s=List001 b=True r=122.000000
1686008: i=20 s=List020 b=True r=220.000000
1687008: i=30 s=List000 b=True r=110.000000
1688008: i=5 s=List005 b=True r=130.000000
1689008: i=54 s=Lista054 b=False r=0.000000
0a8606ee
LR
1690])
1691
1692# Tests to verify the functionality of two column compound index.
1693# It tests index for two columns using string and integer fields.
1694# The run of test-ovsdb generates the output of the display of data using the different indexes defined in
1695# the program.
1696# Then, some at_checks are used to verify the correctness of the corresponding index as well as the existence
1697# of all the rows involved in the test.
1698m4_define([OVSDB_CHECK_IDL_COMPOUND_INDEX_DOUBLE_COLUMN_C],
1699 [AT_SETUP([$1 - C])
1700 AT_KEYWORDS([ovsdb server idl compound_index_double_column compound_index positive $5])
1701 AT_CHECK([ovsdb_start_idltest])
1702 m4_if([$2], [], [],
7ef00082 1703 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
0a8606ee
LR
1704# Generate the data to be tested.
1705 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-compound-index unix:socket $3],
7ef00082 1706 [0], [stdout], [ignore])
0a8606ee
LR
1707# Filter the rows of data that corresponds to the string-integer index eliminating the extra columns of data.
1708# This is done to verifiy that the output data is in the correct and expected order.
1709 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: s=.*' | sed -e 's/ b=.*//g']],
7ef00082 1710 [0], [$4])
0a8606ee
LR
1711# Here, the data is filtered and sorted in order to have all the rows in the index and be
1712# able to determined that all the involved rows are present.
1713 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: s=.*' | sort -k 1,1n -k 2,2 -k 3,3]],
7ef00082 1714 [0], [$5])
0a8606ee
LR
1715# Filter the rows of data that corresponds to the integer index eliminating the extra columns of data.
1716# This is done to verifiy that the output data is in the correct and expected order.
1717 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: i=.*' | sed -e 's/ b=.*//g']],
7ef00082 1718 [0], [$6])
0a8606ee
LR
1719# Here again, the data is filtered and sorted in order to have all the rows in the index and be
1720# able to determined that all the involved rows are present.
1721 AT_CHECK([[cat stdout | grep -oh '[0-9]\{3\}: i=.*' | sort -k 1,1n -k 2,2 -k 3,3]],
7ef00082 1722 [0], [$7])
0a8606ee
LR
1723 OVSDB_SERVER_SHUTDOWN
1724 AT_CLEANUP])
1725
1726OVSDB_CHECK_IDL_COMPOUND_INDEX_DOUBLE_COLUMN_C([Compound_index, double column test ],
1727 [['["idltest",
1728 {"op": "insert", "table": "simple", "row": {"s":"List000", "i": 1, "b":true, "r":101.0}},
1729 {"op": "insert", "table": "simple", "row": {"s":"List000", "i": 2, "b":false, "r":102.0}},
1730 {"op": "insert", "table": "simple", "row": {"s":"List000", "i": 10, "b":true, "r":110.0}},
1731 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 1, "b":false, "r":110.0}},
1732 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 2, "b":true, "r":120.0}},
1733 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 2, "b":true, "r":122.0}},
1734 {"op": "insert", "table": "simple", "row": {"s":"List001", "i": 4, "b":true, "r":130.0}},
1735 {"op": "insert", "table": "simple", "row": {"s":"List005", "i": 5, "b":true, "r":130.0}},
1736 {"op": "insert", "table": "simple", "row": {"s":"List020", "i": 20, "b":true, "r":220.0}},
1737 {"op": "insert", "table": "simple", "row": {"s":"List020", "i": 19, "b":true, "r":219.0}}
1738 ]']],
1739 [idl_compound_index_double_column],
1740 [001: s=List000 i=1
1741001: s=List000 i=2
1742001: s=List000 i=10
1743001: s=List001 i=1
1744001: s=List001 i=2
1745001: s=List001 i=2
1746001: s=List001 i=4
1747001: s=List005 i=5
1748001: s=List020 i=19
1749001: s=List020 i=20
1750002: s=List000 i=10
1751002: s=List000 i=2
1752002: s=List000 i=1
1753002: s=List001 i=4
1754002: s=List001 i=2
1755002: s=List001 i=2
1756002: s=List001 i=1
1757002: s=List005 i=5
1758002: s=List020 i=20
1759002: s=List020 i=19
1760003: s=List000 i=10
1761004: s=List001 i=1
1762004: s=List001 i=2
1763004: s=List001 i=2
1764004: s=List001 i=4
1765004: s=List005 i=5
1766],
1767 [001: s=List000 i=1 b=True r=101.000000
1768001: s=List000 i=10 b=True r=110.000000
1769001: s=List000 i=2 b=False r=102.000000
1770001: s=List001 i=1 b=False r=110.000000
1771001: s=List001 i=2 b=True r=120.000000
1772001: s=List001 i=2 b=True r=122.000000
1773001: s=List001 i=4 b=True r=130.000000
1774001: s=List005 i=5 b=True r=130.000000
1775001: s=List020 i=19 b=True r=219.000000
1776001: s=List020 i=20 b=True r=220.000000
1777002: s=List000 i=1 b=True r=101.000000
1778002: s=List000 i=10 b=True r=110.000000
1779002: s=List000 i=2 b=False r=102.000000
1780002: s=List001 i=1 b=False r=110.000000
1781002: s=List001 i=2 b=True r=120.000000
1782002: s=List001 i=2 b=True r=122.000000
1783002: s=List001 i=4 b=True r=130.000000
1784002: s=List005 i=5 b=True r=130.000000
1785002: s=List020 i=19 b=True r=219.000000
1786002: s=List020 i=20 b=True r=220.000000
1787003: s=List000 i=10 b=True r=110.000000
1788004: s=List001 i=1 b=False r=110.000000
1789004: s=List001 i=2 b=True r=120.000000
1790004: s=List001 i=2 b=True r=122.000000
1791004: s=List001 i=4 b=True r=130.000000
1792004: s=List005 i=5 b=True r=130.000000
1793],
1794 [005: i=1 s=List000
1795005: i=1 s=List001
1796005: i=2 s=List000
1797005: i=2 s=List001
1798005: i=2 s=List001
1799005: i=4 s=List001
1800005: i=5 s=List005
1801005: i=10 s=List000
1802005: i=19 s=List020
1803005: i=20 s=List020
1804006: i=20 s=List020
1805006: i=19 s=List020
1806006: i=10 s=List000
1807006: i=5 s=List005
1808006: i=4 s=List001
1809006: i=2 s=List000
1810006: i=2 s=List001
1811006: i=2 s=List001
1812006: i=1 s=List000
1813006: i=1 s=List001
1814],
1815 [005: i=1 s=List000 b=True r=101.000000
1816005: i=1 s=List001 b=False r=110.000000
1817005: i=10 s=List000 b=True r=110.000000
1818005: i=19 s=List020 b=True r=219.000000
1819005: i=2 s=List000 b=False r=102.000000
1820005: i=2 s=List001 b=True r=120.000000
1821005: i=2 s=List001 b=True r=122.000000
1822005: i=20 s=List020 b=True r=220.000000
1823005: i=4 s=List001 b=True r=130.000000
1824005: i=5 s=List005 b=True r=130.000000
1825006: i=1 s=List000 b=True r=101.000000
1826006: i=1 s=List001 b=False r=110.000000
1827006: i=10 s=List000 b=True r=110.000000
1828006: i=19 s=List020 b=True r=219.000000
1829006: i=2 s=List000 b=False r=102.000000
1830006: i=2 s=List001 b=True r=120.000000
1831006: i=2 s=List001 b=True r=122.000000
1832006: i=20 s=List020 b=True r=220.000000
1833006: i=4 s=List001 b=True r=130.000000
1834006: i=5 s=List005 b=True r=130.000000
1835])
3cc1634f
HZ
1836
1837m4_define([OVSDB_CHECK_IDL_COMPOUND_INDEX_WITH_REF],
1838 [AT_SETUP([$1 - C])
1839 AT_KEYWORDS([ovsdb server idl compound_index compound_index_with_ref positive $5])
1840 AT_CHECK([ovsdb_start_idltest])
1841 m4_if([$2], [], [],
1842 [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])])
1843 AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-compound-index-with-ref unix:socket $3],
1844 [0], [stdout], [ignore])
c724bd67 1845 AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]),
3cc1634f
HZ
1846 [0], [$4])
1847 OVSDB_SERVER_SHUTDOWN
1848 AT_CLEANUP])
1849
1850OVSDB_CHECK_IDL_COMPOUND_INDEX_WITH_REF([set, simple3 idl-compound-index-with-ref, initially populated],
1851[],
1852[],
1853[[000: After add to other table + set of strong ref
1854001: name= uset=[] uref=[[<0>]]
1855002: check simple4: not empty
1856003: Query using index with reference
1857004: name= uset=[] uref=[[<0>]]
1858005: After delete
1859007: check simple4: empty
1860008: End test
1861]])
c1aa16d1 1862
cfef5ae8
IM
1863m4_define([CHECK_STREAM_OPEN_BLOCK],
1864 [AT_SETUP([Check Stream open block - C - $1])
1865 AT_SKIP_IF([test "$1" = "tcp6" && test "$IS_WIN32" = "yes"])
1866 AT_SKIP_IF([test "$1" = "tcp6" && test "$HAVE_IPV6" = "no"])
1867 AT_KEYWORDS([Check Stream open block $1])
1868 AT_CHECK([ovsdb_start_idltest "ptcp:0:$2"])
1869 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
fe495d0c 1870 WRONG_PORT=$(($TCP_PORT + 101))
cfef5ae8
IM
1871 AT_CHECK([test-stream tcp:$2:$TCP_PORT], [0], [ignore])
1872 AT_CHECK([test-stream tcp:$2:$WRONG_PORT], [1], [ignore], [ignore])
1873 OVSDB_SERVER_SHUTDOWN
1874 AT_CHECK([test-stream tcp:$2:$TCP_PORT], [1], [ignore], [ignore])
1875 AT_CLEANUP])
1876
1877CHECK_STREAM_OPEN_BLOCK([tcp], [127.0.0.1])
1878CHECK_STREAM_OPEN_BLOCK([tcp6], [[[::1]]])
1879
c1aa16d1
NS
1880m4_define([CHECK_STREAM_OPEN_BLOCK_PY],
1881 [AT_SETUP([$1])
1882 AT_SKIP_IF([test $2 = no])
1883 AT_KEYWORDS([Check PY Stream open block - $3])
1884 AT_CHECK([ovsdb_start_idltest "ptcp:0:127.0.0.1"])
1885 PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
fe495d0c 1886 WRONG_PORT=$(($TCP_PORT + 101))
c1aa16d1
NS
1887 AT_CHECK([$3 $srcdir/test-stream.py tcp:127.0.0.1:$TCP_PORT], [0], [ignore])
1888 AT_CHECK([$3 $srcdir/test-stream.py tcp:127.0.0.1:$WRONG_PORT], [1], [ignore])
1889 OVSDB_SERVER_SHUTDOWN
1890 AT_CHECK([$3 $srcdir/test-stream.py tcp:127.0.0.1:$TCP_PORT], [1], [ignore])
1891 AT_CLEANUP])
1892
1dd218ae
BP
1893CHECK_STREAM_OPEN_BLOCK_PY([Check PY2 Stream open block], [$HAVE_PYTHON2], [$PYTHON2])
1894CHECK_STREAM_OPEN_BLOCK_PY([Check PY3 Stream open block], [$HAVE_PYTHON3], [$PYTHON3])
c39751e4
TE
1895
1896# same as OVSDB_CHECK_IDL but uses Python IDL implementation with tcp
1897# with multiple remotes to assert the idl connects to the leader of the Raft cluster
1898m4_define([OVSDB_CHECK_IDL_LEADER_ONLY_PYN],
1899 [AT_SETUP([$1])
1900 AT_SKIP_IF([test $7 = no])
1901 AT_KEYWORDS([ovsdb server idl Python leader_only with tcp socket])
1902 m4_define([LPBK],[127.0.0.1])
1903 AT_CHECK([ovsdb_cluster_start_idltest $2 "ptcp:0:"LPBK])
1904 PARSE_LISTENING_PORT([s2.log], [TCP_PORT_1])
1905 PARSE_LISTENING_PORT([s3.log], [TCP_PORT_2])
1906 PARSE_LISTENING_PORT([s1.log], [TCP_PORT_3])
1907 remotes=tcp:LPBK:$TCP_PORT_1,tcp:LPBK:$TCP_PORT_2,tcp:LPBK:$TCP_PORT_3
1908 pids=$(cat s2.pid s3.pid s1.pid | tr '\n' ',')
1909 echo $pids
1910 AT_CHECK([$8 $srcdir/test-ovsdb.py -t30 idl-cluster $srcdir/idltest.ovsschema $remotes $pids $3],
1911 [0], [stdout], [ignore])
1912 remote=$(ovsdb_cluster_leader $remotes "idltest")
1913 leader=$(echo $remote | cut -d'|' -f 1)
1914 AT_CHECK([grep -F -- "${leader}" stdout], [0], [ignore])
1915 AT_CLEANUP])
1916
1917m4_define([OVSDB_CHECK_IDL_LEADER_ONLY_PY],
1918 [OVSDB_CHECK_IDL_LEADER_ONLY_PYN([$1 - Python2 (leader only)], [$2], [$3], [$4], [$5], [$6],
1919 [$HAVE_PYTHON], [$PYTHON])
1920 OVSDB_CHECK_IDL_LEADER_ONLY_PYN([$1 - Python3 (leader only)], [$2], [$3], [$4], [$5], [$6],
1921 [$HAVE_PYTHON3], [$PYTHON3])])
1922
1923OVSDB_CHECK_IDL_LEADER_ONLY_PY([Check Python IDL connects to leader], 3, ['remote'])
1924OVSDB_CHECK_IDL_LEADER_ONLY_PY([Check Python IDL reconnects to leader], 3, ['remote' '+remotestop' 'remote'])