1 AT_BANNER([OVSDB -- ovsdb-server monitors])
3 # OVSDB_CHECK_MONITOR(TITLE, SCHEMA, [PRE-MONITOR-TXN], DB, TABLE,
4 # TRANSACTIONS, OUTPUT, [COLUMNS], [KEYWORDS])
6 # Creates a database with the given SCHEMA, starts an ovsdb-server on
7 # that database, and runs each of the TRANSACTIONS (which should be a
8 # quoted list of quoted strings) against it with ovsdb-client one at a
9 # time. COLUMNS, if specified, is passed to ovsdb-client as the set
10 # of columns and operations to select.
12 # Checks that the overall output is OUTPUT, but UUIDs in the output
13 # are replaced by markers of the form <N> where N is a number. The
14 # first unique UUID is replaced by <0>, the next by <1>, and so on.
15 # If a given UUID appears more than once it is always replaced by the
18 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
19 m4_define([OVSDB_CHECK_MONITOR],
21 AT_KEYWORDS([ovsdb server monitor positive $9])
23 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
24 m4_foreach([txn], [$3],
25 [AT_CHECK([ovsdb-tool transact db 'txn'], [0], [ignore], [ignore])])
26 AT_CAPTURE_FILE([ovsdb-server-log])
27 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/server-pid --remote=punix:socket --unixctl="`pwd`"/unixctl --log-file="`pwd`"/ovsdb-server-log db >/dev/null 2>&1],
29 AT_CAPTURE_FILE([ovsdb-client-log])
30 if test "$IS_WIN32" = "yes"; then
31 AT_CHECK([ovsdb-client -vjsonrpc --pidfile="`pwd`"/client-pid --log-file="`pwd`"/ovsdb-client-log -d json monitor --format=csv unix:socket $4 $5 $8 > output 2>/dev/null &],
32 [0], [ignore], [ignore], [kill `cat server-pid`])
35 AT_CHECK([ovsdb-client -vjsonrpc --detach --no-chdir --pidfile="`pwd`"/client-pid --log-file="`pwd`"/ovsdb-client-log -d json monitor --format=csv unix:socket $4 $5 $8 > output],
36 [0], [ignore], [ignore], [kill `cat server-pid`])
38 m4_foreach([txn], [$6],
39 [AT_CHECK([ovsdb-client transact unix:socket 'txn'], [0],
40 [ignore], [ignore], [kill `cat server-pid client-pid`])])
41 AT_CHECK([ovsdb-client transact unix:socket '[["$4"]]'], [0],
42 [ignore], [ignore], [kill `cat server-pid client-pid`])
43 OVS_APP_EXIT_AND_WAIT_BY_TARGET([`pwd`/unixctl], [`pwd`/server-pid])
44 OVS_WAIT_UNTIL([test ! -e client-pid])
45 AT_CHECK([${PERL} $srcdir/ovsdb-monitor-sort.pl < output | ${PERL} $srcdir/uuidfilt.pl], [0], [$7], [ignore])
48 # OVSDB_CHECK_MONITOR_COND(TITLE, SCHEMA, [PRE-MONITOR-TXN], DB, TABLE,
49 # TRANSACTIONS, OUTPUT, CONDITIONS, [COLUMNS], [KEYWORDS],
50 # [CONDITIONS_CHANGE])
52 # Creates a database with the given SCHEMA, starts an ovsdb-server on
53 # that database, and runs each of the TRANSACTIONS (which should be a
54 # quoted list of quoted strings) against it with ovsdb-client one at a
55 # time. COLUMNS, if specified, is passed to ovsdb-client as the set
56 # of columns and operations to select.
58 # Checks that the overall output is OUTPUT, but UUIDs in the output
59 # are replaced by markers of the form <N> where N is a number. The
60 # first unique UUID is replaced by <0>, the next by <1>, and so on.
61 # If a given UUID appears more than once it is always replaced by the
64 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
65 m4_define([OVSDB_CHECK_MONITOR_COND],
67 AT_KEYWORDS([ovsdb server monitor monitor-cond positive $10])
69 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
70 m4_foreach([txn], [$3],
71 [AT_CHECK([ovsdb-tool transact db 'txn'], [0], [ignore], [ignore])])
72 AT_CAPTURE_FILE([ovsdb-server-log])
73 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/server-pid --remote=punix:socket --unixctl="`pwd`"/unixctl --log-file="`pwd`"/ovsdb-server-log db >/dev/null 2>&1],
75 if test "$IS_WIN32" = "yes"; then
76 AT_CHECK([ovsdb-client -vjsonrpc --pidfile="`pwd`"/client-pid -d json monitor-cond --format=csv unix:socket $4 '[$8]' $5 $9 > output &],
77 [0], [ignore], [ignore], [kill `cat server-pid`])
80 AT_CHECK([ ovsdb-client -vjsonrpc --detach --no-chdir --pidfile="`pwd`"/client-pid -d json monitor-cond --format=csv unix:socket $4 '[$8]' $5 $9 > output],
81 [0], [ignore], [ignore], [kill `cat server-pid`])
83 m4_foreach([txn], [$6],
84 [AT_CHECK([ovsdb-client transact unix:socket 'txn'], [0],
85 [ignore], [ignore], [kill `cat server-pid client-pid`])])
86 CLIENT_PID=`cat "$OVS_RUNDIR"/client-pid 2>/dev/null`
87 m4_foreach([cond], [$10],
88 [AT_CHECK([ovs-appctl -t "`pwd`"/ovsdb-client.$CLIENT_PID.ctl ovsdb-client/cond_change $5 'cond'], [0], [ignore], [ignore])])
89 AT_CHECK([ovsdb-client transact unix:socket '[["$4"]]'], [0],
90 [ignore], [ignore], [kill `cat server-pid client-pid`])
91 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl -e exit], [0], [ignore], [ignore])
92 OVS_WAIT_UNTIL([test ! -e server-pid && test ! -e client-pid])
93 AT_CHECK([${PERL} $srcdir/ovsdb-monitor-sort.pl < output | ${PERL} $srcdir/uuidfilt.pl], [0], [$7], [ignore])
96 OVSDB_CHECK_MONITOR([monitor insert into empty table],
99 [ordinals], [ordinals],
103 "row": {"number": 0, "name": "zero"}}]]]],
104 [[row,action,name,number,_version
105 <0>,insert,"""zero""",0,"[""uuid"",""<1>""]"
108 OVSDB_CHECK_MONITOR([monitor insert into populated table],
113 "row": {"number": 10, "name": "ten"}}]]]],
114 [ordinals], [ordinals],
118 "row": {"number": 0, "name": "zero"}}]]]],
119 [[row,action,name,number,_version
120 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
122 row,action,name,number,_version
123 <2>,insert,"""zero""",0,"[""uuid"",""<3>""]"
126 OVSDB_CHECK_MONITOR([monitor delete],
131 "row": {"number": 10, "name": "ten"}}]]]],
132 [ordinals], [ordinals],
136 "where": [["number", "==", 10]]}]]]],
137 [[row,action,name,number,_version
138 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
140 row,action,name,number,_version
141 <0>,delete,"""ten""",10,"[""uuid"",""<1>""]"
144 OVSDB_CHECK_MONITOR([monitor row update],
149 "row": {"number": 10, "name": "ten"}}]]]],
150 [ordinals], [ordinals],
154 "where": [["number", "==", 10]],
155 "row": {"name": "five plus five"}}]]]],
156 [[row,action,name,number,_version
157 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
159 row,action,name,number,_version
160 <0>,old,"""ten""",,"[""uuid"",""<1>""]"
161 ,new,"""five plus five""",10,"[""uuid"",""<2>""]"
164 OVSDB_CHECK_MONITOR([monitor no-op row updates],
169 "row": {"number": 10, "name": "ten"}}]]]],
170 [ordinals], [ordinals],
174 "where": [["number", "==", 10]],
175 "row": {"number": 10, "name": "ten"}}]]],
179 "row": {"number": 9, "name": "nine"}}]]]],
180 [[row,action,name,number,_version
181 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
183 row,action,name,number,_version
184 <2>,insert,"""nine""",9,"[""uuid"",""<3>""]"
187 OVSDB_CHECK_MONITOR([monitor insert-and-update transaction],
192 "row": {"number": 10, "name": "ten"}}]]]],
193 [ordinals], [ordinals],
197 "row": {"number": 9, "name": "nine"},
198 "uuid-name": "nine"},
201 "where": [["_uuid", "==", ["named-uuid", "nine"]]],
202 "row": {"name": "three squared"}}]]]],
203 [[row,action,name,number,_version
204 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
206 row,action,name,number,_version
207 <2>,insert,"""three squared""",9,"[""uuid"",""<3>""]"
210 OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction],
215 "row": {"number": 10, "name": "ten"}}]]]],
216 [ordinals], [ordinals],
220 "row": {"number": 9, "name": "nine"},
221 "uuid-name": "nine"},
224 "where": [["_uuid", "==", ["named-uuid", "nine"]]],
225 "row": {"name": "three squared"}},
228 "where": [["_uuid", "==", ["named-uuid", "nine"]]]},
231 "row": {"number": 7, "name": "seven"}}]]]],
232 [[row,action,name,number,_version
233 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
235 row,action,name,number,_version
236 <2>,insert,"""seven""",7,"[""uuid"",""<3>""]"
239 OVSDB_CHECK_MONITOR([monitor weak reference change],
245 "a2a1": ["named-uuid", "a0"],
246 "a2b": ["named-uuid", "b2"]},
251 "a2a": ["named-uuid", "a0"],
252 "a2a1": ["named-uuid", "a1"],
253 "a2b": ["named-uuid", "b2"]},
258 "uuid-name": "b2"}]]]],
263 "where": [["a", "==", 0]]}]]]],
264 [[row,action,a,a2a,a2a1,a2b,_version
265 <0>,initial,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]"
266 <3>,initial,1,"[""uuid"",""<0>""]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<4>""]"
268 row,action,a,a2a,a2a1,a2b,_version
269 <0>,delete,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]"
270 <3>,old,,"[""uuid"",""<0>""]",,,"[""uuid"",""<4>""]"
271 ,new,1,"[""set"",[]]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<5>""]"
274 OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction],
279 "row": {"number": 10, "name": "ten"}}]]]],
280 [ordinals], [ordinals],
284 "row": {"number": 9, "name": "nine"},
285 "uuid-name": "nine"},
288 "where": [["_uuid", "==", ["named-uuid", "nine"]]],
289 "row": {"name": "three squared"}},
292 "where": [["_uuid", "==", ["named-uuid", "nine"]]]},
295 "row": {"number": 7, "name": "seven"}}]]]],
296 [[row,action,name,number,_version
297 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
299 row,action,name,number,_version
300 <2>,insert,"""seven""",7,"[""uuid"",""<3>""]"
303 AT_BANNER([ovsdb -- ovsdb-monitor monitor only some operations])
305 m4_define([OVSDB_MONITOR_INITIAL],
309 "row": {"number": 10, "name": "ten"}}]]]])
310 m4_define([OVSDB_MONITOR_TXNS],
314 "row": {"number": 5, "name": "five"}}]]],
318 "where": [["name", "==", "five"]],
319 "row": {"name": "FIVE"}}]]],
325 OVSDB_CHECK_MONITOR([monitor all operations],
326 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
327 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
328 [[row,action,name,number,_version
329 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
331 row,action,name,number,_version
332 <2>,insert,"""five""",5,"[""uuid"",""<3>""]"
334 row,action,name,number,_version
335 <2>,old,"""five""",,"[""uuid"",""<3>""]"
336 ,new,"""FIVE""",5,"[""uuid"",""<4>""]"
338 row,action,name,number,_version
339 <2>,delete,"""FIVE""",5,"[""uuid"",""<4>""]"
340 <0>,delete,"""ten""",10,"[""uuid"",""<1>""]"
343 dnl A monitor with "initial" only doesn't really make sense,
344 dnl but it's still allowed and should work.
345 OVSDB_CHECK_MONITOR([monitor initial only],
346 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
347 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
348 [[row,action,name,number,_version
349 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
350 ]], [!insert,!delete,!modify])
352 OVSDB_CHECK_MONITOR([monitor insert only],
353 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
354 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
355 [[row,action,name,number,_version
356 <0>,insert,"""five""",5,"[""uuid"",""<1>""]"
357 ]], [!initial,!delete,!modify])
359 OVSDB_CHECK_MONITOR([monitor delete only],
360 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
361 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
362 [[row,action,name,number,_version
363 <0>,delete,"""FIVE""",5,"[""uuid"",""<1>""]"
364 <2>,delete,"""ten""",10,"[""uuid"",""<3>""]"
365 ]], [!initial,!insert,!modify])
367 OVSDB_CHECK_MONITOR([monitor modify only],
368 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
369 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
370 [[row,action,name,number,_version
371 <0>,old,"""five""",,"[""uuid"",""<1>""]"
372 ,new,"""FIVE""",5,"[""uuid"",""<2>""]"
373 ]], [!initial,!insert,!delete])
375 AT_BANNER([ovsdb -- ovsdb-monitor-cond conditional monitor only some operations])
377 OVSDB_CHECK_MONITOR_COND([monitor-cond empty condition],
382 "row": {"number": 0, "name": "zero"}},
385 "row": {"number": 1, "name": "one"}},
388 "row": {"number": 2, "name": "two"}}]]]],
389 [ordinals], [ordinals],
393 "row": {"number": 10, "name": "ten"}},
396 "row": {"number": 11, "name": "eleven"}}]]]],
397 [[row,action,name,number,_version
398 <0>,initial,"""one""",1,"[""uuid"",""<1>""]"
399 <2>,initial,"""two""",2,"[""uuid"",""<3>""]"
400 <4>,initial,"""zero""",,"[""uuid"",""<5>""]"
402 row,action,name,number,_version
403 <6>,insert,"""eleven""",11,"[""uuid"",""<7>""]"
404 <8>,insert,"""ten""",10,"[""uuid"",""<9>""]"
408 OVSDB_CHECK_MONITOR_COND([monitor-cond multiple conditions],
413 "row": {"number": 0, "name": "zero"}},
416 "row": {"number": 1, "name": "one"}},
419 "row": {"number": 2, "name": "two"}}]]]],
420 [ordinals], [ordinals],
424 "row": {"number": 10, "name": "ten"}},
427 "row": {"number": 11, "name": "eleven"}}]]]],
428 [[row,action,name,number,_version
429 <0>,initial,"""one""",1,"[""uuid"",""<1>""]"
431 row,action,name,number,_version
432 <2>,insert,"""ten""",10,"[""uuid"",""<3>""]"
434 [[["name","==","one"],["name","==","ten"]]])
436 OVSDB_CHECK_MONITOR_COND([monitor-cond delete from populated table],
441 "row": {"number": 0, "name": "zero"}},
444 "row": {"number": 1, "name": "one"}},
447 "row": {"number": 2, "name": "two"}}]]]],
448 [ordinals], [ordinals],
453 [[row,action,name,number,_version
454 <0>,initial,"""one""",1,"[""uuid"",""<1>""]"
456 row,action,name,number,_version
459 [[["name","==","one"],["name","==","ten"]]])
461 OVSDB_CHECK_MONITOR_COND([monitor-cond insert due to modify],
466 "row": {"number": 0, "name": "zero"}},
469 "row": {"number": 1, "name": "one"}},
472 "row": {"number": 2, "name": "two"}}]]]],
473 [ordinals], [ordinals],
477 "where": [["name", "==", "one"]],
478 "row": {"name": "ONE"}}]]]],
479 [[row,action,name,number,_version
480 <0>,insert,"""ONE""",1,"[""uuid"",""<1>""]"
482 [[["name","==","ONE"]]],
483 [!initial,!delete,!modify])
485 OVSDB_CHECK_MONITOR_COND([monitor-cond delete due to modify],
490 "row": {"number": 0, "name": "zero"}},
493 "row": {"number": 1, "name": "one"}},
496 "row": {"number": 2, "name": "two"}}]]]],
497 [ordinals], [ordinals],
501 "where": [["name", "==", "one"]],
502 "row": {"name": "ONE"}}]]]],
503 [[row,action,name,number,_version
506 [[["name","==","one"]]],
507 [!initial,!insert,!modify])
509 OVSDB_CHECK_MONITOR_COND([monitor-cond condition non-monitored columns],
514 "row": {"number": 0, "name": "zero"}},
517 "row": {"number": 1, "name": "one"}},
520 "row": {"number": 2, "name": "two"}}]]]],
521 [ordinals], [ordinals],
525 "row": {"number": 10, "name": "ten"}},
528 "row": {"number": 11, "name": "eleven"}}]]]],
535 [[["name","==","one"],["name","==","ten"]]],
538 OVSDB_CHECK_MONITOR_COND([monitor-cond-change],
543 "row": {"number": 0, "name": "zero"}},
546 "row": {"number": 1, "name": "one"}},
549 "row": {"number": 2, "name": "two"}}]]]],
550 [ordinals], [ordinals],
552 [[row,action,name,number,_version
553 <0>,initial,"""one""",1,"[""uuid"",""<1>""]"
554 <2>,initial,"""two""",2,"[""uuid"",""<3>""]"
555 <4>,initial,"""zero""",,"[""uuid"",""<5>""]"
557 row,action,name,number,_version
560 row,action,name,number,_version
563 row,action,name,number,_version
566 row,action,name,number,_version
567 <0>,insert,"""one""",1,"[""uuid"",""<1>""]"
568 <2>,insert,"""two""",2,"[""uuid"",""<3>""]"
569 <4>,insert,"""zero""",,"[""uuid"",""<5>""]"
573 [[[[["name","==","one"],["name","==","two"]]]],
574 [[[["name","==","one"]]]],