]> git.proxmox.com Git - ovs.git/blame - tests/ovsdb-monitor.at
Require Python 3 and remove support for Python 2.
[ovs.git] / tests / ovsdb-monitor.at
CommitLineData
a8425c53
BP
1AT_BANNER([OVSDB -- ovsdb-server monitors])
2
1b1d2e6d
BP
3OVS_START_SHELL_HELPERS
4# ovsdb_check_monitor SCHEMA_FUNC DB TABLE OUTPUT COLUMNS
5# PRE-MONITOR-TXN... -- TRANSACTION...
6ovsdb_check_monitor () {
7 local schema_func=$1 db=$2 table=$3 output=$4 columns=$5
8 shift; shift; shift; shift; shift
9 $schema_func > schema
10 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
11 while test "$1" != "--"; do
5a0e4aec
BP
12 AT_CHECK([ovsdb-tool transact db "$1"], [0], [ignore], [ignore])
13 shift
1b1d2e6d
BP
14 done
15 shift
16 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file db > ovsdb-server.stdout 2> ovsdb-server.stderr],
5a0e4aec 17 [0], [], [])
1b1d2e6d
BP
18 on_exit 'kill `cat ovsdb-server.pid`'
19 if test "$IS_WIN32" = "yes"; then
20 AT_CHECK([ovsdb-client -vjsonrpc --pidfile --log-file -d json monitor --format=csv unix:socket $db $table $columns > output 2> ovsdb-client.stderr &],
5a0e4aec 21 [0], [ignore], [ignore])
1b1d2e6d
BP
22 sleep 1
23 else
9a403b07 24 AT_CHECK([ovsdb-client -vjsonrpc --detach --no-chdir --pidfile --log-file -d json monitor --format=csv unix:socket $db $table $columns > output 2> ovsdb-client.stderr],
5a0e4aec 25 [0], [ignore], [ignore])
1b1d2e6d
BP
26 fi
27 on_exit 'kill `cat ovsdb-client.pid`'
28 for txn in ${1+"$@"} '[["'$db'"]]'; do
29 AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0], [ignore], [ignore])
30 done
31 OVS_APP_EXIT_AND_WAIT_BY_TARGET([ovsdb-server], [ovsdb-server.pid])
32 OVS_WAIT_UNTIL([test ! -e ovsdb-client.pid])
1ca0323e 33 AT_CHECK_UNQUOTED([$PYTHON3 $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0], [$output], [ignore])
1b1d2e6d
BP
34}
35OVS_END_SHELL_HELPERS
36
7360012b 37# OVSDB_CHECK_MONITOR(TITLE, SCHEMA, [PRE-MONITOR-TXN], DB, TABLE,
20aa445d 38# TRANSACTIONS, OUTPUT, [COLUMNS], [KEYWORDS])
a8425c53
BP
39#
40# Creates a database with the given SCHEMA, starts an ovsdb-server on
41# that database, and runs each of the TRANSACTIONS (which should be a
42# quoted list of quoted strings) against it with ovsdb-client one at a
20aa445d
BP
43# time. COLUMNS, if specified, is passed to ovsdb-client as the set
44# of columns and operations to select.
a8425c53
BP
45#
46# Checks that the overall output is OUTPUT, but UUIDs in the output
47# are replaced by markers of the form <N> where N is a number. The
48# first unique UUID is replaced by <0>, the next by <1>, and so on.
49# If a given UUID appears more than once it is always replaced by the
50# same marker.
51#
52# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
1b1d2e6d 53m4_define([OVSDB_CHECK_MONITOR],
a8425c53 54 [AT_SETUP([$1])
fd193af4 55 AT_KEYWORDS([ovsdb server monitor positive $9])
1b1d2e6d
BP
56 AT_CAPTURE_FILE([ovsdb-server.log])
57 AT_CAPTURE_FILE([ovsdb-server.stdout])
58 AT_CAPTURE_FILE([ovsdb-server.stderr])
59 AT_CAPTURE_FILE([ovsdb-client.log])
60 AT_CAPTURE_FILE([ovsdb-client.stderr])
61 ovsdb_check_monitor '$2' '$4' '$5' '$7' '$8' \
62 m4_foreach([txn], [$3], ['txn' ]) -- \
63 m4_foreach([txn], [$6], ['txn' ])
a8425c53
BP
64 AT_CLEANUP])
65
c383f3bf
LS
66# OVSDB_CHECK_MONITOR_COND(TITLE, SCHEMA, [PRE-MONITOR-TXN], DB, TABLE,
67# TRANSACTIONS, OUTPUT, CONDITIONS, [COLUMNS], [KEYWORDS],
68# [CONDITIONS_CHANGE])
69#
70# Creates a database with the given SCHEMA, starts an ovsdb-server on
71# that database, and runs each of the TRANSACTIONS (which should be a
72# quoted list of quoted strings) against it with ovsdb-client one at a
73# time. COLUMNS, if specified, is passed to ovsdb-client as the set
74# of columns and operations to select.
75#
76# Checks that the overall output is OUTPUT, but UUIDs in the output
77# are replaced by markers of the form <N> where N is a number. The
78# first unique UUID is replaced by <0>, the next by <1>, and so on.
79# If a given UUID appears more than once it is always replaced by the
80# same marker.
81#
82# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
83m4_define([OVSDB_CHECK_MONITOR_COND],
84 [AT_SETUP([$1])
85 AT_KEYWORDS([ovsdb server monitor monitor-cond positive $10])
86 $2 > schema
87 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
1b1d2e6d
BP
88 for txn in m4_foreach([txn], [$3], ['txn' ]); do
89 AT_CHECK([ovsdb-tool transact db "$txn"], [0], [ignore], [ignore])
90 done
c383f3bf 91 AT_CAPTURE_FILE([ovsdb-server-log])
56120500
BP
92 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file="`pwd`"/ovsdb-server-log db >/dev/null 2>&1])
93 on_exit 'kill `cat ovsdb-server.pid`'
94 AT_CHECK([ovsdb-client -vjsonrpc --pidfile --detach --no-chdir -d json monitor-cond --format=csv unix:socket $4 '[$8]' $5 $9 > output],
5a0e4aec 95 [0], [ignore], [ignore])
56120500 96 on_exit 'kill `cat ovsdb-client.pid`'
1b1d2e6d
BP
97 for txn in m4_foreach([txn], [$6], ['txn' ]); do
98 AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0],
99 [ignore], [ignore], [kill `cat server-pid client-pid`])
100 done
101 for cond in m4_foreach([cond], [$10], ['cond' ]); do
102 AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/cond_change $5 "$cond"], [0], [ignore], [ignore])
103 done
c383f3bf 104 AT_CHECK([ovsdb-client transact unix:socket '[["$4"]]'], [0],
56120500
BP
105 [ignore], [ignore])
106 AT_CHECK([ovs-appctl -t ovsdb-server -e exit], [0], [ignore], [ignore])
107 OVS_WAIT_UNTIL([test ! -e ovsdb-server.pid && test ! -e ovsdb-client.pid])
1ca0323e 108 AT_CHECK([$PYTHON3 $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0], [$7], [ignore])
c383f3bf
LS
109 AT_CLEANUP])
110
8fcf509e 111OVSDB_CHECK_MONITOR([monitor insert into empty table],
39ab07af 112 [ordinal_schema],
a8425c53 113 [],
7360012b 114 [ordinals], [ordinals],
9cb53f26
BP
115 [[[["ordinals",
116 {"op": "insert",
a8425c53
BP
117 "table": "ordinals",
118 "row": {"number": 0, "name": "zero"}}]]]],
119 [[row,action,name,number,_version
120<0>,insert,"""zero""",0,"[""uuid"",""<1>""]"
121]])
8fcf509e
BP
122
123OVSDB_CHECK_MONITOR([monitor insert into populated table],
39ab07af 124 [ordinal_schema],
9cb53f26
BP
125 [[[["ordinals",
126 {"op": "insert",
8fcf509e
BP
127 "table": "ordinals",
128 "row": {"number": 10, "name": "ten"}}]]]],
7360012b 129 [ordinals], [ordinals],
9cb53f26
BP
130 [[[["ordinals",
131 {"op": "insert",
8fcf509e
BP
132 "table": "ordinals",
133 "row": {"number": 0, "name": "zero"}}]]]],
134 [[row,action,name,number,_version
135<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
e5125481 136
8fcf509e
BP
137row,action,name,number,_version
138<2>,insert,"""zero""",0,"[""uuid"",""<3>""]"
139]])
140
141OVSDB_CHECK_MONITOR([monitor delete],
39ab07af 142 [ordinal_schema],
9cb53f26
BP
143 [[[["ordinals",
144 {"op": "insert",
8fcf509e
BP
145 "table": "ordinals",
146 "row": {"number": 10, "name": "ten"}}]]]],
7360012b 147 [ordinals], [ordinals],
9cb53f26
BP
148 [[[["ordinals",
149 {"op": "delete",
8fcf509e
BP
150 "table": "ordinals",
151 "where": [["number", "==", 10]]}]]]],
152 [[row,action,name,number,_version
153<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
e5125481 154
8fcf509e
BP
155row,action,name,number,_version
156<0>,delete,"""ten""",10,"[""uuid"",""<1>""]"
157]])
158
159OVSDB_CHECK_MONITOR([monitor row update],
39ab07af 160 [ordinal_schema],
9cb53f26
BP
161 [[[["ordinals",
162 {"op": "insert",
8fcf509e
BP
163 "table": "ordinals",
164 "row": {"number": 10, "name": "ten"}}]]]],
7360012b 165 [ordinals], [ordinals],
9cb53f26
BP
166 [[[["ordinals",
167 {"op": "update",
8fcf509e
BP
168 "table": "ordinals",
169 "where": [["number", "==", 10]],
170 "row": {"name": "five plus five"}}]]]],
171 [[row,action,name,number,_version
172<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
e5125481 173
8fcf509e
BP
174row,action,name,number,_version
175<0>,old,"""ten""",,"[""uuid"",""<1>""]"
176,new,"""five plus five""",10,"[""uuid"",""<2>""]"
177]])
178
179OVSDB_CHECK_MONITOR([monitor no-op row updates],
39ab07af 180 [ordinal_schema],
9cb53f26
BP
181 [[[["ordinals",
182 {"op": "insert",
8fcf509e
BP
183 "table": "ordinals",
184 "row": {"number": 10, "name": "ten"}}]]]],
7360012b 185 [ordinals], [ordinals],
9cb53f26
BP
186 [[[["ordinals",
187 {"op": "update",
8fcf509e
BP
188 "table": "ordinals",
189 "where": [["number", "==", 10]],
190 "row": {"number": 10, "name": "ten"}}]]],
9cb53f26
BP
191 [[["ordinals",
192 {"op": "insert",
8fcf509e
BP
193 "table": "ordinals",
194 "row": {"number": 9, "name": "nine"}}]]]],
195 [[row,action,name,number,_version
196<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
e5125481 197
8fcf509e
BP
198row,action,name,number,_version
199<2>,insert,"""nine""",9,"[""uuid"",""<3>""]"
200]])
201
202OVSDB_CHECK_MONITOR([monitor insert-and-update transaction],
39ab07af 203 [ordinal_schema],
9cb53f26
BP
204 [[[["ordinals",
205 {"op": "insert",
8fcf509e
BP
206 "table": "ordinals",
207 "row": {"number": 10, "name": "ten"}}]]]],
7360012b 208 [ordinals], [ordinals],
9cb53f26
BP
209 [[[["ordinals",
210 {"op": "insert",
8fcf509e
BP
211 "table": "ordinals",
212 "row": {"number": 9, "name": "nine"},
213 "uuid-name": "nine"},
214 {"op": "update",
215 "table": "ordinals",
216 "where": [["_uuid", "==", ["named-uuid", "nine"]]],
217 "row": {"name": "three squared"}}]]]],
218 [[row,action,name,number,_version
219<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
e5125481 220
8fcf509e
BP
221row,action,name,number,_version
222<2>,insert,"""three squared""",9,"[""uuid"",""<3>""]"
223]])
224
8fcf509e 225OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction],
39ab07af 226 [ordinal_schema],
9cb53f26
BP
227 [[[["ordinals",
228 {"op": "insert",
8fcf509e
BP
229 "table": "ordinals",
230 "row": {"number": 10, "name": "ten"}}]]]],
7360012b 231 [ordinals], [ordinals],
9cb53f26
BP
232 [[[["ordinals",
233 {"op": "insert",
8fcf509e
BP
234 "table": "ordinals",
235 "row": {"number": 9, "name": "nine"},
236 "uuid-name": "nine"},
237 {"op": "update",
238 "table": "ordinals",
239 "where": [["_uuid", "==", ["named-uuid", "nine"]]],
240 "row": {"name": "three squared"}},
241 {"op": "delete",
242 "table": "ordinals",
243 "where": [["_uuid", "==", ["named-uuid", "nine"]]]},
244 {"op": "insert",
245 "table": "ordinals",
246 "row": {"number": 7, "name": "seven"}}]]]],
247 [[row,action,name,number,_version
248<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
e5125481 249
8fcf509e
BP
250row,action,name,number,_version
251<2>,insert,"""seven""",7,"[""uuid"",""<3>""]"
252]])
253
7360012b 254OVSDB_CHECK_MONITOR([monitor weak reference change],
39ab07af 255 [weak_schema],
7360012b
BP
256 [[[["weak",
257 {"op": "insert",
258 "table": "a",
259 "row": {"a": 0,
260 "a2a1": ["named-uuid", "a0"],
261 "a2b": ["named-uuid", "b2"]},
262 "uuid-name": "a0"},
263 {"op": "insert",
264 "table": "a",
265 "row": {"a": 1,
266 "a2a": ["named-uuid", "a0"],
267 "a2a1": ["named-uuid", "a1"],
268 "a2b": ["named-uuid", "b2"]},
269 "uuid-name": "a1"},
270 {"op": "insert",
271 "table": "b",
272 "row": {"b": 2},
273 "uuid-name": "b2"}]]]],
274 [weak], [a],
275 [[[["weak",
276 {"op": "delete",
277 "table": "a",
278 "where": [["a", "==", 0]]}]]]],
a1ae5dc8
BP
279 [[row,action,a,a2a,a2a1,a2b,_version
280<0>,initial,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]"
281<3>,initial,1,"[""uuid"",""<0>""]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<4>""]"
7360012b 282
a1ae5dc8
BP
283row,action,a,a2a,a2a1,a2b,_version
284<0>,delete,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]"
5cd9f691 285<3>,old,,"[""uuid"",""<0>""]",,,"[""uuid"",""<4>""]"
a1ae5dc8 286,new,1,"[""set"",[]]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<5>""]"
7360012b
BP
287]])
288
fd193af4 289OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction],
39ab07af 290 [ordinal_schema],
fd193af4
BP
291 [[[["ordinals",
292 {"op": "insert",
293 "table": "ordinals",
294 "row": {"number": 10, "name": "ten"}}]]]],
295 [ordinals], [ordinals],
296 [[[["ordinals",
297 {"op": "insert",
298 "table": "ordinals",
299 "row": {"number": 9, "name": "nine"},
300 "uuid-name": "nine"},
301 {"op": "update",
302 "table": "ordinals",
303 "where": [["_uuid", "==", ["named-uuid", "nine"]]],
304 "row": {"name": "three squared"}},
305 {"op": "delete",
306 "table": "ordinals",
307 "where": [["_uuid", "==", ["named-uuid", "nine"]]]},
308 {"op": "insert",
309 "table": "ordinals",
310 "row": {"number": 7, "name": "seven"}}]]]],
311 [[row,action,name,number,_version
312<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
313
314row,action,name,number,_version
315<2>,insert,"""seven""",7,"[""uuid"",""<3>""]"
316]])
317\f
318AT_BANNER([ovsdb -- ovsdb-monitor monitor only some operations])
319
320m4_define([OVSDB_MONITOR_INITIAL],
321 [[[["ordinals",
322 {"op": "insert",
323 "table": "ordinals",
324 "row": {"number": 10, "name": "ten"}}]]]])
325m4_define([OVSDB_MONITOR_TXNS],
326 [[[["ordinals",
327 {"op": "insert",
328 "table": "ordinals",
329 "row": {"number": 5, "name": "five"}}]]],
330 [[["ordinals",
331 {"op": "update",
332 "table": "ordinals",
333 "where": [["name", "==", "five"]],
334 "row": {"name": "FIVE"}}]]],
335 [[["ordinals",
336 {"op": "delete",
337 "table": "ordinals",
338 "where": []}]]]])
339
340OVSDB_CHECK_MONITOR([monitor all operations],
39ab07af 341 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
fd193af4
BP
342 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
343 [[row,action,name,number,_version
344<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
345
346row,action,name,number,_version
347<2>,insert,"""five""",5,"[""uuid"",""<3>""]"
348
349row,action,name,number,_version
350<2>,old,"""five""",,"[""uuid"",""<3>""]"
351,new,"""FIVE""",5,"[""uuid"",""<4>""]"
352
353row,action,name,number,_version
354<2>,delete,"""FIVE""",5,"[""uuid"",""<4>""]"
355<0>,delete,"""ten""",10,"[""uuid"",""<1>""]"
356]])
357
358dnl A monitor with "initial" only doesn't really make sense,
359dnl but it's still allowed and should work.
360OVSDB_CHECK_MONITOR([monitor initial only],
39ab07af 361 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
fd193af4
BP
362 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
363 [[row,action,name,number,_version
364<0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
20aa445d 365]], [!insert,!delete,!modify])
fd193af4
BP
366
367OVSDB_CHECK_MONITOR([monitor insert only],
39ab07af 368 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
fd193af4
BP
369 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
370 [[row,action,name,number,_version
371<0>,insert,"""five""",5,"[""uuid"",""<1>""]"
20aa445d 372]], [!initial,!delete,!modify])
fd193af4
BP
373
374OVSDB_CHECK_MONITOR([monitor delete only],
39ab07af 375 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
fd193af4
BP
376 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
377 [[row,action,name,number,_version
378<0>,delete,"""FIVE""",5,"[""uuid"",""<1>""]"
379<2>,delete,"""ten""",10,"[""uuid"",""<3>""]"
20aa445d 380]], [!initial,!insert,!modify])
fd193af4
BP
381
382OVSDB_CHECK_MONITOR([monitor modify only],
39ab07af 383 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
fd193af4
BP
384 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
385 [[row,action,name,number,_version
386<0>,old,"""five""",,"[""uuid"",""<1>""]"
387,new,"""FIVE""",5,"[""uuid"",""<2>""]"
20aa445d 388]], [!initial,!insert,!delete])
c383f3bf
LS
389
390AT_BANNER([ovsdb -- ovsdb-monitor-cond conditional monitor only some operations])
391
392OVSDB_CHECK_MONITOR_COND([monitor-cond empty condition],
393 [ordinal_schema],
394 [[[["ordinals",
395 {"op": "insert",
396 "table": "ordinals",
397 "row": {"number": 0, "name": "zero"}},
398 {"op": "insert",
399 "table": "ordinals",
400 "row": {"number": 1, "name": "one"}},
401 {"op": "insert",
402 "table": "ordinals",
403 "row": {"number": 2, "name": "two"}}]]]],
404 [ordinals], [ordinals],
405 [[[["ordinals",
406 {"op": "insert",
407 "table": "ordinals",
408 "row": {"number": 10, "name": "ten"}},
409 {"op": "insert",
410 "table": "ordinals",
411 "row": {"number": 11, "name": "eleven"}}]]]],
412 [[row,action,name,number,_version
413<0>,initial,"""one""",1,"[""uuid"",""<1>""]"
414<2>,initial,"""two""",2,"[""uuid"",""<3>""]"
415<4>,initial,"""zero""",,"[""uuid"",""<5>""]"
416
417row,action,name,number,_version
418<6>,insert,"""eleven""",11,"[""uuid"",""<7>""]"
419<8>,insert,"""ten""",10,"[""uuid"",""<9>""]"
420]],
421 [[]])
422
423OVSDB_CHECK_MONITOR_COND([monitor-cond multiple conditions],
424 [ordinal_schema],
425 [[[["ordinals",
426 {"op": "insert",
427 "table": "ordinals",
428 "row": {"number": 0, "name": "zero"}},
429 {"op": "insert",
430 "table": "ordinals",
431 "row": {"number": 1, "name": "one"}},
432 {"op": "insert",
433 "table": "ordinals",
434 "row": {"number": 2, "name": "two"}}]]]],
435 [ordinals], [ordinals],
436 [[[["ordinals",
437 {"op": "insert",
438 "table": "ordinals",
439 "row": {"number": 10, "name": "ten"}},
440 {"op": "insert",
441 "table": "ordinals",
442 "row": {"number": 11, "name": "eleven"}}]]]],
443 [[row,action,name,number,_version
444<0>,initial,"""one""",1,"[""uuid"",""<1>""]"
445
446row,action,name,number,_version
447<2>,insert,"""ten""",10,"[""uuid"",""<3>""]"
448]],
449 [[["name","==","one"],["name","==","ten"]]])
450
451OVSDB_CHECK_MONITOR_COND([monitor-cond delete from populated table],
452 [ordinal_schema],
453 [[[["ordinals",
454 {"op": "insert",
455 "table": "ordinals",
456 "row": {"number": 0, "name": "zero"}},
457 {"op": "insert",
458 "table": "ordinals",
459 "row": {"number": 1, "name": "one"}},
460 {"op": "insert",
461 "table": "ordinals",
462 "row": {"number": 2, "name": "two"}}]]]],
463 [ordinals], [ordinals],
464 [[[["ordinals",
465 {"op": "delete",
466 "table": "ordinals",
467 "where": []}]]]],
468 [[row,action,name,number,_version
469<0>,initial,"""one""",1,"[""uuid"",""<1>""]"
470
471row,action,name,number,_version
472<0>,delete,,,
473]],
474 [[["name","==","one"],["name","==","ten"]]])
475
476OVSDB_CHECK_MONITOR_COND([monitor-cond insert due to modify],
477 [ordinal_schema],
478 [[[["ordinals",
479 {"op": "insert",
480 "table": "ordinals",
481 "row": {"number": 0, "name": "zero"}},
482 {"op": "insert",
483 "table": "ordinals",
484 "row": {"number": 1, "name": "one"}},
485 {"op": "insert",
486 "table": "ordinals",
487 "row": {"number": 2, "name": "two"}}]]]],
488 [ordinals], [ordinals],
489 [[[["ordinals",
490 {"op": "update",
491 "table": "ordinals",
492 "where": [["name", "==", "one"]],
493 "row": {"name": "ONE"}}]]]],
494 [[row,action,name,number,_version
495<0>,insert,"""ONE""",1,"[""uuid"",""<1>""]"
496]],
497 [[["name","==","ONE"]]],
498 [!initial,!delete,!modify])
499
500OVSDB_CHECK_MONITOR_COND([monitor-cond delete due to modify],
501 [ordinal_schema],
502 [[[["ordinals",
503 {"op": "insert",
504 "table": "ordinals",
505 "row": {"number": 0, "name": "zero"}},
506 {"op": "insert",
507 "table": "ordinals",
508 "row": {"number": 1, "name": "one"}},
509 {"op": "insert",
510 "table": "ordinals",
511 "row": {"number": 2, "name": "two"}}]]]],
512 [ordinals], [ordinals],
513 [[[["ordinals",
514 {"op": "update",
515 "table": "ordinals",
516 "where": [["name", "==", "one"]],
517 "row": {"name": "ONE"}}]]]],
518 [[row,action,name,number,_version
519<0>,delete,,,
520]],
521 [[["name","==","one"]]],
522 [!initial,!insert,!modify])
523
524OVSDB_CHECK_MONITOR_COND([monitor-cond condition non-monitored columns],
525 [ordinal_schema],
526 [[[["ordinals",
527 {"op": "insert",
528 "table": "ordinals",
529 "row": {"number": 0, "name": "zero"}},
530 {"op": "insert",
531 "table": "ordinals",
532 "row": {"number": 1, "name": "one"}},
533 {"op": "insert",
534 "table": "ordinals",
535 "row": {"number": 2, "name": "two"}}]]]],
536 [ordinals], [ordinals],
537 [[[["ordinals",
538 {"op": "insert",
539 "table": "ordinals",
540 "row": {"number": 10, "name": "ten"}},
541 {"op": "insert",
542 "table": "ordinals",
543 "row": {"number": 11, "name": "eleven"}}]]]],
544 [[row,action,number
545<0>,initial,1
546
547row,action,number
548<1>,insert,10
549]],
550 [[["name","==","one"],["name","==","ten"]]],
551 ["number"])
552
553OVSDB_CHECK_MONITOR_COND([monitor-cond-change],
554 [ordinal_schema],
555 [[[["ordinals",
556 {"op": "insert",
557 "table": "ordinals",
558 "row": {"number": 0, "name": "zero"}},
559 {"op": "insert",
560 "table": "ordinals",
561 "row": {"number": 1, "name": "one"}},
562 {"op": "insert",
563 "table": "ordinals",
564 "row": {"number": 2, "name": "two"}}]]]],
565 [ordinals], [ordinals],
566 [],
567 [[row,action,name,number,_version
568<0>,initial,"""one""",1,"[""uuid"",""<1>""]"
569<2>,initial,"""two""",2,"[""uuid"",""<3>""]"
570<4>,initial,"""zero""",,"[""uuid"",""<5>""]"
571
572row,action,name,number,_version
573<4>,delete,,,
574
575row,action,name,number,_version
576<2>,delete,,,
577
578row,action,name,number,_version
579<0>,delete,,,
580
581row,action,name,number,_version
582<0>,insert,"""one""",1,"[""uuid"",""<1>""]"
583<2>,insert,"""two""",2,"[""uuid"",""<3>""]"
584<4>,insert,"""zero""",,"[""uuid"",""<5>""]"
585]],
586 [[]],
587 [],
588 [[[[["name","==","one"],["name","==","two"]]]],
589 [[[["name","==","one"]]]],
590 [[[false]]],
591 [[[true]]]])
e0f42d4a
HZ
592
593
594AT_SETUP(monitor-cond-change with many sessions pending)
595AT_KEYWORDS([ovsdb server monitor monitor-cond negative])
596ordinal_schema > schema
597AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
e0f42d4a 598AT_CAPTURE_FILE([ovsdb-server-log])
9167cb52 599
e0f42d4a
HZ
600AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file="`pwd`"/ovsdb-server-log db >/dev/null 2>&1])
601on_exit 'kill `cat ovsdb-server.pid`'
602for txn in m4_foreach([txn], [[[["ordinals",
603 {"op": "insert",
604 "table": "ordinals",
605 "row": {"number": 0, "name": "zero"}},
606 {"op": "insert",
607 "table": "ordinals",
608 "row": {"number": 1, "name": "one"}},
609 {"op": "insert",
610 "table": "ordinals",
611 "row": {"number": 2, "name": "two"}}]]]], ['txn' ]); do
612 AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0], [ignore], [ignore])
613done
614
615# 1001 clients monitoring column "name" and with condition for "name" only.
616# The clients are created in a way that the 991th client will request condition
617# change, so that the chance is high that the condition change will be handled
618# before some pending changes are freed.
619
620cond='[[["name","==","ten"]]]'
621for i in `seq 1 990`; do
622 AT_CHECK([ovsdb-client -vjsonrpc --pidfile=ovsdb-client$i.pid --detach --no-chdir -d json monitor-cond --format=csv unix:socket ordinals $cond ordinals ["name"]], [0], [ignore], [ignore])
623done
624
625AT_CHECK([ovsdb-client -vjsonrpc --pidfile --detach --no-chdir -d json monitor-cond --format=csv unix:socket ordinals $cond ordinals ["name"] > output],
626 [0], [ignore], [ignore])
627
628for i in `seq 991 1000`; do
629 AT_CHECK([ovsdb-client -vjsonrpc --pidfile=ovsdb-client$i.pid --detach --no-chdir -d json monitor-cond --format=csv unix:socket ordinals $cond ordinals ["name"]], [0], [ignore], [ignore])
630done
631
632for txn in m4_foreach([txn], [[[["ordinals",
633 {"op": "insert",
634 "table": "ordinals",
635 "row": {"number": 10, "name": "ten"}}]]]], ['txn' ]); do
636 AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0],
637 [ignore], [ignore], [kill `cat server-pid client-pid`])
638done
639
640# Change the condition so that a new column "number" is added to monitor table.
641cond='[[["number","==",1]]]'
642AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/cond_change ordinals $cond], [0], [ignore], [ignore])
643
644# Give some time for the server to flush and free pending changes
645# (to crash, when n_columns is not handled properly)
646sleep 1
647
648AT_CHECK([ovsdb-client transact unix:socket '[["ordinals"]]'], [0],
649 [ignore], [ignore])
650AT_CHECK([ovs-appctl -t ovsdb-server -e exit], [0], [ignore], [ignore])
651OVS_WAIT_UNTIL([test ! -e ovsdb-server.pid && test ! -e ovsdb-client.pid])
1ca0323e 652AT_CHECK([$PYTHON3 $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0], [[row,action,name
e0f42d4a
HZ
653<0>,insert,"""ten"""
654
655row,action,name
656<0>,delete,
657<1>,insert,"""one"""
658]], [ignore])
659AT_CLEANUP
9167cb52
HZ
660
661
662# Test monitor-cond-since with zero uuid, which shouldn't
663# be found in server and server should send all rows
664# as initial.
665AT_SETUP([monitor-cond-since not found])
666AT_KEYWORDS([ovsdb server monitor monitor-cond-since positive])
667ordinal_schema > schema
668AT_CHECK([ovsdb-tool create-cluster db schema unix:db.raft], [0], [stdout], [ignore])
669AT_CAPTURE_FILE([ovsdb-server-log])
670AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file="`pwd`"/ovsdb-server-log db >/dev/null 2>&1])
671on_exit 'kill `cat ovsdb-server.pid`'
672for txn in m4_foreach([txn], [[[["ordinals",
673 {"op": "insert",
674 "table": "ordinals",
675 "row": {"number": 0, "name": "zero"}},
676 {"op": "insert",
677 "table": "ordinals",
678 "row": {"number": 1, "name": "one"}},
679 {"op": "insert",
680 "table": "ordinals",
681 "row": {"number": 2, "name": "two"}}]]]], ['txn' ]); do
682 AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0], [ignore], [ignore])
683done
684
685# Omitting the last_id parameter in ovsdb-client monitor-cond-since command
686# will by default using all zero uuid, which doesn't exist in any history txn.
687AT_CHECK([ovsdb-client -vjsonrpc --pidfile --detach --no-chdir -d json monitor-cond-since --format=csv unix:socket ordinals '[[["name","==","one"],["name","==","ten"]]]' ordinals > output],
688 [0], [ignore], [ignore])
689on_exit 'kill `cat ovsdb-client.pid`'
690for txn in m4_foreach([txn], [[[["ordinals",
691 {"op": "insert",
692 "table": "ordinals",
693 "row": {"number": 10, "name": "ten"}},
694 {"op": "insert",
695 "table": "ordinals",
696 "row": {"number": 11, "name": "eleven"}}]]]], ['txn' ]); do
697 AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0],
698 [ignore], [ignore], [kill `cat server-pid client-pid`])
699done
700AT_CHECK([ovsdb-client transact unix:socket '[["ordinals"]]'], [0],
701 [ignore], [ignore])
702AT_CHECK([ovs-appctl -t ovsdb-server -e exit], [0], [ignore], [ignore])
703OVS_WAIT_UNTIL([test ! -e ovsdb-server.pid && test ! -e ovsdb-client.pid])
1ca0323e 704AT_CHECK([$PYTHON3 $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0],
9167cb52
HZ
705 [[found: false, last_id: <0>
706row,action,name,number,_version
707<1>,initial,"""one""",1,"[""uuid"",""<2>""]"
708
709last_id: <3>
710row,action,name,number,_version
711<4>,insert,"""ten""",10,"[""uuid"",""<5>""]"
712]], [ignore])
713AT_CLEANUP
714
715
716# Test monitor-cond-since in ovsdb server restart scenario.
717# ovsdb-client should receive only new changes after the
718# specific transaction id.
719AT_SETUP([monitor-cond-since db restart])
720AT_KEYWORDS([ovsdb server monitor monitor-cond-since positive])
721ordinal_schema > schema
722AT_CHECK([ovsdb-tool create-cluster db schema unix:db.raft], [0], [stdout], [ignore])
723AT_CAPTURE_FILE([ovsdb-server-log])
724AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file="`pwd`"/ovsdb-server-log db >/dev/null 2>&1])
725on_exit 'kill `cat ovsdb-server.pid`'
726for txn in m4_foreach([txn], [[[["ordinals",
727 {"op": "insert",
728 "table": "ordinals",
729 "row": {"number": 0, "name": "zero"}},
730 {"op": "insert",
731 "table": "ordinals",
732 "row": {"number": 1, "name": "one"}},
733 {"op": "insert",
734 "table": "ordinals",
735 "row": {"number": 2, "name": "two"}}]]]], ['txn' ]); do
736 AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0], [ignore], [ignore])
737done
738
739AT_CHECK([ovsdb-client -vjsonrpc --pidfile --detach --no-chdir -d json monitor-cond-since --format=csv unix:socket ordinals '[[["name","==","one"],["name","==","ten"]]]' ordinals > output],
740 [0], [ignore], [ignore])
741on_exit 'kill `cat ovsdb-client.pid`'
742OVS_WAIT_UNTIL([grep last_id output])
743
744kill `cat ovsdb-client.pid`
745kill `cat ovsdb-server.pid`
746OVS_WAIT_UNTIL([test ! -e ovsdb-server.pid && test ! -e ovsdb-client.pid])
747
748# Remember the last_id, which will be used for monitor-cond-since later.
749last_id=`grep last_id output | awk '{print $4}'`
750
751AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file="`pwd`"/ovsdb-server-log db >/dev/null 2>&1])
752
753# Some new changes made to db after restarting the server.
754for txn in m4_foreach([txn], [[[["ordinals",
755 {"op": "insert",
756 "table": "ordinals",
757 "row": {"number": 10, "name": "ten"}},
758 {"op": "insert",
759 "table": "ordinals",
760 "row": {"number": 11, "name": "eleven"}}]]]], ['txn' ]); do
761 AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0],
762 [ignore], [ignore], [kill `cat server-pid client-pid`])
763done
764
765# Use last_id to monitor and get only the new changes.
766AT_CHECK([ovsdb-client -vjsonrpc --pidfile --detach --no-chdir -d json monitor-cond-since --format=csv unix:socket ordinals $last_id '[[["name","==","one"],["name","==","ten"]]]' ordinals > output],
767 [0], [ignore], [ignore])
768
769AT_CHECK([ovsdb-client transact unix:socket '[["ordinals"]]'], [0],
770 [ignore], [ignore])
771AT_CHECK([ovs-appctl -t ovsdb-server -e exit], [0], [ignore], [ignore])
772OVS_WAIT_UNTIL([test ! -e ovsdb-server.pid && test ! -e ovsdb-client.pid])
1ca0323e 773AT_CHECK([$PYTHON3 $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0],
9167cb52
HZ
774 [[found: true, last_id: <0>
775row,action,name,number,_version
776<1>,insert,"""ten""",10,"[""uuid"",""<2>""]"
777]], [ignore])
778AT_CLEANUP
779
780
781# Test monitor-cond-since with last_id found in server
782# but there is no new change after that transaction.
783AT_SETUP([monitor-cond-since found but no new rows])
784AT_KEYWORDS([ovsdb server monitor monitor-cond-since positive])
785ordinal_schema > schema
786AT_CHECK([ovsdb-tool create-cluster db schema unix:db.raft], [0], [stdout], [ignore])
787AT_CAPTURE_FILE([ovsdb-server-log])
788AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file="`pwd`"/ovsdb-server-log db >/dev/null 2>&1])
789on_exit 'kill `cat ovsdb-server.pid`'
790for txn in m4_foreach([txn], [[[["ordinals",
791 {"op": "insert",
792 "table": "ordinals",
793 "row": {"number": 0, "name": "zero"}},
794 {"op": "insert",
795 "table": "ordinals",
796 "row": {"number": 1, "name": "one"}},
797 {"op": "insert",
798 "table": "ordinals",
799 "row": {"number": 2, "name": "two"}}]]]], ['txn' ]); do
800 AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0], [ignore], [ignore])
801done
802AT_CHECK([ovsdb-client -vjsonrpc --pidfile --detach --no-chdir -d json monitor-cond-since --format=csv unix:socket ordinals '[[["name","==","one"],["name","==","ten"]]]' ordinals > output],
803 [0], [ignore], [ignore])
804on_exit 'kill `cat ovsdb-client.pid`'
805OVS_WAIT_UNTIL([grep last_id output])
806
807kill `cat ovsdb-client.pid`
808OVS_WAIT_UNTIL([test ! -e ovsdb-client.pid])
809last_id=`grep last_id output | awk '{print $4}'`
810AT_CHECK([ovsdb-client -vjsonrpc --pidfile --detach --no-chdir -d json monitor-cond-since --format=csv unix:socket ordinals $last_id '[[["name","==","one"],["name","==","ten"]]]' ordinals > output],
811 [0], [ignore], [ignore])
812
813AT_CHECK([ovsdb-client transact unix:socket '[["ordinals"]]'], [0],
814 [ignore], [ignore])
815AT_CHECK([ovs-appctl -t ovsdb-server -e exit], [0], [ignore], [ignore])
816OVS_WAIT_UNTIL([test ! -e ovsdb-server.pid && test ! -e ovsdb-client.pid])
1ca0323e 817AT_CHECK([$PYTHON3 $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0],
9167cb52
HZ
818 [[found: true, last_id: <0>
819]], [ignore])
820AT_CLEANUP
821
822
823# Test monitor-cond-since against empty DB
824AT_SETUP([monitor-cond-since empty db])
825AT_KEYWORDS([ovsdb server monitor monitor-cond-since positive])
826ordinal_schema > schema
827AT_CHECK([ovsdb-tool create-cluster db schema unix:db.raft], [0], [stdout], [ignore])
828AT_CAPTURE_FILE([ovsdb-server-log])
829AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file="`pwd`"/ovsdb-server-log db >/dev/null 2>&1])
830on_exit 'kill `cat ovsdb-server.pid`'
831AT_CHECK([ovsdb-client -vjsonrpc --pidfile --detach --no-chdir -d json monitor-cond-since --format=csv unix:socket ordinals '[[["name","==","one"],["name","==","ten"]]]' ordinals > output],
832 [0], [ignore], [ignore])
833on_exit 'kill `cat ovsdb-client.pid`'
834OVS_WAIT_UNTIL([grep last_id output])
835
836AT_CHECK([ovsdb-client transact unix:socket '[["ordinals"]]'], [0],
837 [ignore], [ignore])
838AT_CHECK([ovs-appctl -t ovsdb-server -e exit], [0], [ignore], [ignore])
839OVS_WAIT_UNTIL([test ! -e ovsdb-server.pid && test ! -e ovsdb-client.pid])
1ca0323e 840AT_CHECK([$PYTHON3 $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0],
9167cb52
HZ
841 [[found: false, last_id: <0>
842]], [ignore])
843AT_CLEANUP
844
845
846# Test monitor-cond-since with cond-change followed.
847AT_SETUP([monitor-cond-since condition change])
848AT_KEYWORDS([ovsdb server monitor monitor-cond-since positive])
849ordinal_schema > schema
850AT_CHECK([ovsdb-tool create-cluster db schema unix:db.raft], [0], [stdout], [ignore])
851AT_CAPTURE_FILE([ovsdb-server-log])
852AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file="`pwd`"/ovsdb-server-log db >/dev/null 2>&1])
853on_exit 'kill `cat ovsdb-server.pid`'
854for txn in m4_foreach([txn], [[[["ordinals",
855 {"op": "insert",
856 "table": "ordinals",
857 "row": {"number": 0, "name": "zero"}},
858 {"op": "insert",
859 "table": "ordinals",
860 "row": {"number": 1, "name": "one"}},
861 {"op": "insert",
862 "table": "ordinals",
863 "row": {"number": 2, "name": "two"}}]]]], ['txn' ]); do
864 AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0], [ignore], [ignore])
865done
866AT_CHECK([ovsdb-client -vjsonrpc --pidfile --detach --no-chdir -d json monitor-cond-since --format=csv unix:socket ordinals '[[]]' ordinals > output], [0], [ignore], [ignore])
867on_exit 'kill `cat ovsdb-client.pid`'
868for cond in m4_foreach([cond],
869 [[[[["name","==","one"],["name","==","two"]]]],
870 [[[["name","==","one"]]]],
871 [[[false]]],
872 [[[true]]]], ['cond' ]); do
873 AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/cond_change ordinals "$cond"], [0], [ignore], [ignore])
874done
875AT_CHECK([ovsdb-client transact unix:socket '[["ordinals"]]'], [0],
876 [ignore], [ignore])
877AT_CHECK([ovs-appctl -t ovsdb-server -e exit], [0], [ignore], [ignore])
878OVS_WAIT_UNTIL([test ! -e ovsdb-server.pid && test ! -e ovsdb-client.pid])
1ca0323e 879AT_CHECK([$PYTHON3 $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0],
9167cb52
HZ
880 [[found: false, last_id: <0>
881row,action,name,number,_version
882<1>,initial,"""one""",1,"[""uuid"",""<2>""]"
883<3>,initial,"""two""",2,"[""uuid"",""<4>""]"
884<5>,initial,"""zero""",,"[""uuid"",""<6>""]"
885
886last_id: <0>
887row,action,name,number,_version
888<5>,delete,,,
889
890last_id: <0>
891row,action,name,number,_version
892<3>,delete,,,
893
894last_id: <0>
895row,action,name,number,_version
896<1>,delete,,,
897
898last_id: <0>
899row,action,name,number,_version
900<1>,insert,"""one""",1,"[""uuid"",""<2>""]"
901<3>,insert,"""two""",2,"[""uuid"",""<4>""]"
902<5>,insert,"""zero""",,"[""uuid"",""<6>""]"
903]], [ignore])
904AT_CLEANUP
905
906
907# Test monitor-cond-since with non-cluster mode server
908AT_SETUP([monitor-cond-since non-cluster])
909AT_KEYWORDS([ovsdb server monitor monitor-cond-since positive])
910ordinal_schema > schema
911AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
912AT_CAPTURE_FILE([ovsdb-server-log])
913AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file="`pwd`"/ovsdb-server-log db >/dev/null 2>&1])
914on_exit 'kill `cat ovsdb-server.pid`'
915for txn in m4_foreach([txn], [[[["ordinals",
916 {"op": "insert",
917 "table": "ordinals",
918 "row": {"number": 0, "name": "zero"}},
919 {"op": "insert",
920 "table": "ordinals",
921 "row": {"number": 1, "name": "one"}},
922 {"op": "insert",
923 "table": "ordinals",
924 "row": {"number": 2, "name": "two"}}]]]], ['txn' ]); do
925 AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0], [ignore], [ignore])
926done
927
928AT_CHECK([ovsdb-client -vjsonrpc --pidfile --detach --no-chdir -d json monitor-cond-since --format=csv unix:socket ordinals '[[["name","==","one"],["name","==","ten"]]]' ordinals > output],
929 [0], [ignore], [ignore])
930on_exit 'kill `cat ovsdb-client.pid`'
c194367c
HZ
931for txn in m4_foreach([txn], [[[["ordinals",
932 {"op": "insert",
933 "table": "ordinals",
934 "row": {"number": 10, "name": "ten"}},
935 {"op": "insert",
936 "table": "ordinals",
937 "row": {"number": 11, "name": "eleven"}}]]]], ['txn' ]); do
938 AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0],
939 [ignore], [ignore], [kill `cat server-pid client-pid`])
940done
941AT_CHECK([ovsdb-client transact unix:socket '[["ordinals"]]'], [0],
942 [ignore], [ignore])
943AT_CHECK([ovs-appctl -t ovsdb-server -e exit], [0], [ignore], [ignore])
944OVS_WAIT_UNTIL([test ! -e ovsdb-server.pid && test ! -e ovsdb-client.pid])
945
946# Transaction shouldn't be found, and last_id returned should always
947# be the same (all zero uuid)
1ca0323e 948AT_CHECK([$PYTHON3 $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0],
c194367c
HZ
949 [[found: false, last_id: <0>
950row,action,name,number,_version
951<1>,initial,"""one""",1,"[""uuid"",""<2>""]"
952
953last_id: <0>
954row,action,name,number,_version
955<3>,insert,"""ten""",10,"[""uuid"",""<4>""]"
956]], [ignore])
957AT_CLEANUP
958
959
960# Test monitor-cond-since with non-cluster mode server with non-zero last_id
961AT_SETUP([monitor-cond-since non-cluster non-zero last_id])
962AT_KEYWORDS([ovsdb server monitor monitor-cond-since negative])
963ordinal_schema > schema
964AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
965AT_CAPTURE_FILE([ovsdb-server-log])
966AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file="`pwd`"/ovsdb-server-log db >/dev/null 2>&1])
967on_exit 'kill `cat ovsdb-server.pid`'
968for txn in m4_foreach([txn], [[[["ordinals",
969 {"op": "insert",
970 "table": "ordinals",
971 "row": {"number": 0, "name": "zero"}},
972 {"op": "insert",
973 "table": "ordinals",
974 "row": {"number": 1, "name": "one"}},
975 {"op": "insert",
976 "table": "ordinals",
977 "row": {"number": 2, "name": "two"}}]]]], ['txn' ]); do
978 AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0], [ignore], [ignore])
979done
980
981# A non-zero uuid
982last_id=11111111-1111-1111-1111-111111111111
983AT_CHECK([ovsdb-client -vjsonrpc --pidfile --detach --no-chdir -d json monitor-cond-since --format=csv unix:socket ordinals $last_id '[[["name","==","one"],["name","==","ten"]]]' ordinals > output],
984 [0], [ignore], [ignore])
985on_exit 'kill `cat ovsdb-client.pid`'
9167cb52
HZ
986for txn in m4_foreach([txn], [[[["ordinals",
987 {"op": "insert",
988 "table": "ordinals",
989 "row": {"number": 10, "name": "ten"}},
990 {"op": "insert",
991 "table": "ordinals",
992 "row": {"number": 11, "name": "eleven"}}]]]], ['txn' ]); do
993 AT_CHECK([ovsdb-client transact unix:socket "$txn"], [0],
994 [ignore], [ignore], [kill `cat server-pid client-pid`])
995done
996AT_CHECK([ovsdb-client transact unix:socket '[["ordinals"]]'], [0],
997 [ignore], [ignore])
998AT_CHECK([ovs-appctl -t ovsdb-server -e exit], [0], [ignore], [ignore])
999OVS_WAIT_UNTIL([test ! -e ovsdb-server.pid && test ! -e ovsdb-client.pid])
1000
1001# Transaction shouldn't be found, and last_id returned should always
1002# be the same (all zero uuid)
1ca0323e 1003AT_CHECK([$PYTHON3 $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0],
9167cb52
HZ
1004 [[found: false, last_id: <0>
1005row,action,name,number,_version
1006<1>,initial,"""one""",1,"[""uuid"",""<2>""]"
1007
1008last_id: <0>
1009row,action,name,number,_version
1010<3>,insert,"""ten""",10,"[""uuid"",""<4>""]"
1011]], [ignore])
1012AT_CLEANUP
1013