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 if test "$IS_WIN32" = "yes"; then
30 AT_CHECK([ovsdb-client -vjsonrpc --pidfile="`pwd`"/client-pid -d json monitor --format=csv unix:socket $4 $5 $8 > output &],
31 [0], [ignore], [ignore], [kill `cat server-pid`])
34 AT_CHECK([ovsdb-client -vjsonrpc --detach --no-chdir --pidfile="`pwd`"/client-pid -d json monitor --format=csv unix:socket $4 $5 $8 > output],
35 [0], [ignore], [ignore], [kill `cat server-pid`])
37 m4_foreach([txn], [$6],
38 [AT_CHECK([ovsdb-client transact unix:socket 'txn'], [0],
39 [ignore], [ignore], [kill `cat server-pid client-pid`])])
40 AT_CHECK([ovsdb-client transact unix:socket '[["$4"]]'], [0],
41 [ignore], [ignore], [kill `cat server-pid client-pid`])
42 AT_CHECK([ovs-appctl -t "`pwd`"/unixctl -e exit], [0], [ignore], [ignore])
43 OVS_WAIT_UNTIL([test ! -e server-pid && test ! -e client-pid])
44 AT_CHECK([${PERL} $srcdir/ovsdb-monitor-sort.pl < output | ${PERL} $srcdir/uuidfilt.pl], [0], [$7], [ignore])
47 OVSDB_CHECK_MONITOR([monitor insert into empty table],
50 [ordinals], [ordinals],
54 "row": {"number": 0, "name": "zero"}}]]]],
55 [[row,action,name,number,_version
56 <0>,insert,"""zero""",0,"[""uuid"",""<1>""]"
59 OVSDB_CHECK_MONITOR([monitor insert into populated table],
64 "row": {"number": 10, "name": "ten"}}]]]],
65 [ordinals], [ordinals],
69 "row": {"number": 0, "name": "zero"}}]]]],
70 [[row,action,name,number,_version
71 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
73 row,action,name,number,_version
74 <2>,insert,"""zero""",0,"[""uuid"",""<3>""]"
77 OVSDB_CHECK_MONITOR([monitor delete],
82 "row": {"number": 10, "name": "ten"}}]]]],
83 [ordinals], [ordinals],
87 "where": [["number", "==", 10]]}]]]],
88 [[row,action,name,number,_version
89 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
91 row,action,name,number,_version
92 <0>,delete,"""ten""",10,"[""uuid"",""<1>""]"
95 OVSDB_CHECK_MONITOR([monitor row update],
100 "row": {"number": 10, "name": "ten"}}]]]],
101 [ordinals], [ordinals],
105 "where": [["number", "==", 10]],
106 "row": {"name": "five plus five"}}]]]],
107 [[row,action,name,number,_version
108 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
110 row,action,name,number,_version
111 <0>,old,"""ten""",,"[""uuid"",""<1>""]"
112 ,new,"""five plus five""",10,"[""uuid"",""<2>""]"
115 OVSDB_CHECK_MONITOR([monitor no-op row updates],
120 "row": {"number": 10, "name": "ten"}}]]]],
121 [ordinals], [ordinals],
125 "where": [["number", "==", 10]],
126 "row": {"number": 10, "name": "ten"}}]]],
130 "row": {"number": 9, "name": "nine"}}]]]],
131 [[row,action,name,number,_version
132 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
134 row,action,name,number,_version
135 <2>,insert,"""nine""",9,"[""uuid"",""<3>""]"
138 OVSDB_CHECK_MONITOR([monitor insert-and-update transaction],
143 "row": {"number": 10, "name": "ten"}}]]]],
144 [ordinals], [ordinals],
148 "row": {"number": 9, "name": "nine"},
149 "uuid-name": "nine"},
152 "where": [["_uuid", "==", ["named-uuid", "nine"]]],
153 "row": {"name": "three squared"}}]]]],
154 [[row,action,name,number,_version
155 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
157 row,action,name,number,_version
158 <2>,insert,"""three squared""",9,"[""uuid"",""<3>""]"
161 OVSDB_CHECK_MONITOR([monitor insert-update-and-delete transaction],
166 "row": {"number": 10, "name": "ten"}}]]]],
167 [ordinals], [ordinals],
171 "row": {"number": 9, "name": "nine"},
172 "uuid-name": "nine"},
175 "where": [["_uuid", "==", ["named-uuid", "nine"]]],
176 "row": {"name": "three squared"}},
179 "where": [["_uuid", "==", ["named-uuid", "nine"]]]},
182 "row": {"number": 7, "name": "seven"}}]]]],
183 [[row,action,name,number,_version
184 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
186 row,action,name,number,_version
187 <2>,insert,"""seven""",7,"[""uuid"",""<3>""]"
190 OVSDB_CHECK_MONITOR([monitor weak reference change],
196 "a2a1": ["named-uuid", "a0"],
197 "a2b": ["named-uuid", "b2"]},
202 "a2a": ["named-uuid", "a0"],
203 "a2a1": ["named-uuid", "a1"],
204 "a2b": ["named-uuid", "b2"]},
209 "uuid-name": "b2"}]]]],
214 "where": [["a", "==", 0]]}]]]],
215 [[row,action,a,a2a,a2a1,a2b,_version
216 <0>,initial,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]"
217 <3>,initial,1,"[""uuid"",""<0>""]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<4>""]"
219 row,action,a,a2a,a2a1,a2b,_version
220 <0>,delete,0,"[""set"",[]]","[""uuid"",""<0>""]","[""uuid"",""<1>""]","[""uuid"",""<2>""]"
221 <3>,old,,"[""uuid"",""<0>""]",,,"[""uuid"",""<4>""]"
222 ,new,1,"[""set"",[]]","[""uuid"",""<3>""]","[""uuid"",""<1>""]","[""uuid"",""<5>""]"
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 AT_BANNER([ovsdb -- ovsdb-monitor monitor only some operations])
256 m4_define([OVSDB_MONITOR_INITIAL],
260 "row": {"number": 10, "name": "ten"}}]]]])
261 m4_define([OVSDB_MONITOR_TXNS],
265 "row": {"number": 5, "name": "five"}}]]],
269 "where": [["name", "==", "five"]],
270 "row": {"name": "FIVE"}}]]],
276 OVSDB_CHECK_MONITOR([monitor all operations],
277 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
278 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
279 [[row,action,name,number,_version
280 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
282 row,action,name,number,_version
283 <2>,insert,"""five""",5,"[""uuid"",""<3>""]"
285 row,action,name,number,_version
286 <2>,old,"""five""",,"[""uuid"",""<3>""]"
287 ,new,"""FIVE""",5,"[""uuid"",""<4>""]"
289 row,action,name,number,_version
290 <2>,delete,"""FIVE""",5,"[""uuid"",""<4>""]"
291 <0>,delete,"""ten""",10,"[""uuid"",""<1>""]"
294 dnl A monitor with "initial" only doesn't really make sense,
295 dnl but it's still allowed and should work.
296 OVSDB_CHECK_MONITOR([monitor initial only],
297 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
298 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
299 [[row,action,name,number,_version
300 <0>,initial,"""ten""",10,"[""uuid"",""<1>""]"
301 ]], [!insert,!delete,!modify])
303 OVSDB_CHECK_MONITOR([monitor insert only],
304 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
305 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
306 [[row,action,name,number,_version
307 <0>,insert,"""five""",5,"[""uuid"",""<1>""]"
308 ]], [!initial,!delete,!modify])
310 OVSDB_CHECK_MONITOR([monitor delete only],
311 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
312 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
313 [[row,action,name,number,_version
314 <0>,delete,"""FIVE""",5,"[""uuid"",""<1>""]"
315 <2>,delete,"""ten""",10,"[""uuid"",""<3>""]"
316 ]], [!initial,!insert,!modify])
318 OVSDB_CHECK_MONITOR([monitor modify only],
319 [ordinal_schema], [OVSDB_MONITOR_INITIAL],
320 [ordinals], [ordinals], [OVSDB_MONITOR_TXNS],
321 [[row,action,name,number,_version
322 <0>,old,"""five""",,"[""uuid"",""<1>""]"
323 ,new,"""FIVE""",5,"[""uuid"",""<2>""]"
324 ]], [!initial,!insert,!delete])