1 AT_BANNER([OVSDB -- ovsdb-server monitors])
3 OVS_START_SHELL_HELPERS
4 # ovsdb_check_monitor SCHEMA_FUNC DB TABLE OUTPUT COLUMNS
5 # PRE-MONITOR-TXN... -- TRANSACTION...
6 ovsdb_check_monitor () {
7 local schema_func=$1 db=$2 table=$3 output=$4 columns=$5
8 shift; shift; shift; shift; shift
10 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
11 while test "$1" != "--"; do
12 AT_CHECK([ovsdb-tool transact db "$1"], [0], [ignore], [ignore])
16 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file db > ovsdb-server.stdout 2> ovsdb-server.stderr],
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 &],
21 [0], [ignore], [ignore])
24 AT_CHECK([ovsdb-client -vjsonrpc --detach --pidfile --log-file -d json monitor --format=csv unix:socket $db $table $columns > output 2> ovsdb-client.stderr],
25 [0], [ignore], [ignore])
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])
31 OVS_APP_EXIT_AND_WAIT_BY_TARGET([ovsdb-server], [ovsdb-server.pid])
32 OVS_WAIT_UNTIL([test ! -e ovsdb-client.pid])
33 AT_CHECK_UNQUOTED([$PYTHON $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0], [$output], [ignore])
37 # OVSDB_CHECK_MONITOR(TITLE, SCHEMA, [PRE-MONITOR-TXN], DB, TABLE,
38 # TRANSACTIONS, OUTPUT, [COLUMNS], [KEYWORDS])
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
43 # time. COLUMNS, if specified, is passed to ovsdb-client as the set
44 # of columns and operations to select.
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
52 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
53 m4_define([OVSDB_CHECK_MONITOR],
55 AT_KEYWORDS([ovsdb server monitor positive $9])
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' ])
66 # OVSDB_CHECK_MONITOR_COND(TITLE, SCHEMA, [PRE-MONITOR-TXN], DB, TABLE,
67 # TRANSACTIONS, OUTPUT, CONDITIONS, [COLUMNS], [KEYWORDS],
68 # [CONDITIONS_CHANGE])
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.
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
82 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
83 m4_define([OVSDB_CHECK_MONITOR_COND],
85 AT_KEYWORDS([ovsdb server monitor monitor-cond positive $10])
87 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
88 for txn in m4_foreach([txn], [$3], ['txn' ]); do
89 AT_CHECK([ovsdb-tool transact db "$txn"], [0], [ignore], [ignore])
91 AT_CAPTURE_FILE([ovsdb-server-log])
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],
95 [0], [ignore], [ignore])
96 on_exit 'kill `cat ovsdb-client.pid`'
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`])
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])
104 AT_CHECK([ovsdb-client transact unix:socket '[["$4"]]'], [0],
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])
108 AT_CHECK([$PYTHON $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0], [$7], [ignore])
111 OVSDB_CHECK_MONITOR([monitor insert into empty table],
114 [ordinals], [ordinals],
118 "row": {"number": 0, "name": "zero"}}]]]],
119 [[row,action,name,number,_version
120 <0>,insert,"""zero""",0,"[""uuid"",""<1>""]"
123 OVSDB_CHECK_MONITOR([monitor insert into populated table],
128 "row": {"number": 10, "name": "ten"}}]]]],
129 [ordinals], [ordinals],
133 "row": {"number": 0, "name": "zero"}}]]]],
134 [[row,action,name,number,_version
135 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
137 row,action,name,number,_version
138 <2>,insert,"""zero""",0,"[""uuid"",""<3>""]"
141 OVSDB_CHECK_MONITOR([monitor delete],
146 "row": {"number": 10, "name": "ten"}}]]]],
147 [ordinals], [ordinals],
151 "where": [["number", "==", 10]]}]]]],
152 [[row,action,name,number,_version
153 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
155 row,action,name,number,_version
156 <0>,delete,"""ten""",10,"[""uuid"",""<1>""]"
159 OVSDB_CHECK_MONITOR([monitor row update],
164 "row": {"number": 10, "name": "ten"}}]]]],
165 [ordinals], [ordinals],
169 "where": [["number", "==", 10]],
170 "row": {"name": "five plus five"}}]]]],
171 [[row,action,name,number,_version
172 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
174 row,action,name,number,_version
175 <0>,old,"""ten""",,"[""uuid"",""<1>""]"
176 ,new,"""five plus five""",10,"[""uuid"",""<2>""]"
179 OVSDB_CHECK_MONITOR([monitor no-op row updates],
184 "row": {"number": 10, "name": "ten"}}]]]],
185 [ordinals], [ordinals],
189 "where": [["number", "==", 10]],
190 "row": {"number": 10, "name": "ten"}}]]],
194 "row": {"number": 9, "name": "nine"}}]]]],
195 [[row,action,name,number,_version
196 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
198 row,action,name,number,_version
199 <2>,insert,"""nine""",9,"[""uuid"",""<3>""]"
202 OVSDB_CHECK_MONITOR([monitor insert-and-update transaction],
207 "row": {"number": 10, "name": "ten"}}]]]],
208 [ordinals], [ordinals],
212 "row": {"number": 9, "name": "nine"},
213 "uuid-name": "nine"},
216 "where": [["_uuid", "==", ["named-uuid", "nine"]]],
217 "row": {"name": "three squared"}}]]]],
218 [[row,action,name,number,_version
219 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
221 row,action,name,number,_version
222 <2>,insert,"""three squared""",9,"[""uuid"",""<3>""]"
225 OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction],
230 "row": {"number": 10, "name": "ten"}}]]]],
231 [ordinals], [ordinals],
235 "row": {"number": 9, "name": "nine"},
236 "uuid-name": "nine"},
239 "where": [["_uuid", "==", ["named-uuid", "nine"]]],
240 "row": {"name": "three squared"}},
243 "where": [["_uuid", "==", ["named-uuid", "nine"]]]},
246 "row": {"number": 7, "name": "seven"}}]]]],
247 [[row,action,name,number,_version
248 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
250 row,action,name,number,_version
251 <2>,insert,"""seven""",7,"[""uuid"",""<3>""]"
254 OVSDB_CHECK_MONITOR([monitor weak reference change],
260 "a2a1": ["named-uuid", "a0"],
261 "a2b": ["named-uuid", "b2"]},
266 "a2a": ["named-uuid", "a0"],
267 "a2a1": ["named-uuid", "a1"],
268 "a2b": ["named-uuid", "b2"]},
273 "uuid-name": "b2"}]]]],
278 "where": [["a", "==", 0]]}]]]],
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>""]"
283 row,action,a,a2a,a2a1,a2b,_version
284 <0>,delete,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]"
285 <3>,old,,"[""uuid"",""<0>""]",,,"[""uuid"",""<4>""]"
286 ,new,1,"[""set"",[]]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<5>""]"
289 OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction],
294 "row": {"number": 10, "name": "ten"}}]]]],
295 [ordinals], [ordinals],
299 "row": {"number": 9, "name": "nine"},
300 "uuid-name": "nine"},
303 "where": [["_uuid", "==", ["named-uuid", "nine"]]],
304 "row": {"name": "three squared"}},
307 "where": [["_uuid", "==", ["named-uuid", "nine"]]]},
310 "row": {"number": 7, "name": "seven"}}]]]],
311 [[row,action,name,number,_version
312 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
314 row,action,name,number,_version
315 <2>,insert,"""seven""",7,"[""uuid"",""<3>""]"
318 AT_BANNER([ovsdb -- ovsdb-monitor monitor only some operations])
320 m4_define([OVSDB_MONITOR_INITIAL],
324 "row": {"number": 10, "name": "ten"}}]]]])
325 m4_define([OVSDB_MONITOR_TXNS],
329 "row": {"number": 5, "name": "five"}}]]],
333 "where": [["name", "==", "five"]],
334 "row": {"name": "FIVE"}}]]],
340 OVSDB_CHECK_MONITOR([monitor all operations],
341 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
342 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
343 [[row,action,name,number,_version
344 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
346 row,action,name,number,_version
347 <2>,insert,"""five""",5,"[""uuid"",""<3>""]"
349 row,action,name,number,_version
350 <2>,old,"""five""",,"[""uuid"",""<3>""]"
351 ,new,"""FIVE""",5,"[""uuid"",""<4>""]"
353 row,action,name,number,_version
354 <2>,delete,"""FIVE""",5,"[""uuid"",""<4>""]"
355 <0>,delete,"""ten""",10,"[""uuid"",""<1>""]"
358 dnl A monitor with "initial" only doesn't really make sense,
359 dnl but it's still allowed and should work.
360 OVSDB_CHECK_MONITOR([monitor initial only],
361 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
362 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
363 [[row,action,name,number,_version
364 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
365 ]], [!insert,!delete,!modify])
367 OVSDB_CHECK_MONITOR([monitor insert only],
368 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
369 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
370 [[row,action,name,number,_version
371 <0>,insert,"""five""",5,"[""uuid"",""<1>""]"
372 ]], [!initial,!delete,!modify])
374 OVSDB_CHECK_MONITOR([monitor delete only],
375 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
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>""]"
380 ]], [!initial,!insert,!modify])
382 OVSDB_CHECK_MONITOR([monitor modify only],
383 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
384 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
385 [[row,action,name,number,_version
386 <0>,old,"""five""",,"[""uuid"",""<1>""]"
387 ,new,"""FIVE""",5,"[""uuid"",""<2>""]"
388 ]], [!initial,!insert,!delete])
390 AT_BANNER([ovsdb -- ovsdb-monitor-cond conditional monitor only some operations])
392 OVSDB_CHECK_MONITOR_COND([monitor-cond empty condition],
397 "row": {"number": 0, "name": "zero"}},
400 "row": {"number": 1, "name": "one"}},
403 "row": {"number": 2, "name": "two"}}]]]],
404 [ordinals], [ordinals],
408 "row": {"number": 10, "name": "ten"}},
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>""]"
417 row,action,name,number,_version
418 <6>,insert,"""eleven""",11,"[""uuid"",""<7>""]"
419 <8>,insert,"""ten""",10,"[""uuid"",""<9>""]"
423 OVSDB_CHECK_MONITOR_COND([monitor-cond multiple conditions],
428 "row": {"number": 0, "name": "zero"}},
431 "row": {"number": 1, "name": "one"}},
434 "row": {"number": 2, "name": "two"}}]]]],
435 [ordinals], [ordinals],
439 "row": {"number": 10, "name": "ten"}},
442 "row": {"number": 11, "name": "eleven"}}]]]],
443 [[row,action,name,number,_version
444 <0>,initial,"""one""",1,"[""uuid"",""<1>""]"
446 row,action,name,number,_version
447 <2>,insert,"""ten""",10,"[""uuid"",""<3>""]"
449 [[["name","==","one"],["name","==","ten"]]])
451 OVSDB_CHECK_MONITOR_COND([monitor-cond delete from populated table],
456 "row": {"number": 0, "name": "zero"}},
459 "row": {"number": 1, "name": "one"}},
462 "row": {"number": 2, "name": "two"}}]]]],
463 [ordinals], [ordinals],
468 [[row,action,name,number,_version
469 <0>,initial,"""one""",1,"[""uuid"",""<1>""]"
471 row,action,name,number,_version
474 [[["name","==","one"],["name","==","ten"]]])
476 OVSDB_CHECK_MONITOR_COND([monitor-cond insert due to modify],
481 "row": {"number": 0, "name": "zero"}},
484 "row": {"number": 1, "name": "one"}},
487 "row": {"number": 2, "name": "two"}}]]]],
488 [ordinals], [ordinals],
492 "where": [["name", "==", "one"]],
493 "row": {"name": "ONE"}}]]]],
494 [[row,action,name,number,_version
495 <0>,insert,"""ONE""",1,"[""uuid"",""<1>""]"
497 [[["name","==","ONE"]]],
498 [!initial,!delete,!modify])
500 OVSDB_CHECK_MONITOR_COND([monitor-cond delete due to modify],
505 "row": {"number": 0, "name": "zero"}},
508 "row": {"number": 1, "name": "one"}},
511 "row": {"number": 2, "name": "two"}}]]]],
512 [ordinals], [ordinals],
516 "where": [["name", "==", "one"]],
517 "row": {"name": "ONE"}}]]]],
518 [[row,action,name,number,_version
521 [[["name","==","one"]]],
522 [!initial,!insert,!modify])
524 OVSDB_CHECK_MONITOR_COND([monitor-cond condition non-monitored columns],
529 "row": {"number": 0, "name": "zero"}},
532 "row": {"number": 1, "name": "one"}},
535 "row": {"number": 2, "name": "two"}}]]]],
536 [ordinals], [ordinals],
540 "row": {"number": 10, "name": "ten"}},
543 "row": {"number": 11, "name": "eleven"}}]]]],
550 [[["name","==","one"],["name","==","ten"]]],
553 OVSDB_CHECK_MONITOR_COND([monitor-cond-change],
558 "row": {"number": 0, "name": "zero"}},
561 "row": {"number": 1, "name": "one"}},
564 "row": {"number": 2, "name": "two"}}]]]],
565 [ordinals], [ordinals],
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>""]"
572 row,action,name,number,_version
575 row,action,name,number,_version
578 row,action,name,number,_version
581 row,action,name,number,_version
582 <0>,insert,"""one""",1,"[""uuid"",""<1>""]"
583 <2>,insert,"""two""",2,"[""uuid"",""<3>""]"
584 <4>,insert,"""zero""",,"[""uuid"",""<5>""]"
588 [[[[["name","==","one"],["name","==","two"]]]],
589 [[[["name","==","one"]]]],