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 --remote=punix:socket --log-file="`pwd`"/ovsdb-server-log db >/dev/null 2>&1],
29 on_exit 'kill `cat ovsdb-server.pid`'
30 AT_CAPTURE_FILE([ovsdb-client-log])
31 if test "$IS_WIN32" = "yes"; then
32 AT_CHECK([ovsdb-client -vjsonrpc --pidfile --log-file="`pwd`"/ovsdb-client-log -d json monitor --format=csv unix:socket $4 $5 $8 > output 2>/dev/null &],
33 [0], [ignore], [ignore])
36 AT_CHECK([ovsdb-client -vjsonrpc --detach --no-chdir --pidfile --log-file="`pwd`"/ovsdb-client-log -d json monitor --format=csv unix:socket $4 $5 $8 > output],
37 [0], [ignore], [ignore])
39 on_exit 'kill `cat ovsdb-client.pid`'
40 m4_foreach([txn], [$6],
41 [AT_CHECK([ovsdb-client transact unix:socket 'txn'], [0],
43 AT_CHECK([ovsdb-client transact unix:socket '[["$4"]]'], [0],
45 OVS_APP_EXIT_AND_WAIT_BY_TARGET([ovsdb-server], [ovsdb-server.pid])
46 OVS_WAIT_UNTIL([test ! -e ovsdb-client.pid])
47 AT_CHECK([$PYTHON $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0], [$7], [ignore])
50 # OVSDB_CHECK_MONITOR_COND(TITLE, SCHEMA, [PRE-MONITOR-TXN], DB, TABLE,
51 # TRANSACTIONS, OUTPUT, CONDITIONS, [COLUMNS], [KEYWORDS],
52 # [CONDITIONS_CHANGE])
54 # Creates a database with the given SCHEMA, starts an ovsdb-server on
55 # that database, and runs each of the TRANSACTIONS (which should be a
56 # quoted list of quoted strings) against it with ovsdb-client one at a
57 # time. COLUMNS, if specified, is passed to ovsdb-client as the set
58 # of columns and operations to select.
60 # Checks that the overall output is OUTPUT, but UUIDs in the output
61 # are replaced by markers of the form <N> where N is a number. The
62 # first unique UUID is replaced by <0>, the next by <1>, and so on.
63 # If a given UUID appears more than once it is always replaced by the
66 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
67 m4_define([OVSDB_CHECK_MONITOR_COND],
69 AT_KEYWORDS([ovsdb server monitor monitor-cond positive $10])
71 AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore])
72 m4_foreach([txn], [$3],
73 [AT_CHECK([ovsdb-tool transact db 'txn'], [0], [ignore], [ignore])])
74 AT_CAPTURE_FILE([ovsdb-server-log])
75 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file="`pwd`"/ovsdb-server-log db >/dev/null 2>&1])
76 on_exit 'kill `cat ovsdb-server.pid`'
77 AT_CHECK([ovsdb-client -vjsonrpc --pidfile --detach --no-chdir -d json monitor-cond --format=csv unix:socket $4 '[$8]' $5 $9 > output],
78 [0], [ignore], [ignore])
79 on_exit 'kill `cat ovsdb-client.pid`'
80 m4_foreach([txn], [$6],
81 [AT_CHECK([ovsdb-client transact unix:socket 'txn'], [0],
82 [ignore], [ignore], [kill `cat server-pid client-pid`])])
83 m4_foreach([cond], [$10],
84 [AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/cond_change $5 'cond'], [0], [ignore], [ignore])])
85 AT_CHECK([ovsdb-client transact unix:socket '[["$4"]]'], [0],
87 AT_CHECK([ovs-appctl -t ovsdb-server -e exit], [0], [ignore], [ignore])
88 OVS_WAIT_UNTIL([test ! -e ovsdb-server.pid && test ! -e ovsdb-client.pid])
89 AT_CHECK([$PYTHON $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0], [$7], [ignore])
92 OVSDB_CHECK_MONITOR([monitor insert into empty table],
95 [ordinals], [ordinals],
99 "row": {"number": 0, "name": "zero"}}]]]],
100 [[row,action,name,number,_version
101 <0>,insert,"""zero""",0,"[""uuid"",""<1>""]"
104 OVSDB_CHECK_MONITOR([monitor insert into populated table],
109 "row": {"number": 10, "name": "ten"}}]]]],
110 [ordinals], [ordinals],
114 "row": {"number": 0, "name": "zero"}}]]]],
115 [[row,action,name,number,_version
116 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
118 row,action,name,number,_version
119 <2>,insert,"""zero""",0,"[""uuid"",""<3>""]"
122 OVSDB_CHECK_MONITOR([monitor delete],
127 "row": {"number": 10, "name": "ten"}}]]]],
128 [ordinals], [ordinals],
132 "where": [["number", "==", 10]]}]]]],
133 [[row,action,name,number,_version
134 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
136 row,action,name,number,_version
137 <0>,delete,"""ten""",10,"[""uuid"",""<1>""]"
140 OVSDB_CHECK_MONITOR([monitor row update],
145 "row": {"number": 10, "name": "ten"}}]]]],
146 [ordinals], [ordinals],
150 "where": [["number", "==", 10]],
151 "row": {"name": "five plus five"}}]]]],
152 [[row,action,name,number,_version
153 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
155 row,action,name,number,_version
156 <0>,old,"""ten""",,"[""uuid"",""<1>""]"
157 ,new,"""five plus five""",10,"[""uuid"",""<2>""]"
160 OVSDB_CHECK_MONITOR([monitor no-op row updates],
165 "row": {"number": 10, "name": "ten"}}]]]],
166 [ordinals], [ordinals],
170 "where": [["number", "==", 10]],
171 "row": {"number": 10, "name": "ten"}}]]],
175 "row": {"number": 9, "name": "nine"}}]]]],
176 [[row,action,name,number,_version
177 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
179 row,action,name,number,_version
180 <2>,insert,"""nine""",9,"[""uuid"",""<3>""]"
183 OVSDB_CHECK_MONITOR([monitor insert-and-update transaction],
188 "row": {"number": 10, "name": "ten"}}]]]],
189 [ordinals], [ordinals],
193 "row": {"number": 9, "name": "nine"},
194 "uuid-name": "nine"},
197 "where": [["_uuid", "==", ["named-uuid", "nine"]]],
198 "row": {"name": "three squared"}}]]]],
199 [[row,action,name,number,_version
200 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
202 row,action,name,number,_version
203 <2>,insert,"""three squared""",9,"[""uuid"",""<3>""]"
206 OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction],
211 "row": {"number": 10, "name": "ten"}}]]]],
212 [ordinals], [ordinals],
216 "row": {"number": 9, "name": "nine"},
217 "uuid-name": "nine"},
220 "where": [["_uuid", "==", ["named-uuid", "nine"]]],
221 "row": {"name": "three squared"}},
224 "where": [["_uuid", "==", ["named-uuid", "nine"]]]},
227 "row": {"number": 7, "name": "seven"}}]]]],
228 [[row,action,name,number,_version
229 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
231 row,action,name,number,_version
232 <2>,insert,"""seven""",7,"[""uuid"",""<3>""]"
235 OVSDB_CHECK_MONITOR([monitor weak reference change],
241 "a2a1": ["named-uuid", "a0"],
242 "a2b": ["named-uuid", "b2"]},
247 "a2a": ["named-uuid", "a0"],
248 "a2a1": ["named-uuid", "a1"],
249 "a2b": ["named-uuid", "b2"]},
254 "uuid-name": "b2"}]]]],
259 "where": [["a", "==", 0]]}]]]],
260 [[row,action,a,a2a,a2a1,a2b,_version
261 <0>,initial,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]"
262 <3>,initial,1,"[""uuid"",""<0>""]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<4>""]"
264 row,action,a,a2a,a2a1,a2b,_version
265 <0>,delete,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]"
266 <3>,old,,"[""uuid"",""<0>""]",,,"[""uuid"",""<4>""]"
267 ,new,1,"[""set"",[]]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<5>""]"
270 OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction],
275 "row": {"number": 10, "name": "ten"}}]]]],
276 [ordinals], [ordinals],
280 "row": {"number": 9, "name": "nine"},
281 "uuid-name": "nine"},
284 "where": [["_uuid", "==", ["named-uuid", "nine"]]],
285 "row": {"name": "three squared"}},
288 "where": [["_uuid", "==", ["named-uuid", "nine"]]]},
291 "row": {"number": 7, "name": "seven"}}]]]],
292 [[row,action,name,number,_version
293 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
295 row,action,name,number,_version
296 <2>,insert,"""seven""",7,"[""uuid"",""<3>""]"
299 AT_BANNER([ovsdb -- ovsdb-monitor monitor only some operations])
301 m4_define([OVSDB_MONITOR_INITIAL],
305 "row": {"number": 10, "name": "ten"}}]]]])
306 m4_define([OVSDB_MONITOR_TXNS],
310 "row": {"number": 5, "name": "five"}}]]],
314 "where": [["name", "==", "five"]],
315 "row": {"name": "FIVE"}}]]],
321 OVSDB_CHECK_MONITOR([monitor all operations],
322 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
323 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
324 [[row,action,name,number,_version
325 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
327 row,action,name,number,_version
328 <2>,insert,"""five""",5,"[""uuid"",""<3>""]"
330 row,action,name,number,_version
331 <2>,old,"""five""",,"[""uuid"",""<3>""]"
332 ,new,"""FIVE""",5,"[""uuid"",""<4>""]"
334 row,action,name,number,_version
335 <2>,delete,"""FIVE""",5,"[""uuid"",""<4>""]"
336 <0>,delete,"""ten""",10,"[""uuid"",""<1>""]"
339 dnl A monitor with "initial" only doesn't really make sense,
340 dnl but it's still allowed and should work.
341 OVSDB_CHECK_MONITOR([monitor initial only],
342 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
343 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
344 [[row,action,name,number,_version
345 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
346 ]], [!insert,!delete,!modify])
348 OVSDB_CHECK_MONITOR([monitor insert only],
349 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
350 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
351 [[row,action,name,number,_version
352 <0>,insert,"""five""",5,"[""uuid"",""<1>""]"
353 ]], [!initial,!delete,!modify])
355 OVSDB_CHECK_MONITOR([monitor delete only],
356 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
357 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
358 [[row,action,name,number,_version
359 <0>,delete,"""FIVE""",5,"[""uuid"",""<1>""]"
360 <2>,delete,"""ten""",10,"[""uuid"",""<3>""]"
361 ]], [!initial,!insert,!modify])
363 OVSDB_CHECK_MONITOR([monitor modify only],
364 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
365 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
366 [[row,action,name,number,_version
367 <0>,old,"""five""",,"[""uuid"",""<1>""]"
368 ,new,"""FIVE""",5,"[""uuid"",""<2>""]"
369 ]], [!initial,!insert,!delete])
371 AT_BANNER([ovsdb -- ovsdb-monitor-cond conditional monitor only some operations])
373 OVSDB_CHECK_MONITOR_COND([monitor-cond empty condition],
378 "row": {"number": 0, "name": "zero"}},
381 "row": {"number": 1, "name": "one"}},
384 "row": {"number": 2, "name": "two"}}]]]],
385 [ordinals], [ordinals],
389 "row": {"number": 10, "name": "ten"}},
392 "row": {"number": 11, "name": "eleven"}}]]]],
393 [[row,action,name,number,_version
394 <0>,initial,"""one""",1,"[""uuid"",""<1>""]"
395 <2>,initial,"""two""",2,"[""uuid"",""<3>""]"
396 <4>,initial,"""zero""",,"[""uuid"",""<5>""]"
398 row,action,name,number,_version
399 <6>,insert,"""eleven""",11,"[""uuid"",""<7>""]"
400 <8>,insert,"""ten""",10,"[""uuid"",""<9>""]"
404 OVSDB_CHECK_MONITOR_COND([monitor-cond multiple conditions],
409 "row": {"number": 0, "name": "zero"}},
412 "row": {"number": 1, "name": "one"}},
415 "row": {"number": 2, "name": "two"}}]]]],
416 [ordinals], [ordinals],
420 "row": {"number": 10, "name": "ten"}},
423 "row": {"number": 11, "name": "eleven"}}]]]],
424 [[row,action,name,number,_version
425 <0>,initial,"""one""",1,"[""uuid"",""<1>""]"
427 row,action,name,number,_version
428 <2>,insert,"""ten""",10,"[""uuid"",""<3>""]"
430 [[["name","==","one"],["name","==","ten"]]])
432 OVSDB_CHECK_MONITOR_COND([monitor-cond delete from populated table],
437 "row": {"number": 0, "name": "zero"}},
440 "row": {"number": 1, "name": "one"}},
443 "row": {"number": 2, "name": "two"}}]]]],
444 [ordinals], [ordinals],
449 [[row,action,name,number,_version
450 <0>,initial,"""one""",1,"[""uuid"",""<1>""]"
452 row,action,name,number,_version
455 [[["name","==","one"],["name","==","ten"]]])
457 OVSDB_CHECK_MONITOR_COND([monitor-cond insert due to modify],
462 "row": {"number": 0, "name": "zero"}},
465 "row": {"number": 1, "name": "one"}},
468 "row": {"number": 2, "name": "two"}}]]]],
469 [ordinals], [ordinals],
473 "where": [["name", "==", "one"]],
474 "row": {"name": "ONE"}}]]]],
475 [[row,action,name,number,_version
476 <0>,insert,"""ONE""",1,"[""uuid"",""<1>""]"
478 [[["name","==","ONE"]]],
479 [!initial,!delete,!modify])
481 OVSDB_CHECK_MONITOR_COND([monitor-cond delete due to modify],
486 "row": {"number": 0, "name": "zero"}},
489 "row": {"number": 1, "name": "one"}},
492 "row": {"number": 2, "name": "two"}}]]]],
493 [ordinals], [ordinals],
497 "where": [["name", "==", "one"]],
498 "row": {"name": "ONE"}}]]]],
499 [[row,action,name,number,_version
502 [[["name","==","one"]]],
503 [!initial,!insert,!modify])
505 OVSDB_CHECK_MONITOR_COND([monitor-cond condition non-monitored columns],
510 "row": {"number": 0, "name": "zero"}},
513 "row": {"number": 1, "name": "one"}},
516 "row": {"number": 2, "name": "two"}}]]]],
517 [ordinals], [ordinals],
521 "row": {"number": 10, "name": "ten"}},
524 "row": {"number": 11, "name": "eleven"}}]]]],
531 [[["name","==","one"],["name","==","ten"]]],
534 OVSDB_CHECK_MONITOR_COND([monitor-cond-change],
539 "row": {"number": 0, "name": "zero"}},
542 "row": {"number": 1, "name": "one"}},
545 "row": {"number": 2, "name": "two"}}]]]],
546 [ordinals], [ordinals],
548 [[row,action,name,number,_version
549 <0>,initial,"""one""",1,"[""uuid"",""<1>""]"
550 <2>,initial,"""two""",2,"[""uuid"",""<3>""]"
551 <4>,initial,"""zero""",,"[""uuid"",""<5>""]"
553 row,action,name,number,_version
556 row,action,name,number,_version
559 row,action,name,number,_version
562 row,action,name,number,_version
563 <0>,insert,"""one""",1,"[""uuid"",""<1>""]"
564 <2>,insert,"""two""",2,"[""uuid"",""<3>""]"
565 <4>,insert,"""zero""",,"[""uuid"",""<5>""]"
569 [[[[["name","==","one"],["name","==","two"]]]],
570 [[[["name","==","one"]]]],